Components for Developers
© 2000-2008, Two Pilots

PDF Library Download Features Manual Tutorials FAQ Pricing HTML2PDF Add-on History In the Lab

PDF Creator Pilot documentation

Download CHM version of this manual.
Actions
CreateJavascriptAction

See Also Example
Collapse All

Creates a JavaScript action in a PDF document.

Syntax

LONG CreateJavascriptAction (
BSTR scriptContents
)
Parameters
scriptContents
String containing JavaScript code.

Return value
Created action index.

Remarks

CreateJavascriptAction is an Action category function that creates a JavaScript action. The described script is compiled and executed by the JavaScript interpreter. Depending on the script, it can interact with the resulting document, such as updating form fields or changing the appearance. Check Adobe Technical Note #5186, "Acrobat Forms JavaScript Object Specification" for the JavaScript script subclass language details.

The return value is an action identifier in document's actions collection and can be used in AddControlToAction, OpenDocumentAction, PDFANNOTATION_OnBeforeFormatting, PDFANNOTATION_OnChange, PDFANNOTATION_OnKeyPress, PDFANNOTATION_OnSetFocus, PDFANNOTATION_OnLostFocus, PDFANNOTATION_OnMouseDown, PDFANNOTATION_OnMouseUp, PDFANNOTATION_OnMouseEnter, PDFANNOTATION_OnMouseExit, PDFANNOTATION_OnOtherControlChanged, PDFPAGE_SetAction, PDFANNOTATION_Action, PDFOUTLINENODE_Action.

Example

How to create JavaSript action, an alert window, associated with the button

Delphi
[copy to clipboard]
{ PDF object is supposed to be created }
PDF.PDFPAGE_CreateControl_Button('Btn1', 20, 90, 65, 105);
PDF.PDFANNOTATION_Caption := 'Alert demo';
actionIndex = PDF.CreateJavascriptAction('app.alert("This window created as result of CreateJavascriptAction")');
PDF.PDFANNOTATION_OnMouseUp := actionIndex;
C/C++
[copy to clipboard]
// PDF object is supposed to be created
PDF->PDFPAGE_CreateControl_Button("Btn1", 20, 90, 65, 105);
PDF->PDFANNOTATION_Caption = "Alert demo";
LONG actionIndex = PDF->CreateJavascriptAction("app.alert(\"This window created as result of CreateJavascriptAction\")");
PDF->PDFANNOTATION_OnMouseUp = actionIndex;
C#
[copy to clipboard]
// PDF object is supposed to be created
PDF.PDFPAGE_CreateControl_Button("Btn1", 20, 90, 65, 105);
PDF.PDFANNOTATION_Caption = "Alert demo";
long actionIndex = PDF.CreateJavascriptAction("app.alert(\"This window created as result of CreateJavascriptAction\")");
PDF.PDFANNOTATION_OnMouseUp = actionIndex;
Visual Basic
[copy to clipboard]
' PDF object is supposed to be created
PDF.PDFPAGE_CreateControl_Button "Btn1", 20, 90, 65, 105
PDF.PDFANNOTATION_Caption = "Alert demo"
actionIndex = PDF.CreateJavascriptAction("app.alert('This window created as result of createJavascriptAction')")
PDF.PDFANNOTATION_OnMouseUp = actionIndex

See Also

PDF Library Download Features Manual Tutorials FAQ Pricing HTML2PDF Add-on History In the Lab

 

 

PDF Library | Virtual Printer | Converters to PDF

Support | Blog | Forum | Contacts

© 2000-2008, Two Pilots