ExecuteDocumentScript

Forms, JavaScript safety

Description

Runs the document's open action JavaScript or one of its document-level trigger scripts

Syntax

Delphi

Function TPDFlib.ExecuteDocumentScript(Const Trigger: WideString): Integer;

ActiveX

Function PDFlib::ExecuteDocumentScript(Trigger As String) As Long

Available on IPDFlibrary4 from type library version 3.5

DLL

int DLExecuteDocumentScript(int InstanceID, const wchar_t* Trigger);
int DLExecuteDocumentScriptA(int InstanceID, const char* Trigger);

Parameters

TriggerOpen for the open action, or WC will close, WS will save, DS did save, WP will print and DP did print

Return values

Returns 1 when the script ran, or 0 when the action is absent (diagnostics report notRun with reason missingAction), the trigger or target is invalid (LastErrorCode 708, or a missing form or field), or the script is unsupported, invalid or over budget (706, 708, 709)

Remarks

event.type is Doc and event.name is Open, WillClose, WillSave, DidSave, WillPrint or DidPrint. Running a will-save or will-print script does not save or print the document

The script runs in the bounded form-script runtime with the configured limits and host action mode. event.type and event.name identify the event, and event.rc is not used. Field values the script assigns, such as getField("Total").value = ..., are written to the document

Host actions such as app.alert are never performed; see SetFormScriptHostActionMode

Document-level scripts that define functions are not run by this method

See also

ExecuteFormFieldScriptEvent, SetFormScriptHostActionMode, GetFormScriptDiagnostics