pdfChangeJavaScript
Replace the script text of a document-level named JavaScript
| Exported names | pdfChangeJavaScriptA, pdfChangeJavaScriptW |
|---|
Purpose — Replace the script text of a document-level named JavaScript entry (the /Names/JavaScript table, not an action object).
Description — This operates on a different registry than pdfCreateJSAction/pdfChangeJavaScriptAction. Named document-level scripts are added by the engine's AddJavaScript(Name, Script, Unicode) (a name-keyed table, FJSName/FJSScript, its own 1-based handle space starting at 1) — this call rewrites the script at Handle in *that* table. Passing an action handle from pdfCreateJSAction here is a handle-space mismatch and will silently fail or hit the wrong slot; the two handle spaces are not interchangeable. Handle must be non-empty-named (FJSName[Handle-1] <> '') for the call to succeed.
Declarations
BOOL32 __stdcall pdfChangeJavaScriptA(PPDF IPDF, uint32_t Handle, const char* NewScript);
BOOL32 __stdcall pdfChangeJavaScriptW(PPDF IPDF, uint32_t Handle, const wchar_t* NewScript);
function pdfChangeJavaScriptA(const IPDF: PPDF; Handle: Cardinal; const NewScript: PAnsiChar): LongBool; stdcall; external 'LumasPdf.dll';
function pdfChangeJavaScriptW(const IPDF: PPDF; Handle: Cardinal; const NewScript: PWideChar): LongBool; stdcall; external 'LumasPdf.dll';
Parameters
| Parameter | Type | Description |
|---|---|---|
IPDF | PPDF | Instance handle. |
Handle | Cardinal | 1-based handle into the named-JavaScript table (returned by the internal AddJavaScript, not by pdfCreateJSAction). |
NewScript | string | Replacement script. W is stored with its Unicode flag set. |
Return value — TRUE on success; FALSE if Handle is out of range or names an empty slot.
See also — pdfChangeJavaScriptName, pdfChangeJavaScriptAction
C# (P/Invoke)
[return: MarshalAs(UnmanagedType.Bool)]
Core
pdfChangeJavaScriptA
pdfChangeJavaScriptW
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.