[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Interactive HTML form with PDF output and database saving feature

Posted on 2009-05-11
2
Medium Priority
?
551 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article discusses how to implement server side field validation and display customized error messages to the client.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

656 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