Define headers and footers flexibly with n2pdf
Did you already know that with n2pdf you can define headers and footers flexibly and customize them dynamically? You want to write a report or a letter, or just need headers and footers in your text? Then we would like to show you how helpful n2pdf can be here for you.
Your headers and footers can consist of unformatted text or the content of a rich text field. For one n2pdf has to know that certain content is to be output as header or footer, for another this output can be defined to appear only on a certain page. All declarations have to be made upon the transfer of the content.
This definition is made via the functions for adding content – N2PDFAddContent for unformatted and N2PDFAddRTConent for formatted content. For this n2pdf makes use of constants.
Another constant is used to define, on which pages certain content is to appear. Below you will find a list of all options to define, on which pages headers and footers are to appear.
|N2PDFVALUE_HF_ALL_PAGES||On all pages|
|N2PDFVALUE_HF_FIRST_PAGE||Only on the first page|
|N2PDFVALUE_HF_LAST_PAGE||Only on the last page|
|N2PDFVALUE_HF_EVEN_PAGES||On all even pages|
|N2PDFVALUE_HF_ODD_PAGES||On all odd pages|
|N2PDFVALUE_HF_NOT_FIRST_LAST_PAGES||On all pages, except the first and the last page|
Here a few examples of how transferring content from your database could look:
Display the content “All pages” on all pages in your document header.
Call N2PDFAddContent ( JobID, N2PDFVALUE_CONTENT_HEADER, N2PDFVALUE_HF_ALL_PAGES, “All pages” )
Display the content “All pages” on all pages in your document footer.
Call N2PDFAddContent ( JobID, N2PDFVALUE_CONTENT_FOOTER, N2PDFVALUE_HF_ALL_PAGES, “All pages” )
Display the content “Odd pages” on all pages in your document header.
Call N2PDFAddContent ( JobID, N2PDFVALUE_CONTENT_HEADER, N2PDFVALUE_HF_ODD_PAGES, “Odd pages” )
Based on the basic principle mentioned above you can now define any content as header or footer. Our internal constants provide a special service here, as they are a special kind of placeholder.
An example for the use of a placeholder (page numbering) in a rich text field:
Page [ACTPG] of [SUMPG]
Try all opportunities of n2pdf for yourself! For that SoftVision offers numerous support options – from a list of further placeholders, which you can find in the developer manual of n2pdf, to various options you can test for yourself in the sample database “n2pdf 3.2 – Header and Footer (R5)”, which is provided with the installation.
Of course, our technical support is available anytime and free of charge.
… and now good luck with testing!