org.faceless.pdf2
Class JSEngine

java.lang.Object
  extended by org.faceless.pdf2.JSEngine

public final class JSEngine
extends Object

This class handles the running of all JavaScript on the document. It's not required to read or edit the JavaScript actions the make up a document - it's used to actually run those actions, typically by an interactive application like the PDFViewer. This requires a JavaScript implementation, which means at least Java 1.6 or the use of Mozilla Rhino.

Although this class is public there is generally no reason to call the methods in this class directly, unless you're implementing your own PDF Viewer or modifying the JavaScript security permissions.

Since:
2.9

Constructor Summary
JSEngine(JSCoreMethods core)
          Create a new JSEngine
 
Method Summary
 String getImplementationDescription()
          Get a human-readable description of the JavaScript implementation
 String getImplementationType()
          Get a the type of JavaScript implementation
 boolean runEvent(JSEvent event)
          Raise and run the specified JavaScript event.
static void setPermissions(Permissions perms)
           Set the Permissions that are allowed for any JavaScript run by the PDF Library.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSEngine

public JSEngine(JSCoreMethods core)
Create a new JSEngine

Parameters:
core - the JSCoreMethods implementation to use
Method Detail

getImplementationDescription

public String getImplementationDescription()
Get a human-readable description of the JavaScript implementation


getImplementationType

public String getImplementationType()
Get a the type of JavaScript implementation


setPermissions

public static void setPermissions(Permissions perms)

Set the Permissions that are allowed for any JavaScript run by the PDF Library. The JavaScript engines supplied with most Java 1.6 implementations and Mozilla Rhino both allow access to the full Java class hierarchy, so it's important to place restrictions on what actions JavaScript in a PDF can perform, otherwise simply setting a field value with the PDF library could run any Java commands on your system.

By default, a minimal set of the permissions are in place. Enforcing permissions requires a SecurityManager, and the JavaScript engine will install one if none is set.

Since:
2.11.4

runEvent

public boolean runEvent(JSEvent event)
Raise and run the specified JavaScript event. Synchronized - JavaScript in PDF is single threaded

Returns:
the value of event.rc - true if the event succeeded, false otherwise


Copyright © 2001-2012 Big Faceless Organization