| Category | Positional page-text replacement |
|---|---|
| Exported names | pdfReplacePageTextA |
| Note | not a find/replace by content, and every occurrence of the matched bytes is replaced (see Remarks) |
Purpose — Nominally "replace page text"; actually replaces the first show-text operator's literal string content on the active page, and every other occurrence of those exact bytes elsewhere on the same page.
Description — the name is misleading; read this before using it.
- Locates the first
Tj(or first string inside aTJarray) operator onD.ActivePageIndexand captures its raw bytes (oldS) — you do not supply the text to search for; it is always whatever the first show-string on the page happens to contain. - Rewrites the entire page content stream, replacing every occurrence of
oldSas a byte substring inside any literal(...)or hex<...>show-string on the page withNewText— not just the one operator it was found in. If that exact string appears in multiple show-text operators (e.g. a repeated header/footer fragment), all of them change. Stackis accepted in the exported signature but never read by this implementation.
Declarations
BOOL32 __stdcall pdfReplacePageTextA(PPDF IPDF, const char* NewText, TPDFStack* Stack);
function pdfReplacePageTextA(const IPDF: PPDF; const NewText: PAnsiChar; var Stack: TPDFStack): LongBool; stdcall; external 'LumasPdf.dll';
Parameters
| Parameter | Type | Description |
|---|---|---|
IPDF | PPDF | Instance handle with an active page. |
NewText | PAnsiChar | Replacement bytes (ANSI only — this entry point has no W variant; use pdfReplacePageTextEx for Unicode). |
Stack | TPDFStack* | Accepted for ABI compatibility; not read. |
Return value — TRUE if a first show-string was found and at least one substitution occurred; FALSE if the page has no show-text operators or the active page can't be read.
See also — pdfReplacePageTextEx, pdfReplacePageTextNth
C# (P/Invoke)
[return: MarshalAs(UnmanagedType.Bool)]
Core
pdfReplacePageTextA
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.