Copy link to clipboard
Copied
How can you create a button to do the Import Data option - i have it where i can select the .txt file but it does not give me the option when doing it manually , i am not getting the "Import Data from Delimited text file"
I have read so many posts and realize you cannot make separte forms for each line but i thought if i can have a button open this up and then just select each line for each new PDF form would work.
I want to give a big THANK YOU to TRY67 - solution found. In the form preference under "Security (Enhanced)" under Sandbox Protections the first 2 boxes were checked "Enable Protected Mode at startup" and "Run in AppContainer". Under "Enable Enhanced Security" was also checked. All these were unchecked and the button now works. snapshot attached.
Copy link to clipboard
Copied
This has to be done with JavaScript, and from what you've described you need an automation script:
Here's an article on automation scripting:
https://www.pdfscripting.com/public/Automating-Acrobat.cfm
And here's a (not free) tool that does exactly what you've described:
https://www.pdfscripting.com/public/ImportExport-Excel-Data-as-Text-Description.cfm
And you could write a script that does create a new form for each line.
Copy link to clipboard
Copied
Appreciate the information very informative.
I have searched and did reach out to Adobe about importing data and filling in a pdf form and i received it could not be done. Then i found on one blog to use the Excel AddIn Power PDF Filler, which did not work cause it goes by when the field was created and the field name (SMH).
I have an 8 page PDF form and then i have a Excel Spreadsheet with the field names and i can manually import it into the pdf form one line at a time.
You say it can be done with javascript - i know some but probably not what is needed to write the whole script.
Is it possible to help me start?
Copy link to clipboard
Copied
Such a script is not difficult to write, but you do need some programming skills.
Here's the Acrobat JavaScript Reference entry for the "importTextData" function, which is what you'll need
https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/doc.html#importtextdata
Be sure to examine the example code.
A simple way to do this is to develop and run the script in the Console Window.
Here's a video tutorial on using the Acrobat JavaScript Console.
https://www.pdfscripting.com/public/images/video/AcroJSIntro/AcroJSIntro_ConsoleWindow.cfm
Copy link to clipboard
Copied
Thank you for the information and the console window is a great help to use.
When I use the button with the javascript to importTextData() the console window provides me with a 1 – cannot open file.
When I manually use the Import Data from the menu in Adobe I locate the file select the row and the information is populated within the form.
Why does this manual way work and not when you put the script in the button. I cannot designate a path as I have 10 people who would be saving the text file to their desktop or some location on their laptop.
Copy link to clipboard
Copied
If you don't specify anything as the parameter of importTextData it will prompt you to select a file.
And the "1" return code does not mean "Error: Cannot Open File", but "Warning: User Cancelled File Select". This is an error in the documentation. All the values that are shown as negatives are actually positives, and vice versa.
Copy link to clipboard
Copied
appreciate know the positives are negatives - so i selected the file, and then nothing happens i see no error.
This is javascript for a button and so ran it in the console window as Thom suggested using that and i get this
this.importTextData()
1
And again i selected the file and then nothing
Copy link to clipboard
Copied
So you didn't get the row selection popup?
The importTextData() function should behave exactly like the manual import text data.
Copy link to clipboard
Copied
correct - did not get the selection popup. And yes that was my assumption that it should act like the manual import. The form i am trying to fill in has 166 fields - the excel spreadsheet matches with the field name values and i saved it as a tab delimiter file. Spinning my wheels and head and appreciate everyones input and suggestions.
Copy link to clipboard
Copied
Make sure the file is not open anywhere else when selecting it, especially not in Excel.
Copy link to clipboard
Copied
Having the file open in Excel would do it. This can be deceiving. When you "save as" a tab delimited file from Excel, that tab delimited file is now open in Excel. It has to be closed before it can be opened by Acrobat, even though it's only for reading.
Copy link to clipboard
Copied
i rebooted my laptop made sure nothing was open and still same results. However, question, when i manually do it the pdf form has to be in a "edit" form mode to have the option - do not think that this or should make a difference. This really does not make any sense as it should be the simple command - manually i get the dialog box. Put the importTextData in the button (javascript) and no dialog box came up.
Copy link to clipboard
Copied
Prepare Form mode (i.e. edit form) is not necessary. The JavaScript should work regardless.
The console window is the best way to test this kind of funtionality because it provides a privileged environment, which the form button does not. It's also faster and easier to work with.
Copy link to clipboard
Copied
Hi yes i used the console window and here is a snapshot - after i selected the file the next line shows "1"
Copy link to clipboard
Copied
Very strange. Can you share the PDF and text files with us?
Copy link to clipboard
Copied
Is it possible to email you the form and file directly?
Copy link to clipboard
Copied
Sorry hit post to soon - or i can drop it and once you pick it up can i delete it from the post? Sorry new to this.
Copy link to clipboard
Copied
Either way is possible. If you want to email it to me do so via [try6767 at gmail.com].
Copy link to clipboard
Copied
I want to give a big THANK YOU to TRY67 - solution found. In the form preference under "Security (Enhanced)" under Sandbox Protections the first 2 boxes were checked "Enable Protected Mode at startup" and "Run in AppContainer". Under "Enable Enhanced Security" was also checked. All these were unchecked and the button now works. snapshot attached.
Copy link to clipboard
Copied
Hi Thom, I did join the PDFScripting and downloaded the one you suggested.
I am following the script but how do i get assistance with it? I need to change out the location of the text file as it can be different for each user of the form.
I can see the looping through until completed and it does make sense, however, stuck on trying to identify the location.