A
A Short Acrobat JavaScript FAQ
How can I construct my own colors?
How can I construct my own colors?
Colors are
Array
objects in which the first item in the array is a string describing the color
space ('G' for grayscale, 'RGB' for RGB, 'CMYK' for CMYK) and the following items are numeric
values for the respective components of the color space. Hence:
color.blue = new Array("RGB", 0, 0, 1);
color.cyan = new Array("CMYK", 1, 0, 0, 0);
To make a custom color, just declare an array containing the color-space type and channel
values you want to use.
How can I prompt the user for a response in a dialog?
Use the
response
defined in the
App
object. This method displays a dialog box
containing a question and an entry field for the user to reply to the question. (Optionally,
the dialog can have a title or a default value for the answer to the question.) The return
value is a string containing the user’s response. If the user clicks
Cancel,
the response is the
null object.
var dialogTitle = "Please Confirm";
var defaultAnswer = "No.";
var reply = app.response("Did you really mean to type that?",
dialogTitle, defaultAnswer);
How can I fetch an URL from JavaScript?
Use the
getURL
method of the
doc
object. This method retrieves the specified URL over
the internet using a GET. If the current document is being viewed inside the browser or
Acrobat Web Capture is not available, it uses the Weblink plug-in to retrieve the requested
URL.
How can I determine if the mouse has entered/left a certain area on
an Acrobat form?
Create an invisible, read-only text field at the place where you want to detect mouse entry
or exit. Then attach JavaScripts to the mouse-enter and/or mouse-exit actions of the field.
270
Acrobat JavaScript Scripting Guide