Default JavaScript Behavior
Here is the default behavior:
- Qoppa’s PDF components will prompt user to choose whether to enable or disable Javascript when opening a JavaScript-enabled PDF form.
- Qoppa’s Java PDF libraries have JavaScript disabled for all PDF documents.
Turn On JavaScript & Remove JavaScript Warning
To turn on JavaScript and remove the warning popup, for all JavaScript-enabled PDF forms, make the following static call before loading any PDF form:
com.qoppa.pdf.JavaScriptSettings.setJSEnabled(new JavaScriptEnabler(true)); |
The argument to this method is an object that implements IJavaScriptEnabler, the JavaScriptEnabler class used above is a simple implementation of this interface that is always true or false. An application can create its own implementation of the interface to decide whether to enable JavaScript depending on the document or any other external criteria.
Note that the rhino jar file rhino.jar is required in the class path for JavaScript to run. If the jar file is not present, JavaScript will not give any error but simply not run. This jar can be found under the installation folder of the library demo program.
Turn Off JavaScript
To turn off JavaScript, make the following static call before loading any PDF form:
com.qoppa.pdf.JavaScriptSettings.setJSEnabled(new JavaScriptEnabler(false)); |