Navigation:  DominoPDF > Helper Functions >

Function: DomPDFAddJavaScript

Previous pageReturn to chapter overviewNext page

The DomPDFAddJavaScript function is used to add document and page level JavaScript to any PDF file.

Note: The DomPDFAddJavaScript function does not support encrypted PDF files. If support for encrypted PDF files is required please contact Primeapple for details.

LOTUSSCRIPT

Declarations

Declare Function DomPDFAddJavaScript Lib "DOMINOPDF.DLL" (Byval szInput As String, Byval szActionLevel As String, Byval szActionType As String, Byval iPageNumber As Long, Byval szJavaScript As String) As Long

Return Value

Returns 0 if successful or -1 if unsuccessful.

Syntax

szInput - A file name and path of a PDF file.

For example;

c:\my documents\contacts.pdf

szActionLevel - The PDF level where JavaScript is added.

This is the location where JavaScript will be added to the PDF file. The options available are;

Document - Add the JavaScript at Document level.

Page - Add the JavaScript at Page level.

Open - Add the JavaScript at the PDF file open level.

szActionType - Depending on the action level, the type of JavaScript action to add.

The Document and Page action levels support different action types (or events). The options available are;

For Document action level; DC - Document Close, WS - Will Save, DS - Did Save, WP - Will Print, DP - Did Print.

For Page action level; O - Page Open, C - Page Close.

For Open action level; Not Applicable.

iPageNumber - For Page action level the page number to use.

This is the page number to use when the Page action level is used.

szJavaScript - The JavaScript to be added or a valid path and file name of a file containing the JavaScript.

This is the actual JavaScript to be added. Can be the actual JavaScript or the path to a file containing the JavaScript code.

For example; app.beep(0);

Example

Sub Initialize

'Declare variables...

Dim sInput As String

 

'Set values...

sInput = |c:\test.PDF|

 

'Error handler...

On Error Goto Error_Handler

 

'Add JavaScript to PDF file...

Call DomPDFAddJavaScript(sInput, "Document", "DC", 0, "app.beep(0);")

Call DomPDFAddJavaScript(sInput, "Page", "O", 1, "app.beep(0);")

Call DomPDFAddJavaScript(sInput, "Open", "", 0, "app.beep(0);")

 

The_End:

Exit Sub

 

Error_Handler:

Print Error$

Resume The_End

End Sub