?
Solved

Interactive HTML form with PDF output and database saving feature

Posted on 2009-05-11
2
Medium Priority
?
548 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
Bobaran98 earned 2000 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

762 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