Can I convert PHP output to PDF and e-mail it?

zelmo_t

New member
If you google php pdf you'll get a number of hits suggesting how you can create PDFs in PHP. The PDF library recommended by the book I read three years ago is FPDF, but there may be better options now.
 
My website has a long form that I'd like to export to PDF and then e-mail to myself.

Currently, my form collects data and submits it to a PHP file, which e-mails me the results. Instead of getting an HTML e-mail which has printing limitations (inconsistent CSS, background colors don't print automatically, etc.) I'd like to get a consistent and attractive PDF attached to an e-mail. It would be nice if I could include some graphics, but I'm more concerned with readability (specifically, alternating colors in the rows.)

Is there an easy way to do this automatically and for free?
 
Yes you can, but I think you're solving the wrong problem. Instead of PDF, I think you should either 1) convert the form data to a CSV file format (comma separated value) and open it in Excel[1], or 2) make correct print CSS (the best practices for making print CSS differs from regular CSS, e.g. in print CSS using pt measurement is preferred instead of px)

[1] then possibly use a script or Excel macro to convert the CSV to a more attractive format. HTML and PDF are useless for data processing, it is only useful for preparing document for printing.
 
Back
Top