• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
15

Import text file to fillable PDF form

Explorer ,
Nov 22, 2023 Nov 22, 2023

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"

Cindy31563458wshx_0-1700686450046.png

 

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.

 

TOPICS
How to , JavaScript , PDF forms

Views

3.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Nov 29, 2023 Nov 29, 2023

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.

Votes

Translate

Translate
Community Expert ,
Nov 22, 2023 Nov 22, 2023

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. 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 24, 2023 Nov 24, 2023

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 24, 2023 Nov 24, 2023

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

 

 

 

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 27, 2023 Nov 27, 2023

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 27, 2023 Nov 27, 2023

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 27, 2023 Nov 27, 2023

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 27, 2023 Nov 27, 2023

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. 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 27, 2023 Nov 27, 2023

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 27, 2023 Nov 27, 2023

Copy link to clipboard

Copied

Make sure the file is not open anywhere else when selecting it, especially not in Excel.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 27, 2023 Nov 27, 2023

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. 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 27, 2023 Nov 27, 2023

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 27, 2023 Nov 27, 2023

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. 

 

 

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 27, 2023 Nov 27, 2023

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"

Cindy31563458wshx_0-1701120723822.png

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 27, 2023 Nov 27, 2023

Copy link to clipboard

Copied

Very strange. Can you share the PDF and text files with us?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 28, 2023 Nov 28, 2023

Copy link to clipboard

Copied

Is it possible to email you the form and file directly?  

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 28, 2023 Nov 28, 2023

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 28, 2023 Nov 28, 2023

Copy link to clipboard

Copied

Either way is possible. If you want to email it to me do so via [try6767 at gmail.com].

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 29, 2023 Nov 29, 2023

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 04, 2023 Dec 04, 2023

Copy link to clipboard

Copied

LATEST

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. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines