Generating a PDF file from a website with dynamic data

I am trying to find a method to generate a PDF file from a website. A user completes some training, and I need to generate a PDF file with their name, class title, and decorative border. The data comes from the database, and the needs to be saved with a specific filename unique to the individual/class.

I can generate an html file with the decorative border as the background, and all of the dynamic data formatted nicely. What I can't find a way to do is to then have the server convert that html file to a pdf format and save it for later access.

I could use a different method, such as a stock PDF file, but I would need to be able to insert the dynamic data and then save it as a unique file.


Dave Monahan


2 Answers

You cannot use Adobe Acrobat on a server - it's technically and legally not qualified for this task.

Here are some general ideas, but what exactly you need to do depends on your server setup.

You can create a form that has form fields for the variable information, the rest of the document (e.g. the border and e.g. pictures of signatures, ...) are static content. This form can be created in Adobe Acrobat. You can then fill in the form in Acrobat or the free Reader to see if the formatting is correct, and print a proof.

Once you are satisfied with your form, you need to automate filling in the form. This can be done with a data merging application on the server: You would extract the data from the database, and then merge it with the interactive form you've created. There are different ways you can do that. A cheap and simple way is to use the pdftk (http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/) tool to merge data and form. There are other tools available, but again, what you can use and what makes the most sense depends on your server setup.

After the data is merged, you need to "flatten" the form, so that it's no longer an interactive form (otherwise the user could use remove "John Doe" from the form and replace it with "Jane Doe"). pdftk can flatten the form as well.

The last step is just standard server technology, you save the form with the filename you need and the user can download it.

If this is not something you feel comfortable doing, you should hire somebody who can build this system for you. If you need more information, or help building this system, feel free to get in touch with me. My contact information is on my profile page.

Karl Heinz Kremer
PDF Acrobatics Without a Net
PDF Software Development, Training and More...
http://www.khkonsulting.com


Karl Heinz Kremer   

I don't completely understand your question.
Who is saving the PDF document and where?

Anyway it seems to me this matters mainly deals with server programming and very little with Adobe Acrobat or Reader. Maybe LiveCycle as web service could be relevant http://help.adobe.com/en_US/livecycle/9.0/programLC/help/index.htm?content=000518.html but its server licence is very expensive.

ColdFusion is another Adobe application (though not focused on forms) that will allow you to generate a PDF on the fly (dynamically) http://stackoverflow.com/questions/73964/how-do-i-turn-a-coldfusion-page-into-a-pdf-download

Otherwise you may simply create a webpage and prompt the user to Save As through the appropriate headers (see tip given in the last answer of the last link).

Finally there's the possibility to work with a template PDF to fill in with fresh data every time. This solution may actually be relevant to this Forum but we should better understand your project and answers to first question put here in particular.

If the end-user needs to open and save the document with custom data, you may think about sending him a XFDF file linked to the template PDF on your server.

Hope it helps.


Ricardo Falegnami   


Please specify a reason: