AddPageNumberPlaceholder

Page layout, Pagination, Text

Description

Records a text box on the selected page and defers its drawing until final page and chapter counts are known

Syntax

Delphi

Function TPDFlib.AddPageNumberPlaceholder(Left, Top, Width, Height: Double; Const Text: WideString; Options: Integer): Integer;

ActiveX

Function PDFlib::AddPageNumberPlaceholder(Left As Double, Top As Double, Width As Double, Height As Double, Text As String, Options As Long) As Long

DLL

int DLAddPageNumberPlaceholder(int InstanceID, double Left, double Top, double Width, double Height, const wchar_t* Text, int Options);
int DLAddPageNumberPlaceholderA(int InstanceID, double Left, double Top, double Width, double Height, const char* Text, int Options);

Parameters

Left, Top, Width, HeightText-box geometry in the current coordinate system
TextTemplate containing pagination tokens and ordinary text
OptionsVertical placement and no-wrap option from 0 through 5 with the same meaning as DrawTextBox

Tokens

<%PageNo%>Physical selected page number
<%TotalPages%>Final document page count
<%ChapterPageNo%>One-based page number within the current chapter
<%ChapterTotalPages%>Final page count of the current chapter
<%ChapterName%>Name registered by StartPageNumberChapter

Return values

Returns the one-based placeholder identifier, or 0 for invalid geometry, options, text, selection, or a document whose placeholders were already resolved

Remarks

The call captures the selected font, text size, colors, alignment, spacing, kerning, decoration, scale, origin, and translated text-box geometry without drawing page content

Date, time, and custom OnCalcVariable tokens use the same rules as ExpandVariableTokens

Call ResolvePageNumberPlaceholders exactly once after the complete page structure is stable and before saving