Generating a PDF invoice directly from my php and mysql website

Hi Everybody,

I've got a webshop where customers can buy certain items.
The items they order are stored as an order in a MySQL database.

I would like to generate an PDF invoice directly from the site and email it.

(hit button --> get data from mysql --> generate pdf --> email to customer)

The site is hosted by an external party.

I hope somebody's got an idea.

Thanx in advance

G.
LVL 1
GeerdAsked:
Who is Participating?
 
michel-angeloConnect With a Mentor Commented:
Well, this is one of these things that you download, unzip and upload .. and
I didn't take the time to read the documentation (VERY well done).
I was just trying to share the fact that I came accross the same problem, when I was starting scripting in PHP and this was a life saver at the time.
pdf-php remains in my toolbox since then ..
Here is an example:

require "class.ezpdf.php"; // PHP-PDF Class

$doc =& new Cezpdf('letter'); // choice of format
$doc->ezImage("logo.jpg","","","none"); // insert score logo
$doc->ezText("<b>Application for: ".$question1.".".$question3.".".$question2."</b>",9,array("justification"=>"center")); // name of the applicant
$doc->ezNewPage(); // Next Page
// Creates files ouput to avoid Internet Explorer Bug
// The page called has an .php extension and the stream output
// has a .pdf extension. IE does not take the file back for display.
$pdfcode = $doc->ezOutput();
$dir = "pdf_files";

if (!file_exists($dir)) {
mkdir ($dir,0777);
}
$fname = './'.$dir.'/'.$question1.'.pdf';
$fp = fopen($fname,'w');
fwrite($fp,$pdfcode);
fclose($fp);
$delay = '0';

M.
0
 
dr_dedoConnect With a Mentor Commented:
0
 
michel-angeloCommented:
http://sourceforge.net/projects/pdf-php
Easy to use, well documented.
HINT: do not forget to install the font directory when you use it, it got me for an hour :)
0
 
dr_dedoCommented:
>> it got me for an hour :)
easy indeed :P
0
 
dr_dedoCommented:
niceeeee

now to the second part, the questioner want to send that PDF via email

you can use almighty phpMailer tool to do that. get it here
http://phpmailer.sourceforge.net/

when u save that PDF to a file, add that file as an attachment to the email and when mail is sent, delete the generated PDF file unlink(file_path)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.