Headers and Footers |
Start page Previous page Next page |
n2pdf supports the creation of headers and footers for the PDF file. A header or footer can consist of plain text or the content of a RichText field. A header or footer can also be defined based on the content of a given page and will enclose the main text of the PDF file.
In n2pdf headers and footers are defined using the function N2PDFAddContent or N2PDFAddRTContent, whereby when used with these functions the constant
N2PDFVALUE_CONTENT_HEADER
specifies the header and
N2PDFVALUE_CONTENT_FOOTER
specifies the footer (see the parameter <ContentType> under functions).
The page on which the header, footer and/or inserted content is to appear can be specified using an additional constant (see the parameter <ContentOption> under the functions listed above). Here are the options available for setting headers and footers using the above-named functions:
Header on footer on individual pages As well as using the constants named above, you can also set a header or footer (Parameter <ContentType>) selectively for a particular page. In this case, simply pass the desired page number as a negative value in the parameter <ContentOption>.
Empty headers and footers If you want to delete the content of a header or footer, simply pass an empty text ("") as the value for the header or footer.
Example:
The following calls are needed to specify different headers for the even and odd pages: Call N2PDFAddContent ( JobID, N2PDFVALUE_CONTENT_HEADER,_ N2PDFVALUE_HF_EVEN_PAGES, "Even pages" )
Call N2PDFAddContent ( JobID, N2PDFVALUE_CONTENT_HEADER,_ N2PDFVALUE_HF_ODD_PAGES, "Odd pages" )
Header for a certain page: Call N2PDFAddContent ( JobID, N2PDFVALUE_CONTENT_HEADER,_ -5, "Header for page 5" )
The same footer on all pages except for page 5 which has no footer at all: Call N2PDFAddContent ( JobID, N2PDFVALUE_CONTENT_FOOTER,_ N2PDFVALUE_HF_ALL_PAGES, "All pages" )
Call N2PDFAddContent ( JobID, N2PDFVALUE_CONTENT_FOOTER, -5, "" )
Plain text to be added a header or footer will be inserted using the currently selected text template.
Chapter headings in headers and footersIf the title of the current chapter is to be shown in a header or footer, e.g. in books, this can be done using the constant "[TOC]" (se document Constants"). The constant "[TOC]" is replaced with the current chapter text, which was defined in the main text with "[TOC:x]" (see document "Table of contents").
For this constant to be available in headers and footers, the option N2PDFOPTION_TOC_HF_VARIABLE must be set to the value N2PDFVALUE_TRUE:
Call N2PDFSetOption ( JobID, N2PDFOPTION_TOC_HF_VARIABLE, N2PDFVALUE_TRUE, "" )
It is also possible to specify whether the chapter numbering is part of the constant. If the option N2PDFOPTION_TOC_HF_VARIABLE_WITH_LEVEL is set to N2PDFVALUE_TRUE, then the numbering is included (see image); for N2PDFVALUE_FALSE, it is not.
Do not use chapter numbering: Call N2PDFSetOption ( JobID, N2PDFOPTION_TOC_HF_VARIABLE_WITH_LEVEL, N2PDFVALUE_FALSE, "" )
With very many levels of chapter numbering, it is possible that only a certain depth of chapter/section headings is wanted, e.g. only main chapters at the first level. The option N2PDFOPTION_TOC_HF_VARIABLE_MAX_LEVEL can be used to decide the max. level. The parameter is set according to the numbering of "[TOC:x]".
Use only chapter headings of the first level: Call N2PDFSetOption ( JobID, N2PDFOPTION_TOC_HF_VARIABLE_MAX_LEVEL, "1", "" )
|