)
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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to add different header and footer in different pages in a PDF Document

Platform: WinForms |
Control: PDF |
Published Date: November 18, 2014 |
Last Revised Date: May 7, 2019
Tags: header, pdf, footer

How to add different header and footer in different pages of a PDF Document

It is possible to add different Header and Footer in different pages of a PDF document. To achieve this, multiple sections has to be created using the PdfSection class and the header and footer can be added separately in each section.

The code snippets given below explains how to create multiple sections in a PDF document and add header and footers to it.

C#

            //Creating section1 and adding pages to them
            PdfSection section1 = doc.Sections.Add();
            section1.Pages.Add();
            section1.Pages.Add();
 
            //Creating section2 and adding pages to them
            PdfSection section2 = doc.Sections.Add();
            section2.Pages.Add();
            section2.Pages.Add();
 
            //Including header and footer to the 1st section
            section1.Template.Top = AddHeader(doc, "Header 1");
            section1.Template.Bottom = AddFooter(doc, "Footer 1");
 
            //Including header and footer to the 2nd section
            section2.Template.Top = AddHeader(doc, "Header 2");
            section2.Template.Bottom = AddFooter(doc, "Footer 2");

 

Please find the working sample in the below link location.

http://www.syncfusion.com/downloads/support/directtrac/131081/DifferentHeaderAndFooter1982126851.zip

 

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment
Comments
Adrian Grigore
Nov 06, 2018

This workaround does not work if the content of the document spans several pages (i.e. a PDFGrid that is several pages long).

Reply
Karthikeyan Chandrasekar [Syncfusion]
Nov 08, 2018

@Adrian Grigore - Please find the sample to meet your requirement.

 http://www.syncfusion.com/downloads/support/directtrac/general/ze/Header_and_Footer-2134054523

hytham
Aug 18, 2020

how i can add footer to the last page only in xamarin forms pdf ?

Reply
Sowmiya Loganathan [Syncfusion]
Aug 19, 2020

Hi Hythm,

We have create the sample to add footer in the last page of PDF document in Xamarin Forms platform. Please find the download link for the same from below,

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/GettingStarted-2092754246 Output document: https://www.syncfusion.com/downloads/support/directtrac/general/pd/Sample-1446164549

Please try the above sample in your end and let us know if you have any concerns on this.

Regards,

Sowmiya Loganathan

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
Live Chat Icon