AddPageHeaderFooter
Page Manipulation, Annotations
Description
Shared primitive behind AddPageHeader and AddPageFooter. Stamps a running line at the top or bottom edge of every page in the range, using the currently selected font in overlay mode, expanding stamp tokens against each target page, and enclosing the result in a Pagination artifact with subtype Header or Footer
Syntax
Delphi
Function TPDFlib.AddPageHeaderFooter(Const PageRange, Text: WideString;
Margin, Opacity: Double; Alignment: Integer; IsHeader: Boolean): Integer;Parameters
| PageRange | Page-range expression, or an empty string for every page |
|---|---|
| Text | Line text; the tokens understood by ExpandStampTokens expand against each target page |
| Margin | Distance from the top edge (header) or bottom edge (footer) to the line, in PDF points |
| Opacity | Text opacity between 0 and 1, where 1 draws fully opaque |
| Alignment | 0 aligns left at the margin, 1 centres between the margins, 2 aligns right and keeps the margin distance from the right edge |
| IsHeader | True stamps a header at the top margin, False stamps a footer at the bottom margin |
Return values
The number of pages on which the line was stamped, or 0 when no document is selected, Text is empty, or no page of the range could be selected
Remarks
The line is measured with the current font and size, so call SelectFont first. With IsHeader True the line sits at Margin from the top edge; with False it sits at Margin from the bottom edge, computed against the current page height and text height. The selected page is restored when the call returns
Example
PDF.SelectFont(PDF.AddStandardFont(sfHelvetica));
PDF.AddPageHeaderFooter('2-', 'Confidential - <%PageNo%>', 20, 0.6, 2, False);