API referenceCore SDK

pdfChangeJavaScript

Replace the script text of a document-level named JavaScript

Exported namespdfChangeJavaScriptA, pdfChangeJavaScriptW

Purpose — Replace the script text of a document-level named JavaScript entry (the /Names/JavaScript table, not an action object).

DescriptionThis 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

C
BOOL32 __stdcall pdfChangeJavaScriptA(PPDF IPDF, uint32_t Handle, const char* NewScript);
BOOL32 __stdcall pdfChangeJavaScriptW(PPDF IPDF, uint32_t Handle, const wchar_t* NewScript);
Delphi
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

ParameterTypeDescription
IPDFPPDFInstance handle.
HandleCardinal1-based handle into the named-JavaScript table (returned by the internal AddJavaScript, not by pdfCreateJSAction).
NewScriptstringReplacement script. W is stored with its Unicode flag set.

Return valueTRUE on success; FALSE if Handle is out of range or names an empty slot.

See alsopdfChangeJavaScriptName, pdfChangeJavaScriptAction

C# (P/Invoke)

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

Core

Exported names

pdfChangeJavaScriptA pdfChangeJavaScriptW

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.