Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Import XML using JavaScript

New Here ,
May 12, 2021 May 12, 2021

Copy link to clipboard

Copied

Hi,

 

We're trying to create a PDF form that lets the user import (preferably XML) data on a button click.

 

The following works just fine on my machine.

 

this.importXFAData("/c/temp/import.xml")

 

But when I try this on another computer it won't work, due to the path not having been added to the Enhanced Security settings.

 

Is there a way to achieve this without adding the path there?

Or is there even a better way to do this?

 

Thank you.

TOPICS
JavaScript

Views

1.6K

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 12, 2021 May 12, 2021

Copy link to clipboard

Copied

What happens when you try this on another computer?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 13, 2021 May 13, 2021

Copy link to clipboard

Copied

Hi Bernd,

 

Nothing happens when I copy the file to another machine. It seems to be ignoring the javascript.

 

I get the following in the console:

NotAllowedError: Security settings prevent access to this property or method.

Doc.importXFAData:1:Field Button4:Mouse Up

 

I can see this being on purpose, but i wonder if there is a way to achieve this. I can't be the only one that needs end-users to be able to populate a form with external data.

 

Any advice is greatly appreciated.

 

PS: Wir koennen das auch in deutsch machen. Falls das einfacher ist.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 13, 2021 May 13, 2021

Copy link to clipboard

Copied

You can try this:

this.importXFAData();

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 13, 2021 May 13, 2021

Copy link to clipboard

Copied

Hi, I haven't tested with the end user, but I'm sure it won't work for my scenario. This requires the end user to select the file manually, which I’m trying to avoid.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 13, 2021 May 13, 2021

Copy link to clipboard

Copied

- In what application (including exact version number) are you opening the file on the other computer?

- Yes, you can drop the file-path from the code and then you'll be prompted to select it.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 13, 2021 May 13, 2021

Copy link to clipboard

Copied

The file was created in Acrobat XI (11.0.23) and I'm sure the end user has a similar version, since these applications are deployed companywide equally.
As for dropping the path. I did that on my machine and it works, but as mentioned aboded that won't work what I'm trying to achieve. End users should not be prompted to select a file.

Please let me know, if there is another or better way to do that. I’m sure other companies have similar requirements.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 13, 2021 May 13, 2021

Copy link to clipboard

Copied

I wonder if you're trying to use the method in Acrobat Reader? 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 13, 2021 May 13, 2021

Copy link to clipboard

Copied

That would be my guess, too... Hence my question from above.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 13, 2021 May 13, 2021

Copy link to clipboard

Copied

Please see my response above. Thank you.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 17, 2021 May 17, 2021

Copy link to clipboard

Copied

Using the file path in this function requires privilege. As you've noted, adding the path to the "Enhanced Security" is one way to make this work.  There are several other methods, but they all require the user to do something on thier system to explicitly create a privileged context.  You can read all about it here:

https://www.pdfscripting.com/public/Trust-and-Privilege-in-Acrobat-Scripts.cfm

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 17, 2021 May 17, 2021

Copy link to clipboard

Copied

I figured as much. It seemed like it would be a security concern if i had the ability to add trusted paths.


With that being clarified, is there a way to accomplish this differently? Surly I can't be the only person trying to populate pdf form fields.

 

Any advice is greatly appreciated.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 17, 2021 May 17, 2021

Copy link to clipboard

Copied

LATEST

There are several ways to populate PDF form fields. The best method, or at least the available options depend on the specifics of your workflow. For example, who are these users? Are they in your office? Are they remote? are they random people? What kind of devices are they using? What kind of PDF viewers are they using? Do you have any control over thier systems? Where does the data come from? That sort of thing.

 

You can read more about loading data into forms here:

https://www.pdfscripting.com/public/Form-Data-Handling.cfm

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines