Using the debugger with Adobe Reader
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.
- 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).
(This will break into the Debugger when exceptions occur.)
When you use the xfa.host.getFocus() 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:
xfa.host.getFocus 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.
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.
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:
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.
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.