View Full Version : MySQL data to PDF using PHP

05-20-2008, 01:00 AM
Good Evening All,

I have a task that involves a user inputting data into MySQL through a simple HTML form, but then after saving the data, the user must be able to click a button and for that record that they just saved, be able to display those values on a pdf that I will scan in into the computer...

Any ideas on how to get the MySQL data onto a PDF, simply by inserting data?


05-20-2008, 10:19 AM
Here are the absolute basics for creating a PDF file. I would recommend reading the PHP.net pdf manual (http://uk.php.net/manual/en/ref.pdf.php) pages for more information.

$pdf = PDF_new(); // Start working with a pdf
PDF_open_file($pdf, '/path/to/your.pdf'); // Creates a new pdf at the specified location
$font = PDF_findfont($pdf, 'Times-Roman', 'host');

PDF_begin_page($pdf, 595, 842); // Starts a new page of given x y dimensions
PDF_show_xy($pdf, 'Text to be written', 50, 750); // 50, 750 is cursor position

PDF_close($pdf); // Closes the $pdf resource
PDF_delete($pdf); // Does not delete the pdf just the memory resource

Len Whistler
05-20-2008, 08:58 PM
I recommend http://www.fpdf.org Take a look at the tutorials, scripts, manual, and forum. It's much easier than the php manual.