0% found this document useful (0 votes)
232 views

101 Formse Tips

Ted padova Designing Forms Graphics and text that fall off a page can only be handled in Adobe InDesign. To create Adobe PDF Layers, you need to use an application that supports creating layers.

Uploaded by

motionblur1
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
232 views

101 Formse Tips

Ted padova Designing Forms Graphics and text that fall off a page can only be handled in Adobe InDesign. To create Adobe PDF Layers, you need to use an application that supports creating layers.

Uploaded by

motionblur1
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

http://www.acrobatusers.

com/blogs/tedpadova 101 Forms eTips


1

101 Forms eTips

ted padova

http://www.west.net/~ted
http://www.acrobatusers.com
http://www.acrobatusers.com/blogs/tedpadova

ted padova [email protected]


welcome 101 Forms eTips
2

Welcome
LICENSE AGREEMENT:
By opening this file you agree to the terms and conditions
of this License Agreement.
1. This document is yours! You are free to do with it as
you wish without reservation.
2. You can distribute the document to whomever you
wish.
3. You can modify the document as you see fit.
4. You can claim any or all information as your own
without giving credit to the author
(this will be our secret).
5. You can use the Replace Pages command in Acrobat
and eliminate any unwanted photos you see. You can

enjoy!
replace the photos on this document with your own
images thereby acknowledging you as the author of
this file.
6. You can cut, copy, and paste any or all information into
other documents of your own design.
ted
ted, I understand, and I
Agree Do not Agree

Clicking agree and saving the file will eliminate this annoying message.

ted padova [email protected]


designing forms
3

Designing
Forms
Indicates that the procedure
cannot be executed in
Adobe Reader
name
Address
City State
eMail Address
Phone
Contact info

ted padova [email protected]


designing forms

1 2
4

Breaking Page Borders Changing Midpoints on Objects


Graphics and text that fall off a page can only be handled in Adobe Suppose you want a graphic to fall completely off
InDesign. To design a form with objects breaking page borders, do a page. Do the following:
the following:
 Create a 1-pixel new document in
 Add an object or text to a Master Page. Photoshop on a layer.
 The center point of the object must be within the page  Save the file as a .psd file.
border.
 Place the 1-pixel file in InDesign on a
 Choose Object | Interactive | Convert to Button. Master Page.
 Apply the Master Page to a document page.  Add the graphic and place on a Master Page
 Export to PDF —in the Export Adobe PDF dialog box  Group the graphic and the 1-pixel image.
be certain to check the box for Interactive Elements.
 Be certain the center point of the grouped objects falls within
the page border.
 Follow steps in Tip #1 to export to PDF.

ted padova [email protected]


designing forms

3 4
5

Creating PDFs with Adobe PDF Layers Adding Buttons to Layers


In order to create Adobe PDF Layers, you need to use an Adding any kind of form field to a PDF in Acrobat
application that supports creating layers. Programs such as applies the field to all layers in the document. If you
Adobe InDesign, Adobe Illustrator, and AutoCAD are among those want to add Button fields that appear only when
applications that enable you to export layered files to PDF. a given layer is in view, add the buttons in Adobe
InDesign. To add a button in Adobe InDesign, do
Layered files offer you additional design opportunities for your the following:
forms. You might want to change a layer view to play a video file,
show a layout for a seating chart or map to a location, or many  Place an image or add a line of text on a document page.
other similar conditions.
 Select the image or text frame.
To export to Adobe PDF, be certain to check the box in your applica-
tion or when using the PDF Maker for exporting layers such as the  Choose Object | Interactive | Convert to Button (alternately
check box shown when exporting to PDF from Adobe InDesign. you can open a context menu and choose the same menu
command).
 Click the Select tool and double click an object or choose
Object | Interactive | Button Options.
 Click the Select tool and double click an object or choose
Object | Interactive | Button Options.
 Choose a Behavior from the drop down menu and click the
Add button to assign an action to the button.
Note that there
are only a limited
number of actions
Set the layer view in your you can assign to
t e d ’s t i p
application program that a button in Adobe
you want shown in Acrobat InDesign. If you
don’t find the
before you export to PDF. The action you want
visible and hidden layers in to assign to the
your application document button, you can
will appear with identical add an Action in
visibility when you open the Adobe Acrobat.
PDF file.

ted padova [email protected]


designing forms

5 6
6

Adding Hyperlinks in Application Documents Designing for RFFR


In a word, don’t add links to views, pages, sections, etc. in an Run Form Field Recognition works best on forms
application document such as Adobe InDesign. When you create that have lines identifying field locations. If you
links and bookmarks in Adobe InDesign and export to PDF, the links create form designs in programs that support
are made to Named Destinations. layers and your field objects are rectangles, filled
boxes with colors or gradients, or other complex
Destinations add a lot of overhead to your file size. When possible, design elements, using RFFR won’t properly
try to avoid creating Named Destinations in your PDF files. create the field objects.
To over come the problem, do the following:
 Create a temporary layer in your form design (remember you
need to be working in a program that supports layers and
exporting to PDF with Adobe PDF Layers.
 Copy the field objects to a temporary layer. If you use boxes
for the final design, press the Option/Alt key and drag
selected objects in the layers panel to the temporary layer.
 In InDesign or Adobe Illustrator, delete the top, left, and right
side of the boxes leaving the bottom line on each box.
 Export to PDF with Adobe PDF Layers.
 Open the Layers panel and select
the temporary layer.
 Choose Forms | Run Form Field
Recognition.
t e d ’s t i p Likewise, don’t create links  Hide the temporary layer.
for URLs and email addresses.
Acrobat viewers 7 and above  In the Layers panel open the Options
are intelligent and automati- menu and choose Flatten Layers.
cally recognize URL and email
text without creating links. t e d ’s t i p To duplicate selected objects on a
Like Destinations, adding layer, open the Layers panel and notice
links increase your file size. the small rectangle appearng aside the
Layer name. Press Option/Alt and drag
the rectangle to a new layer to
duplicate the selected items.

ted padova [email protected]


designing forms

7 8
7

Replacing Pages Replacing Pages in Tiled Views


The command I use most when creating forms and slide presen- If you have a number of pages to replace in a document
tations is the Document | Replace Pages command. I always find or you want a more visual approach to replacing pages,
myself tweaking the page design after I’ve added fields on a form. you can drag and drop pages between documents.
Because Acrobat doesn’t provide you a very good editing environ- Here’s how to do it:
ment in terms of editing text and images, the ideal method for edit-
ing documents is to return to the authoring program, make your  Open two documents in Acrobat. One file is your
changes, and export to PDF. original design and the other file is the new design.

If you added a number of fields to an original design, then you’ll  Choose Window | Tile | Vertically.
want to change the background data while retaining the field ob-  Open the Pages panel on both documents.
jects. To to do so:
 Click and drag the thumbnail on the new design to the old
 Modify a form in the original authoring program. design containing field objects.
 Export to PDF.  Move the cursor to the page number below the thumbnail
and wait until the page appears reversed in color (black).
 Open the file containing field objects.
 Choose Document | Replace Pages.  Release the mouse button and the page is replaced.
 Select the new design and click OK.

t e d ’s t i p I find that when I edit a


design and export to PDF
I name the new file with a
number preceding the file
name —something like
0.myFormDesign.pdf. When
it comes time to replace the
page, there’s no question
about what file I need to use
for the page replacement

ted padova [email protected]


designing forms

9
8

Editing Text on a Form


The ideal, of course, is to return to the authoring program, edit your  The text is reformed into a contiguous block and can now be
document, and export to PDF. Next, use the Replace Pages methods edited with word wrap and paragraph controls. Edit the text
described in Tips #7 & 8. as needed.

There may be times however where you need to edit a legacy form
and you don’t have the original authoring application document. To
edit text on such a form, do the following (note that this tip requires
you to have Adobe Illustrator installed on your computer).
 Click a text block with the TouchUp Object tool.
 Open a context menu and choose Edit Object.
By default, the text opens in Adobe Illustrator. When
you select the text you’ll notice the lines broken and
the paragraph formatting is lost.
 Choose File | Save.
Be certain to use Save and not Save As.
 View the PDF File.
The text is dynamically updated in the PDF.

t e d ’s t i p Note that if you don’t have


the same fonts installed on
your system that were used
 Open the Rulers and drag guidelines to the bounding area of in the original form, opening
the text block.
the file in Illustrator will
 Select all the text. cause font substitution.

 Choose Edit | Cut (Command/CTRL + X). If you must edit the form
rather than recreating it,
 Click the Type tool in the Toolbox and draw a rectangle to the choose a typeface close to
guidelines. the original font that you
have installed on your
 Choose Edit | Paste. system.

ted padova [email protected]


designing forms

0 12
9

Editing Images on a Form Flattening Fields


Again, if you have a legacy form and don’t have the original appli- Field objects like destinations and links add
cation authoring document you can edit images in a program like overhead to your files ad increase file size.
Photoshop or Photoshop Elements. Additionally, form fields add to the file size. If
you have a form that no longer requires editing
To edit an image do the following: the field data and you want to display the form
while retaining the data you can flatten the
 Click an image with the TouchUp Object tool. fields.
 Press the Option/Alt key and double click the image. Follow these steps to retain data while eliminating field objects:
By default, the image opens in Adobe Photoshop.  Choose Advanced | PDF Optimizer
 Edit the image and click Save (not Save As).  Click Discard Objects in the left pane in the PDF Optimizer.
Your edits are dynamically changed in the PDF document.

1
Adding Document Properties
Some authoring applications offer you options for adding
Document Property information such as Title, Subject, Author, and  Click OK.
Keywords.
If you redesign a form and create several PDFs during the process,
 Name the file.
you’re best off adding Document Property information in the  Click Save.
authoring application so you don’t have to keep editing the proper-
ties on each new file in Acrobat.
 In a program like Adobe InDesign, choose File | File Info. t e d ’s t i p Be certain to provide a new
name when prompted by the
 Fill in the fields for Document Title, Author, Description, and PDF Optimizer before you
Keywords. save the file. Keep the origi-
nal file just in case you need
 Export to PDF to go back and make some
The Document Properties are retained. This information is edits on the form.
particularly important when you want to search for forms on
your hard drive or server.

ted padova [email protected]


working with fields
10

Working
with Fields
Indicates that the task
name Ted Padova
cannot be performed in
Address 555 Techo Way
City Davao State PI
Adobe Reader
eMail Address [email protected]
Phone 888.555.1212

Item Price Qty Amount


Golf balls 39.95 2 $79.95
Glove 12.95 1 $12.95
Hat 29.95 1 $29.95
Total $122.80

SUBMIT FORM

ted padova [email protected]


working with fields

3 15
11

Using Run Form Field Recognition Creating Comb Fields


RFFR is fine for simple forms not requiring a lot JavaScript and cal- Comb fields are often found on government
culations. If you have complex tables and you need to use hierarchi- forms where a user is expected to fill in sepa-
cal names for your fields to simplify calculations, you’re better off rate boxes (or divisions with vertical lines) as a
not using RFFR. single field object.
For simple forms do the following: Comb fields properties are applied to text
fields.
 Open the form in Acrobat Pro.
To create a comb field, do the following:
 Choose Forms | Run Form Field Recognition.
 Create a text field.
 Edit fields as need to finish up the form.

4
 Open the Text Field Properties dialog box (double click the
field with either the Select Object tool or the Text Field tool
or open a context menu on a selected field and choose
Scanning for Run Form Field Recognition Properties to open the Text Field Properties dialog box).
You can scan paper forms and use Run Form Field Recognition by  Click Options.
following the steps below:
 Scan a form using a high interpolated resolution of 1200 ppi  Remove the check marks for Scroll Long Text and Check
Spelling.
or above.
 Choose Document | OCR Text Recognition |  Click the Comb of check box. 1 2 3 4 5 6 7 8
Recognize Text Using OCR.  Type a value in the characters field box for the number of
characters you want to use in the comb field.
 Choose Forms | Run Form Field Recognition.

t e d ’s t i p When you use Recognize


Text Using OCR Acrobat will
straighten a scan within 14
degrees of rotation.

ted padova [email protected]


working with fields

6 17
12

Creating Arbitrary Masks Formatting Numbers


An arbitrary mask might be used for a section number, an account If you add calculations to fields you must
number, an identification code or similar type of field. The mask can format the fields as numbers. Before writing
contain alpha, numeric, or both types of characters. JavaScripts, using Simplified Field Notation, or
using the formula presets, be certain to format
Quite often, you might use an arbitrary mask for an area on a form all the fields containing numeric values.
that might be used for Official Use Only. If the user needs to fill in
a field with an arbitrary mask, it’s helpful to add an instruction or To format text fields as number containers do
dialog box informing the user exactly how to fill in the field. the following:
To create a field with an arbitrary mask do the following:  Create a text field.
 Create a text field.  Open the Text Field Properties dialog box (double click the
field with either the Select Object tool or the Text Field tool
 Open the Text Field Properties dialog box. or open a context menu on a selected field and choose
Properties to open the Text Field Properties dialog box).
 Click the Format tab.
 Click the Format tab.
 Choose Special from the Select format category drop down
menu.  Choose Number from the Select format category menu.
 Scroll the Special Options list and choose Arbitrary Mask.  Select options for the number attributes.
 Type a code in the field box below the Special Options list.

Note: wildcard alpha characters are A, wildcard numeric characters


are 9. Any other character retains the character in the code.
Arbitrary mask field: GF-5431-761-EE

ted padova [email protected]


working with fields

8 19
13

Adding Button Faces Adding Rollovers to Button Faces


A button face is an icon or an image appearing within a Button To format text fields as number containers do
field. You can use button faces for importing images or using icons the following:
for buttons that invoke actions such as resetting a form, submitting
a form, navigating pages, playing and stopping video clips, and a  Follow steps in Tip # 18 to create a button
number of other action items you want to assign to a button. face.

To add a button face to a Button field, do the following:  Choose Push for the Behavior

 Create a button field.  Click Rollover in the State list.

 Open the Button Field Properties dialog box.  Follow the same steps for importing a button face.

 Click the Options tab.


 Choose Icon only from the Layout drop down menu.
 Click Choose icon.
 Click Browse in the Select Icon dialog box.
 Navigate folders on your hard drive to locate a file to import
as a button face.
Note that from the Files of type (Windows) or Show (Macin-
tosh) drop down menu you can choose from a number of
different file formats to import for your button face.
 Select the file to import and click Select.
 Click OK in the Select Icon dialog box.

t e d ’s t i p When adding buttons, t e d ’s t i p Creating buttons with trans-


choose from the options parency is quite simple. For
in the Behavior drop down vector objects use Adobe
menu. If you choose None, Illustrator. For images, add an
you can eliminate the focus image to a transparent layer
rectangle when the button is and save the file as a PDF. All
clicked. transparency is preserved
with both Illustrator and
Photoshop layered files.

ted padova [email protected]


working with fields

0 21
14

Duplicating Buttons Across Multiple Pages Adding a Reset Button


A common use for a Button with a button face is navigating pages. To add a button to reset the form fields, do
If your files are displayed in Full Screen mode, you may want to add the following:
navigational buttons to help the end user move around your docu-
ment.  Create a Button field.

To create a navigational button and duplicate it across multiple  Click the Actions tab.
pages, do the following:  Choose Reset a form in the Select Action
 Add a button to the second page of a multi-page document. menu.

 Click the Action tab and add an action to move to the next  Click Add.
page. You can use either an Execute Menu Item action or a
JavaScript Action to move to the next page.  Check the fields you want to reset in the Reset a Form dialog.

 Choose Execute a Menu Item from the Select Action drop


down menu and click Add.
 Click View>Go To>Next Page in the Menu Item dialog box.
 Repeat the same steps for a button to navigate to the previ-
ous page. Click View>Go To>Previous Page in the Menu Item
dialog box.
 Click OK and Close the Button Field Properties dialog box.
 Select both buttons.
 Open a context menu on the button and choose Duplicate.
 Enter the Page Range in the Duplicate Field dialog box (3 to
[last page number]).
 Click OK. t e d ’s t i p A much better way to reset
 Click the previous button and choose Duplicate. a form is to use a JavaScript.
You have a much easier way
 Enter 2 for the Page Range. (Note: if you want a button on to identify fields to clear
page 1 for navigating to the next page, start on page 2 data if you name the fields
instead of page 3 and follow the same steps. properly. See Tip # 59 for
more on resetting forms with
JavaScripts.

ted padova [email protected]


working with fields

2 23
15

Submitting Forms to eMail Addresses Creating a Table


To create a Submit Form button, do the following: One thing to remember when creating tables
in Acrobat is to avoid using hierarchical
 Add a button on a form. names. In most cases, you’ll want Acrobat to
rename the first row fields with parent/child
 Open the Button Field Properties dialog box and click the names.
Actions tab.
To create a table, do the following.
 Choose Submit a form from the Select Action drop down
menu.  Add text fields across a row or column and format the fields
—especially the number fields.
 Click Add.
 Type an eMail address in the top field in the Submit Form  Select the fields and open a context menu.
Selections dialog box. The syntax for the line of type is:  Choose Place Multiple Fields.
mailto:<your email address>  Enter the number of rows and columns you want for the
table in the Create Multiple Copies of Fields dialog box and
 Check an export format and click OK. click OK.

t e d ’s t i p

Item Price Qty Amount


$19.95 2 $39.90
$89.95 1 $89.95
$19.95 1 $19.95

If you want the PDF


returned to you by Adobe Total $149.80
Reader users, be certain
to enable the form with
Adobe Reader usage rights
before sending your form t e d ’s t i p To learn how to straighten up
to Reader users. the rows and columns, see
Tip # 24.

ted padova [email protected]


working with fields

4 25
16

Managing Fields Setting Appearance Defaults


When you create tables as shown in Tip #23, the fields may not fall When creating Button fields I personally
within the table area of your design. With a few short steps using dislike the default gray fill on Button fields. If
context menus you can align fields within any table. you want to change the default appearance
of buttons or any other kind of field, do the
 Create a table following steps in Tip #23. Don’t bother trying following:
to mess around with positioning fields in the Create Multiple
Copies of Fields dialog box.
Note that the first row (or column) of fields should be aligned  Add a field to a document page and adjust the Appearance
properly before you create the table. settings as you like in the Appearance tab of the field’s prop-
erties dialog box.
 Select the last row (or column) of fields and move them to
position in the last row (or column) of your table design.  Click Close and open a context menu on the field.
 Use the Select object tool and drag through the first column  Choose Use Current Properties as New Defaults.
(or row) to select only one column (or row) of fields.
When you quit Acrobat and relaunch the program, the new
 Open a context menu and choose Distribute | Vertically (or defaults are still honored in Acrobat.

26
Horizontally).
 Select the next row (or column) and perform the same steps.
Duplicating Fields
For a quick method for duplicating fields, do
the following:
 Create one or more fields on a page.
 Select the field(s) with the Select Object
tool.
 Press the Option/CTRL key and drag the field(s) to duplicate.
t e d ’s t i p Additional context menu
commands appearing when t e d ’s t i p Another quick method for du-
you open the menu on plicating fields is to select the
selected fields include fields you want to duplicate
aligning fields and sizing and press the Option/CTRL key.
them. With the fields selected and the
modifier key depressed strike
the Right or Left Arrow key.

ted padova [email protected]


working with fields

7 28
17

Adding an Address Block Renaming Fields


Adobe LiveCycle Designer has a nifty group of fields in the Library Take a look at Tip #27 and you’ll find an
panel called an Address Block. See Tip #87 for more on using the example of one good reason why we would
Address Block in Adobe LiveCycle Designer. want to change field names. Changing field
names that use a hierarchical structure is
Unfortunately, Acrobat doesn’t have an easy way to add these com- quite easy in Acrobat. Let’s take Tip #27 as
monly used fields. Here’s a little workaround to help out. an example and do the following:
 Create a blank new page by choosing File | Create PDF | From  Choose View | Navigation Panels | Fields.
Blank Page.
Using Tip #27 as an example, you’ll find the root name ap-
 Add Fields on the blank new page for last name, first name, pearing as xxx. Nested below the root name are the fields
address 1, address 2, city, state, zip, email, and phone con- with child names.
tacts (i.e., land, mobile, and fax).
 Open a context menu on the root name (in this example xxx).
 Name the fields xxx.last.name, xxx.first.name, xxx.address1,
xxx.address2, xxx.city, etc. The important thing is to use  Choose Rename field.
parent/child names and use something like xxx for the root
name. (See Tip #28 for instructions on changing field names).  Type a new parent name (such as employee) and press enter.
All fields will take on the parent name and you’ll see field
 Save the file to a location where you want to keep templates names like employee.last.name, employee.first.name, etc.
and commonly used files.
 While the file is still open in Acrobat, choose File | Organizer | t e d ’s t i p

Add to a Collection. (Note you must first save your document


before the menu command will be active).
 Click a Collection in the Add to Collection dialog box or click
the New Collection button to create a new collection and
save your file to that collection.
Each time you want to add an address block, open the file
from the Organizer and copy fields from the template docu- You can quickly access navi-
ment and paste the address block in your new form design. gation panels by opening a
context menu on a Navigation
t e d ’s t i p When you create a blank new page Panel button and choose the
you get an annoying text block on the panel you want to display.
new page. To eliminate the text block
and use the blank page for a template,
choose File | Save and save the file.
When you reopen the file, the text block
is gone.

ted padova [email protected]


working with fields

9
18

Duplicating Check boxes and Radio Buttons


Check box and radio button fields most often are named with the
same identical field name, but they are assigned different Export 5XPDPMVNOT
Values in the Options tab. PGDIFDLCPYöFMET
If you want to create a table containing a series of check boxes or
radio buttons you can’t use Place Multiple Fields described in Tip #23
where I talked about creating tables. For check boxes and radio but-
tons you need a little workaround.
 Create one column or row of check boxes or radio buttons
using the Place Multiple Fields command explained in Tip
#23.
NOTE: be sure to name the fields using a hierarchical name
—something like xxx.item. Acrobat will name the fields xxx.
item.0, xxx.item.1, xxx.item.1, etc. when you create the table.
 Distribute the fields so they line up as described in Tip #24.
 Select the fields using the Select Object tool.
 Press Option/CTRL and drag to duplicate the fields as  Choose Edit | Copy or press Command/CTRL + C.
described in Tip #26. Move the duplicated fields to position
in the table.  Open the Fields panel and rename the parent name of the
fields as described in Tip #28.
 While the new column (or row) of fields is selected, open the
Properties dialog box and click Options. Note that you can  Choose Edit | Paste or press Command/CTRL + V. Note that
edit Options for multiple fields. the pasted fields will have different names since you copied
them before changing the parent name of the selected fields.
 Change the export value. If you used the default value Yes for
the first column (or row), change the value for the duplicated  Again rename the fields in the Fields panel and move the
fields to No. fields to position. Repeat the steps until you finish adding
fields to all columns/rows.
 Click Close in the Properties dialog box.
At this point you should have two columns (or rows) of fields t e d ’s t i p
When you paste fields on a form, be certain to have
properly formatted and having different export values for the the Select Object tool selected. If the Hand tool is
fields in row 1 vs. 2 or column 1 vs. 2. selected and you paste fields, clicking the Select
 Select both columns (or rows) of fields. Object tool to move the fields deselects the fields
and can make it difficult to reselect them.

ted padova [email protected]


working with fields

0
19

Adding Barcode Fields


You’ll want to observe a few precautions when creating barcode
fields.
Commercial
 Populate a form with all the fields you expect to see on the
final form.
 Save the form.
 Test the form by filling in all the fields.
 While the fields are populated with data, add a Barcode field
(click the Barcode tool and draw a rectangle on your form).
Barcodes need to know how much data are to be added to
the code to estimate the size of the field, hence your reason
for populating the form with data.
 Click the Value tab in the Barcode Properties dialog box.
 Click Pick to open the Field Selection dialog box.
 Uncheck boxes for the fields that you don’t want to be added
to the barcode.

Keep in touch with what’s happening with


Acrobat, PDFs, and
LiveCycle Designer on Acrobat Users.
http://www.acrobatusers.com

ted padova [email protected]


setting initial views
20

Initial
Views
name Ted Padova

Address 555 Techo Way


Indicates that the task
City Davao State PI cannot be performed in
eMail Address [email protected] Adobe Reader
Phone 888.555.1212

Item Price Qty Amount


Golf balls 39.95 2 $79.95
Glove 12.95 1 $12.95
Hat 29.95 1 $29.95
Total $122.80

SUBMIT FORM

ted padova [email protected]


setting initial views

1 32
21

Setting Initial Views Opening in Full Screen Mode


Perhaps one of the most overlooked setting most forms authors Full screen mode can be an ideal viewing
make is not setting an initial view for the way they want a form to experience for users filling out a form espe-
be displayed on a computer monitor. If left to individual users, pref- cially forms that are designed with landscape
erences for initial views can vary greatly meaning your forms will views.
appear with a different initial view on different users' computers.
It’s important to add all navigation buttons,
The first thing to determine is how do you want your form dis- print, reset, exit, and submit buttons on
played on a user’s system. If you have multiple pages, do you want forms that you want displayed in Full Screen mode.
the Page Layout to be single pages or a continuous page view?
What zoom level do you want the user to see when they open your To save a file that will open in Full Screen mode do the following:
form? Should it open with a 100% view, a Fit in Page view, or a dif-
ferent zoom level?
 Press Command/CTRL + D to open the Document Properties
dialog box.
When you make choices in the Initial View tab of the Document  Click the Initial View tab.
Properties and save your form, the settings prevail on everyone’s
 Check Open in Full Screen mode and save the file.

33
computer and overrides the individual user’s preferences settings.
To set an initial view, do the following:
Hiding the Cursor in FS Mode
 Press Command/CTRL + D to open the Document Properties
dialog box. If you have all the navigation buttons on a
form the default cursor that appears when
 Click the Initial View tab. you open a file in Full Screen mode can be
 Choose a Page Layout from the Page Layout drop down distracting for users. With a simple JavaScript
menu. you can eliminate the cursor that advances
page navigation.
 Choose a magnification setting from the Magnification drop
down menu. Do the following to hide the cursor when a file opens in FS mode.

 Save the form and the Initial View settings are saved with the  Choose Advanced | Document Processing | Document
document. JavaScripts.
 Type a name in the Script Name field box and click Add.
 Delete the default text and type:
app.fs.clickAdvances = false;
 Click OK, click Close in the JavaScript Functions dialog box,
and save the file.

ted padova [email protected]


setting initial views

4 36
22

Hiding the Navigation Panel Setting Custom Zoom Levels


If your forms are intended to be filled in in standard viewing mode When you make adjustments for the Initial
you can gain a little more real estate for viewing a from when the View, you choose zoom views from a set of
Navigation Panel is hidden. preset magnifications.
 Press Command/CTRL + D to open the Document Properties If you want to use a zoom view other than a
dialog box. preset, you need to write a JavaScript to set a
custom view.
 Click the Initial View tab.
Here’s how you do it:
 Check Hide Window Controls under the User Interface
Options.  Choose Advanced | Document Processing | Document
JavaScripts.
 Save the file. The next time you open the document, the
Navigation Panel is hidden.  Type a name in the Script Name field box and click Add.

5
 Delete the default text and type:
Viewing the Navigation Panel this.zoom = 69;

If you want to temporarily view the Navigation Panel when a file has The above script sets the zoom view to 69% when the file is
been saved with Hide Window Controls, do the following: opened.

 Move the cursor to the far left of the Document Pane.  Click OK, click Close in the JavaScript Functions dialog box,
and save the file.
 Open a context menu.
 Choose Show Navigation Panel Buttons.

ted padova [email protected]


writing javascripts
23

Writing
JavaScripts
Indicates that the script cannot
be executed in Adobe Reader

name Ted Padova

Address 555 Techo Way


City Davao State PI
eMail Address [email protected]
Phone 888.555.1212

Item Price Qty Amount


Golf balls 39.95 2 $79.95
Glove 12.95 1 $12.95
Hat 29.95 1 $29.95
Total $122.80

SUBMIT FORM

ted padova [email protected]


writing javascripts

7 38
24

Navigating Views Creating an Application Alert


On a button action do the following: Application alerts can help you save some
space on a form. Rather than adding instruc-
 Create a Button field. tions on the form itself, you can create one or
more application alert dialog boxes to inform
 Click the Actions tab. users procedures for filling in a form.
 Choose Run a JavaScript from the Select Action drop down Follow these steps:
menu.
 Type one of the following scripts in the JavaScript Editor.  Choose Advanced | Document Processing | Document
JavaScripts.
To go to the next page: this.pageNum++;
 Type a name in the Script Name field box and click Add.
To go to the previous page: this.pageNum--;
 Delete the default text and type (without the line numbers):
To go to a specific page: this.pageNum = 0;
1. var msg = "Please fill in all form fields";
 Click OK in the JavaScript Editor. 2. app.alert(msg);
 Click Close in the Button Properties dialog box. Whatever text you add between the quotes in line 1 will ap-
pear in the dialog box.
 Click OK, click Close in the JavaScript Functions dialog box,
and save the file. Upon saving the file, the dialog box will
appear and give you a preview of the application alert.

t e d ’s t i p Keep in mind that JavaScript is zero t e d ’s t i p The above script opens the alert
based. Therefore if you want to write a dialog box each time the file is
script that opens page 7 in a document, opened because the script is
your script needs to be written as: added as a Document JavaScript.
this.pageNum = 6; The same script could also be
added to a Page Action (open the
Properties dialog on a Page in the
Pages Panel and click Action and
add the script in the same man-
ner), a bookmark, a button, or a
Document Action.

ted padova [email protected]


writing javascripts

9 40
25

Dismissing Application Alerts Adding Line Breaks to Alerts


At times you'll want to alert a user when a document is first opened. You might want to format the text a little in an
However, if a user opens your form several times and continually alert dialog box to emphasize a line of type.
sees the same dialog box appear each time the file opens, it can By adding a few control switches you can
become quite annoying. easily add line breaks to messages in
application alert dialog boxes.
To provide a user an option to dismiss the application alert, use the
example code below on a Document Level JavaScript (see Tip #38 Here's a sample script that adds a line break.
for adding a Document Level JavaScript) :
1. var msg = "Here's a script with a line break.\n\
1. if(typeof(global.bShowWarning1) == nVisit my blog at\n\nhttp://www.acrobatusers/
"undefined") blogs/tedpadova"

2. { 2. app.alert(msg);

3. global.bShowWarning1 = true; In line one the \n\n coding creates the line break.
4. global.bPersistWarn1 = false;
Click Me

41
5. }
6. if(global.bShowWarning1)
Invoking Actions on Field Entry
7. {
Actions such as application alerts, calculations,
8. var oCk = {bAfterValue:false}; and a variety of other action types can be
9. app.alert({cMsg:"Instructions: Fill out this invoked when a user tabs into a field.
form carefully and click the Submit Form
button when finished.", nIcon:1,oCheckbox:oCk, To add a JavaScript when a user tabs into a
cTitle:"Reminder"}); field, do the following:
10. global.bShowWarning1 = !oCk.bAfterValue;  Open the field properties on the field where you want the
11. }
action to be invoked.
 Click the Actions tab.
 Open the Mouse Trigger drop down menu and choose On
t e d ’s t i p Focus. This option sets the action to when a user tabs into the
This button has sample code: field.

Click Me  Choose Run a JavaScript from the Select Action drop down
menu and click Add.
 Type your script in the JavaScript Editor.

ted padova [email protected]


writing javascripts

2 43
26

Assessing Viewer Versions Assessing Viewer Types


Some features in Acrobat viewers 6, 7, and 8 and above may not be Another assessment function available to
available to users of earlier versions of Acrobat. To help a user un- you in Acrobat is assessing the viewer type.
derstand if a feature won't work in an earlier version, you can have This code should be added to the forms that
Acrobat assess the viewer and report in an application alert dialog have certain actions that can't be executed in
box a message if it detects a version lower than one you want to Adobe Reader.
specify in the code.
To write a script that assesses viewer versions, add the following
script to a Document Level JavaScript: To write a script that assesses viewer types, add the following script
to a Document Level JavaScript:
1. //is the viewer version less than 8.1
1. //is Adobe Reader as opposed to Adobe Acrobat
2. if(app.viewerVersion < 8.1)
2. if(app.viewerType == "Reader")
3. {
3. {
4. var msg = "Some features won't work in
Acrobat viewer versions less than version 4. var msg = "Filling out this form requires
8.1."; either Adobe Acrobat Pro or Adobe Acrobat
Standard";
5. app.alert(msg);
5. app.alert(msg);
6. }
6. }

t e d ’s t i p Line 1 in the above code is a com- t e d ’s t i p If you want to assess both


ment line. When you see a line viewerVersion and viewerType, you
preceded by // remember that the can add both scripts to a
line has no effect on executing the Document Level JavaScript.
script.
Simply add the above script fol-
It's a good idea to add comments lowing line 6 in the viewerVersion
so that when you want to later script.
review some of your code it will be
much clearer to you.
Many of the scripts in this docu-
ment won't have comments due to
space limitations.

ted padova [email protected]


writing javascripts

4 45
27

Assessing Document Information Autotabbing Fields


You can use JavaScript to report back to you certain information You can set up fields with autotabs so that
about a document such as Title, Author, Subject, Keywords and when a user completes filling in a field, the
more. cursor jumps to the next field. You might use
this feature if you have a SS number or phone
To write a script that reports the PDF author on a button action, add number where the numbers are filled in sepa-
the following script on a button: rate fields.
1. var f = this.getField("textField");
To set up an auto tab, do the following:
2.
f.value = ("Author is: " + this.author);
 Write a Document Level JavaScript and enter the following
Line 1 identifies the text field where the information will be report- code:
ed. The script is written on a button and when clicked the author of 1. function goNext(item, event, cName)
the PDF is shown in the text field.
2. {
Coding for other information that can be reported in the JavaScript
Console (see Tip #47 for more on using the JavaScript Console) or 3.
AFNumber_Keystroke(0, 0, 0, 0, "",true);
within a text field includes: 4.
if (event.rc &&
this.title; // title field 5.
AFMergeChange(event).length ==event.target.
charLimit)
this.subject; // subject field
6.
item.getField(cName).setFocus();
this.keywords; // keywords field
7. }
this.producer; // PDF producer application
this.creator; // authoring document  Create three fields (ss.1, ss.2, ss.3) and set the limit of charac-
ters in the Options tab to 3 for the first field, 2 for the second
this.creationDate; // date PDF was created and 4 for the third. We'll use a Social Security number as an
example.
this.modDate; // date PDF was modified
this.pageNum; // page number of current page
 Open the Format tab in the first field properties and click the
Custom Keystroke Script radio button and click Edit.
this.numPages; // number of pages in the PDF
 In the JavaScript Editor, add the following code.
this.filesize; // the file size of the PDF
1. goNext(this, event, "ss.2");
this.path; // directory path for file location
In the above script, ss.2 is the next field that follows the field
this.numTemplates; // # of templates in the PDF where the script is written.
this.numFields; // number of fields in the file  Repeat the same steps for the second field and jump to the
next field (ssl.3).

ted padova [email protected]


writing javascripts

6 48
28

Printing Pages Via JavaScript Eliminating Fields From Print


Adding buttons to print pages is particularly useful when your You may want to print a document without
forms are displayed in Full Screen mode. the data in certain fields printed on the out-
put. You can use the Form Field drop down
To write a script that prints the current page in view, use the follow- menu in the General tab in the Document
ing script on a button field: Properties and choose Visible but doesn't print
1. this.print (false, this.pageNum, this.page- and the field won't print on the output.
Num, {bShinkToFit: true});
If you have some conditional items where if X occurs, then you
The false item in the above script prevents the Print dialog box from don't want certain fields to print, you can use a JavaScript to control
opening and the page is sent directly to the printer. The whether fields print or not. To prevent a field from printing, use the
{bShrinkToFit: true} item shrinks the page to fit within the paper size following example:
if the PDF page is larger than the output page size.
 On a button field create a JavaScript and enter the following
To print all pages in a document, use: code:

1. this.print(true); 1. var f = this.getField(myFfield");

7
// myField is the field name

Printing from the JavaScript Console

49
f.print = false;

If you happen to be viewing a file in Full Screen mode and you


want to print a page or the entire document while remaining in Full Printing with Annotations
Screen mode, you can use the JavaScript Console.
If you want to print a file with the
To print a document while in Full Screen mode, do the following: annotations added to the output, use the
following JavaScript on a button field:
 Press Command/CTRL + J to open the JavaScript Editor.
 Create a button field and add a JavaScript
 In the JavaScript Console type the following code to print the using the following code:
entire document.
1. this.print (true, {bAnnotations: true,
1. this.print(true);
bShrinkToFit: true, bReverse: true});
 Press the NumPad Enter key on your keyboard.
 The above code is used to print annotations and the
bShrinkToFIt toggle is on as well as printing in reverse order.
To eliminate any of the items, delete those not desired from
the code.

ted padova [email protected]


writing javascripts

0 51
29

Creating Document Actions Date Stamping a Document


You can execute JavaScripts during certain document actions such You may want to date stamp a form at the
as saving a file, printing a file, or closing a file. You may want to add time a user signs the form or submits the
an application alert when a file prints to provide the user form.
instructions on what to do with the form after printing it.
You can add a JavaScript on a signature field
To write a script on a Document Action, do the following: or a button. Use the following example to add
a date stamp when a user signs a form:
 Choose Advanced | Document Processing | Set
Document Actions.  Create a Signature field on a form and click the Signed tab in
the Signature Properties dialog box.
 Choose an action in the scrollable list (for example
Document Did Print).  Click the This field executes when the field is signed radio
button and click the Edit button.
 Click Edit to open the JavaScript Editor.
 Type the following script in the JavaScript Editor:
 Add an application alert in the JavaScript Editor such as the
example shown: 1. var f=this.getField("date");{

1. var msg = "Please deliver the form to the f.value = (new Date()).toString();
accounting department";
AFDate_FormatEx("h:MM tt, mmm dd, yyyy");
2. app.alert(msg);
}

date in the script above is the name of the field where the
date will be added.

ted padova [email protected]


writing javascripts

2 53
30

Summing Rows and Columns Using Simplified Field Notation


The easiest way to sum a column or row is to not write a JavaScript Acrobat offers only a limited number of built-
and use the built-in formula for summing data that Acrobat pro- in formulas. If you want math functions such
vides you. To use the built-in formula for summing a series of data as division and subtraction, you need to use
fields, do the following: either JavaScript or Simplified Field Notation.
 Create a column (or row) of fields formatted as numbers. Simplified Field Notation is a much easier
scripting language based on syntax similar to
 Be certain to name the fields with hierarchical names such as formulas written in spreadsheet programs. Keep in mind that
amount.0, amount.1, amount.2, etc. you cannot use hierarchical field names when using
 Double-click the field that holds the data sum with the Select Simplified Field Notation.
Object tool to open the field properties dialog box. To calculate a sum and add a sales tax using SFN, do the following:
 Click the Calculate tab.  Open a text field properties for a total field and click
 Choose sum(+) from the Value is the drop down menu. Calculate.

 Click the Pick button.  Click the Simplified field notation radio button and click the
Edit button.
 Check the box where you see the parent name in the Field  Type the following script in the JavaScript Editor:
Selection dialog box.
1. (item0 + item1 + item2 + item3) + ((item0 +
 Click OK. item1 + item2 + item3) *.00725)
When you return to the Calculate pane in the field
Properties, you should see the parent name shown in the
 The above script sums data in fields item0, item1, and item2
and adds a sales tax of 7.25%. Note that the fields all have
field box below the Value is the drop down menu. separate names and do not use parent/child names.

ted padova [email protected]


writing javascripts

4 55
31

Summing Data with JavaScript Calculating a Sales Tax


You may want to sum data in a column or row and add a sales tax to Sales tax calculations can be handled easily
the sum, a shipping charge, apply a discount, or some other math with built-in formulas, Simplified Field
function as part of the field calculation. Notation, and JavaScript when you have
separate fields for a subtotal and a tax field.
If you use the built-in formula described in Tip #52 you can't add a
second calculation. If you use a Simplified Field Notation script, you Using JavaScript the following script would
need to name each field separately in the formula —something be used to calculate a sales tax:
that could be very tedious with long columns or rows.
 Open the Calculate tab on a field to hold the data calculation
In order to extend the formula to calculate a total and apply the and click Edit for Custom Calculation Script.
total to another calculation, your best option is to use JavaScript.
 Type the following script in the JavaScript Editor:
 Open the Calculate tab on a field to hold the data calculation 1. var f = this.getField("subtotal");
and click Edit for Custom Calculation Script.
2. event.value = Math.round(f.value * 7.25) / 100;
 In the JavaScript Editor, type the following code:
1. var f = this.getField("amount");
 The above script assigns a variable to a field called subTotal

56
where the sum of data in a row or column has been calcu-
2. var a = f.getArray(); lated. The second line of code calculates a sales tax of 7.25%.
3. var sum = 0; Calculating a Shipping Charge
4.
for (i =0; i < a.length; i++)
A shipping charge might be calculated based
5.
sum += a[i].value; on the total cost of items purchased. The fol-
lowing formula calculates a shipping charge
6. event.value = sum + (sum * .08); of 12% of the total purchase amount.
Line 1 sets up an array with a field having a parent name of  Open the Calculate tab on a field to hold
amount. The form contains several fields named amount.0, the data calculation and click Edit for
amount.1, amount.2, etc. The loop is executed and picks up Custom Calculation Script.
the value for each field and adds it to a variable called sum.
The last line adds the sum to the sum * a sales tax of 8%.  Type the following script in the JavaScript Editor:
1. var g = this.getField("subtotal");
2. event.value = Math.max(2, Math.floor(g.value /
12));

 The above script assigns a variable to a field called subTotal


where the sum of data in a row or column is calculated. The
second line of code calculates a shipping charge of 12%.

ted padova [email protected]


writing javascripts

7 59
32

Importing Images Resetting a Form


You may want to add a photo or logo to a form and enable the user Acrobat has a built-in function for resetting a
to import an image on a button action. form that was described in Tip #21. This action
works fine when you want to reset all fields or
Here's how to do it: all fields with a few exceptions on a form.
 Create a button field and choose Icon only in the Options tab. You may have different sections of a form that
you don't want to reset such as the identify-
 Click the Actions tab and add a JavaScript. ing information or fields that contain fixed data that you use for
 In the JavaScript Editor, type the following code: calculations.
1. event.target.buttonImportIcon(); Using JavaScript the following script would be used to reset form
fields having the same parent name:
When the user clicks the button, the Select Icon dialog opens.
 Create a button and add a JavaScript.

8
Note: to make this work in Adobe Reader see Tip # 88.
 Type the following script in the JavaScript Editor:
Showing/Hiding Fields 1. var resetFields = this.getField("customerData");
Acrobat provides you an action to show and hide fields. If you 2. this.resetForm(resetFields);
have many fields to show/hide, you need to check each item in the
Show/Hide Field dialog box. An easier way to handle the task is to  The above script resets the fields with the parent name of
use JavaScript. Be certain to use hierarchical names before writing customerData.
the script.
 Create a button field and click the Actions tab and add a t e d ’s t i p If you want to reset all fields on a form, use
JavaScript. the following script:

 In the JavaScript Editor, type the following code: this.resetForm();

1. var f = this.getField("myField");//parent name This kind of script might be added as a


Document Level JavaScript or Page Action
2. f.hidden=true;//hides all fields with the same script along with an Application Response
parent name
dialog box that prompts the user to reset a
form.
t e d ’s t i p To show hidden fields use the
following script in line 2: If a user partially completes an order form,
the user would say no to resetting a form.
2. f.hidden=false;
If the user starts anew, then perhaps all the
data might be reset on the form.

ted padova [email protected]


writing javascripts

0 61
33

Setting Fields to Read Only Deleting Fields


Fields that are set to Read Only in the General tab of the field prop- Deleting fields can provide another level of
erties dialog box, prevent data entry or changing the field data by security on a form. When a user submits a
an end user. If the form is secured with Acrobat Security, the user form or prints a form, you can delete all fields
won't be able to edit the fields and change the data. with no data. Something like a travel reim-
bursement form might be one example of
You might set fields to Read Only that have fixed price values and a form where deleting fields could be em-
calculations. ployed.
To set a field for Read Only, do the following: If there are no fields to add data, the form can't be changed by
another user.
 Open the properties dialog box on any field.
Using JavaScript the following script would be used to delete a
 Click the General tab. series of fields containing no data:
 Check the box for Read Only.  Add a JavaScript to a Signature Field, a Document Action, or
a Submit button.

t e d ’s t i p You might start with fields that are marked  Type the following script in the JavaScript Editor:
for reading and writing and later, after the 1. for (var i = 0; i < 5;i++)
user executes certain actions, you might
want to lock the fields to prevent data entry. 2.
{var f = this.getField("amount."+i);
To handle this task add a JavaScript in the 3.
if (f.value == "")
Calculate tab where you want the field
marked as Read Only. 4.
removeField("amount."+i);

Here's a sample: 5. }

1. var f = this.getField("item")  The above script deletes all fields with the parent name of
amount that have no data.
2. f.readonly=true;

All fields with the same parent name are


marked as Read Only.
To disable Read Only, use the following in a
script like the above:
2. f.readonly=false;

ted padova [email protected]


writing javascripts

2 63
34

Deleting Zeros from Calculation Fields Adding URLs to Text


If you have a table and the last column or row of data is a calculated Text added to a background design that con-
field (something like price * qty), the default result is 0.00 until data tains a URL or email address is automatically
are added for the fields within the calculation. recognized in Acrobat viewers 7 and above.
There's no need to add links or buttons to
You can eliminate default zeros in calculated fields with JavaScript. navigate to a URL or open your default email
client on a button click.
Example script:
1. var f = this.getField("price.0"); However, if you ask a user to add a URL to a text field, the text field
isn't recognized as a URL link. Using JavaScript, you can create the
2. var g = this.getField("qty.0"); link by doing the following:
3. if (g.value !=0)  Create a Text field.
4. event.value = f.value * g.value;
 Open the Actions tab and choose Mouse Up for the Mouse
5. else Trigger. This trigger will execute the action when a user clicks
on the text field.
6. event.value ="";
 Add a JavaScript in the Actions tab and type the following in
In lines 1 and 2 the variables are assigned for a price and the JavaScript Editor:
quantity field. The result of the calculation is an amount
determined by multiplying the price * the quantity. 1. if ( !/^\s*$/.test(event.target.value) )

Line 3 checks the qty field and if it's not zero, the calculation app.launchURL(event.target.value);
is performed. If the result is zero, line 6 is executed where no  The next time a user clicks in the text field, the URL opens in

64
value is entered in the field resulting in eliminating default the user's default Web browser.
zeros.
URL Links in New Windows
Note that you cannot eliminate By default, a URL link opens in the same
t e d ’s t i p

zeros using the built-in formulas window if the browser is open and displays
or Simplified Field Notation. You a web page. Using JavaScript you can force a
must use JavaScript in order to URL link to open in a second window:
eliminate the zeros.  On a link button or any field containing a
URL link use the following script:
1. app.launchURL(“http://www.mycompany.com/file.
pdf”, true);

The true statement in the above code triggers opening the


link in a new browser window.

ted padova [email protected]


writing javascripts

5 66
35

Adding Annotations Using JavaScript Adding Fields Using


You might have a need for a user to add a comment note, add a JavaScript
Stamp comment, or a Text Box comment based on a conditional
You can add fields using JavaScript. You
response.
might add a field for user input based on
a user response.
Perhaps clicking a check box where the item is Other among a list of
other options is one example where you might use this feature. This task cannot be performed in Adobe
If the check box is clicked, a Text Box is added to the document Reader when forms are created in Acro-
page or some such other type of condition. bat. However, you can create dynamic forms in Adobe LiveCycle
Designer that enable Adobe Reader users to spawn fields on a page.
Note that the file must be enabled with Adobe Reader usage rights
for this to work in Adobe Reader. Example script:
 Add a JavaScript to a button, a check box, or radio button 1. var f = this.addField("newField", "text",
and click the Actions tab.
2.
page = this.pageNum,[100,100,200,200])
 Type the following in the JavaScript Editor: 3.
f.textSize = 9;
1. var annot = this.addAnnot(
4.
f.textfont = font.Helvtica;
2. {page: this.pageNum,
5.
f.textColor = color.white;
3. type: "FreeText",
6.
f.fillColor = new Array("RGB", .9, .9, .9);
4. rect: [396,298,629,406],
7.
f.alignment = "left";
5. strokeColor: color.white,
8.
f.multiline = true;
6. fillColor: ["RGB", .85, .85, .85],
9.
f.readonly = false;
7. }
Line 2 identifies the x,y coordinates for the field rectangle.
8. ); Before writing the script, be certain to identify the exact coor-
dinates where you want the field to appear.
Line 3 identifies the type of annotation to be added to the See Tip #67 for an easy method for identifying x,y
page. In this example FreeText is a Text Box comment.
coordinates.
Line 4 specifies the Text Box rectangle coordinates. You need
to precisely determine where the coordinates are for the
annotation you want to add using the script (See Tip #68 for
how to determine x,y coordinates).
Lines 5 and 6 set attributes for the border color and the fill
color of the Text Box.

ted padova [email protected]


writing javascripts

7 68
36

Determining x,y Coordinates Changing Text Colors


Tips #65 and #66 use x,y coordinates to determine the bounding By default, Acrobat permits you to iden-
area for annotations and fields. Before you start writing a script you tify negative values with a red color in the
need to know the coordinates for where you want the object to ap- Format tab. If you want to emphasize a value
pear on the page. that's not a negative value or use another
color other than red, you can do so using
To easily determine the coordinates you'll use in your JavaScript JavaScript.
code, do the following:
Example script in the Format tab in a text field:
 Open the Comment and Markup toolbar. 1. var f = this.getField("fieldName");
 Click the Rectangle Comment tool. 2.
if (event.value >50)
 Draw a Rectangle comment in the area of your form where 3 f.textColor = color.red;
you want to create an annotation or field.
4. else
 Open the JavaScript Console (Command/CTRL + J). 5. f.textColor = color.black
 Enter the following code in the Console. The above script sets the text color to red if the value in a
1. this.getAnnots()[0].rect; field named fieldName is greater than 50.

 Press the NumPad Enter key on your keyboard.


Acrobat provides you with some default colors
The JavaScript Console reports back to you the coordinates.
t e d ’s t i p

that you can assign to text and objects. If you


want to create a custom color look up a color in
 Ignore all digits after the decimal point and use the whole a program like Adobe Photoshop and record the
numbers for the x,y coordinates in your script.
RGB (or CMYK) values. The colors in Photoshop
use whole numbers to express color.
In Acrobat you define a color by using something
like ["RGB", .503, .982, .495]
To convert the color values from Photoshop to
Acrobat, take a Photoshop color and divide by
255. Therefore a color like a red value of 149
in Photoshop would be a red value of .584 in
Acrobat. The syntax for changing a color in a field
would be something like:
event.target.textColor = ["RGB",
.503, .982, .495];

ted padova [email protected]


writing javascripts

9 70
37

Spawning Pages From Templates Changing OCG States


Spawning pages from templates provides you with options for Optional Content Groups are layers in a PDF
many uses. PDF files can be made more dynamic by adding content document. You have available an action to Set
on-the-fly through new pages added to a document. Layer Visibility, but there are conditions where
the action won't work and you need to use a
 Add a page to a document that you want to use for a JavaScript to change layer visibility.
template and navigate to that page.
 Click the Edit Layout tool in the Forms toolbar. To examine scripts that change layer visibility open the
 Choose Forms | Page Templates. Attachments panel and open the file attachment: housePlansForm.
pdf. Look over the JavaScripts in this document to discover how to
 Type a name in the Page Templates dialog and click Add. change layer visibility using JavaScript.
To hide the template from view, click the Eye icon.

71
 Add a JavaScript to a button field and enter the following
code in the JavaScript Editor.
Limiting Character Strings
1. var a = this.getTemplate(“myTemplate”);
You can limit the number of characters added
2. a.spawn ({ to a text field with a JavaScript. To do so, use the
example below:
3. nPage:this.numPages,
 Open the Text field properties on a field.
4. bRename:true,
 Click the Format tab.
5. bOverlay:false
 Click the Custom Keystroke Script radio button.
6. })
 Click Edit and add the following script in the JavaScript
Be certain that you use the name you assigned to the tem- Editor.
plate in Line 1. When you click the button, a new page is
spawned from the template. 1. var f = this.getField("myField");
2. if (event.value.length > 10)
t e d ’s t i p By default the bOverlay switch is
3. {
off meaning new pages are ap-
pended to the document. If you 4.
var msg = "Your entry is too long
want to overlay the new page on (limit 10 chars).";
an existing page (like adding a
5.
app.alert(msg);
watermark), set the toggle to true
as shown below: 6. }
bRename:true,

ted padova [email protected]


writing javascripts

2 73
38

Popup Menus for URL Navigation Popup Menus for Page Views
Popup menus provide you with navigation options that can be used The app.popUpMenuEx object is the preferred
when viewing PDF files in Full Screen views. The following popup way to write a script for application popup
menu item opens different URLs in your default Web browser. menus. However, you can get by with a much
easier script that works well in all Acrobat view-
 Add the following script to a button: ers.
1. // Declare pop-up menu properties as an
array. The following example uses a simple method
for navigating pages in PDF.
2. var aParams = [
 Navigate to a view you want for a page link to a popup menu
3. {cName: "Acrobat User Community", cReturn: item.
"www.acrobatusers.com"},
4. {cName: "-"},  Choose View | Navigation Panels | Destinations.
5. {cName: "Acrobat User Blogs", cReturn:  Click the Create new destination tool in the Destinations
"http://www.acrobatusers.com/blogs"}, panel.
7. {cName: "Ted's Blog Site", cReturn: "http://  Repeat the steps for creating destinations to all views you
www.acrobatusers.com/blogs/tedpadova"} want to link to in a popup menu.
9. ];  Create a button field and add a JavaScript with the following
10. var cChoice = app.popUpMenuEx.apply( app, code:
aParams );
1. var cChoice = app.popUpMenu
11. if ( cChoice != null ) app.
2. (["First Page", "Home"],
launchURL(cChoice);
3. ["Second Page", "Samples"],
The above popup menu works much better than bookmarks if you
intend to display your form in Full Screen mode. 4. ["Third Page", "JavaScripts"],
5. ["Fourth Page","URL Links"],

t e d ’s t i p You can add an unobtrusive pop- 6. ["Fifth Page","Sample Forms"]);


up menu to a form that provides 7. this.gotoNamedDest(cChoice);
URLs where users can explore
more product information, con- The first item in steps 2-6 is a parent name that shows a child
tact info, company brochures, etc. name when the menu is opened. The child names are the
One button can open many links same exact names as the destination names and a click on
and not disturb the form design. the name in the menu opens the destination view.

ted padova [email protected]


writing javascripts

4 76
39

Popup Menus for Opening Files Emailing Form Data


To create a popup menu that opens files, be certain to place the From a button or a JavaScript assigned to
files in the same folder as the document containing the popup another action you can attach just the form
menu. data from the open document to an email
message.
Add the following JavaScript to a button:
On a button field, add the following script:
1. var cChoice = app.popUpMenu
2. (["Human Resource Forms", "hrForm.pdf", "va-
cationLeave.pdf"], 1. // use mailForm in this routine
3. ["Sales Forms", "salesOrder.pdf", "custom- 2. // gets the user address from a field
erID.pdf", "purchaseForm.pdf"],
3. var f = this.getField("useraddress");
4. ["Administration Forms", "creditApplication-
Form.pdf", "creditApprovalLetter.pdf"]); 4. this.mailForm(true, f.value, "", "","Subject");
5. this.slave = app.openDoc((cChoice), this); The above script attaches an FDF form data file to an email mes-
sage. Line 3 picks up an email address from the form that the PDF
author added to a text field and uses that address for the To field in
Each of the items (2-4) has multiple submenu items that open the
a new email message.
respective PDF documents.
Don't forget the semicolon (;) at the end of line 4. Each of the other

5
lines of code (2-3) end with a comma.
Note that if you want to reference
Emailing a PDF
t e d ’s t i p

fields on a page that have been filled


in by you and you don't want them to
From a button or a JavaScript assigned to another action you can
be visible to the end user, you can fill
attach the open PDF document to an email message.
in a field and hide the field.
On a button field, add the following script:
Open the General tab in the field
1. // use mailDoc in this routine properties dialog box and choose
Hidden from the Form Field drop
2. this.mailDoc(true, "[email protected]", down menu.
"cc goes here", "bcc goes here","Subject goes
here");
JavaScript will pick up the field
data even when the field is hidden.

ted padova [email protected]


writing javascripts

7
40

Checking for Empty Fields


Before a document is submitted, you might want to have the form On a submit button, add the following script:
checked to be certain that all fields have been filled in. The script to
1. // the procedure begins here
perform such a function has two parts. The first part is a function
added as a document level JavaScript. The second part is the script 2. var okToSubmit = true;
that executes when the Submit a Form button is clicked.
3. // loop over all fields:
Add the following function as a Document Level JavaScript and
4. for (var j = 0; j < this.numFields; j++)
name the function aField:
5. {
 Choose Advanced | Document Processing | Document
JavaScripts. 6. var fieldname =

 Type aField in the Script Name text box and click Add. 7. this.getNthFieldName(j);

 Type the following code in the JavaScript Editor. 8. var theField = this.getField(fieldname);
9. if (theField.type != 'text')
1. function checkField(aField)
10. continue; // get past the button fields
2. {
11. var valid = checkField( theField );
3. if (aField.value == "") // empty field
12. if (!valid) // valid == 0? Halt!
4. {
13. {
5. var msg = "No fields can be left empty.";
14. okToSubmit = false; // set flag
6. app.alert(msg);
7. return 0; 15. break; // exit loop prematurely

8. } The above routine checks all text fields to be certain some data
exist in the fields. If a field is left empty, the app.alert dialog box
9. } // end of function described in the aField function reports the error.
Click Close in the JavaScript Functions dialog box.

ted padova [email protected]


writing javascripts

8
41

Creating Fixed Response Options


You may have a form where you want a user to make a selection 1. if (!event.willCommit) {
from a Combo Box and based on that selection, offer choices 2. var a = this.getField("type.0");
respective to the first choice in a second Combo Box.
3. a.clearItems();
Something like choosing a shirt in one column and have sizes ap-
pearing in a second column might be one example of such a case. 4. switch (event.change) {
If you have shirts, pants, hats, and other articles of clothing , the 5. case "Golf Balls":a.setItems(["",
choices in the second column will change based on the first column "Titleist", "Pinnicle", "MaxFli"]);
choice.
6. break;
For the script (opposite page) to execute properly, you need to cre-
7. case "Golf Hats":a.setItems(["", "Navy",
ate a table with at least two columns (or rows). The script is added "White", "Green"]);
to the fields in the first column (or row) in the Format tab, then
duplicated for all subsequent columns/rows. 8. break;

Do the following to set up the table: 9. case "Golf Shirts":a.setItems(["", "Small",


"Medium", "Large", "Extra Large"]);
 Create a table with 5 columns as shown below. 10. break;
 Open the text field properties in the first field in column one 11. case "Golf Shoes":a.setItems(["", "Size 9",
and click the Format tab. "Size 9.5", "Size 10","Size 10.5",
"Size 11", "Size 11.5", "Size 12"]);
 Add a Custom Keystroke Script and type the code at right in
the JavaScript Editor. 12. break;
13. case "Golf Tees":a.setItems(["", "25",
"50", "100"]);

Item Type Price Qty Amount 14. break;


15. }
Golf Balls Pinnicle $19.95 2 $39.90

Golf Shoes Size 9.5 $89.95 1 $89.95 t e d ’s t i p


If you want a fixed price for each item
selected for Item and Type, add a
Golf Hats Navy $19.95 1 $19.95 JavaScript in the Calculate tab for the
Price field.
$149.80
Total
Open a price field in the table at
left and you can view the JavaScript
added here to create the fixed prices.

ted padova [email protected]


writing javascripts

9 80
42

Creating Application Response Dialog Boxes Adding Data to Secondary Forms


An application response dialog box typically presents the user with If you have a product brochure of a large file size,
a question and solicits an answer. Based on the response certain you might want to add application response dialog
actions can be invoked. You might want to ask a user how many boxes to populate a secondary form or copy data
products to purchase. The user responds and you can then take the from a form page on a product brochure to another
data from the dialog box and add it to a field object. document you use as an order form.
To perform such a task, do the following: On a button field, add the following script:
 Create a text field.  Create a form and add the following Document Level JavaScript:
 Create a button field and add the JavaScript below: 1. this.disclosed = true;

1. var t = this.getField("qty");  On a button field in another document add the following script:
// the target field
1. this.slave = app.openDoc("myForm.pdf",this);
2. var cResponse = app.response({
2. this.bringToFront();
3. cQuestion: "How many do you want?",
3. for (var i = 0; i <4; i++) {//good for 4 fields
4. cTitle: "Quantity to purchase"});
4. var quantity = this.getField("qty."+i);
5. if ( cResponse == null){
// if Cancel is selected 5. var result = this.slave.getField("oQty."+i);
6. app.alert("Cancel order for this item?"); 6. result.value = quantity.value;
7. cResponse = 0; 7. var amount = this.getField("total." +i);
8. } 8. var cResult = this.slave.getField("oAmount."+i);
9. else 9. cResult.value = amount.value;
10. app.alert("You ordered, \""+cResponse+"\"... 10.
}
items",2);//confirmation dialog
11.
slave.bringToFront();
11. {
12. t.value = cResponse; // places the data from
the dialog to the target field t e d ’s t i p If you want Adobe Reader users to fill in a
form apart from a brochure, add the form
13. } to a PDF Package. Add a submit form but-
ton and enable the form with Reader us-
Click Me age rights. When the Reader user submits
a form in a PDF Package, only the form is
sent back to you.

ted padova [email protected]


adding menu items
43

Adding
Menu Items
Scripts cannot be written in
Adobe Reader, but the menus
created in Acrobat do appear
in Adobe Reader.

ted padova [email protected]


adding menu items

82
44

About Adding Menu Commands Counting Page Templates


You can add custom menu commands in Acrobat and the same Add a menu command in the Tools menu that
commands you create in Acrobat are also usable in Adobe Reader. counts Page Templates. Counting Page
Templates can be helpful in diagnosing forms
To create a custom menu command you need to add a JavaScript to and provide information about forms that
your JavaScripts folder. have been secured with Acrobat Security.
On Windows the directory path for the JavaScripts folder is:  Write a JavaScript with a text editor using
Program Files:Adobe:Acrobat: 8.0: Acrobat:JavaScripts the following code:
On the Macintosh the path is: 1. function totalTemplates(){
Users:User Log-on:Library:Acrobat User Data:80_x86:JavaScripts
2. app.alert("Total Page Templates: " + this.
Copy the file attachments in this document to the JavaScripts folder numTemplates);
on your computer. 3. }

1
Save your text files with a .js extension. 4. app.addMenuItem ({cName: "Page Templates",
cParent: "Tools", cExec: "totalTemplates()"
Counting Fields 5. });
Add a menu command that counts the total fields on a from. This
The above script adds the menu command to the Tools menu
can help compare forms, diagnose forms, and provide information
(line 4).
on forms that have been secured with Acrobat Security.
When you select the menu item, a dialog box opens reporting the
find.
t e d ’s t i p You can add both menu commands
 Write a JavaScript with a text editor using the following code: in Tips #81 and #82 in the same script.
Copy lines 1-3 in one script and paste
1. function totalFields(){ it after line 3 in the first script. Then
2. app.alert("Total Fields: " + this.numFields); paste lines 4-5 at the end of the first
script.
3. }
Open the Attachments pane in this
4. app.addMenuItem ({cName: "Number of Fields", file and copy the tools.js file to your
cParent: "Tools", cExec: "totalFields()" JavaScript folder and you won't need
to write the scripts.
5. });

The above script adds the menu command to the Tools menu
(line 4).

ted padova [email protected]


adding menu items

3 84
45

Listing Menu Items Adding a URL to a Menu


It you want to access a menu command using JavaScript or add You can add menu commands in Acrobat that
a menu item, you need to know the menu items names used by open URLs in your default Web browser.
JavaScript.
Here's the JavaScript code for accessing the
To view a list of menu item names, do the following: FedEx/Kinkos web site to order prints. Replace
the URL in this script with your favorite print
 Open the JavaScript Console (Command/CTRL + J). service.
 Type the following code in the Console:  Write a JavaScript with a text editor using the following code:
1. app.listMenuItems(); 1. app.addMenuItem({
 Press the NumPad Enter key and all the menu item names are 2. cName: "FedExKinkos",
shown in the JavaScript Console.
3. cParent: "Help",
4. cExec: "app.launchURL('https://
partner.fedexkinkos.com/partnerInit.do');",
5. nPos: 16
});

Line 5 in the above code positions the command in the Help


menu. You may want to change the position by typing a
different value.
When the menu command is selected your default
Web browser opens and takes you to the target URL.

t e d ’s t i p To display toolbar buttons, type the


following in the JS Console:
app.listToolbarButtons();

ted padova [email protected]


adding menu items

5
46

Add a File | New Menu Command


16. app.addSubMenu({ cName: "New", cParent:
Acrobat provides you an option to create new blank pages. Howev- "File", nPos: 0 })
er, the new pages by default have a text block that can be annoying
when you want to use blank pages for temporary documents to 17. app.addMenuItem({ cName: "Letter Portrait",
hold form fields. cParent: "New", cExec: "trustedNewDoc();"});
18. app.addMenuItem({ cName: "Let-
With a little JavaScript you can create the missing File | New ter Landscape", cParent: "New", cExec:
command that Acrobat has avoided through 8 generations of the "trustedNewDoc(792,612);"});
program. The following code creates the command with several
different custom page size options: 19. app.addMenuItem({ cName: "A4", cParent: "New",
cExec: "trustedNewDoc(420,595)"});
 Type the following code in a text editor and save the file to 20. app.addMenuItem({ cName: "Slide
your JavaScript folder with a .js extension: (10x7.5)", cParent: "New", cExec:
"trustedNewDoc(720,540);"});
1. trustedNewDoc = app.trustedFunction( function
(nWidth, nHeight) 21. app.addMenuItem({ cName: "Screen
(640x480)", cParent: "New", cExec:
2. { "trustedNewDoc(640,480);"});
3. app.beginPriv(); 22. app.addMenuItem({ cName: "Note
4. switch( arguments.length ) { (4x3)", cParent: "New", cExec:
"trustedNewDoc(288,216);"});
5. case 2:
23. app.addMenuItem({ cName: "Custom...", cParent:
6. app.newDoc( nWidth, nHeight ); "New", cExec:

7. break; 24. "var nWidth = app.response({ cQuestion:'Enter


Width in Points',\
8. case 1:
25. cTitle: 'Custom Page Size'});"
9. app.newDoc( nWidth ); +"if (nWidth == null) nWidth = 612;"
+"var nHeight = app.response({
10. break; cQuestion:'Enter Height in Points',\

11. default: 26. cTitle: 'Custom Page Size'});"


+"if (nHeight == null) nHeight =
12. app.newDoc(); 792;"+"trustedNewDoc(nWidth, nHeight) "});
13. }
t e d ’s t i p Open the Attachments panel in this
14. app.endPriv(); file and copy the newPage.js file to
15. }) your JavaScript folder and you won't
need to write the script.

ted padova [email protected]


adobe livecycle designer
47

Adobe
LiveCycle Designer
Windows Only

ted padova [email protected]


adobe livecycle designer

6 87
48

Changing the Default Template Adding an Address Block


LiveCycle Designer (LCD) offers you an number of templates that Tip #27 described creating an address block
you can modify to create your own personal forms. When you in Acrobat by copying/pasting fields between
choose File | New the New Form Assistant opens where you can documents.
choose from one of the many templates available to Designer.
LiveCycle Designer provides you a default
When you click the New tool in Designer, you can bypass the New block of fields you can drag and drop to your
Form Assistant dialog box and create a form based on a template. forms.
To change the default template in Designer to one that you prefer
when clicking the New tool, do the following: To add an address block to a Designer form, do the following:

 Choose Tools | Template Manager (note that you do not need  Create a blank new form (click the New tool in the Designer
a file open to work in the Template Manager). toolbar.

 Click the tabs to view the templates and choose the one you  Open the Library panel and scroll down to the Custom
want to use as your default template. section in the panel.

 Click Set Selected as Default in the Template Manager.  Click the Address Block item and drag it to your form.

t e d ’s t i p You can customize an address block or any


other group of fields and add them to your
Library panel.
Edit the fields on a blank new page and drag
them to the Library panel. The Add Library
Object dialog opens where you can add a
name, description, and select which group
you want to add the fields.

ted padova [email protected]


adobe livecycle designer

8 89
49

Adding Button Imports Editing Backgrounds


Tip #57 described how to add a button import on an Acrobat form LiveCycle Designer is not a sophisticated
using a JavaScript. When you create a button import in Acrobat, the design tool as you find with programs like
JavaScript cannot be used in Adobe Reader. ' Adobe InDesign and Adobe Illustrator.
Using LiveCycle Designer, you can add a button field that an Adobe However, you can add a few design elements
Reader user can use to add button faces to a button from a variety in Designer and change background colors to
of different image formats. solid colors and gradients.
To add a button that can be used to import images in both Acrobat To change a background color to a gradient, do the following:
and Adobe Reader, do the following:
 Create a new blank document.
 Create a form or import a form from Adobe Acrobat (see Tip
#95 for instructions on converting Acrobat forms to LiveCycle  Click the Master Page tab.
Designer forms).
 Size down the default subform content area to reduce the
 Open the Library panel and open the Standard fields panel. size of the rectangle.

 Click the Image Field and drag it to your form.  Drag the Image object from the Standard library panel.

 Save the form. Note that you do not need any scripting for  Size the image to fill the page size.
the button action to work in Adobe Reader.
 Open the Border panel.
 Choose from options in the Background fill for a Radial - to
edge or Radial - to center.
 Resize the subform content area to the desired size.

t e d ’s t i p Note that the form does not need to be


enabled with Adobe Reader usage rights
for the Reader user to import images.

ted padova [email protected]


adobe livecycle designer

0 91
50

Binding an XML Sample File to a Form Testing the XML Data File
Designing forms in LiveCycle Designer for data imports need to be As a takeoff from Tip #90, continue editing your
debugged in two areas. You must have a proper XML file that can be form with field formatting and layout.
imported in your form and you need to have the proper data con-
nections and scripting on the form in Designer. When the form is designed as you like, open the
Data View panel and do the following to test the
Testing and debugging a form can be a challenge if one or the data connection:
other items is not properly set up. To test a form for data imports to
be certain the form scripts work properly, you can start by creating  Open the Data View panel and right click on Data Connection
a sample XML file. at the top of the menu to open a context menu.

To create a sample XML file you can use Windows NotePad. Another  Choose Delete Data Connection.
solution is to use an XML editor. My preference for editing XML files  Remove the check mark in the Delete Data Connection
is using TextPad (http:www.//textpad.com). dialog box and click OK.
 Write a short script in an XML editor or Windows NotePad.  Choose File | Form Properties.
 In Designer, open the Data View panel on a new blank  Click the Defaults tab and click the Browse icon to the right of
document.
the Data File field box.
 Open the Data View menu and choose New Data Connection.
 Choose Sample XML Data file in the New Data Connection
dialog box and click Next.
 Select the sample XML file and click Finish.
 Drag fields from the Data View panel to the document page.
 Locate the sample XML file and click Open.
 Click OK in the Form Properties dialog box and click
PDF Preview.
If the sample data do not import properly and if your XML file
was written correctly, you'll know that you have some
problems with the design of your form.

ted padova [email protected]


adobe livecycle designer

2 93
51

Creating a WSDL Connection Enabling an XML Form


A Web service can be searched on the Internet and you can bind Adobe Designer does not have a menu
data to a WSDL connection. You might want to connect to a command for enabling PDF forms with
weather service, a currency converter, or any number of different Adobe Reader usage rights.
web services available on the Internet.
To enable a PDF with usage rights you need
To connect to a Web service, do the following: to use Adobe Acrobat.
 Locate a URL for a Web service and one that you can bind  Complete your form editing in Adobe Designer.
to. You can search for Web services in your browser to poke
around looking for a Web service.  Save the file and open in Adobe Acrobat Pro (v8.1).

 Copy the URL from your Location bar in your Web browser.  Choose Advanced | Enable Usage Rights in Adobe Reader.

94
 In a new blank form in Designer open the Data View panel.
 Open the Data View menu and choose New Data Connection. Distributing an XML Form
 Click WSDL File in the New Data Connection Dialog box and Although a command exists in Adobe
click Next. LiveCycle Designer for distributing a form,
the wizard used with the Distribute form
 Paste the URL in the WSDL File text field and click Next. command is handled by Acrobat.
 A list of operations appear in the New Data Connection When you choose to distribute a form in De-
dialog box. Look over the descriptions and choose the item signer, Designer launches Acrobat and opens
to bind to by selecting it in Select an Operation list. Click the form.
Finish.
To distribute a form from Designer, do the following.
 Drag the Data Connection from the Data View panel to your
form.  Complete your form editing in Adobe Designer.
 Be certain you have a Submit button on your form.
 Choose File | Distribute Form.
The form opens in Acrobat and the Form Distribution
Options wizard opens.
 Complete steps in the Form Distribution Options wizard to
create a data set and email the form or save it and send later.

ted padova [email protected]


adobe livecycle designer

5 96
52

Adding a PDF Background Converting a PDF Form


In an effort to help Designer with a little more sophistication in the PDF forms with form data fields can be
design stage of a form, version 8 supports adding PDF opened in LiveCycle Designer and the fields
backgrounds. are recognized by Designer.
If you want to add design appearances not available in LiveCycle Before opening a form in Designer you need
Designer, create a design in a program like Adobe InDesign or to decide whether it will be more efficient to
Adobe Illustrator and export/save as PDF. use the original fields created in Acrobat or
create new fields in Designer.
To import a PDF background, do the following:
Assuming you want to use the fields created in Acrobat, do the
 In Designer choose File | Open or click the Open tool. following to convert the Acrobat form to a LiveCycle Designer XML
form.
 Locate the PDF document you want to import and select it in
the Open dialog box. Click Open.  In Designer, choose File | Open or click the Open button.
 Click the Create an Interactive Form with Fixed Pages radio  Locate the PDF form containing data fields in the Open
button. dialog box, select it, and click Open.
If you choose Create an Interactive Form with a Flowable
Content, Designer can open the form, but the graphics will The Acrobat data fields are converted to XML form objects.
often change color values and may not appear like your  Edit the form and save it.
original design. If using this option, you'll need to experiment
a little on how to design a form so the content can be edited The form is now an XML form.
in Designer. Click Next.
Note that after saving the form, the form can no longer be
edited in Adobe Acrobat.

t e d ’s t i p If you have JavaScripts in your original PDF


form, you'll need to rewrite all the scripts.
Designer cannot translate the Acrobat
JavaScripts to Designer JavaScripts.
Before converting a form, it's a good idea to
 Type an email address in the Return email address text box delete all Document Level and Document
and click Finish.
Action JavaScripts.
 The design background is imported and you can now add
the form fields in Adobe LiveCycle Designer.

ted padova [email protected]


adobe livecycle designer

7 98
53

Using Transparent Images Calculating Columns


Designer supports image formats that are limited to: Tip #54 described a way to use an array to
calculate a column or row of data using
.bmp, .eps, .jpg, .gif, .png, and .tif. JavaScript.
Only those formats supporting transparency can be imported with Whereas Acrobat uses the scripting lan-
the transparency intact. guages of Simplified Field Notation and
JavaScript, Designer uses FormCalc and
As an easy method for importing transparent images in Designer,
JavaScript.
use Adobe Photoshop and choose the File | Save For Web & Devices
command (Photoshop CS3). In the Save For Web & Devices window Simplified Field Notation in Acrobat is not well suited for summing
you can see what formats honor transparency. columns and rows of data, but FormCalc in Designer can be used
quite easily for adding columns and rows of data.
Use either GIF or PNG-24 for the file format. EPS is supported by de-
signer, but the rendering in Designer leaves much for desire. If your The following is an example of a FormCalc Script that sums data in
files are not intended for commercial press and color separating, GIF a column:
or PNG-24 will render the images fine onscreen.
1. sum(detail.table.rowdata[*].total[*])
 After saving a file in a format that preserves transparency,
add the Image object to a form.  In the above script, detail is a subform containing a table.
 Open a context menu on the Image object and select Choose table follows the subform and identifies the table where the
Image. data appear.
 Select the image in the Browse for Image File dialog box and rowdata contains
click Open. the cells in the
table.
total is the field
containing
the data to be
summed.

ted padova [email protected]


adobe livecycle designer

9 100
54

Creating Tables Adding a Total Field to a Table


Tip #23 described creating a table of data using Acrobat. With You can float fields using subforms in
Acrobat you need to design the table background in an author- Designer. If you're having trouble get-
ing program if you want alternating rows of colors, apply stoke ting a subform to float properly so the
weights and colors, merge cells, and other features associated calculation fields don't move down the
with table designs. page as data are populated in a table,
you can add the calculation fields as cells
One strong design feature in LiveCycle Designer is having a table in a table.
editor where you can easily create table designs with all the neces-
sary background attributes and data formatting. To format a table for accommodating a calculation field, do the fol-
lowing:
To create a table in Designer, do the following:
 Move the cursor to the left side of a table until you see a left
 Choose Table | Insert table to open the Insert Table dialog. pointing arrow. Click the select the row.
 Edit the Columns and Rows field boxes to insert the number  Choose Table | Insert | Row Below to insert another row.
of columns/rows you want in your table.
 Drag the cursor through all the cells that won't have a
 Leave the default Include Header Row in Table to create a calculation to select them.
header row. If you want a footer row too, check the box for
Include Footer Row in Table.  Open a context menu and choose Merge Cells.
 Click OK in the Insert Table dialog box.  Click the cell that requires a formula and drag a Numeric Field
to the cell from the Standard Library panel.
 Name and format the field.
 Open the Script Editor (CTRL + Shift + 5) and choose
Calculate from the Show drop down menu.
 Type the formula for the calculation in the Script Editor.


Edit the table using the Border, Font, and Paragraph panels.

ted padova [email protected]


adobe livecycle designer

01
55

101 Forms eTips


Use the Resources Available to You
For those users who are having difficulty getting started with Live-
Cycle Designer, there are a number of resources that can help you
learn the program and become proficient.
Check out some of these resources: contact me at: [email protected]
 Samples in the Designer 8.0 folder: Open the folder inside the if you have any questions
Acrobat 8.0 folder and open the EN (for English installations
of Designer). Open the Samples folder and review the many
sample files installed with Designer.
 FormCalc Manual: Open the Designer 8.0 | Documentation |
EN folder and you'll find a manual for using FormCalc.
 Visit the Designer Home: Choose Help | Adobe on the Web.
Your default Web browser opens and takes you to the
LiveCycle Designer Home page
 Visit the Developer Connection: Log on to:
http://www.adobe.com/devnet/livecycle/
to find information, tips, and sample files.
 Visit the Designer Scripting Examples: Log on to:
http://www.adobe.com/devnet/livecycle/designer
_scripting_samples.html
to find sample files.
 Visit Thom Parker's JavaScript Corner: Log on to:
http://www.acrobatusers.com/tech_corners/
javascript_corner/index.php
to find information, tips, and techniques on
Acrobat and LiveCycle Designer JavaScripting.
 Visit Carl Young's AcroViews: Log on to:

©
http://www.acrobatusers.com/blogs/pdftrainer/
to find information, tips, and techniques on

not!
working with LiveCycle Designer Forms.
 ted's blog: Log on to:
http://www.acrobatusers.com/blogs/tedpadova/
for tips on using Acrobat and LiveCycle Designer.

ted padova [email protected]

You might also like