Articles in this section
Category / Section

How to use the existing PDF as a background for the new PDF file?

1 min read

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 it.
doc.Save("sample.pdf");
doc.Close();

Sample Link:

https://www.syncfusion.com/downloads/support/directtrac/general/PdfBackground-666474198.zip

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied