1

I made an interactive PDF with InDesign contain some textfields and a button. When this button is pushed I want it to extract the values from the textfields and put these into an XML file. So what this button has to do is call the action "Export form data" with as file extension *.xml. I thought this can be done using javascript (within the actions tab in the properties of the button), but I can't seem to find it.

I have Adobe acrobat Pro 10 and I work on a mac.

I already tried following codes:

this.saveAs("../Test.xml" , "com.adobe.acrobat.xml-1-00");

and

var name = getField("name").value;
var jobId = getField("jobId ").value;
var fieldsToSubmit = ['name', 'jobId'];

this.submitForm
({
               aFields: fieldsToSubmit,
               cSubmitAs: 'XML',
               cPath: "../"
});

This last one works if I use cURL instead of cPath with an email address defined. But this isn't really what I need. The XML file should be submitted to an local storage for example "/users/MyDocuments/Folder/filename.xml".

Can someone please tell me what I'm doing wrong ? Or is this impossible ?

Kind regards

Michiel

3
  • There is no cPath argument in the submitForm() method, that's why cPath does not work. Commented Apr 2, 2014 at 14:16
  • I figured out that too :) but isn't there any alternative ? Commented Apr 8, 2014 at 6:30
  • The path argument is cURL; you may try it out with the file: protocol (no guarantee that it works), but better use the exportAsXML() or exportAsXFDF() method. Commented Apr 8, 2014 at 11:30

2 Answers 2

1

As you want to write the exported data file to the file system (instead of submitting to a service), submitForm() is not really suitable.

The closest coming to my mind would be exporting as XFDF. XFDF is an XML representation of FDF, the PDF native forms data format. XFDF can then easily be transformed to what you need.

Another approach would be creating the XML file content and write it into a Data Object, which then can be exported.

The latter would get an immediately usable result, but would require more programming.

For both methods, it is strongly suggested to consult the Acrobat JavaScript documentation, which is part of the Acrobat SDK, downloadable from the Adobe website.

Sign up to request clarification or add additional context in comments.

Comments

1

Woo-hoo! I found it!

var url = "mailto:[email protected]?subject=My Subject&body=Here is my form data.";
this.submitForm({cURL: url, cSubmitAs: "XFDF"})

I modified a solution that was provided for "XFDF":

https://kbpdfstudio.qoppa.com/send-email-with-pdf-form-data-using-javascript-submitform/

All I did was swap "XDFL" for "XML."
JavaScript magic!

1 Comment

The question was about saving, not sending an email.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.