//Load the existing documents
PdfLoadedDocument loadedDocument1 = new PdfLoadedDocument(@"input.pdf");
PdfLoadedDocument loadedDocument2 = new PdfLoadedDocument(@"input1.pdf");
//Create the new document
PdfDocument document = new PdfDocument();
PdfPage page = document.Pages.Add();
//Create a template from the first document
PdfPageBase loadedPage = loadedDocument1.Pages[0];
PdfTemplate template = loadedPage.CreateTemplate();
//Draw the loaded template into new document.
page.Graphics.DrawPdfTemplate(template, new PointF(0, 0), new SizeF(100, 100));
// Create a template from the second document
loadedPage = loadedDocument2.Pages[0];
template = loadedPage.CreateTemplate();
//Draw the loaded template into new document.
page.Graphics.DrawPdfTemplate(template, new PointF(10, 10), new SizeF(500, 600));
//Save the new document.
document.Save(@"../../output.pdf");
//Close the documents
loadedDocument1.Close(true);
loadedDocument2.Close(true);
document.Close(true); |