pdfReplacePageTextNth
Replace exactly the Index-th non-empty literal show-string
| Category | Positional page-text replacement |
|---|---|
| Note | the only genuinely single-run-targeted variant, with a hex-string gap (see Remarks) |
Purpose — Replace exactly the Index-th non-empty literal show-string on the active page, leaving every other run untouched.
Description — Unlike pdfReplacePageText/Ex, this call targets one specific run by position, wholesale (the entire matched literal's content is replaced with NewText, not a substring match) and does not touch any other run even if they share identical text.
Declarations
BOOL32 __stdcall pdfReplacePageTextNthA(PPDF IPDF, int32_t Index, const char* NewText);
BOOL32 __stdcall pdfReplacePageTextNthW(PPDF IPDF, int32_t Index, const wchar_t* NewText);
function pdfReplacePageTextNthA(const IPDF: PPDF; Index: Integer; const NewText: PAnsiChar): LongBool; stdcall; external 'LumasPdf.dll';
function pdfReplacePageTextNthW(const IPDF: PPDF; Index: Integer; const NewText: PWideChar): LongBool; stdcall; external 'LumasPdf.dll';
Parameters
| Parameter | Type | Description |
|---|---|---|
IPDF | PPDF | Instance handle with an active page. |
Index | Integer | Zero-based index counting non-empty literal (...) show-strings in content order — matches pdfGetPageText's run numbering. |
NewText | string | Replacement text, written verbatim as the new literal (no font-aware re-encoding — the W variant just narrows to ANSI bytes). |
Return value — TRUE if a literal at Index was found and replaced; FALSE if Index is out of range.
Remarks — verified gap: hex-encoded show-strings are never targeted. This function's scanner only recognizes literal (...) strings; a <...>-hex-encoded show-string is copied through verbatim and does not count toward the Index numbering at all. If a page mixes literal and hex-encoded show-strings, Index only enumerates the literal ones, which can make the numbering surprising relative to reading order.
See also — pdfReplacePageText
C# (P/Invoke)
[return: MarshalAs(UnmanagedType.Bool)]
Core
pdfReplacePageTextNthA
pdfReplacePageTextNthW
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.