Skip to main content
Participant
August 10, 2018
Answered

I want to look up data from an external file and use it to fill an acrobat form field

  • August 10, 2018
  • 2 replies
  • 2398 views

I'm working on a travel form pdf and want to look up the travel distances in an external Excel spreadsheet (or cvs, tab-delimited text file, etc.).  All I've found on this is creating an array or table in the pdf to search using javascript.  That seems rather arduous given the number of cities in a given state.   Any help here is appreciated.

Thanks,

Randall

This topic has been closed for replies.
Correct answer George_Johnson

Reader is not able to use most of the methods that Acrobat can to access data in external files, but it can read data in file attachments. So you could include a data file (e.g., tab delimited text) and read it using the doc.getDataObjectContents JavaScript method. This keeps the data with the document that uses it, so it's a portable solution. It could be rather slow depending on how much data is involved.

An alternative is to have each user install a folder-level JavaScript file that simply contains the data, similar to how you could by including it in a document. This approach would be faster than the previous one. It isn't really portable since each user would have to separately install the file, but the single data source would be readily available to any number of forms once it's installed.

2 replies

Participant
May 5, 2023

Do you know the limits of the amount of data using the CSV method you describe.

Let call the limit lines of text in an excel file...

 

20,000?

100,000?

 

before it gets slow?

I want to import a catalog of products that is quite large.

 

Thanks

 

Ryan

Participant
May 5, 2023

@REMZilla see question above - thanks

Participant
May 5, 2023

@George_Johnson - see question above - thanks

Inspiring
August 10, 2018

Does it need to work with Reader?

REMZillaAuthor
Participant
August 11, 2018

Yes.

George_JohnsonCorrect answer
Inspiring
August 11, 2018

Reader is not able to use most of the methods that Acrobat can to access data in external files, but it can read data in file attachments. So you could include a data file (e.g., tab delimited text) and read it using the doc.getDataObjectContents JavaScript method. This keeps the data with the document that uses it, so it's a portable solution. It could be rather slow depending on how much data is involved.

An alternative is to have each user install a folder-level JavaScript file that simply contains the data, similar to how you could by including it in a document. This approach would be faster than the previous one. It isn't really portable since each user would have to separately install the file, but the single data source would be readily available to any number of forms once it's installed.