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

Script to batch import xml into Livecycle Designer form

jyyming
Registered: Nov 19 2009
Posts: 11

My scenario is pretty straightforward however I failed to find a solution for it.
I have a livecycle designer form which I need to filled in.
After some consideration, we have figured out that the best way to fill in this form is through xml data.

Based on data in database, I managed to generate the xml file. The problem is how do I import into the pdf in batch? I have thousands of xml file generated, and each of them need to be saved into a pdf file respectively and I will need to keep the pdf file.

On top of that, the pdf form is rights enabled form which after I import the data I would like to maintain the rights enabled property. This is so that when I send my file to customer, customer is able to export xml from the pdf file.

Help is really appreciated I have been struggling on this for weeks now.

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
So you want to use a LiveCycle Form in a variable data operation? Batch is the wrong way to go. You're better off using an OLE Database connection on the form, and then controling it from a folder level script.

But you can import XML data with:

xfa.host.importData();

However, this function is heavily restricted. Read about it in the XFA Object Reference.

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

jyyming
Registered: Nov 19 2009
Posts: 11
Thom,

Thanks for your reply.
I am very new to this, but do I still need a human to open up the Acrobat to invoke the folder level scripts?
LaiMing
Registered: Nov 26 2009
Posts: 1
Hi,

i have the same problem. I want to open a pdf file that loads automatically data from a xml file without human interaction.
I used the xfa.host.importData() and works, but doesn't load the xml file automatically when a user opens the pdf file.

How can i load a xml file in opening moment of a pdf file?

Thanks.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
jyyming,
Yes, you still need to open acrobat and invoke the script. The reason for this is that Acrobat is not a Server and is not supposed to be used as one.

But there are a couple of ways around this. First, you could use the Acrobat IAC (Inter Application Communication) API to control the opening a PDF and running the automation script. Basically you write a VB app to perform the bit that cannot be done from JavaScript. Second ,you could use Cold fusion 9 to perform exactly this same process, i.e. automatically merge data in to a PDF form without Acrobat at all. But that is a different can of worms.

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

jyyming
Registered: Nov 19 2009
Posts: 11
Thomp,

Thanks for your reply.

What I am trying now is i use the Acrobat IAC to open the pdf file. Within that pdf file i have a javascript that actually loads the data to each field by performing database call. I tried to open the pdf manually, trigger the javascript function (as an event on the click of a button), it is able to fill in all the pdf fields correctly.

Then, I see that Acrobat IAC is able to perform javascript function call by calling this method ExecuteThisJavascript in the Fields class. More testing is still needed, but I am not sure am I on the correct path? Hopefully this will work.

Thanks

-jyyming
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The best way to get access to scripts in the IAC is with the JSObject. What I usually do is write folder level functions and then run them through the JSObject. This is much better then invoking scripts on the document because 1) you don't need to put any scirpts in the documents and 2) folder level scripts can be trusted, which gets around all kinds of issues.

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

jyyming
Registered: Nov 19 2009
Posts: 11
In the end i found the solution, i use the ExecuteThisJavascript to call xfa.host.importData("filename.xml") which will help me import the data into the pdf, and lock the necessary fields.

By doing this also it will not ruined the reader enabled thingy.

Thanks a lot Thomp for your prompt response.