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

Xml datasource, question

dariush
Registered: May 2 2011
Posts: 5

Hi,
I've created a form which binds a sample xml datasource.
Using the preview tab in the form configuration I've setted up the use of a sample xml data file and everything works fine.
Now I'd like to publish the final xdp file, how can I load a final xml file and populate my fields?
Best regards,
Dariush

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Do you mean publish the PDF file? That's what's being displayed in the Preview Window. When the form is connected to a sample XML file, the XML is used to structure the form's data model. To load and save data into and out of the form the regular Form import data and form export data operations are still necessary. In Acrobat 9 and earlier these options are accessed from the "Forms > Manage Form Data" menu. You can pre-load the data using this menu in Acrobat Pro and then save the form.

If on the other hand you really do want to save as XDP and have a preloaded data model, then thats a different animal.

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

dariush
Registered: May 2 2011
Posts: 5
hi Thom,
thank you for the answer.
Let me give you a more detailed view of my problem. I've installed lc ES2 and adobe reader X.
I've developed a form using an xml datasource and a sample xml file (defined in form properties->preview tab).
The xml file changes dynamically so I cannot create a static pdf file from LC, but I'd need to load the data every time that form is opened.
I'd need to load data always from THE SAME XML file, contents may change but its location is always the same.
I tried the importData js method and it gives me a security error (using adobe reader X); looking at the forums, it seems that the data loading can be done only with acrobat and not with the free reader, am I right?

thank you again,
Dariush
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Importing and exporting local data directly, using the import/export functionality is restricted in both Reader and Acrobat Pro because it is a security risk. In Acrobat Pro all you need is a trusted function. But in Reader you also need special Enabling Rights, which makes this a near impossible task. But, there is a solution,

Read this article:
http://acrobatusers.com/articles/getting-external-data-acrobat-x-javascript


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

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Importing and exporting local data directly, using the import/export functionality is restricted in both Reader and Acrobat Pro because it is a security risk. In Acrobat Pro all you need is a trusted function. But in Reader you also need special Enabling Rights, which makes this a near impossible task. But, there is a solution,

Read this article:
http://acrobatusers.com/articles/getting-external-data-acrobat-x-javascript


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

dariush
Registered: May 2 2011
Posts: 5
Hi thom,
just finished to read the js file attached with the example.
My form if binded a lot with the external file (It is 40 pages form with +-150 bindings), it seems that if I decide to use the sample approach I'd have to rewrite the whole form, isn't it?

Let me know, thank you very much.
Dariush.

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
I don't think you'd have to change anything on you're current form. (of course I don't know for sure because I haven't looked at it) Since the XML is used to structure the data model in the form, a different method of loading the data won't impact any code on the form. But, this is a different method of loading data. It requires creating a folder level script that you would use to pre-populate the form. It doesn't have anything to do with what the user sees when they use the form.

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

dariush
Registered: May 2 2011
Posts: 5
Hi thom,
I'm trying to integrate my livecycle based form with the examlpe js, but looking at the code I see

else if(oDoc.xfa != null)
{
var cMsg = "Current Form is LiveCycle (XFA)\n\nThis tool only operates on AcroForm PDFs";
app.alert(cMsg,0,0,cAlertTitle);
return;
}

That means no chance for my form?
Best regards,
Dariush
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Good Catch! The code was written to populate fields on an AcroForm, i.e., it uses the "doc.getField()" function to acquire the field objects. It could however be easily converted to populate fields on a LiveCycle form by switching out the "doc.getField()" calls with "oDoc.xfa.form.resolveNode()" calls.

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