Expand my Community achievements bar.

Use parameter to define location of xml-file

Avatar

Level 1

Hi,

here is a question about importing data from a xml-file using the xfa.host.importdata

A tool we use generates a copy of a 'template'-pdf an put it into a unique folder. This unique folder will contain:

(1) a Batch-file

(2) a fillable, certified, reader-enabled pdf

(3) a xml-file containing data for the pdf

The batchfile will run a command 'start iexplore.exe file://C:/Doc.pdf?Address="C:/Doc.xml"

So, the Internet Explorer will be started, opens the local PDF and creates a parameter with the location of the xml-file.

So, now is my question how to make it work that in the DocReady-event the command xfa.host.importdata(); will be executed pointing to the xml-file. It should be like xfa.host.importdata("C:/Doc.xml");

If I put the command in the click-event of a button, it works fine, but I need help with setting up that command using the parameter.

Thank in advance!

Erik

1 Reply

Avatar

Former Community Member

You will not be able to automate using script the reading of a data file. This is deemed a security risk (as the user is not aware that this iis happening) and as such the user must pick the file.

There is another way though. There is an xml format supported by XFA forms called XML Data Package(XDP). This format keeps the data in teh same way as the xml file but allows a couple of goodies in it. Like the template that was used to create the file. If you open your PDF file and save the data out in that xdp format, then open the file in a text editor you will see a reference to the template that was used to load it. Now if you double click the xdp file then it will open the data file, find the reference to the template and merge the data and template together for you. This is not a security risk because the user casued teh data file to open. Note that this will not work on machines that have Designer on it because the XDP extension is registered with Designer and not Acrobat/Reader. If you change that association in Windows then it will work fine.

So my suggested solution is to make your data files xdp files and add the reference to the template that you want to use and have the user launch the xdp file and you shoudl be able to accomplish what you asked for.

Hope that helps

Paul