These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Forms Data Import Print

tgizmo
Registered: Jun 14 2009
Posts: 8
Answered

I am using LiveCycle Designer ES to customize new hire enrollment forms. These are blank insurance enrollment and payroll setup forms. We add employee information (name, dob, doh, address, etc... populated by a database) to create signature ready documents. We need to create a separate form for each employee. The forms are printed and distributed to employees in a paper format. I can view the first record in LiveCycle. How do I print the custom forms from LiveCycle? Thanks in advance for your help.

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
When you create a "data connection" in a LiveCycle form the default action is for Acrobat to open the data connection to the first record when the form is loaded into Acrobat. You'll know Acrobat is trying to open the connection because it will popup a dialog asking you if you want to allow the form to connect. However, LiveCycle also does the same thing when you setup the connection in the first place so you'll see the first record even if the connection is not made in Acrobat.

The first bit is to make sure the connection is being opened. Once you've go this bit you can add code to navigate the DB.

In a Livecycle form the DB connection is under the "sourceSet" model. Look this up in the "XML Forms Object Model Reference" and you'll find a list of all the functions that can be used with the connection.

For example, assuming you have a data connection called "MyConnection", add a button to the top of the form and label it "Next". Set the presence so that the button doesn't print. Place the following code in the click event:
   xfa.sourceSet.MyConnection.next();
Every time the button is clicked the DB record will advance and display new data on the form. When you print the form the "Next" button will not be visible. You could even Automate the process, in fact I'll be adding an automation tool for doing exactly this to www.pdfscripting.com later this month.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

tgizmo
Registered: Jun 14 2009
Posts: 8
Thanks. I was able to add the Next button and click to the other records in the database. How do I print the separate forms for each employee? I'm only halfway smart and don't know how to do this (other than one at a time).
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
To Manually print: click the next button and then select print from the file menu.
or you can add a print button to the form, or even add print code to the next button.

xfa.host.print();

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

tgizmo
Registered: Jun 14 2009
Posts: 8
Thom,

Thanks. I know how to manually print the forms. How do I print them all at the same time?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
For this you need to automate printing without displaying the print dialog. Do you have the "XML Forms Object Reference?"

http://partners.adobe.com/public/developer/xml/topic.php

The print function I've shown in the last post is documented there. The first argument for the function is used so suppress the print dialog, but it will only work when the print function is run from a privileged context.

If you only have one form, then the easiest way for you do this is to add a button to the form that runs code to loop through all the records and print the form for each one. Then to get the privileged context you need to make this work you'll need to save the form as Certified. Once this is done you'll be able to print out the whole DB.

The code should look something like this:
xfa.sourceSet.MyConn.first();while(!xfa.sourceSet.MyConn.isEOF()){xfa.host.print(false);xfa.sourceSet.MyConn.next();}

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

tgizmo
Registered: Jun 14 2009
Posts: 8
You are the best! Thanks for your help....