| Category | Text output |
|---|---|
| Exported names | pdfWriteTextA, pdfWriteTextW |
| Thread safety | pdfWriteTextA serializes via the instance mutex when pdfEnableMutex is armed (D.Lock/D.Unlock); pdfWriteTextW does not take the lock — a verified inconsistency between the two variants. |
Purpose — Draw a single line of text at an absolute page position with the current font/size/color.
Description — Requires an open document, open page, and a font selected via pdfSetFont/pdfSetFontEx; a NULL/empty string or missing precondition returns FALSE with nothing drawn. Dispatches by font kind:
- CID-predefined fonts (
Wonly supportsUCS2-mode CMaps;Aaccepts pre-encoded bytes verbatim in the CMap's source encoding for both UCS2 and legacy-HCMaps). - Embedded TrueType: encoded to Identity-H GIDs directly from Unicode (
W) or via a WinAnsi decode step (A); synthetic bold/oblique (from-SynBold/-SynItalmarkers set whenpdfSetFontcouldn't find a real styled face) is honored automatically. - Standard 14 / embedded Type 1:
Awrites raw bytes as WinAnsi;Wtranscodes to code page 1252 (WinAnsi) — deliberately notCP_ACP(see the source comment:CP_ACP"corrupts output on non-Western systems"). If any character can't round-trip through WinAnsi (WC_NO_BEST_FIT_CHARSdetects this precisely, not just "close enough" substitution), the engine transparently loads an embedded Unicode TrueType fallback — the first available of Arial, Segoe UI, or Tahoma — and redraws the run through it as Identity-H GIDs instead of dropping characters to'?'. If no system font is found, it falls through to the lossy WinAnsi write.
If FBidiMode is not bmNone, W input is reordered per UAX#9 (logical → visual order) before any of the above — required because PDF stores glyphs in visual order. Pure LTR text is returned unchanged, so this never affects plain Latin output.
Declarations
BOOL32 __stdcall pdfWriteTextA(PPDF IPDF, double PosX, double PosY, const char* AText);
BOOL32 __stdcall pdfWriteTextW(PPDF IPDF, double PosX, double PosY, const wchar_t* AText);
function pdfWriteTextA(const IPDF: PPDF; PosX, PosY: Double; const AText: PAnsiChar): LongBool; stdcall; external 'LumasPdf.dll';
function pdfWriteTextW(const IPDF: PPDF; PosX, PosY: Double; const AText: PWideChar): LongBool; stdcall; external 'LumasPdf.dll';
Parameters
| Parameter | Type | Description |
|---|---|---|
IPDF | PPDF | Instance handle with an open page and selected font. |
PosX, PosY | Double | Baseline origin, in the page's current coordinate system. |
AText | string | Text to draw. NULL returns FALSE immediately. |
Return value — TRUE on success; FALSE on any missing precondition (no document/page/font, NULL/empty text) or invalid handle.
Remarks — "last text position" reports the END of the run. After a successful call, pdfGetLastTextPosX/Y reflect the position after the text — PosX + GetTextWidth(text) — not the starting position you passed in. This is deliberate behavior. An underline, if pdfSetTextUnderline is active, is emitted spanning exactly this computed width.
See also — pdfWriteTextEx, pdfGetTextWidth
C# (P/Invoke)
[return: MarshalAs(UnmanagedType.Bool)]
Text
pdfWriteTextA
pdfWriteTextW
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.