Forum Moderators: coopster

Message Too Old, No Replies

creating PDF using php

         

me_great

6:25 pm on Mar 24, 2008 (gmt 0)

10+ Year Member



Hi,

I want to create pdf file using php.

But, Can I convert a whole webpage into a pdf file?

Thanks.

milocold

7:24 pm on Mar 24, 2008 (gmt 0)

10+ Year Member



Yup!

Try googling class.pdf.php and class.Cezpdf.php

I used them both and found it much easier than trying to install php's pdf module. The class makes it really easy to add images and tables as well to better format your stuff.

==> Sample:

// Make a new pdf object
$obj_Pdf =& new Cezpdf();

// Set justification vars
$aStr_CenterJustification = array('justification' => 'center');

$obj_Pdf->selectFont('fonts/Helvetica.afm'); // Set font
$obj_Pdf->setLineStyle(1); // Set Line Style
$obj_Pdf->setColor(0,0,0);

// Set the Y-cordPage where the data is to be placed
$obj_Pdf->ezSetY(760);

// Page Content
$obj_Pdf->ezText("<b>Hello World</b>", 10, $aStr_CenterJustification);

// Collect output and write it to newly created pdf file.
$str_PdfCode = $obj_Pdf->ezOutput();

// Write it to a file
$fp=fopen("test_file.pdf",'w');
fwrite($fp,$str_PdfCode);
fclose($fp);

Hope that helps ya a bit!

M.Cold

me_great

8:37 pm on Mar 24, 2008 (gmt 0)

10+ Year Member



Thanks for the reply...

But I have a webpage already created in php , and I want to convert that to a pdf using php...

Can you please help in that...

henry0

9:48 pm on Mar 24, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



me_great
it's pure PHP
and the script "genre" Is called OOP

Which stands for Object Oriented Programming
it uses classes, even if you are not a "php pro"
most of those classes are easy to use
G for then and other linked to creating a PDF with php