com.qoppa.pdf
Class JavaScriptSettings

java.lang.Object
  extended by com.qoppa.pdf.JavaScriptSettings

public final class JavaScriptSettings
extends Object

This class contains settings for running JavaScript. It has options to enable / disable Javascript as well as to enable Javascript popups and to enable error reporting. The settings are as follows

JSEnabler - This object is called back when a document is loaded to determine if JavaScript will be enabled. The default is to have this field null, which implies that Javascript is disabled. There is a simple implementation class provided to enable / disable Javascript: JavaScriptEnabler.
AllowPopups - This flag determines if JavaScript alerts will pop up in a message box or be printed to the console. Note that since some alerts require user input, an Exception will be thrown if this flag is set to false when an alert contains more than one option. Default is false.
SilenceErrors - This flag determines if formatting errors generated from predefined formats will pop up in a message box or if the system will beep. The default setting of true means the system will beep instead of popping up a message box.

Author:
Qoppa Software

Method Summary
static IJavaScriptEnabler getJSEnabler()
          Get the JavaScriptEnabler.
static boolean isAllowPopups()
          Returns true if popups are allowed.
static boolean isSilenceErrors()
          Returns true if errors will be silenced instead of displaying an alert.
static void setAllowPopups(boolean allowPopups)
          Set to true to allow pop ups for alerts.
static void setJSEnabler(IJavaScriptEnabler enabler)
          Set the JavaScriptEnabler.
static void setSilenceErrors(boolean silenceErrors)
          Set to true to silence errors.
static boolean shouldEnableJS(IPDFDocument doc)
          Returns true if JavaScript should be enabled for the document.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

shouldEnableJS

public static boolean shouldEnableJS(IPDFDocument doc)
Returns true if JavaScript should be enabled for the document. This is a convenience method, it passes the call on to the registered JavaScriptEnabler object. If there is no JavaScriptEnabler (it is null), then this method return false, disabling Javascript.

Parameters:
doc - The PDF document that is being loaded. This is passed on to the IJavaScriptEnabler implementation.

setJSEnabler

public static void setJSEnabler(IJavaScriptEnabler enabler)
Set the JavaScriptEnabler. If this is set to null, shouldEnableJS() will always return false, thereby disabling Javascript. A default implementation of this interface is provided in the JavaScriptEnabler class, that takes true or false in its constructor. A host application can also create a custom implementation that uses other criteria to determine whether to enable Javascript.

Parameters:
enabler - The implementation of JavaScriptEnabler.

getJSEnabler

public static IJavaScriptEnabler getJSEnabler()
Get the JavaScriptEnabler.


isAllowPopups

public static boolean isAllowPopups()
Returns true if popups are allowed. Otherwise alerts will be printed to standard out. Note that since some alerts require user input, an Exception will be thrown if this flag is set to false when an alert contains more than one option.

Returns:
True if popups are allowed. False otherwise.

setAllowPopups

public static void setAllowPopups(boolean allowPopups)
Set to true to allow pop ups for alerts. If set to false, alerts will be printed to standard out.

Parameters:
allowPopups - Set to true to allow pop ups for alerts. Set to false to print alerts to standard out.

isSilenceErrors

public static boolean isSilenceErrors()
Returns true if errors will be silenced instead of displaying an alert.

Returns:
True if errors will be silenced, false otherwise.

setSilenceErrors

public static void setSilenceErrors(boolean silenceErrors)
Set to true to silence errors. If set to false, errors will display in an alert.

Parameters:
silenceErrors - Set to true to silence errors. Set to false to display errors in an alert.