-
1. Re: How can I export a PDF form and the filled in fields to a text document?
MichaelN Nov 4, 2014 4:38 PM (in response to Lynx_TWO)How exactly are the Adobe Reader users exporting the form to TXT format?
The method to use is
this.exportAsText()
This can be placed into a button that the user clicks when they have completed the form and are ready to export the text.
-
2. Re: How can I export a PDF form and the filled in fields to a text document?
Lynx_TWO Nov 4, 2014 4:47 PM (in response to Lynx_TWO)Users are able to "Save As" a text file through adobe reader however, the only text exported are the questions in the base PDF, not the answers in the form fields. I will try the
- this.exportAsText()
However, I do not know if this will work in Adobe Reader...
-
3. Re: How can I export a PDF form and the filled in fields to a text document?
Lynx_TWO Nov 4, 2014 5:01 PM (in response to Lynx_TWO)OK, so this.exportAsText() KIND of works in Pro except there is no simple formatting, such as adding each item to a different line. In adobe reader however, the button simply refuses to work. Any other suggestions?
-
4. Re: How can I export a PDF form and the filled in fields to a text document?
Gilad D (try67) Nov 5, 2014 1:32 AM (in response to Lynx_TWO)It might be possible with a script, but it's not going to be easy to
develop it, as you would have to figure out where to insert the value of
the form fields in the text stream of the page.
-
5. Re: How can I export a PDF form and the filled in fields to a text document?
Lynx_TWO Nov 5, 2014 4:00 AM (in response to Gilad D (try67))I'm up for the challenge, especially if I only have to do it once and assign the script to a button .
Do you have any references to the command lines/scripts I would have to write? I assume the script would have to tell adobe something like:
[Place header value here]
[paragraph]
[paragraph]
[place custom text here] [place field value here]
[paragraph]
[place custom text here] [place field value here]
etc. etc.
I could literally script to re-create the form in custom text and simply tell adobe where to place the field values? This would be ideal, I just need to know an example of what the script would look like
Basically this would leave the form as a graphical interface for the user, and I would only be outputting what the user entered in the form field data. The questions would be entered again as text into the script. I would also need to be able to generate a "yes" or "no" depending on what is checked in the radio boxes.
-
6. Re: How can I export a PDF form and the filled in fields to a text document?
Gilad D (try67) Nov 5, 2014 4:24 AM (in response to Lynx_TWO)Do you have any experience in writing scripts for PDF files? This is quite
a complex task for a beginner.
-
7. Re: How can I export a PDF form and the filled in fields to a text document?
Lynx_TWO Nov 5, 2014 4:33 AM (in response to Gilad D (try67))I do not however, I am somewhat familiar with coding, so as long as I can interpret the language, I should be good to go. This will be a good learning experience lol I learn best by doing it anyway As long as I have information translating the syntax, I should be OK
-
8. Re: How can I export a PDF form and the filled in fields to a text document?
Gilad D (try67) Nov 5, 2014 4:40 AM (in response to Lynx_TWO)The JavaScript API for Acrobat (and Reader) is available here: JavaScript for Acrobat | Adobe Developer Connection
What you'll basically need to do is use a loop with the getPageNthWord method of the Document object to extract the static text and then the getField method to retrieve the field objects and their values and locations. The most tricky part would be to determine where and when to insert the field values into the rest of the text. Also, you would need to find a way of exporting the final text somehow. You can't do it directly to a file (as Reader can't do that), so you might need to use some workarounds like a large text field, a dialog object, or even just the console window.
-
9. Re: How can I export a PDF form and the filled in fields to a text document?
Lynx_TWO Nov 5, 2014 4:42 AM (in response to Gilad D (try67))Awesome! I will get going on this tonight
-
10. Re: How can I export a PDF form and the filled in fields to a text document?
Lynx_TWO Nov 5, 2014 6:22 PM (in response to Gilad D (try67))OK, so I tried this as a starting point, and assigned it to a button on page 3 of the form.
p=0; console.show(); console.clear(); for (var j = 0; j < this.getPageNumWords(p);j++) { var word = this.getPageNthWord(p,j,false); console.println(word); }This gives me all the words on the first page not in fields, and each word goes on a separate line. Now, characters in the document such as "&" or ")" cause the rest of the word to go on the next line down.
Next, I tried this:
console.show(); console.clear(); for (var j = 0; j < this.getPageNthWord(j);j++) var word = this.getPageNthWord(j,false); console.println(word);
This only gives me the first word on page 3, the page the button is placed?
What I need to do is run the code and place words on one line until the code hits a keyword "var cKeyWord1 = “Key1” for example?, then insert the value of field one, Start a new line in the console, restart the code where it left off until it hits the next key word "var cKeyWord2 = “Key2”, insert the value of field two, add a new line, and on and on.
Is this possible?
-
11. Re: How can I export a PDF form and the filled in fields to a text document?
Gilad D (try67) Nov 6, 2014 1:00 AM (in response to Lynx_TWO)There are several very basic mistakes in your code. I suggest you start by learning the core JS syntax (for example, here: JavaScript Tutorial), before moving on to more complex things.



