Programming Acrobat JavaScript Using Visual Basic

Programming Acrobat JavaScript Using Visual BasicAcrobat 7.0 provides a rich set of JavaScript programming interfaces that are designed to be used from within the Acrobat environment. It also provides a mechanism (known as JSObject) that allows external clients to access the same functionality from environments such as Visual Basic.
This document gives you the information you need to get started using the extended functionality of JavaScript from a Visual Basic programming environment. It provides a set of examples to illustrate the key concepts.

What is JSObject?
In precise terms, JSObject is an interpretation layer between an OLE Automation client such as a Visual Basic application and the JavaScript functionality provided by Acrobat. From a programmer’s point of view, the end result is that programming JSObject from a Visual Basic environment is quite similar to programming in JavaScript using the Acrobat console.

Tips on Translating JavaScript to JSObject
Covering every method available to JSObject is beyond the scope of this document. However, the Acrobat JavaScript Scripting Reference covers the subject in detail, and much can be inferred from the reference by keeping a few basic facts in mind:
1.Most of the objects and methods in the reference are available in Visual Basic, but not all. In particular, any JavaScript object that requires the new operator for construction cannot be created in Visual Basic. This includes the Report object.
2.The Annots object is unusual in that it requires JSObject to set and get its properties as a separate object using the getProps and setProps methods.
3.If you are unsure what type to use to declare a variable, declare it as a Variant. This gives Visual Basic more flexibility for type conversion, and helps prevent runtime errors.
4.JSObject cannot add new properties, methods, or objects to JavaScript. Due to this limitation, the global.setPersistent property is not meaningful.
5.JSObject is case-insensitive. Visual Basic often capitalizes leading characters of an identifier and prevents you from changing its case. Don’t be concerned about this, since JSObject ignores case when matching the identifier to its JavaScript equivalent.
6.JSObject always returns values as Variants. This includes property gets as well as return values from method calls. An empty Variant is used when a null return value is expected. When JSObject returns an array, each element in the array is a Variant. To determine the actual data type of a Variant, use the utility functions IsArray, IsNumeric, IsEmpty, IsObject, and VarType from the Information module of the VBA library.
7.JSObject can process most elemental Visual Basic types for property puts and input parameters to method calls, including Variant, Array, Boolean, String, Date, Double, Long, Integer, and Byte. JSObject can accept Object parameters, but only when the Object was the result of a property get or method call to a JSObject. JSObject fails to accept values of type Error and Currency.

Website: www.adobe.com | Filesize: 346kb
No of Page(s): 12
Click here to download Programming Acrobat JavaScript Using Visual Basic.

Related Tutorial

Tags: ,

Comments

Leave a Reply