Hello,
i have one PDF document with one page. The page displays the company layout such as Header and Footer. I know want to take this document to be the "backround" of the new pdf i generate. I cant split the existing document in header or footer. If i use the DrawPdfTemplate my PageSettings Margins for the new document are used and so the template isn´t where it supposed to be.
How can i achive the result to use the existing document to be present in all my new pages in the new PDF File.
Thanks
Hi Gowthamraj,
with the second link can´t set my needed margins as i mentioned before.
The first link worked but i need to save the generated PDF first reopen it draw Backround and save it again.
With this workaround i can live but would be nice if i can directly set the PDF Template that igonores my page margins.
|
//Loads the Pdf document
PdfLoadedDocument ldoc = new PdfLoadedDocument("../../Data/Essential_Pdf.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();
//Sets document page margins to zero
doc.PageSettings.Margins.All = 0;
//Adds new Page
PdfPage page = doc.Pages.Add();
//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("../../sample1.pdf");
doc.Close(); |