PDFescape Desktop version allows you to add custom JavaScript code to your PDF documents (not available in the Online version). You can use JavaScript to add interactivity, perform calculations, and validate form data in your PDF forms. Here's how to use JavaScript in PDFescape:
-
Open your PDF document in PDFescape and select the "Form Field" tool from the toolbar.
-
Add a form field to your document, such as a Radio button or a Push-button.
-
Right-click on the form field and select "Properties" from the context menu. You should be in an Edit mode to change the properties of the form
-
In the "Properties" dialog box, select the "Events" tab.
-
Click the "Set" button to add a new action (Action tab).
-
In the "Add Action" dialog box, choose "JavaScript".
-
In the "JavaScript Editor" dialog box, enter your custom JavaScript code.
-
Click "OK" to close the "JavaScript Editor" dialog box and save your code.
-
Click "OK" to close the "Properties" dialog box and save your action.
You can now test your JavaScript code by interacting with the form field you added the action to. For example, if you added a button, you can click on the button to trigger the JavaScript code.
Here are some examples of JavaScript code you can use in PDFescape:
-
To perform calculations in a form field:
this.getField("field1").value = this.getField("field2").value + this.getField("field3").value;
This code adds the values of two other form fields ("field2" and "field3") and sets the result as the value of "field1".
-
To validate form data:
if (this.getField("email").value.indexOf("@") == -1) { app.alert("Please enter a valid email address."); }
This code checks if the value of the "email" field contains the "@" symbol and displays an alert message if it doesn't.
-
To add interactivity:
this.getField("button1").display = display.hidden;
This code hides the "button1" form field when the document is opened. You can use this to create interactive forms that display or hide form fields based on user input.
In summary, PDFescape allows you to add custom JavaScript code to your PDF documents. You can use JavaScript to add interactivity, perform calculations, and validate form data in your PDF forms.