Link

Enabling PDF JavaScript

Some PDF forms use JavaScript to improve the user experience. It can do a variety of things, such as change field colours, populating fields with options & running calculations as the user enters values.

FormVu makes an effort to emulate the frequently used features of the JavaScript for Acrobat API in the browser. For the majority of files you’ll find FormVu re-creates the functionality needed. It should be noted however, it is not able to emulate all methods and objects.

With the 2 different PDF Form formats (AcroForm & XFA), FormVu handles JavaScript differently in both cases.

XFA

JavaScript is enabled by default. This allows you to utilize some XFA specific features like dynamic reflow, allowing for the PDF to be expanded/reduced as required.

AcroForm

AcroForm JavaScript implementation details are available here.

JavaScript is disabled by default. You can enable the setting either with FormViewerOptions or with a JVM flag.

FormViewerOptions

FormViewerOptions formviewerOptions = new FormViewerOptions();
formviewerOptions.setEnableAcroFormJS(true);

JVM Flag

The JVM flag can be set when run from command line:

-Dorg.jpedal.pdf2html.enableAcroFormJS=true

or from Java:

System.setProperty("org.jpedal.pdf2html.enableAcroFormJS", "true");

This will change the output so that you have two new files output:

  • formvuacroform.js
  • EmbeddedScript.js

Where EmbeddedScript’s content contains the file specific custom JavaScript, this is then dynamically loaded into form.html via formvuacroform.js.

We advise that users are careful with enabling JavaScript, a malicious PDF file could use JavaScript as a possible attack vector. In order to be safe, we suggest that you only convert with JavaScript enabled for PDF files that you trust.


What's included in your FormVu trial?

  • Access to download the SDK and run it locally.
  • Access to the cloud trial to convert documents in the IDR cloud.
  • Access to the Docker image to set up your own trial server in the cloud.
  • Communicate with IDR developers to ask questions & get expert advice.
  • Plenty of time to experiment and build a proof of concept.
  • Over 100 articles to help you get started and learn about FormVu.
  • An exceptional PDF Form to HTML converter that took over 20 years to build!

Start Your Free Trial