API referenceText

pdfGetHTMLTextWidth

Measure the natural (unwrapped) width of HTML at Size —

CategoryHTML text measurement

Purpose — Measure the natural (unwrapped) width of HTML at Size — the width of its widest line with no wrap constraint.

Description — Calls RenderHtml with Width=0 (no wrap) and Measure=True (no drawing); returns the resulting natural width. Because there's no wrap width, this reports the width of the single widest hard-break segment, not a wrapped-paragraph width.

Declarations

C
double __stdcall pdfGetHTMLTextWidth(PPDF IPDF, double Size, const char* HTML);
double __stdcall pdfGetHTMLTextWidthA(PPDF IPDF, double Size, const char* HTML);
double __stdcall pdfGetHTMLTextWidthW(PPDF IPDF, double Size, const wchar_t* HTML);
Delphi
function pdfGetHTMLTextWidthA(const IPDF: PPDF; Size: Double; HTML: PAnsiChar): Double; stdcall; external 'LumasPdf.dll';
function pdfGetHTMLTextWidthW(const IPDF: PPDF; Size: Double; HTML: PWideChar): Double; stdcall; external 'LumasPdf.dll';

Parameters

ParameterTypeDescription
IPDFPPDFInstance handle.
SizeDoubleFont size; <= 0 defaults to 12.
HTMLstringHTML-subset fragment.

Return value — Natural width in points; 0.0 on an invalid handle or parse failure.

See alsopdfDrawHTMLText

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
public static extern double pdfGetHTMLTextWidthW(IntPtr IPDF, double Size, IntPtr HTML);
public static extern double pdfGetHTMLTextWidth(IntPtr IPDF, double Size, IntPtr HTML);
public static extern double pdfGetHTMLTextWidthA(IntPtr IPDF, double Size, IntPtr HTML);
Area
Text
Category

Getters

Exported names

pdfGetHTMLTextWidthW pdfGetHTMLTextWidth pdfGetHTMLTextWidthA

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.