AddPageHeader

Page Manipulation, Annotations

Description

Stamps a running header line on one or more pages of the selected document. The text is drawn in overlay mode with the currently selected font, stamp tokens such as <%PageNo%> are expanded against each target page before the line is measured, and the stamped line is enclosed in a Pagination artifact with subtype Header so tagged-PDF readers treat it as page furniture rather than repeating content

Syntax

Delphi

Function TPDFlib.AddPageHeader(Const PageRange, Text: WideString;
  Margin, Opacity: Double; Alignment: Integer): Integer;

Parameters

PageRangePage-range expression, or an empty string for every page
TextHeader text; the tokens understood by ExpandStampTokens expand against each target page
MarginDistance from the top edge of the page to the header line, in PDF points
OpacityText opacity between 0 and 1, where 1 draws fully opaque
Alignment0 aligns left at the margin, 1 centers between the margins, 2 aligns right and keeps the margin distance from the right edge

Return values

The number of pages on which the header 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; content already on the page stays visible underneath the overlay. The selected page is restored when the call returns

For first-page, odd-page, and even-page header roles with HTML content support see ApplyPageHeaderFooterSet

Example

PDF.SelectFont(PDF.AddStandardFont(sfHelvetica));
PDF.AddPageHeader('', 'Quarterly report - page <%PageNo%> of <%TotalPages%>',
  28, 1, 1);