Some test text!

Embedded JavaScriptkeyboard_arrow_down

PDF Embedded JavaScript

PDF documents may contain embedded JavaScript (sometimes known as AcroJS) that is often run in response to events on form fields inside the document. This JavaScript executes in a special environment that contains a number of predefined functions for interacting with fields and the document.

Embedded JavaScript might be used for:

  • Calculating a total based on the value of several fields
  • Formatting a field to add a dollar sign at the front
  • Validating the format of a date field and alerting the user if they entered it incorrectly

In WebViewer

You don't need to do anything to enable embedded JavaScript execution, simply load a PDF document that contains embedded JavaScript and the code will run at the appropriate times. For example in response to clicks by the user or automatically when calculating a field value.


If you don't want embedded JavaScript to execute you can call CoreControls.disableEmbeddedJavaScript().

  .then(instance => {


WebViewer provides an API to customize the embedded JavaScript environment if you would like to change the behavior for some reason. The update function provides access to the embedded environment and lets you make changes.

For examle Adobe Acrobat defines a global ADBE object that some older PDFs might check. So you could define the value to prevent certain popups from appearing.

Annotations.Forms.EmbeddedJS.update(scope => {
  // Scope represents the window scope that embedded javascript runs within
  // Define the ADBE namespace so that older PDFs will find it
  scope.ADBE = {};

Get the answers you need: Support


Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.