| Category | HTML 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
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);
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
| Parameter | Type | Description |
|---|---|---|
IPDF | PPDF | Instance handle. |
Size | Double | Font size; <= 0 defaults to 12. |
HTML | string | HTML-subset fragment. |
Return value — Natural width in points; 0.0 on an invalid handle or parse failure.
See also — pdfDrawHTMLText
C# (P/Invoke)
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);
Getters
pdfGetHTMLTextWidthW
pdfGetHTMLTextWidth
pdfGetHTMLTextWidthA
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.