How to script opening a folder to select an unnamed FDF from among several FDF files

Explorer ,
Nov 07, 2017

Copy link to clipboard

Copied

I would like to find a means to cause a script in DocA to open a specified folder, after which the user would select one of many fdf files in that folder to import into DocA. (The file name is not known when creating the script.)

When I execute the following script in a mouse up action I receive a privileged status warning asking if I trust this site, but when I click "Allow" nothing happens, and placing this in a privileged folder level script does not seem to work either.

var parentPath = this.getField("txtL.Path.Parent").valueAsString;

var agentFolder = this.getField("txtL.Folder.Agent").valueAsString;

     this.importAnFDF("" + parentPath + agentFolder);

Can I do what I want to do? If so, how?

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

It's not possible. You can either specify the entire file-path, or nothing.

If you do the latter you can't control to which folder it will default to.

On Tue, Nov 7, 2017 at 10:38 PM, ddunn@davidsdunn.com <

TOPICS
Acrobat SDK and JavaScript, Macintosh, Windows

Views

172

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

How to script opening a folder to select an unnamed FDF from among several FDF files

Explorer ,
Nov 07, 2017

Copy link to clipboard

Copied

I would like to find a means to cause a script in DocA to open a specified folder, after which the user would select one of many fdf files in that folder to import into DocA. (The file name is not known when creating the script.)

When I execute the following script in a mouse up action I receive a privileged status warning asking if I trust this site, but when I click "Allow" nothing happens, and placing this in a privileged folder level script does not seem to work either.

var parentPath = this.getField("txtL.Path.Parent").valueAsString;

var agentFolder = this.getField("txtL.Folder.Agent").valueAsString;

     this.importAnFDF("" + parentPath + agentFolder);

Can I do what I want to do? If so, how?

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

It's not possible. You can either specify the entire file-path, or nothing.

If you do the latter you can't control to which folder it will default to.

On Tue, Nov 7, 2017 at 10:38 PM, ddunn@davidsdunn.com <

TOPICS
Acrobat SDK and JavaScript, Macintosh, Windows

Views

173

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
Nov 07, 2017 0
Adobe Community Professional ,
Nov 07, 2017

Copy link to clipboard

Copied

If you want the user to select a file themselves, you won't be able to specify the default folder the file chooser dialog is set to. However, it will be "sticky" once chosen.

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
Reply
Loading...
Nov 07, 2017 0
Explorer ,
Nov 07, 2017

Copy link to clipboard

Copied

Thank you. That works fairly well, but It would be nice if I could do what I wanted.

David

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
Reply
Loading...
Nov 07, 2017 0
Most Valuable Participant ,
Nov 07, 2017

Copy link to clipboard

Copied

It's not possible. You can either specify the entire file-path, or nothing.

If you do the latter you can't control to which folder it will default to.

On Tue, Nov 7, 2017 at 10:38 PM, ddunn@davidsdunn.com <

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
Reply
Loading...
Nov 07, 2017 0
Explorer ,
Nov 07, 2017

Copy link to clipboard

Copied

Affirmative. Thank you.

David

How to script opening a folder to select an unnamed FDF from among several FDF files

created by try67<https://forums.adobe.com/people/try67> in JavaScript - View the full discussion<https://forums.adobe.com/message/9953005#9953005>

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
Reply
Loading...
Nov 07, 2017 0
Explorer ,
Nov 19, 2017

Copy link to clipboard

Copied

This is a follow up question to my original question above.

Is there a security reason for not permitting importAnFDF( ) to open a specific folder to allow the user to import an fdf file of the user's choice? This would be a great convenience. If there is no security rationale for not providing this functionality, how do I submit it as a constructive suggestion?


Even it there is a security concern, it seems to me that it ought to be made possible in a privileged context.

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
Reply
Loading...
Nov 19, 2017 0
Adobe Community Professional ,
Nov 19, 2017

Copy link to clipboard

Copied

Yes, this is a security thing. Scripts, especially scripts in  a document cannot be trusted. So access to the file system is heavily restricted. Part of this from early on was not providing robust functionality for functions that do access the file system. If you know the exact location of a file, you can access it with Acrobat JS, but specifying a folder is too much like fishing the system.  The security issue has only gotten worse, so there was never any incentive to improve file system access.

That said, there is a way to do what you want to do. Which is to perform the folder access from an external VB app (assuming your on windows), and then load the FDF with either the IAC, or JS through the IAC.  In this case the UI for opening the FDF is started and run outside of Acrobat. But the FDF load and displaying the loaded file still happen in Acrobat.

Here's a link to the IAC docs

Acrobat DC SDK Documentation

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
Reply
Loading...
Nov 19, 2017 0