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

How import XML?

alexsander_santos
Registered: Apr 10 2009
Posts: 14
Answered

Hi

I will try to explain what I need!

I created a file called test.xml

I have to import this file when the PDF is opened. The xml file is in the same folder that the PDF file. The XML is well-formed.

The imported file should be converted to a string. This string I will use with XMLData.parse() to fil a form in the PDF document.

Can anybody help me creating this script to me? I dont know how to import the file and I donk know how to convert the file to a string.

Thanks. It will save my job!

Alex

My Product Information:
Acrobat Pro 9.0, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
There are two ways to import an XML file into a PDF from a users hard drive, with a script.

1. Import the XML as a Data Object. Then get the contents and parse.
2. Convert the XML to "xfdf" which Acrobat already understands. Use the "importAnXFDF" function. When the file is imported it is automatically parsed and the data placed in the appropiate fields.

Both methods are problematic. If this is expected to be done with Reader, then the form has to have special Reader Rights Enabling that can only be purchased from Adobe. Also, whether it's being done from Reader, Standard, or Professional, using JavaScript to import data into a PDF can only be done from a privileged context.

If you're only doing this from Acrobat Pro and you can put a folder level script on the user's system then either of these two methods will work.

But there are other ways to get data into a form. For example, you can silently import an FDF file into a PDF, even when it is displayed in Reader, and it doesn't require privilege or any special enabling. You cannot do this with any other data format. In fact, there is a import data action for bookmark and button events that will only use FDF. If you can convert your XML data into FDF, then things get easier.

Both XFDF and FDF can contain references to the PDF file. So double clicking on one, or dragging and droping one of these file types into Acrobat/Reader will automatically load the associated PDF and merge in the data. Again, no special privilege or Rights Enabling is needed. If you can open the files this way things are much easier.

Data handling can get wierd and complex, but there are lots of options.

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]

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

alexsander_santos
Registered: Apr 10 2009
Posts: 14
thomp, like Obama told to my president Lula: "You are the man!" Thank you very much!!!!!!
gregzwane
Registered: Feb 19 2008
Posts: 1
hi my name is greg

i just need to know that is the anyway i can import a number of xml into 1 pdf using the batch proccessing and give me result by using javascript on the batch sequence i mean, i am a fundie,

I am a Javascript Fundy

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
First, I would suggest reading over and editing your text before posting. Your post doesn't make a lot of sense. Using some capital letters might help. But I think I get what you want.

Batch processing in Acrobat Professional is for applying the same sequence of operations to several different documents. If you want to apply several different XML files to the same PDF, then you'll need a different technique. For example, the options I've outlined in the previous post.

However, to get a really good answer you'll need to provide more information. For example, is this for a LiveCycle form or an AcroForm? What will this XML data be used for? Is it connected to form fields? Or does it have another purpose? Is the XML gramar fixed? or can it be modified to fit the process?

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

Sabrina Wang
Registered: Jun 29 2009
Posts: 4
Hi, Thomp
I happen to have the same issue about batch import xml file into PDF. To be more specific.
1. I am using LiveCycle designer 8 to create the PDF form.
2. The xml file is the previously submitted data from the PDF, so it's connected to the form fields.
3. Actually I send the form to several people, and received their feedback in E-mail xml attachment, so I want to convert these xml data back into the PDF format.

Kindly please advise how should I do that. Should I create a button and define it with certain script? If so, can you please advise what that script may be?

Thanks a bunch!
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
If you are using Acrobat 8 or 9 there is a built in feature called "Distribute Form" that sets the PDF up with a form data collection file. The returned data is automatically collectied into this file. But you can collect any data into a PDF by using the "Forms > Compile Returned Forms..." menu item.There are some tutorials on this site about distributing and collecting data, goto the Tutorials and enter the search word "collect". You'll get several hits.

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

Sabrina Wang
Registered: Jun 29 2009
Posts: 4
Wow, you are such a quick hand, thanks, Thomp :)
Lissa
Registered: Dec 6 2009
Posts: 4
Hi,

Am getting an XML as the output of a wsdl call....am able to view iton my pdf.
How to parse it and extract a particular node ?

Thanks in advance
Lissa
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
This is a different topic, but, the Acrobat JavaScript model contains two XML APIs. One is the E4X model that was built into JavaScript 1.6 (Acrobat 8). And then there is the XMLData object, added in Acrobat 7, you can find info about it in both the Acrobat JavaScript Reference and the XML Forms Model Object Reference. It 's the same XML model used in LiveCycle Forms.

For XML returned from a web service the E4X is pretty easy to use. You'll find an example of using it in the Acrobat JavaScript reference in the "Doc.metadata" entry. And there's tons of info online, but most of it relates to web pages.

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

Lissa
Registered: Dec 6 2009
Posts: 4
Thank you so much thomp.

I got XMLData methods from the reference you provided. That really helps
gjazz35
Registered: Dec 9 2009
Posts: 1
Ho solo bisogno di sapere che รจ la cosa che posso importare un numero di XML in 1 pdf con l'elaborazione del lotto e mi danno risultato utilizzando i javascript della sequenza batch
jeffreyschlater18
Registered: Dec 19 2009
Posts: 1
Thanks Thomp worked for me!
jewstin32
Registered: Dec 29 2009
Posts: 1
I want to import XML into my database, where do I start? (44634 Requests)

I would start with the Books Online that is installed with SQL server. Take a look at the OPENXML topic (or do a search). You will also want to download SQLXML 3.0 and install the SDK so that you can read up on Bulk Loading XML documents.

There are also a could of books that have just been released on the topic. Programming Microsoft SQL Server 2000 With XML by MS Press SQL Server 2000 XML by WROX

Pick them up at bookpool.com (40% discount usually). Unfortunately I haven't had time to read either one so I can't say which is better.

________________________________

[url=http://www.consolidebtllc.com/]american debt management services[/url] | [url=http://www.kwintessential.co.uk/translation/translation.php]Translation Service London[/url] | [url=http://washington-dui-lawyer.com]wa dui[/url]