API referenceText

pdfReplacePageTextNth

Replace exactly the Index-th non-empty literal show-string

CategoryPositional page-text replacement
Notethe 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

C
BOOL32 __stdcall pdfReplacePageTextNthA(PPDF IPDF, int32_t Index, const char* NewText);
BOOL32 __stdcall pdfReplacePageTextNthW(PPDF IPDF, int32_t Index, const wchar_t* NewText);
Delphi
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

ParameterTypeDescription
IPDFPPDFInstance handle with an active page.
IndexIntegerZero-based index counting non-empty literal (...) show-strings in content order — matches pdfGetPageText's run numbering.
NewTextstringReplacement text, written verbatim as the new literal (no font-aware re-encoding — the W variant just narrows to ANSI bytes).

Return valueTRUE 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 alsopdfReplacePageText

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
[return: MarshalAs(UnmanagedType.Bool)]
Area
Text
Category

Core

Exported names

pdfReplacePageTextNthA pdfReplacePageTextNthW

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.