These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

PDF Price List with prices in an external Text or Excel file

enricomigliore
Registered: Jan 25 2011
Posts: 8

Hello,
 
I created a Price List, with some hundreds items, in the PDF format.
 
At the moment, all prices are hardcoded in the PDF file.
 
Is it possible to link the prices to an external Text or Excel file in order for me to update the Price List without editing the PDF file?
 
Thanks in advance,
Enrico Migliore

George_Johnson
Online
Expert
Registered: Jul 6 2008
Posts: 1876
See the following for some ideas: http://acrobatusers.com/forum/forms-acrobat/order-form-lots-products-calculated-fields

Thom suggests adding the data file as an attachment, but it's possible with an external file as well. You can read a tab-delimited txt file that you export from Excel using the doc.importTextData JavaScript method.
try67
Expert
Registered: Oct 30 2008
Posts: 2398
The problem with importTextData is that you can't specify the cPath parameter unless it's used in a batch or console event. Therefore, you have to select the file manually when calling the method from a doc-level script.
If you really want to do it automatically (and silently) you can use the new util.readFileIntoStream() method to read in the file and apply the values to your fields. However, this will only work in Acrobat (or Reader) version 10 or higher.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
If .rFIS was permitted to run silent from a non-privileged context, PDF files could scrape information from the user's computer and submit to a remote server.

Naturally engineering are not about to leave a hole in util.readFileIntoStream compared to importTextData, so the same sandboxing rules apply - if the cDIPath parameter is specified when calling .rFIS it can only be executed in privileged context, during a batch or console event or when the document is certified with a certificate trusted to execute "embedded high privileged JavaScript".

Without cDIPath specified the user is presented with an OS OpenFile dialog but there is no way to limit the extensions which can be selected or the initial starting folder. You can reject the passed stream reference if it's not what you wanted, but there's no access to the filename or mime type of a ReadStream object so you'd need to analyze the data bit-by-bit and work out what type of file it is. Sorry but .rFIS pretty much assumes your user is going to select the right thing, usually a text file, even though the OpenFile dialog defaults to "*.*" filtering. If they send you back an InDesign file or a shortcut to a program, you're doomed. Probably shouldn't have set it up like that, but hey... nothing's perfect.


try67 wrote:
If you really want to do it automatically (and silently) you can use the new util.readFileIntoStream() method to read in the file and apply the values to your fields.
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Oops, you're totally right. I overlooked this part of the documentation.
Sorry about the misinformation.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
Lol.. no worries - at least that section of the docs is one of the updated ones! It's a real pain not to have access to the mime type of a ReadStream, but maybe next time. Right now .rFIS is one of those "point of principle" methods exposed because it's needed elsewhere, and I'll be interested to see examples of real-world applications for it.
try67
Expert
Registered: Oct 30 2008
Posts: 2398
You'll be happy to hear I'm already using it in some of my scripts. I love the fact that I don't need to import a DataObject, read it, process the contents, and then delete it.
The problem is, of course, that it only works with X, so it can't be used in a general script, only in those made for a specific client, who I know will only use X.

However, I did discover (and reported) a bug related to rFIS. Namely, after running it the original file stays locked and can't be edited until you exit Acrobat/Reader.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com