Posted by a ceTe Software moderator
Hello,
Yes, you can merge dynamically generated PDF report with existing PDF documents without any problem using our DynamicPDF Merger for .NET product. Build the complete PDF report dynamically and get the PDF data in form of byte array. Load this PDF byte array in the PdfDocument class object. Merge PdfDocument object with MergeDocument object by appending it using Append method. Then you can append the existing PDF documents using Append method of the MergeDocument object by accessing the PDFs using file path. Please refer to the documentation on document merge
here.
Below is the sample code to generate PDF from scratch, appending it to MergeDocument and appending existing PDF documents.
//Generating PDF dynamically from scratch.
Document document = new Document();
Page page = new Page();
document.Pages.Add(page);
Label label = new Label("This is to test", 100, 100, 200, 50);
page.Elements.Add(label);
//Outputting document on the form of byte array.
byte[] byteData = document.Draw();
//Create MergeDocument object.
MergeDocument mergeDocument = new MergeDocument();
//Load the dynamically generated PDF which is in the form of Byte array.
PdfDocument pdf = new PdfDocument(byteData);
//Appending he PDF byte data to the MergeDocumet class members.
mergeDocument.Append(pdf);
//Appending existing PDFs to mergeDocument object.
mergeDocument.Append(@"C:\Temp\DocumentA.pdf");
//Save final merged PDF to disk.
mergeDocument.Draw(@"C:\Temp\MyDocument.pdf");
Thanks,
ceTe Software Support Team.