How To Use Triggers To Run Javascripts In PDF Forms

You can use triggers to run javascripts in PDF forms. You can also run javascripts in PDF forms that will run when the document is opened. The steps follow:

In order to edit the PDF document I used Adobe Acrobat DC. This is not a free app but I think Google has a free app and their are other apps out there for editing PDF documents, however I’m not sure of the capabilities.

Triggers

Be aware that buttons, form fields, radio buttons and similar features are called “fields” in the system. In the form I modified, I created a button field to send the form data over the Internet to our website where a WordPress plugin was waiting to process it.

  • In Tools, Prepare Form: double click the “field” to open up the Properties UI
  • Visibility controls are on the General tab, Common Properties section
  • The field name, for programming purposes, is on the General, Name tab, and NOT the misleading Options, Label tab
  • Several Actions and Triggers are available in the Actions tab
  • An Action is matched with a Trigger
  • “Mouse Up” is the trigger for the completion of a successful mouse click
  • Action: Run a Javascript or Submit a form were the two useful features

Submit a form

  • Submit a form, URL: is the target URL for the form when the user clicks the Send button. The target location must have some sort of processing feature or script that is designed to accept and process the form data. We have a free plugin available for WordPress named PDF Form Receiver with many options included
  • The Submit a form action also has a few formats available. Our free WordPress plugin handles HTML and PDF. HTML setting sends the HTML formatted data. The PDF setting sends the form data as a PDF file attachment

Actions

The Actions system is trigger-based. Now there are instances where you may need to run a javascript within a PDF form automatically when the PDF form is opened, not when something fires a trigger. This is called a Document-level Javascript.

Document-Level Javascript

  • Tools, Action Wizard, Create a New Action, More Tools, Document Javascripts. Fill out the name and description, then Save
  • In the Document Javascripts, you can edit and create your javascript. Do not begin the javascript with a function or it may cause adverse effects
  • Close and Save, then open the PDF in the free Adobe Reader app to test your javascripts

 

Leave a Reply

Your email address will not be published. Required fields are marked *