How to add different header and footer in a PDF Document?
It is possible to add different Header and Footer in different pages of a PDF document in WinForms PDF. 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.
//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.
I hope you enjoyed learning about how to add different header and footer in a PDF Document.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!