101 Formse Tips
101 Formse Tips
ted padova
http://www.west.net/~ted
http://www.acrobatusers.com
http://www.acrobatusers.com/blogs/tedpadova
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.
Designing
Forms
Indicates that the procedure
cannot be executed in
Adobe Reader
name
Address
City State
eMail Address
Phone
Contact info
1 2
4
3 4
5
5 6
6
7 8
7
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.
9
8
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.
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.
0 12
9
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.
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
SUBMIT FORM
3 15
11
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.
6 17
12
8 19
13
To add a button face to a Button field, do the following: Choose Push for the Behavior
Open the Button Field Properties dialog box. Follow the same steps for importing a button face.
0 21
14
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.
2 23
15
t e d ’s t i p
4 25
16
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.
7 28
17
9
18
0
19
Initial
Views
name Ted Padova
SUBMIT FORM
1 32
21
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.
4 36
22
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.
Writing
JavaScripts
Indicates that the script cannot
be executed in Adobe Reader
SUBMIT FORM
7 38
24
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.
9 40
25
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.
2 43
26
4 45
27
6 48
28
7
// myField is the field name
49
f.print = false;
0 51
29
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.
2 53
30
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.
4 55
31
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));
7 59
32
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:
0 61
33
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;
2 63
34
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);
5 66
35
7 68
36
9 70
37
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,
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"],
4 76
39
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
7
40
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.
8
41
9 80
42
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.
Adding
Menu Items
Scripts cannot be written in
Adobe Reader, but the menus
created in Acrobat do appear
in Adobe Reader.
82
44
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).
3 84
45
5
46
Adobe
LiveCycle Designer
Windows Only
6 87
48
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.
8 89
49
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.
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.
2 93
51
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.
5 96
52
7 98
53
9 100
54
Edit the table using the Border, Font, and Paragraph panels.
01
55
©
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.