Solved

Interactive HTML form with PDF output and database saving feature

Posted on 2009-05-11
2
542 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
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…

749 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