We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Platform: WinForms |
Control: PDF
Tags: header, pdf, footer

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.


//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[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:


2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile