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

PageRangePage-range expression, or an empty string for every page
TextLine text; the tokens understood by ExpandStampTokens expand against each target page
MarginDistance from the top edge (header) or bottom edge (footer) to the line, in PDF points
OpacityText opacity between 0 and 1, where 1 draws fully opaque
Alignment0 aligns left at the margin, 1 centres between the margins, 2 aligns right and keeps the margin distance from the right edge
IsHeaderTrue 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);