Solved

Interactive HTML form with PDF output and database saving feature

Posted on 2009-05-11
2
540 Views
Last Modified: 2013-12-12
I am trying to streamline a process at my office that works as follows:

1.  Someone gathers all of the data from client, and fills out a certain form (really long form).
2.  Based on this form, the project managers fill out a second form - then they convert this form to PDF and send it over to our hosting company for setup.
3.  Then with the form that has been returned, they update a third spreadsheet which serves as a data repository.

As you can tell, this is a tedious process, and I want to revamp it.  I have a simple solution:

1. The client fills out Form A on a certain website (i can run it on a linux or a windows box).

2.  Based on the response from the client, generate a pdf that can be emailed directly to the hosting company.

3.  Once the hosting company is done setting up the connection, the project manager can go on the website and complete the form that was started in step 1.

4.  Once done, it will update either the excel sheet directly, or store everything in a database (either one is fine).

In other words, need a form that saves data to a database and generates a PDF.  And then has the ability to update the form and the backend with new information.

I can really do this myself and spend 10 hours developing an app.  That would be terrific, but is there any tool that I can use? If so, that would greatly reduce the time needed for me to develop this procedure...  
0
Comment
Question by:shahyan
2 Comments
 
LVL 8

Accepted Solution

by:
Bobaran98 earned 500 total points
ID: 24361423
Great question!  I think what you're looking for can be done with PHP, MySQL, and Adobe Acrobat Professional (not sure what version minimum, but I think 8 is fine).

Okay, so your process:
  1. You use Adobe Acrobat to design the PDF template(s) for the forms to be filled out (I'm sure you're familiar with the PDFs that have editable fields, right?).
  2. You make an HTML form version of that PDF template.
  3. You create your MySQL table to store data from form submissions.
  4. You make a PHP file to accept form submissions, validate, and write data to the MySQL table.
  5. You make a PDF generator in PHP which grabs entries from the MySQL database and pushes the data into the PDF.
That's the simple version.  The step-by-step version is here:  http://koivi.com/fill-pdf-form-fields/tutorial.php

Note that this tutorial also explains how you can skip my step 2 (the HTML form) and have users provide data directly into the PDF template, then submit it to the database that way.  There are pros and cons to this, however.

The really cool part of the tutorial, of course, is where it shows you how to generate the PDF file from the MySQL data.  But you have to have that PDF template for it to work.  The way their code works, the file is saved to a directory on your website when all is done.  I would suggest instead that you change the code at the very end so that rather than saving the file on your site...

// write the file out
if($fp=fopen($fdf_dir.'/'.$fdf_file,'w')) {
fwrite($fp,$fdf_data,strlen($fdf_data));
echo $fdf_file,' written successfully.';
} else {
die('Unable to create file: '.$fdf_dir.'/'.$fdf_file);
}
fclose($fp);

... you instead echo the file data to the browser; because the data includes a mime type specifying the data as PDF, it will probably force the browser into an open-or-save-file dialog:

echo $fdf_data;
exit;

In fact, to build on step 5, I would call my PHP downloader script pdf_generator.php, and it would take one parameter on the querystring-- a unique form submission identifier so that you can pull all submission fields from the database.  That query would also give you the name of your PDF template file, which you could open, fill in, and echo directly to the browser to force download.  As a result, you could create links to pdf_generator.php?id=X the same as if you were creating links to JoeJohnsonsFormSubmissionOnMay252009.pdf.

Pretty cool, huh?  What do you think?  I'm not sure of the cost of Adobe Acrobat Professional, but this definitely isn't functionality that comes with the free one.  I can't imagine it's much though.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now