JavaScript

Wiki Table of Contents

Page Details

First published by:
admin
on 07-07-2009
Last revision by:
Chris Messina
on 07-09-2009
This page has not yet been rated

JavaScript

You can add custom JavaScript actions to your PDF files.

Click Document  > JavaScript and choose from the following:

To add JavaScript actions to PDF document events

  1. Choose Set Document Actions.

  2. Select the Document event in the left window.

  3. Click the Edit button.

  4. Write your JavaScript in the JavaScript Editor text window.

  5. Repair any reported syntax errors and click OK again.

  6. Click OK.

To edit your script directly

  1. Choose JavaScript Console.

  2. Compile your script.

To create custom scripts

  1. Choose Document JavaScripts.

  2. Click Add.

  3. Name your script for identification and click OK.

  4. Click Edit, and compile your script. When done, click OK.

  5. Click Close to finish.

Provided that your script is correct, and it is supported by the version of your PDF, the set event will execute the specified action.

Example

E-mailing the PDF that you have just saved:

  1. Select Document Save Completed in the Set Document Actions dialog.

  2. Click Edit.

  3. Type in the following script: this.mailDoc(true);

  4. Click OK.

After you have successfully saved the PDF, a new, blank e-mail message will pop-up with your PDF attached to it.

Recent Comments

By: Juan José Mari Mari Posted on 09-10-2011 1:28 PM
100% of people found this useful

Javascript in PDF is a powerful tool but there is little or no information available to PDF Converter users of how to use it. Or it is not accessible to me.

I have performed the example stated in the help page for Javascript, and it works well when used EXACTLY how it is defined in the Help article. However, when I try it in the Javascript Console, the answer is: "RangeError: Invalid event type." Cannot understand why this is not working on the console. Do you have any clue for that?

Adobe does have more support than Nuance on this topic. See

livedocs.adobe.com/.../wwhelp.htm

I have tried some of the methods and they do work, but.... the answer is: Should I rely on the fact that Adobe Javascript is 100% compatible with Nuance's?

Comments are welcome.

Thank you in advance.

By: Michael Cox Posted on 09-15-2011 10:24 PM

Juan - would love to know whether you've managed to find out any further info.

I am desparately trying to add javascript to a custom dynamic stamp, based on materials that are readily available for Adobe Acrobat.  

I agree - there appears to be painfully little documentation and support on this point.

What I don't know is how to control when the javascript is triggered (ie to only use if the stamp is being applied).

Any assistance would be appreciated!