Link to home
Start Free TrialLog in
Avatar of sieve
sieve

asked on

html -> pdf without fdf?

Hello,
  Is there any way to take data from an HTML (using PHP) form submitted by a user, send the data to a MySQL database, AND populate a PDF form (produced with Acrobat 6) WITHOUT using the FDF toolkit from Adobe or other pdf libs that have to be installed on the server?
  I'm developing a web application under a huge time-crunch and my hosting provider doesn't have the FDF toolkit installed, and I don't think they'll do it for me.  I can't take the time to find another provider right now, and I've seen some ways of populating PDFs with form data that don't require installing/compiling any dlls or modules, etc.
  Anyone have any experience with this?  I already have the form, and can handle the SQL coding, but I need a way to populate the PDF apart from installing anything on the server, if possible.

Thanks!
Avatar of madwax
madwax

I have used FPDF (PHP-based) with great success and it doesn't need anything to be installed on the server:

http://www.fpdf.org/

You can ask me if you don't get it but I would recommend their examples since they are very good. The only drawback is that ther functions are'nt as good as the other pdf-genrators... but it's free and you dont need to install anything just implement their class in your own (by e.g. an extension)
Avatar of sieve

ASKER

Thanks for the link.

Am I understanding it correctly, basically, rather than actually populating fields, I specify coords for where I want the text to appear?  Not a bad way to do it, but is there a way to input into the actual fields that I've created in the PDF form?  Along with that, I don't see a command for starting with the form I've already created -- how would I make that my starting point.

Sorry for being simplistic -- as I mentioned, I'm under a huge time constraint and I don't want to spend my time re-inventing the wheel!
I don't really understand what you mean with a PDF form.

What you do with the fpdf is that you take your string (or other type) sent from your form and put it into a fpdf-cell which you specify on the pdf-page-to-be. The fpdf generates the code for the pdf and you can open it in your browser.

//jan
If I understood your question right, the simplest solution for you should be:

<?php
define('FPDF_FONTPATH','font/');
require('fpdf.php');

$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output();
?>

where you change the:
$pdf->Cell(40,10,'Hello World!');
to
$pdf->Cell(40,10,$_POST['nameOfTheTextFieldInYourAlreadyCreatedForm']);

where you send your form-data with post and the name of the field in the form is "nameOfTheTextFieldInYourAlreadyCreatedForm"...

Hope this helps,
//jan
Avatar of sieve

ASKER

Thanks, I'm starting to get it.

What I mean by PDF form, is I've created a PDF in Acrobat Professional and added fields to the form, (called PDFForm for this example.)  Basically, I need to collect user information via an html form (called HTMLForm for this example), and populate the fields of PDFForm with that information, plus some added info based on other criteria.  I can get the data from the user, and derive the "added info", but I'm not sure if fpdf can put the two together.

I just found some info that talks about php having pdf capabilities via php_pdf, I know that's a server-side module, but I think most php capable servers already have it installed, and I'm checking to see if mine does.

Any experience with php_pdf?  Will this work?

Here's the link:http://www.phpfreaks.com/phpmanual/page/ref.pdf.html
ASKER CERTIFIED SOLUTION
Avatar of madwax
madwax

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sieve

ASKER


Sorry for letting this sit so long, thanks madwax for your help.  Not the exact answer, but it helped rule some things out.

Ultimately, I ended up using Acrobat Pro to add the fields to the PDF form & tracking down the syntax of the FDF file.  I dynamically adding the user's data and named fields from the PDF to the FDF file and using a PHP script to open the FDF in the user's browser.  Embedded in the FDF is the name of the PDF to open, so Adobe recognizes the FDF and automatically populates the form.  All said, the PDF portion of the script was only 8-10 lines!