Posted by a ceTe Software moderator
Hello,
Yes, the PdfPage object is read-only. You can achieve your requirements by importing a page from the existing PDF using ImportedPage class and add the contents to the page using respective page elements. Add this imported page to the MergeDocument object. Below is the code sample.
string PdfFolder = @"E:\temp\PDF\";
string[] fileList = Directory.GetFiles(PdfFolder, "*.pdf");
MergeDocument finalDocument = new MergeDocument();
for (int i = 0; i < fileList.Length; i++)
{
string filepath = fileList[i];
PdfDocument pdf = new PdfDocument(fileList[i]);
for (int j = 0; j < pdf.Pages.Count; j++)
{
ImportedPage page = new ImportedPage(pdf.Pages[0]);
Code128 barcodeObj = new Code128("123456789", 100, 100, 300);
page.Elements.Add(barcodeObj);
finalDocument.Pages.Add(page);
}
}
finalDocument.Draw("C:\\Temp\\MyDocument.pdf");
Thanks,
ceTe Software Support Team.