API referenceText

pdfWriteFText

Word-wrap and draw AText inside the currently set text

CategoryText output / flowed text
Exported namespdfWriteFTextA, pdfWriteFTextW
NoteAn important precondition applies — see Remarks

Purpose — Word-wrap and draw AText inside the currently set text rectangle, at the current font/size, top-to-bottom.

Description — supports inline format tags. Text may embed control commands, delimited by \, that this engine's flow-text lexer parses and strips before drawing (they never appear as literal glyphs):

TagEffect
\fs<num>\Change font size for the rest of the segment, e.g. \fs18\
\fc<RRGGBB>\ or \fc<r,g,b>\Change fill (text) color, e.g. \fcFF0000\ or \fc255,0,0\
\al\ \ac\ \ar\ \aj\Override alignment: left/center/right/justify for the rest of the flow
\\Literal backslash
any other \...\Recognized and stripped (silently ignored)

Font size and fill color are restored to their pre-call values once the flow finishes. Line height is FCurrentFontSize * 1.2 and re-derives whenever a \fs\ tag changes the size mid-flow.

Declarations

C
BOOL32 __stdcall pdfWriteFTextA(PPDF IPDF, TTextAlign Align, const char* AText);
BOOL32 __stdcall pdfWriteFTextW(PPDF IPDF, TTextAlign Align, const wchar_t* AText);
Delphi
function pdfWriteFTextA(const IPDF: PPDF; Align: TTextAlign; const AText: PAnsiChar): LongBool; stdcall; external 'LumasPdf.dll';
function pdfWriteFTextW(const IPDF: PPDF; Align: TTextAlign; const AText: PWideChar): LongBool; stdcall; external 'LumasPdf.dll';

TTextAlign (from Lumas.Pdf.Types; a Cardinal, not an ordinal enum):

Delphi
TTextAlign = Cardinal;
const taLeft = 0; taCenter = 1; taRight = 2; taJustify = 3; taPlainText = $10000000;

Parameters

ParameterTypeDescription
IPDFPPDFInstance handle with an open page and font.
AlignTTextAlignDefault alignment (overridable per segment via \al\/\ac\/\ar\/\aj\).
ATextstringText to flow, optionally containing format tags.

Return valueTRUE if at least one line was drawn; FALSE if no text rectangle has been set (see Remarks), no font is selected, or AText is empty.

Remarks — required precondition not obvious from the signature. Unlike pdfWriteFTextEx, this entry point has no position/size parameters — it draws into whatever rectangle was last set via pdfSetTextRect. Calling it without a prior pdfSetTextRect (with positive width and height) returns FALSE and draws nothing.

See alsopdfWriteFTextEx, pdfGetFTextHeight

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
[return: MarshalAs(UnmanagedType.Bool)]
Area
Text
Category

Text

Exported names

pdfWriteFTextA pdfWriteFTextW

String variants

The …A form takes UTF-8, …W takes UTF-16; a bare name aliases the ANSI form.

See working code

Worked examples — complete programs in ten languages.