Javascript - creating text box and populating it with data from a CSV file
Copy link to clipboard
Copied
I'm fairly new to Acrobat and javascript. I was able to create a script to create a text box and stamp the PDF with its filename.
Now, I want to create a red text box and populate the box with data from an external CSV file. There are hundreds of PDF's, each with unique filenames. The CSV contains two columns, first is the name of each PDF and beside the name is a string of text. I was hoping to be able to create the text box, have the script read the name of the file that it's currently processing, then pull the text string that matches the name in the CSV file. If that's not possible, is there a way for it to just read the first line and apply it to the first document then read the next line and apply it to the second document etc etc. I realize I'll have to organize the CSV or the filenames to match if the second method is used.
Any help would be appreciated. Thanks.
Copy link to clipboard
Copied
Hi there
Hope you are doing well and sorry for the trouble. As described, you want to craete atext box and populate it with data from CSV file using JavaScript
For more information about using JavaScript with Adobe Acrobat please check out the help pages listed below and see if that helps:
- https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/js_developer_guide.pdf
- https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/js_api_reference.pdf
Regards
Amal
Amal
Copy link to clipboard
Copied
It's possible, but not that simple. First of all, the path of the CSV file will have to be known in advance and hard-coded into the script, or you'll need to select it each time you run it. Once the path is known you need to read its contents, parse them into a data model, and then scan that model looking for a match with the file name. When you find that you return the message text corresponding to that file name and display it in an alert.
If you're interested in hiring a professional developer to create this script for you (for a fee, of course), feel free to contact me privately via [try6767 at gmail.com] and we could discuss it further.

