Articles in this section
Category / Section

How to draw the header and footer outside the bounds of the margin?

1 min read

You can draw the header and footer outside of the margin by using the following steps:

  1. Create a PDF with Margin(Margins.All=value).
  2. Save the document to the MemoryStream and load it via the PdfLoadedDocument.
  3. Convert the loaded document pages to templates.
  4. Create a new PdfDocument with margins set to zero.
  5. Draw the loaded pages template onto the new templates.
  6. Add the header and footer to the new document template.

Refer to the following code example to draw the header outside the margin.

C#

//Load the file stream that contains the 
PdfLoadedDocument ldoc = new PdfLoadedDocument(ms);
//Create the document.
PdfDocument finalDoc = new PdfDocument();
//Get the templates from loadeddocument.
PdfTemplate template = ldoc.Pages[i].CreateTemplate();
finalDoc.Pages.Add();
finalDoc.Pages[i].Graphics.DrawPdfTemplate(template, new PointF(0, 0));
//Add the header outside the bounds of the margin.
PdfPageTemplateElement header = new PdfPageTemplateElement(50, 0,100, 50);
finalDoc.Template.Top = header;

Sample Link:

https://www.syncfusion.com/downloads/support/directtrac/general/MarginSample-279672044.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