How to preserve different headers in even/odd pages?
You can add different headers in odd and even pages by using the BeginPageLayoutEventHandler. You can apply headers alternatively in the pages by using EvenTop and OddTop templates. Refer to the following code.
C#:
// Raise begin page event to draw the graphic elements for each page.
element.BeginPageLayout += new BeginPageLayoutEventHandler(BeginPageLayout);
// Add the different headers in even and odd pages.
private void BeginPageLayout(object sender, BeginPageLayoutEventArgs e)
{
if (index % 2 == 0)
{
e.Page.Section.Template.EvenTop = AddHeader(document, true);
}
else
{
e.Page.Section.Template.OddTop = AddHeader(document, false);
}
}
Sample Link:
https://www.syncfusion.com/downloads/support/directtrac/general/PdfHeader860416762.zip
Note:
Starting with v16.2.0.x, if you reference Syncfusion® assemblies from a trial setup or from the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion® license key in your application to use the components without a trial message.
Conclusion
I hope you enjoyed learning about how to preserve different headers in even/odd pages.
You can refer to our WinForms PDF’s feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms PDF documentation to understand how to present and manipulate data.
For current customers, you can check out our WinForms components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our WinForms PDF and other WinForms components.
If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!