API referenceCore SDK

pdfExecuteJavaScript

Execute a JavaScript snippet against an embedded, real

C
const char* __stdcall pdfExecuteJavaScriptA(PPDF IPDF, const char* Script, const char* FieldsJSON);
const char* __stdcall pdfGetJSConsole(PPDF IPDF);
Delphi
function pdfExecuteJavaScriptA(const IPDF: PPDF; const Script, FieldsJSON: PAnsiChar): PAnsiChar; stdcall;
function pdfGetJSConsole(const IPDF: PPDF): PAnsiChar; stdcall;

Purpose. Execute a JavaScript snippet against an embedded, real ECMAScript engine with an Acrobat-compatible host object model — per an inline source comment, "Lumas extension: real JavaScript execution (BESEN ECMAScript engine + Acrobat host)" — and read back the accumulated console output (console.log-style diagnostics) from the most recent execution.

Description. FieldsJSON supplies a JSON-encoded initial field-value context the script can read/manipulate (this.getField(...)-style Acrobat API calls resolve against it). This is real script execution, not a stub — a notable capability beyond the classic API's typical scope, called out explicitly as a "Lumas extension."

Parameters.

ParameterDescription
IPDFDocument handle.
ScriptJavaScript source to execute.
FieldsJSONJSON field-value context available to the script.

Return value. pdfExecuteJavaScriptA: pointer to the script's result (transient buffer), or nil if IPDF is invalid. pdfGetJSConsole: pointer to the accumulated console output; nil if IPDF invalid.

See also. pdfGetJSFields (not covered in this volume).

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
public static extern IntPtr pdfExecuteJavaScriptA(IntPtr IPDF, [MarshalAs(UnmanagedType.LPStr)] string Script, [MarshalAs(UnmanagedType.LPStr)] string FieldsJSON);
Area
Core SDK
Category

Core

Exported names

pdfExecuteJavaScriptA

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.