API referenceText

pdfGetTextBlockAsString

Extract one page's text and return a single "block" (line) by

CategoryText 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

C
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);
Delphi
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

ParameterTypeDescription
IPDFPPDFInstance handle.
PageNumCardinal1-based page number, same dual-mode resolution as pdfExtractText.
BlockIndexIntegerZero-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 alsopdfExtractText, pdfSplitPageText

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
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);
Area
Text
Category

Getters

Exported names

pdfGetTextBlockAsStringW pdfGetTextBlockAsString pdfGetTextBlockAsStringA

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.