Skip to main content
Inspiring
November 7, 2017
Answered

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

  • November 7, 2017
  • 2 replies
  • 1318 views

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?

This topic has been closed for replies.
Correct answer try67

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 <

2 replies

ODuinnAuthor
Inspiring
November 19, 2017

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.

Thom Parker
Community Expert
Community Expert
November 19, 2017

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

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Joel Geraci
Community Expert
Community Expert
November 7, 2017

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.

ODuinnAuthor
Inspiring
November 7, 2017

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

David

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
November 7, 2017

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 <