Copy link to clipboard
Copied
I'm very new to this community and have no idea where to start on this. I have a text document exported from excel with data propperly named and formated. Testing it by importing it manualy through "prepare from" works perfectly, I was just curious if there was any way to make a button that will (upon being pressed) update the data if there has been any changes? I'm willing to use javascript, or if there is another solution that would also be great. Thank you in advance for any advice on the matter.
Copy link to clipboard
Copied
Yes, it's possible, but with one caveat. If you want to specify the path of the file to import then the script has to run from a trusted context, such as a folder-level script file. Otherwise you'll be prompted to select the file each time you click the button. If you're OK with that all you need is the following code:
this.importTextData();
Copy link to clipboard
Copied
Thank you for the reply, this works perfectly for what I need.
I did see you mention that any other way would need to run from a trusted context, how would I go about that for this type of situation? While I will be using the java you provided, maybe I can use the other method for a different document.
Copy link to clipboard
Copied
I recommend reading these tutorials on the subject:
https://acrobatusers.com/tutorials/trust-and-privilege-in-acrobat-scripts
https://acrobatusers.com/tutorials/using_trusted_functions
Basically you would need to write a trusted function and place it in a .js file that's located in a specific folder on each computer. Then the button could call that function, passing the path of the text file to it as a parameter and it would import the data from it directly.