46,174 questions
You can see Combining PDF documents using iText7 and C#
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi, is there a way to have an Api to read array of PDF files and then combine into single PDF using itext 7? TIA
You can see Combining PDF documents using iText7 and C#
Managed to write a function that is combining 2 pdfs into 1 file. I used a console application. Not sure whether the same I can reuse within API.
private static void createPdf(string DEST,string SRC1,string SRC2)
{
//Initialize PDF document with output intent
PdfDocument pdf = new PdfDocument(new PdfWriter(DEST));
//PdfMerger merger = new PdfMerger(pdf);
PdfMerger merger = new PdfMerger(pdf);
//Add pages from the first document
PdfReader reader = new PdfReader(SRC1);
reader.SetUnethicalReading(true);
PdfDocument firstSourcePdf = new PdfDocument(reader);
merger.Merge(firstSourcePdf, 1, firstSourcePdf.GetNumberOfPages());
//Add pages from the second pdf document
PdfReader reader1 = new PdfReader(SRC2);
reader1.SetUnethicalReading(true);
PdfDocument secondSourcePdf = new PdfDocument(reader1);
merger.Merge(secondSourcePdf, 1, secondSourcePdf.GetNumberOfPages());
firstSourcePdf.Close();
secondSourcePdf.Close();
pdf.Close();
}