pdfGetTextBlockAsString
Extract one page's text and return a single "block" (line) by
| Category | Text extraction |
|---|
Purpose — Extract one page's text and return a single "block" (line) by index.
Description — Calls pdfExtractText internally (Flags=0, no area filter), splits the result on #10, and returns the line at BlockIndex. A "block" here is exactly one reading-order line as produced by the extraction pipeline — not a paragraph, column, or layout-detected text block.
Declarations
const char* __stdcall pdfGetTextBlockAsString(PPDF IPDF, uint32_t PageNum, int32_t BlockIndex);
const char* __stdcall pdfGetTextBlockAsStringA(PPDF IPDF, uint32_t PageNum, int32_t BlockIndex);
const wchar_t* __stdcall pdfGetTextBlockAsStringW(PPDF IPDF, uint32_t PageNum, int32_t BlockIndex);
function pdfGetTextBlockAsStringA(const IPDF: PPDF; PageNum: Cardinal; BlockIndex: Integer): PAnsiChar; stdcall; external 'LumasPdf.dll';
function pdfGetTextBlockAsStringW(const IPDF: PPDF; PageNum: Cardinal; BlockIndex: Integer): PWideChar; stdcall; external 'LumasPdf.dll';
Parameters
| Parameter | Type | Description |
|---|---|---|
IPDF | PPDF | Instance handle. |
PageNum | Cardinal | 1-based page number, same dual-mode resolution as pdfExtractText. |
BlockIndex | Integer | Zero-based line index into the #10-split extraction result. |
Return value — The line text, or NULL/empty if extraction failed or BlockIndex is out of range.
Memory & buffers — Result is a per-instance reusable buffer (D.GapRetA/GapRetW), valid until the next call to this function (or similar "Gap" buffer-returning calls) on the same instance.
See also — pdfExtractText, pdfSplitPageText
C# (P/Invoke)
public static extern IntPtr pdfGetTextBlockAsStringW(IntPtr IPDF, uint PageNum, int BlockIndex);
public static extern IntPtr pdfGetTextBlockAsString(IntPtr IPDF, uint PageNum, int BlockIndex);
public static extern IntPtr pdfGetTextBlockAsStringA(IntPtr IPDF, uint PageNum, int BlockIndex);
Getters
pdfGetTextBlockAsStringW
pdfGetTextBlockAsString
pdfGetTextBlockAsStringA
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.