procedure AddText(const Text, Font: WString; FontSize: Single; X, Y: Double; Color: TColor = clBlack; Alpha: Byte = $FF; Angle: Double = 0.0);
| FontSize | Single. Font size in points (e.g. 12.0 for 12 pt text) |
| Color | TColor. Text fill color. Default is clBlack |
| Alpha | Byte. Opacity of the text, where $00 is fully transparent and $FF is fully opaque. Default is $FF |
| Angle | Double. Rotation angle in degrees, measured counterclockwise from the positive X axis. Default is 0.0 (horizontal) |
AddText renders a Unicode text string onto the current PDF page using the specified font and size. The position (X, Y) is the baseline origin of the first character, measured in PDF user units from the lower-left corner of the page (origin at lower-left, Y increases upward)
The font is identified by its PostScript or family name (e.g. 'Arial', 'Times New Roman'). The font must be available on the system or embedded in the document; if PDFium cannot locate the requested font it will substitute a default font
Use the Color and Alpha parameters to control the appearance of the text fill. Set Alpha to a value less than $FF to render semi-transparent text. The Angle parameter rotates the entire text string counterclockwise around the baseline origin
This method adds the text as a new page object. To modify the content of an existing text object after it has been added, use SetText
A system font is embedded once per document as a CID font keyed by code point: every Unicode character the font covers gets its own CID with an explicit CIDToGIDMap and a one-to-one ToUnicode entry, so characters that share a glyph (space and U+00A0, hyphen and U+00AD, Omega and the Ohm sign) extract as exactly the characters that were written, from the live document and from the saved file alike. Fonts without a Unicode cmap subtable fall back to the native glyph-keyed embedding
Native Free Pascal/LCL builds resolve system font files through fontconfig on Linux and CoreText on macOS, with a 64 MiB font-file limit. The selected native family may be a platform substitution when the requested family is absent; successful font lookup does not prove coverage for every Unicode character
Since v3.205.1, Windows first attempts optional system DirectWrite resolution for an exact installed variable TrueType family and reads its original default-instance program, avoiding GDI substitution. Typographic families missing from the legacy collection require IDWriteFactory6; the resolver accepts one source file up to 64 MiB, extracts the selected collection face when needed, and requires the source family metadata to match exactly
Only the source default instance is selected; axis coordinates, named-instance aliases and synthesized styles are not supplied by this API. Static fonts, missing DirectWrite capabilities and rejected variable candidates retain the existing GDI/native fallback, which may still reject an unavailable family. Segoe UI Variable and Bahnschrift have focused Windows save/subset/reload evidence; other families and collection-based variable fonts require their own verification
// Add a title string near the top of an A4 page
// A4 page height = 841.89 pt; place text 50 pt from the top
Pdf1.AddPage(1, 595, 842);
Pdf1.AddText('Hello, PDFium Delphi Component!', 'Arial', 24, 72, 768);
// Red text at 45 degrees with 50% opacity
Pdf1.AddText('Rotated', 'Arial', 18, 200, 400, clRed, $80, 45);