ExpandStampTokens

Annotations, Extraction

Description

Expands the placeholder tokens of stamp, header and footer text for one page. The classic ampersand tokens &P (page number), &N (total pages), &D (date), &T (document title) and && (literal ampersand) expand first; the text then passes through variable placeholder expansion: <%PageNo%>, <%TotalPages%>, <%ShortDate%>, <%LongDate%>, <%ShortTime%> and <%LongTime%> are built in (names are case-insensitive), and any other <%name%> resolves through the OnCalcVariable event - the handler receives the name and the page number and supplies the per-page replacement, so running numbers, batch codes or client fields can be stamped without pre-processing the text. Without a handler unknown placeholders stay verbatim. StampText and the page header/footer helpers call this expansion automatically for every page in their range.

Syntax

Delphi

Function TPDFlib.ExpandStampTokens(Const Text: WideString; PageNo, TotalPages: Integer): WideString;

Parameters

TextThe stamp, header or footer template whose tokens are expanded
PageNoThe current page number, substituted for &P and <%PageNo%>
TotalPagesThe total page count, substituted for &N and <%TotalPages%>

Return values

Returns Text with every recognised token replaced by its expansion for the given page; unrecognised tokens are kept verbatim