Posts in Category "Javascript"

How to enable the Javascript debugger in Adobe Reader

Using the debugger with Adobe Reader

 The JavaScript Debugger is normally accessed from the Acrobat Pro user interface, but it can also be triggered to appear in Adobe Reader when an exception occurs.  Though fully supported JavaScript debugging is only available in Acrobat Pro, the following instructions make the complete Debugger functionality available in Adobe Reader on Windows and Mac OS platforms.

For Windows, note that this procedure involves editing the registry. Adobe Systems Incorporated does not provide support for editing the registry, which contains critical system and application information. It is recommended that you back up the registry before modifying it.

  1. Get a copy of the file debugger.js from an installation of Acrobat (plugins folder), the Acrobat Developer Center, or from the SDK (Acrobat 9.0 SDK/JavaScriptSupport/Debugger/debugger.js)
  2. Copy the debugger.js into the Reader 9.0/Reader/JavaScripts folder.
  3. Create key/value pairs in the registry settings, starting at the location HKEY_CURRENT_USER\Software\Adobe\Acrobat Reader\9.0\JSPrefs\ on Windows as shown in the table below, or in the property list file :Library:Preferences:com.adobe.Reader9.0.plist on Mac OS.

For Mac OS, use an appropriate editor for the property list file, and add the following children under JSPrefs, using Type “Array” in each case: ConsoleOpen, ConsoleInput, EnableDebugger, and Exceptions. Under each of these children, add the following children: 0 (number) and 1 (boolean).

bConsoleInput REG_DWORD 0×00000001
bEnableDebugger REG_DWORD 0×00000001
iExceptions REG_DWORD 0×00000002
(This will break into the Debugger when exceptions occur.)

4. Close and restart Adobe Reader. At this point the Javascript Debugger will be available.

Note: Since Adobe Reader does not provide access to the Debugger through its menu items or the Ctrl + J key sequence, the only ways to access the Debugger are to execute a JavaScript, cause an error, or customize the user interface (for example, you could add a button that runs a JavaScript causing the Debugger to appear).

VN:F [1.9.22_1171]
Was this helpful? Please rate the content.
Rating: 6.7/10 (3 votes cast)

Acrobat/Reader: can’t set “access” property on Radio-buttons at run-time


It is not possible to set the access property of an individual radio button at run-time in Acrobat or Reader 9, or Acrobat or Reader 7.  This was possible in Acrobat/Reader 8.


Set the property on the exclusion group level (that is, the parent object) and not on the field level. For radio button lists, set the property at the Radio-Button group object and not the individual button object.

Additional information

From Designer 7.1 Help:

About Radio buttons

Radio buttons are contained within exclusion groups. Only one radio button in the exclusion group can be selected at a time.
An exclusion group can be manipulated as one object.
Some options on the Object palette apply to all of the radio buttons in the same exclusion group.


Radio button properties in the Value tab

When you create an exclusion group of radio buttons, the Value tab presents a number of options that you can apply to the entire group.

reference: (181949673)

VN:F [1.9.22_1171]
Was this helpful? Please rate the content.
Rating: 0.0/10 (0 votes cast)

Acrobat/Reader 9: HTTP submit button does not open local files


Security restrictions in Adobe Reader and Acrobat 9 restrict you from opening local files (Excel, Word, and so on) from within a PDF using Javascript (launchURL).  This action poses a security risk for the PDF file, and could allow dangerous files to be opened, and a script to be executed.

In previous versions of Acrobat or Reader (before 9.0), you can point the HTTP Submit button to a file:// URL on a network/local file system. The local file was “downloaded” using the browser’s plug-in. This behavior is not the intention of the HTTP Submit button. So, it’s been locked down in Acrobat and Reader 9 and later.

The HTTP submit button is used to send the form’s data to a server once the form has been filled. The resulting PDF can then be displayed to the user.

To reference or open local files from a PDF, run the PDF file in a privileged context (in the Javascript console or in a batch process). Or, certify the PDF file.  If you are running Acrobat or Reader in a browser context, you could put the local file on a web server and use the HTTP URL.

You can find more information to this security restriction under “app” and then the “methods” tab, and then under the launchURL method:

Extract from the JavaScript Documentation:

Note: Beginning with Acrobat 8.1, file and JavaScript URLs can be executed only when operating in a privileged context, such as during a batch event. File and JavaScript URLs begin with the scheme names javascript or file.

reference: (181917275)

VN:F [1.9.22_1171]
Was this helpful? Please rate the content.
Rating: 7.0/10 (3 votes cast)

Acrobat/Reader 9: no longer works


When you use the method in your form templates you may notice different behavior in Acrobat or Reader 9 compared to previous versions. The method doesn’t work, returns null, or returns the following error: is not a function


Set the target version to 8.1 or later in the Default tab of the template properties in Designer. Or, use the AcrobatVersion parameter in the API. The AcrobatVersion parameter takes precedence over the definition in the template. However, you can use the AcrobatVersion value “Auto” to use the version defined in the templates.

Additional information

The getFocus() method was implemented in XFA 2.6 (Reader 8.1).  If the PDF is rendered with a target version less than 8.1, the call to getFocus doesn’t work.  The target version of a template is defined either:

  • in the XDP template using the Default tab under the template properties, or using the <?formServer defaultPDFRenderFormat acrobat8.1dynamic?> tag in the XML source
  • in the AcrobatVersion setting in the PDFFormRenderSpec when calling the renderPDFForm() method from the Forms API

There is one special case in Acrobat/Reader 8, which allows the call to getFocus() even if the target version is less than 8.1. Therefore, you do not need to use one of the solutions above for Acrobat or Reader 8.  This behavior is a bug in Acrobat 8 as it doesn’t respect the target version and relevant XFA definition. In Acrobat 9, the target version is respected.

reference: (181779861/2714554)

VN:F [1.9.22_1171]
Was this helpful? Please rate the content.
Rating: 0.0/10 (0 votes cast)

Acrobat/Reader: how to close a PDF automatically through Javascript


 If you are trying to close a PDF automatically using Javascript you may encounter differing behaviour depending on whether you are using Acrobat or Reader, and of course, depending on the version.


You should use the setTimeOut() method with the action defined as closeDoc().  The setTimeOut() method must be assigned to a variable in a top level object in the form, to prevent it from being garbage collected when a lower level variable goes out of scope.

In the form:ready event you should add the following script:

var discard = soUtils.closeDoc();

and then create a new Script object on the form with the following code:

function closeDoc()
    var str = "This document will now close."; 
    return app.setTimeOut('this.closeDoc();', 1);

Then the PDF should automatically close itself when opened in Acrobat/Reader.

VN:F [1.9.22_1171]
Was this helpful? Please rate the content.
Rating: 9.8/10 (4 votes cast)

Acrobat/Reader: how to enable Javascript debugger in PDF forms

When you use Javascript in PDF forms, you can enable the Javascript debugger to be able to analyze the Javascript output in Acrobat or Designer.

Use the following approaches to enable Javascript debugging using Acrobat or Designer:

  • Use message box output to display dialog boxes with Javascript values (using the method).
  • Use the Javascript Debugger console in Acrobat. Open it by pressing Ctrl+J or select
    Edit > Preferences > Javascript > Javascript Debugger > Enable Javascript Debugger
    Restart Acrobat to view the Debugger console when using the Preferences option.
  • From Designer, save the form as PDF, open it in Acrobat, and press CTRL+J to open the debugger.
  • Launch Acrobat in the background, open the form in Designer, and goto PDF Preview. This approach uses the Acrobat plug-in, from where pressing Ctrl+J calls up the Javascript debugger.

To execute Javascript expressions directly in the console window, enter the statement and highlight the entire statement using the cursor. (Optionally, highlight multiple lines to execute multiple lines of Javascript code.) Press Ctrl+Enter.

reference: (180009803)

VN:F [1.9.22_1171]
Was this helpful? Please rate the content.
Rating: 8.0/10 (6 votes cast)