• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Assist in button to import data from either a txt file or attached txt file to pdf?

Community Beginner ,
Apr 07, 2021 Apr 07, 2021

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. 

TOPICS
Create PDFs , How to , JavaScript , PDF forms

Views

329

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
Community Expert ,
Apr 07, 2021 Apr 07, 2021

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();

Votes

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
Community Beginner ,
Apr 08, 2021 Apr 08, 2021

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.

Votes

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
Community Expert ,
Apr 08, 2021 Apr 08, 2021

Copy link to clipboard

Copied

LATEST

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.

Votes

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