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

Auto populate forms

Keez
Registered: Dec 9 2011
Posts: 4

Hi there, first post.
 
Can someone steer me in the right direction:
 
I want to create a education based form. I would like to add the following functions to this form:
 
1) Create a drop down list so that I can select a class
2) Depending on the class selected, all of the students names and ID's are populated.
 
Basically, I want to create one generic pdf which any teacher can access and generate their own rolls, dependent on the class selected. There are 10 classes, each class has 15 students.
 
Number 1 is easy.
Number 2 is difficult, as number 2 would have to be linked to selection in number 1.
 
Can this be done in acrobat?
Will I need Livecycle?
Will it involve programming?

maxwyss
Registered: Jul 25 2006
Posts: 255
First to your questions:

Can it be done in Acrobat?:
Yes, and something similar has been done a dozen years ago, and then been in use for more than ten years.

Will I need Livecycle?
Livecycle what? Livecycle is a server product range by Adobe, intended for big organizations. But I assume you are talking about Livecycle Designer. In that case my answer is "you can use it, if you want to make your life miserable"…

Will it involve programming?
Yes, it will involve a little bit of programming.


Now, for a way to implement it:

Let's assume that you will have only a few forms, which means that it is acceptable to manually add document-level scripts.

The idea is to set up a students/student ID table as a document-level script. Tables are represented in Acrobat JavaScript as Arrays. In your case, you will have a multidimensional array (sounds more intimidating than it is). The main array represents the list of your classes. Each class is an array itself. The first element represents the name of the class, and all following elements are little arrays representing the individual students (you may have 2 elements, name and ID, or more, if you want to add more granulated information). You make the definition of this array a document-level script.

So, you have the data table. Now, how do you link it to the drop down menu (represented as a combo box). You can do it manually (may be a little tedious and can cause errors). You set up the items of your combobox so that the "face value" is the name of the class, and the "return value" is the index of that class in your classes array. And that's all needed about the selection of the class.

Filling the student information depends on how you have set up your form. You essentially load the data from your selected individual class array into the according fields.

This is essentially how you would proceed. If you have many students and classes, it may be worthwile to use a database application, such as FileMaker Pro, or even Excel (if you are not blasting some internal limitations of Excel), to assemble the document-level script. It would involve simple text manipulation and concatenation.

If you have a bigger number of forms, but only very few workstations preparing the forms, you may use the same code as an application-level script instead of a document-level script. Then you would have access to it from any form loading the data when opening (in the document's document level, or PageOpen script, you would create the items array for your combobox (see setItems() entry in the Acrobat JavaScript documentation).


THis should not be thaaat difficult to implement. However, if you prefer "buy" over "make", feel free to contact me in private.

Hope this can help.

Max Wyss.

Keez
Registered: Dec 9 2011
Posts: 4
Hi Max, thanks for the great response!!

I prepared a couple of screenshots but now realise that you can't attach pics to posts.

I would need to implement the solution to a 7 page document. Essentially the document pages are the same (slight textual and graphical differences, but that is all). The class and student info needs to be editable for each page. I may have class 1 on page 1 and class 2 on page 2, class 1 on page 3 etc.

The way I see it working is to have a central database linked to the document. That way I can easily add/edit the database, at the same time keeping the links intact. The classes will change annually, hence why I need to be able to edit form content. Excel would be more than adequate, since the class and student details are very basic in terms of databases.

Arrays are not an object you can create in Acrobat? Sounds to me like they are coded tables? If so, the problem I see is managing/changing the students details (required annually), unless editing arrays is very straightforward.

So, how about I create a drop down menu (combo box) for the class list and have the result call on a database to populate the student name and ID fields? Will that be a solid approach? And what do I need to read up on specifically to be able to do it?

thanks again.


try67
Online
Expert
Registered: Oct 30 2008
Posts: 2398
Connecting a database to an Acrobat form is quite complex and requires a lot of scripting knowledge, in both JS and in SQL. Also, it can't be done in Acrobat X. Here's a sample of how it works (from my website):
http://try67.blogspot.com/2009/05/acrobat-connect-pdf-to-database.php
It's easier to implement in LiveCycle, but still requires quite a bit of scripting know-how.

Another option would be to create a script that import the data from a plain-text file (for example, if you have the data in an Excel spreadsheet you can export it as a CSV file or a tab-delimited text file). So it's not a live connection (ie, if you update the database the PDF doesn't get automatically updated), but it's something.
This will also require a relatively advanced knowledge of Acrobat JS scripting.

The easiest option to implement is to include all the data inside the PDF itself (no external data source).

If you're interested, I can create any of these scripts for you. You can contact me personally to discuss it further.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

maxwyss
Registered: Jul 25 2006
Posts: 255
As someone else has stated, hooking up a PDF form directly to a database is tricky, and has been killed off by Adobe with Acrobat 10. Depending on how you plan to distribute the blank form, you have some options, however.

The easiest procedure would be to manually update the master form after a change in the database. You could do this by exporting an FDF, and manually importing that FDFinto the master form. This same procedure would also work if you make available the blank form via a front end, where you would serve the FDF, which then automatically loads its base form. With that, you make sure that whenever someone retrieves the form, it is up to date.

Of course, Acrobat/PDF can create and maniuplate arrays. The Core JavaScript versions used in Acrobat are 1.5 until Acrobat 7, 1.6 in Acrobat 8, and higher versions in Acrobat 9 and 10. In fact, some of the new methods (such as indexOf() ) in the Array object require Acrobat 8 or newer.

ABout Arrays; it was my choice to talk of tables, in order to make things a bit more understandable for the layperson. Don't feel offended about that, please.

As it has been said, it is easiest (and most reliable) to cinlude a database in the document; that will allow the user to work with the document anywhere, even without the need of connecting to a server (and a database).

Hope this can help.

Max Wyss
Keez
Registered: Dec 9 2011
Posts: 4
Hmm, based on the above, hooking up to a database would be out of the question. The training organisation I work for would not allow tampering with the registry - i.e. administrator restrictions. So all the data would need to be embedded into the file.

Using the FDF option the steps would be:
Create the master pdf document with the required forms
Import a FDF file into the pdf , and save it, thereby creating the master document.
To edit the database, export the fdf, edit it, re-import into pdf and save.

Question:
Would you require any external software to edit/maintain the FDF (when changes are required) or can it all be done within Acrobat X?

The complexity still lies in linking the class drop down list to the student pool....
try67
Online
Expert
Registered: Oct 30 2008
Posts: 2398
Using an FDF is not the only/best way of doing it. I think you're better off using the option that imports the database from a plain-text file and embeds it in the PDF. Once this is set-up, all the other code can remain the same, including the part that links the class drop-down to the student pool (which is not very complex).
To update the internal database all you'll have to do is re-import the file, which you could edit in Excel, Access, or just a plain-text editor.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

Keez
Registered: Dec 9 2011
Posts: 4
I agree. Excel it is.

Thanks for everyone's input into this. I'll do more research and post back..
klwalsh611
Registered: Sep 10 2009
Posts: 28
Try6767 - "Another option would be to create a script that import the data from a plain-text file (for example, if you have the data in an Excel spreadsheet you can export it as a CSV file or a tab-delimited text file). So it's not a live connection (ie, if you update the database the PDF doesn't get automatically updated), but it's something."

Do you have an example of how this works? I need to pull a user name and email address from a massive Excel file and can't embed the data in my acroform. The logic is to look for a condition(in this case a Market Center Number selected from a drop-down in the form) and then pull the Controller's Name and the Controller's Email Address into the corresponding fields in the form. I could probably ask my IT dept to parse the Excel file to include just the MC #s, Controller Names and Email Addresses and export it as a tab-delimited or CSV file but I would then need some direction as to how I read that data into my form.
Thanks!
try67
Online
Expert
Registered: Oct 30 2008
Posts: 2398
I have developed various scripts that do just that. Contact me personally to discuss it further (my email address is in my signature below).

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com