Skip to main content
Participant
January 16, 2025
Answered

Read Text From txt File

  • January 16, 2025
  • 2 replies
  • 375 views

My main goal is to rename fields in a form and keep the tab order

.

I've read other posts about mass renaming fields and it looks like the only solution is to create a new field, copy the data from the old field (except with a new name) and then delete the old field. I was able to find a script that does this just fine. The issue I am running into is that the tab order is lost when recreating the fields. 

 

In the program that created the form I can export a txt file that contains a bunch of information, including what order the tabs should be in. I am not sure how to access that txt file so that I can start parsing the data. 

 

I read about converting the txt file to pdf and then reading the data from that, but I was having problems doing that and it isn't really ideal.

Correct answer Thom Parker

Use the "util.readFileIntoStream()" function.  

Here's the reference entry:

https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/JS_API_AcroJS.html#readfileintostream

 

2 replies

try67
Community Expert
Community Expert
January 16, 2025

You can only set the tab order using a script to one of the following options:

- By Rows

- By Columns

- By Structure

The latter *might* correspond to the order in which the fields were created, but I haven't tested it.

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
January 16, 2025

Use the "util.readFileIntoStream()" function.  

Here's the reference entry:

https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/JS_API_AcroJS.html#readfileintostream

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participant
January 17, 2025

This worked perfectly! Thank you!

I was able to I was able to read in the txt file that held the tab order and then rebuild the forms in that order.