easyPDF SDK Usermanual
PDF Creator Programming API  |  Download Free Trial  |  Contact Us to Purchase

AddDocumentJavaScript Method

Adds a document-level JavaScript to the PDF.

Sub AddDocumentJavaScript(InputFileName As String, OutputFileName As String, ScriptName As String, ScriptContent As String)

void AddDocumentJavaScript(string InputFileName, string OutputFileName, string ScriptName, string ScriptContent)

void AddDocumentJavaScript(String InputFileName, String OutputFileName, String ScriptName, String ScriptContent) throws PDFProcessorException


Return Values



Each script is auto-executed upon document open. All JavaScript function definitions are global, and available to be called from other scripts in the PDF. Multiple scripts behave as if they were merged into a single big script.

Note that the name of a script does not affect its functionality in any way. It is only used for organizational and documentation purposes. You can consider the name of the script as a comment. However, each script must have a unique name that may not be empty. If the specified name is not unique, this function automatically appends a number to it, in order to make it unique.

Note: This function can only add global document-level scripts.

Example Usage

Set oProcessor = CreateObject("easyPDF.PDFProcessor.8")
' Add a message box upon document open. Click for more information
oProcessor.AddDocumentJavaScript "C:\test\input.pdf", "C:\test\output.pdf", "Script1", "app.alert({cMsg:""Hello, World!"", nIcon:1});"