tags:

views:

313

answers:

2

hello, anyone can plz help me? i wanted to create pdf file using php and have done it. now i want to create pdf file that get data from mysql table.. i've searched for the sample code for long time but didnt find even a single code related to my query.. thanx in advance

+2  A: 

If you can create a pdf file using php, i would assume you have the skills necessary to retrieve data from a database, then just pass values to whatever you are using to create the pdf file, be it a function, an object method or a procedural section.

I think posting some code will help.

Babiker
php code:$mypdf = PDF_new();PDF_open_file($mypdf, "");PDF_begin_page($mypdf, 595, 842);$myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);PDF_setfont($mypdf, $myfont, 10);PDF_show_xy($mypdf, "Sample PDF, constructed by PHP in real-time.", 50, 750);PDF_show_xy($mypdf, "Made with the PDF libraries for PHP.", 50, 730);PDF_end_page($mypdf);PDF_close($mypdf);$mybuf = PDF_get_buffer($mypdf);$mylen = strlen($mybuf);header("Content-type: application/pdf");header("Content-Length: $mylen");print $mybuf;PDF_delete($mypdf);
Sahar
thanx 4 reply..here's the code that successfully create pdf file using php n i know how to work with php and mysql,i know how to create table etc in mysql and delete,update etc using php but i've nt found a single code that create pdf file using php importing data from mysql tables... ur answer'll b appreciated
Sahar
A: 

thanx 4 reply..here's the code that successfully create pdf file using php n i know how to work with php and mysql,i know how to create table etc in mysql and delete,update etc using php but i've nt found a single code that create pdf file using php importing data from mysql tables... ur answer'll b appreciated

php code:

$mypdf = PDF_new();

PDF_open_file($mypdf, "");

PDF_begin_page($mypdf, 595, 842);

$myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);

PDF_setfont($mypdf, $myfont, 10);

PDF_show_xy($mypdf, "Sample PDF, constructed by PHP in real-time.", 50, 750);

PDF_show_xy($mypdf, "Made with the PDF libraries for PHP.", 50, 730);

PDF_end_page($mypdf);

PDF_close($mypdf);

$mybuf = PDF_get_buffer($mypdf);

$mylen = strlen($mybuf);

header("Content-type: application/pdf");

header("Content-Length: $mylen");

print $mybuf;

PDF_delete($mypdf);

Sahar