Expand my Community achievements bar.

Fill form automatically

Avatar

Former Community Member
I would like to know how to fill a form with XML data automatically, if the XML file exists, without the user needing to choose Import Data.



How can this be done?
12 Replies

Avatar

Former Community Member
I'm in the same place. Trying to figure out how to automate the Import Data option (using XML not FDF) for a form via the SDK or some other means. Anyone have any thoughts on this subject?



I want to be able to provide data for the template without having to know what the fields are in the template. However, at template creation a sample XML file would be used to make the data bindings. This is easy to setup using Adobe's tools, but how do I do this programatically?



Thanks.

Avatar

Former Community Member
I'll assume that you are using LiveCycle Forms since this is posted in this forum. So, if that's the case, then you pass the XML data in as the data parameter to the renderForm() call.



Chris

Adobe Enterprise Developer Support

Avatar

Former Community Member
Yes, I am using LiveCycle Designer for the template and I want to have an external program call the template and load the XML into it. renderForm seems like a reasonable name for what I would need to call, but maybe I have the wrong SDK. I just did a search on all of the documentation that came with the Adobe Acrobat 7.0.5 SDK and did not find reference to renderForm(). Is there another SDK that I need for LiveCycle? It appears I'm looking in the wrong place.

Avatar

Former Community Member
LiveCycle Forms is a server product that provides an API for doing this. The renderForm() method is part of that API.



The Acrobat SDK is used for creating Acrobat plugins, it wouldn't have anything to do with creating a PDF from an XDP template and XML data as far as I know.



Chris

Adobe Enterprise Developer Support

Avatar

Former Community Member
Thanks for the feedback, where do I find info on the API or sample VB code would be even better.

Avatar

Former Community Member
Ok, I figured this out finally and it will work with the Acrobat SDK and a LiveCycle Designed Form. Posting here in case anyone else is in the same boat as I was.



Not exactly the most straight forward method, but it seems to work in my test case. I'm assuming LiveCycle Forms Server has a better way to do this, but also sounds like yet another product/SDK to sift through and frankly I'm beat at this point.



The Acrobat Solution: The Fields object in the SDK has an ExecuteThisJavaScript method. Using that method and calling the forms JS function xfa.host.importData, an external program can automatically fill a PDF with XML data.

Avatar

Former Community Member
I'm in the same boat and am very grateful you continued to post the answer. I have searched the SDK and can't find a reference to the xfa.host.importdata. My remaining problem is how do I specify the path/ filename of the file to import ?

Avatar

Former Community Member
xfa.host.importData("datafilename");



It is easiest to examine the javascript inside of designer first, then you can pull it out and programattically execute it via ExecuteThisJavaScript.



The SDK has a lot in there, but it is definitely lacking in many areas. Unfortunately, the areas it is lacking in all seem to be the areas that I'm after, inter application programming support.

Avatar

Level 9
Hi



You can't specify the filename because it's a potential security violation. You can only specify "", which prompts the user to choose the filename.



You can use "trusted code" to do this, but it requires the user to explicitly copy the .js file containing the trusted code into the appropriate directory on his/her machine.



Howard

http://www.avoka.com

Avatar

Former Community Member
Hi.. I appreciate all the feedback, but if I can't automate it then this is not a workable solution... guess I'll stick with FDF or find another option.

Avatar

Former Community Member
This is a server based application, and since I'm dealing with signed forms located on the server this has worked just fine. I'm not sure why you think it cannot be done and that it requires copying of js files. I'm not using any JS files, I'm sending the JS directly to Adobe via an ExecuteThisJavaScript call.

Avatar

Former Community Member
Hi

This is from China,and my English is not good,expecting someone could understand me.

I want to import XML data into a template automatically ,in the same time ,I am trying to export XML data from a form automatically .

So ,I wrote "xfa.host.exportData("",0);" in an initialize event , then ,a window of exporting showed when the form was opened by Acrobat PRO 7.0.The question is that when I changed the code into "xfa.host.importData("");" ,nothing happended. How did that happen?

Thank you for your time.