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

Populating a form with more than one entry.

acoginthewheel
Registered: Nov 9 2009
Posts: 11

Following up on this thread:
Importing data from a .txt file and have Acrobat create new pages (http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=19300)

This doesn't seem to be too unusual a need.

I have a spreadsheet file which I can import one entry at a time, but I'm wondering if a batch process could go through the spreadsheet, row by row, and create a new PDF-form for each entry.

Is there not an easy way to do this?

I'm not a programmer, but again this doesn't seem to be complicated a process.

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
No, a Batch process opens up multiple PDF files and applies the same operation to each file. You need to apply different data to one PDF. Kind of the opposite. But this is easy enough to do with a script, or with a dynamic LiveCycle form. How it's done depends on what you are doing.

So do you need multiple pages in the PDF or Multiple PDF files? What tools do you have? Acrobat Pro?

If you can exort the data in to an XML file you can design a Dynamic LiveCycle form that will repeat the page for each set of data in the XML. There is no scripting required for this solution, but you need to learn quite a bit about LiveCycle form design.

On the other hand, you can use a CSV file and ordinary PDF form, but this solution requires scripting, some of the code was given in that other thread.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

acoginthewheel
Registered: Nov 9 2009
Posts: 11
Thanks Thom.

I'm on a Mac, so no LiveCycle, but I do have Acrobat Pro 7.

I'll reread that original post, didn't see what I was looking for the first time.

I actually don't care whether each entry gets put in one PDF or multiple PDFs
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
That other thread didn't actually provide all the code you need, but it did provide the one essential line that's used to import data from a csv file. You need to use this in a loop like this
var nRtn = -1;do{nRtn = this.importTextData(...);if(nRtn == 0){var cNewName = .....;this.saveAs(cNewName);}}while(nRtn == 0);

This simple bit of code has to be run from the Console Window. Notice the code is only a template. It's not complete. It shows how to import data from a CSV file to pre-populate a form and then save each import to a different file name.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

acoginthewheel
Registered: Nov 9 2009
Posts: 11
Would I need to hard code the path of the txt file?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Yes, this code is just a quick way to get what you want. It's not intended to be a generalized or fully featured automation script. Make it all as simple and hard coded as possible.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

acoginthewheel
Registered: Nov 9 2009
Posts: 11
I'm sorry to ask elementary questions, but I'm really an AppleScript person, not Javascript.

If you have the time, can you be explicit about where I need to fill in my hard coded locations/filenames...?


If I were to guess, I would put my data text file's path in place of the ellipsis below:

nRtn = this.importTextData(...);




and then (another guess) my PDF form's path in place of this elipsis?

var cNewName = .....;
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Yes that is correct. But for the first one, what you really need to do is download the Acrobat JavaScript Reference and look up the "importTextData()" fucntion. Acrobat has it's own platform independant path syntax. You can also find examples of using this functin on the forum.

As for the file name, it has to be built at runtime since each file must have a unique name. The file name must end with ".pdf"

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script