How to use the existing PDF as a background for the new PDF file?
To use the existing PDF file as a background for the new PDF file, create a Page template of the existing document, then draw the template in the new document Page. The following code example illustrates how to use the existing PDF file as a background for the new PDF file.
C#
// Loads the PDF document
PdfLoadedDocument ldoc = new PdfLoadedDocument("imageDoc.pdf");
// Gets the particular page from loaded document pages
PdfLoadedPage lpage = ldoc.Pages[0] as PdfLoadedPage;
// Create template for the loaded page
PdfTemplate template = lpage.CreateTemplate();
// Creates new PDF document
PdfDocument doc = new PdfDocument();
// Adds new page
PdfPage page = doc.Pages.Add();
// Sets document page margins to zero
doc.PageSettings.Margins.All = 0;
// Draws loaded page as background in the new PDF page using template of the loaded page.
page.Graphics.DrawPdfTemplate(template, new PointF(0, 0), page.Size);
// Save the document and dispose of it.
doc.Save("sample.pdf");
doc.Close();
Sample Link:
https://www.syncfusion.com/downloads/support/directtrac/general/PdfBackground-666474198.zip
Note:
Starting with v16.2.0.x, if you reference Syncfusion® assemblies from a trial setup or from the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion® license key in your application to use the components without a trial message.
Conclusion
I hope you enjoyed learning about how to use the existing PDF as a background for the new PDF file.
You can refer to our WinForms PDF’s feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms PDF documentation to understand how to present and manipulate data.
For current customers, you can check out our WinForms components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our WinForms PDF and other WinForms components.
If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!