focus310 has asked for the wisdom of the Perl Monks concerning the following question:

Hello: I have about 20 forms which are Word documents. All of the forms contain the same demographic information (name, date of birth, etc) which I'm storing in a MySQL database. I'm creating online versions of these forms. The form fields for the demographic information will be populated from the database and the user only has to complete the rest of the form. After submitting the form and being processed, the results are formatted to look like the actual paper form. They are required to maintain copies of all forms. Is there a way to take the results, format and all, and save it as a PDF file? If so, how do I go about doing that? Thank you for your time.

Replies are listed 'Best First'.
Re: Create PDF from Perl
by GrandFather (Saint) on Apr 23, 2007 at 02:03 UTC
Re: Create PDF from Perl
by wjw (Priest) on Apr 23, 2007 at 04:08 UTC
    One thought, use OpenOffice. It has built-in "export as pdf", it is free, multi-platform, handles MS Doc files very well, and there are perl mods for it.

    Just a thought... Good luck.

    ...the majority is always wrong, and always the last to know about it...

Re: Create PDF from Perl
by holli (Abbot) on Apr 23, 2007 at 08:52 UTC
    I think we may have an XY Problem here and I have a couple of questions. You say I have about 20 forms which are Word documents. All of the forms contain the same demographic information. Why so? If they contain the same, why do you have 20? Are they somehow user specific? And are they, already fill-in forms or just plain word files?

    You also so you are creating online versions of these forms. I have seen various ways to "create an online version of a form. From the "wooden table" scanned document that was converted to a pdf for printing and filling by Hand, to a sophisticated Info-Path solution. To give good advice we need to know more about you're Setup. Anyway, given you've got a standard webserver and want to use pdf I basically see two possibilities:

    You create a Html-form where you query the neccessary fields from your user. Once submitted the server takes them and creates a new pdf, enriched with the users input. To create such a PDF you can use something like PDF::Template or FOP. And yes, this requires to recreate your forms but also gives you much control over the output. For example you could use different templates for different users.

    The other way is to use the built-in form functions of the pdf-format. You can use CAM::PDF to read and manipulate such field values. Sadly I have no idea how to create such a file automatically.

    Hope this helps.


    holli, /regexed monk/
      Yes, 20 forms. Here are some examples: Client Incident Form, Client Interview Form, Admission Agreement, Initial Plan of Care, Client Mental Status Evaluation, etc. Need I say more. All of these forms ask for client name, date of birth, data of admission, etc. These forms are also Word documents which are currently being completed by hand. They want to eliminate all the paperwork. So I'm creating the forms online. We have a table which stores all the info. When it's time to fill out a form, some of the infomation is already filled in (from the table). All that is left is to fill out the rest of the form. They want to be able to save the result of the forms as a PDF. They get audited once a year without any notice. That is why they need a PDF file. I'm not sure how to create one.
Re: Create PDF from Perl
by marto (Cardinal) on Apr 23, 2007 at 07:51 UTC
    Hi focus310,

    You may want to take a look at a similar question Web-based PDF export. Super Search is your friend. There are various PDF modules available providing creation and templating solutions.

    Hope this helps

    Martin
Re: Create PDF from Perl
by grantm (Parson) on Apr 24, 2007 at 06:52 UTC
    I have had a great deal of success with the PDF-Reuse module. To use it, you would first export the Word documents to PDF files (there are free tools to do that). Then you use PDF::Reuse to load a PDF as a template and overlay text from the database. You select a font, and a colour and then position some text at specific XY coordinates that coincide with the boxes on the form.