Skip to main content
ocdriveshafts
Participant
Aug 29, 2017 12:45 AM UTC
Question

Mouse up run javascript importTextData

I am trying to get a form to auto fill from a tab delimited text file when a button is clicked.

I have a Mouse up triggered run JavaScript that is running

this.importTextData("/c/Users/username/Desktop/filename.txt", 0)

When I manually enter the data through Manage form data > Import data it accepts the data just fine so I know the file works I just want to make it so it can be run with just the button.

What am I missing?

This topic is closed to new replies. Start a new post to keep the conversation going.

2 replies

Joel Geraci
Community Expert
Community Expert
Aug 29, 2017 4:02 AM UTC

You're missing the phrase in the documentation after the word "Note:"

Acrobat DC SDK Documentation

Note: (Acrobat 8.0) If cPath is specified, this method can only be executed during batch and console events.

You won't be able to execute the code from a button unless you place the file in a privileged location. You can either follow the directions in the answer above or have each user create a special folder and then tell their version of Reader/Acrobat that it's privileged in the Security Enhanced section of the preferences..

J-

Translate
Inspiring
Aug 29, 2017 3:55 AM UTC

You're missing the security restrictions that are in place for this method. In order to trigger it from document, you'll have to place the appropriate code in a document-level JavaScript file. This means that each user will have to install a document-level JavaScript file. More information here: https://acrobatusers.com/tutorials/getting-external-data-into-acrobat-x-javascript 

Translate