Components for Developers
© 2000-2012, Two Pilots

PDF Library Download Features Manual Tutorials FAQ Pricing HTML2PDF-X Pilot History In the Lab

PDF Creator Pilot documentation

Download CHM version of this manual.
Actions
CreateJavascriptAction

See Also Example
Collapse All

This method creates a JavaScript action in a PDF document.

Syntax

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

Return value
Number of the action

Remarks

This method creates a JavaScript action. The specified 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 the document's actions collection and can be used in OnOpenDocumentOnControlMouseDown and other properties (see Annotations).

Example

How to Create a JavaScript Action (an Alert Window) Associated with a Button

Delphi
[copy to clipboard]
{ PDF object is supposed to be created }
btn1 := PDF.AddButton(20, 90, 65, 105, 'Btn1');
PDF.AnnotUnicodeCaption := 'Alert demo';
actionIndex := PDF.CreateJavascriptAction('app.alert("Hello.")');
PDF.OnControlMouseUp := actionIndex;
PDF.SaveToFile('test.pdf', true);
C/C++
[copy to clipboard]
// PDF object is supposed to be created
long btn1 = PDF->AddButton(20, 90, 65, 105, "Btn1");
PDF->AnnotUnicodeCaption = L"Alert demo";
long actionIndex = PDF->CreateJavascriptAction("app.alert('Hello.')");
PDF->OnControlMouseUp = actionIndex;
PDF->SaveToFile("test.pdf", true);
C#
[copy to clipboard]
// PDF object is supposed to be created
long btn1 = PDF.AddButton(20, 90, 65, 105, "Btn1");
PDF.AnnotUnicodeCaption = "Alert demo";
long actionIndex = PDF.CreateJavascriptAction("app.alert('Hello.')");
PDF.OnControlMouseUp = actionIndex;
PDF.SaveToFile("test.pdf", true);
Visual Basic
[copy to clipboard]
' PDF object is supposed to be created
btn1 = PDF.AddButton(20, 90, 65, 105, "Btn1")
PDF.AnnotUnicodeCaption = "Alert demo"
actionIndex = PDF.CreateJavascriptAction("app.alert('Hello.')")
PDF.OnControlMouseUp = actionIndex
PDF.SaveToFile "test.pdf", true

See Also

PDF Library Download Features Manual Tutorials FAQ Pricing HTML2PDF-X Pilot History In the Lab

 

 

PDF Library | Virtual Printer | Converters to PDF

Support | Blog | Forum | Contacts

© 2000-2012, Two Pilots