Skip to main content
Inspiring
January 7, 2020
Answered

Possible to fill form field from another filled with xml-data

  • January 7, 2020
  • 2 replies
  • 2973 views

Hi.

 

Is it possible to fill in a text field an xml export and after that i can press a button "calculate"

an for example the button search a specified text from the xml export and fill it to the right form field?

 

sry, bad english, i hope you understand what i mean.

 

exp.

<Auftragsnummer_Fremdsystem>KKU00123456</Auftragsnummer_Fremdsystem>

 

so fill "KKU00123456" in an extra form field.

 

eMd

This topic has been closed for replies.
Correct answer Thom Parker

You'll find tutorials on E4X here:

https://developer.mozilla.org/en-US/docs/Archive/Web/E4X/Processing_XML_with_E4X

 

However, if you are not a programmer then this may not help much. PM me if you are interested in hiring a developer. 


Just took a look at the E4X reference and it seems to be easier then I thought.

 

Here is a script you can put on a button that will auto fill a form field from XML entered into a different field

 

var myXML = XML(this.getField("XMLField").value;

this.getField("OtherFormField").value = myXML..Auftragsnummer_Fremdsystem;

 

You'll need to change the form field names to match the ones on your form.

2 replies

Thom Parker
Community Expert
January 7, 2020

Yes, this is possible. There are a couple of different ways to do this.

1. If the XML tag matches a field name, and the XML uses a simple flat gramar, then importing the XML will automatically fill the field with the same tag name.

2. Use Acrobat JavaScript to open the XML file and parse out the data.

 

Depending on how you want to do this, Privilege may be required, meaning that there are certain operations that cannot be done in from within a PDF scripting context, such as silently opening an XML file from the user's file  system.

However, if the XML data is text in a form field, then there is no problem. 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
emddummiAuthor
Inspiring
January 8, 2020

But is it not possible that the button reads the content of the field and fills the corresponding values ​​in certain fields? It always has to work with an xml file?

emddummiAuthor
Inspiring
January 9, 2020

Just took a look at the E4X reference and it seems to be easier then I thought.

 

Here is a script you can put on a button that will auto fill a form field from XML entered into a different field

 

var myXML = XML(this.getField("XMLField").value;

this.getField("OtherFormField").value = myXML..Auftragsnummer_Fremdsystem;

 

You'll need to change the form field names to match the ones on your form.


 

var myXML = XML(this.getField("Daten").value);

this.getField("AuftragsNrFremdsys").value = myXML.Auftragsnummer_Fremdsystem;

 

I tried the following code.

Unfortunately it does not work.

 

Thank you very much for your advice, I will read myself in the reference, maybe I will find the error.

Eric Dumas
Community Expert
January 7, 2020

HI, 

Can you confirm the version of the software and the operating system you are using?

I am not sure I fully understand your question but it looks like you will need to create a complex script to get the button to work. Another challenge will be to allow your pdf to connect to a specific external file, which is not always possible for other users.

emddummiAuthor
Inspiring
January 7, 2020

i use windows 10 enterprise ans adobe acrobat standard 2017.011.30142

 

and every user will get the xml data to the clipboard and can paaste it in their pdf file.