26.07.2012 Views

Nitro PDF Professional User Guide

Nitro PDF Professional User Guide

Nitro PDF Professional User Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

82<br />

<strong>Nitro</strong> <strong>PDF</strong> <strong>Professional</strong> <strong>User</strong> <strong>Guide</strong><br />

know where to look for JavaScripts. In <strong>Nitro</strong> <strong>PDF</strong> <strong>Professional</strong> you can find JavaScripts in the following<br />

locations:<br />

· Field scripts. JavaScripts can be used with all field types. In all fields you can add scripts in the Set<br />

Actions properties. In signature fields you can add JavaScripts in both the Set Action properties and in<br />

the Signed properties. By far the most opportunity you have for adding scripts in field properties is<br />

with text fields. In text fields you can add scripts to:<br />

o Format properties. Open the Format properties and select Custom from the Select format<br />

category drop down menu. JavaScripts are added to create a Custom Format Script and<br />

Custom Keystroke Script.<br />

o Validate. Open the Validate properties and select Run custom validation script to add a<br />

JavaScript to validate field data.<br />

o Calculate. The Calculate properties are likely to be the most frequent area where JavaScripts<br />

are created. You can write scripts in two areas. Click the Simplified field notation button and<br />

you can write scripts using syntax similar to spreadsheet formulas. Click the Custom calculation<br />

script and you can write JavaScripts to calculate field data.<br />

o Set Action. Like the other fields, text fields support the Run JavaScript action type.<br />

· JavaScript console. You can open the JavaScript Console and write a script that doesn’t belong to<br />

any field or element. Scripts written in the JavaScript Console can be used to test routines and debug<br />

code.<br />

· Document Actions. Opening, saving and printing <strong>PDF</strong>s are all document actions. JavaScripts can be<br />

written when these actions occur. To add a Document Action, go to the Forms ribbon tab, in the<br />

JavaScript group, click Document Actions.<br />

· Document level JavaScripts. A document level JavaScript can be a function that other scripts call in<br />

subroutines. These scripts are contained at the document level and can be executed by another script<br />

or when opening a file.<br />

· Folder level JavaScripts. A folder level JavaScript is located outside of the <strong>PDF</strong> file and can be used<br />

by more than one <strong>PDF</strong>. When <strong>Nitro</strong> <strong>PDF</strong> <strong>Professional</strong> is opened the scripts are run.<br />

12.12.2 Copying and pasting JavaScripts<br />

JavaScripts can be copied and pasted from one field or other location in a <strong>PDF</strong> document or between two<br />

documents. If you examine <strong>PDF</strong> files for learning JavaScript programming, you can browse <strong>PDF</strong> files<br />

containing scripts, copy a script from a document you download from the Internet, and paste the code into<br />

the JavaScript Editor in your document. With a little code modification, you can quickly add scripts to your<br />

own files.<br />

To copy code between <strong>PDF</strong> files just open them both in <strong>Nitro</strong> <strong>PDF</strong> <strong>Professional</strong>.<br />

12.12.3 Using folder level JavaScript<br />

Folder level JavaScripts are JavaScript files (.JS) that are run during application startup. These can be useful<br />

for loading reusable JavaScript functions into the application, or accessing methods/properties whose<br />

security restrictions only allow them to be run in the app/init event.<br />

Simple examples include loading the user's Windows login into a global JavaScript variable at startup, or<br />

loading a list of employee names from your company into a JS array at startup which can be used by the<br />

forms that are opened in <strong>Nitro</strong> <strong>PDF</strong> <strong>Professional</strong>.<br />

To add or edit a folder level JavaScript:<br />

1. Open <strong>Nitro</strong> <strong>PDF</strong> <strong>Professional</strong>.<br />

2. On the Form ribbon tab, in the JavaScript group, click Folder Level .<br />

© 2008 <strong>Nitro</strong> <strong>PDF</strong> Software

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!