API referenceText

pdfGetWrappedText

Word-wrap Text to Width at the current font/size, returning

CategoryText measurement
Exported namespdfGetWrappedTextA, pdfGetWrappedTextW, pdfGetWrappedText

Purpose — Word-wrap Text to Width at the current font/size, returning the wrapped result as a single string with Delimiter joining the lines.

Description — Normalizes \r\n/\r to \n first, splits into paragraphs on \n (hard breaks are preserved as separate lines in the output), then greedily packs words per paragraph up to Width (measured via the same GetTextWidthStrW used by pdfGetTextWidth). An over-width single word is not broken by this variant — it is emitted as its own (overflowing) line; see pdfGetWrappedTextBreakString for hard-breaking. Width <= 0 disables width-based wrapping entirely (only hard \n breaks apply).

Declarations

C
const char* __stdcall pdfGetWrappedText(PPDF IPDF, double Width, const char* Delimiter, const char* Text);
const char* __stdcall pdfGetWrappedTextA(PPDF IPDF, double Width, const char* Delimiter, const char* Text);
const wchar_t* __stdcall pdfGetWrappedTextW(PPDF IPDF, double Width, const wchar_t* Delimiter, const wchar_t* Text);
Delphi
function pdfGetWrappedTextA(const IPDF: PPDF; Width: Double; Delimiter, Text: PAnsiChar): PAnsiChar; stdcall; external 'LumasPdf.dll';
function pdfGetWrappedTextW(const IPDF: PPDF; Width: Double; Delimiter, Text: PWideChar): PWideChar; stdcall; external 'LumasPdf.dll';

Parameters

ParameterTypeDescription
IPDFPPDFInstance handle with a selected font.
WidthDoubleWrap width in points; <= 0 disables width-based wrapping.
DelimiterstringJoiner inserted between output lines (not necessarily \n — whatever you pass, e.g. could be a literal `"" or "\r\n"`).
TextstringSource text; runs of spaces collapse to single word separators.

Return value — The wrapped, Delimiter-joined string.

See alsopdfGetWrappedTextBreakString, pdfGetWrappedTextLineCount

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
public static extern IntPtr pdfGetWrappedTextW(IntPtr IPDF, double Width, IntPtr Delimiter, IntPtr Text);
public static extern IntPtr pdfGetWrappedText(IntPtr IPDF, double Width, IntPtr Delimiter, IntPtr Text);
public static extern IntPtr pdfGetWrappedTextA(IntPtr IPDF, double Width, IntPtr Delimiter, IntPtr Text);
Area
Text
Category

Getters

Exported names

pdfGetWrappedTextW pdfGetWrappedText pdfGetWrappedTextA

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.