I have a project to save pages created dynamically with php and store them on the server.
I am planning to store a replica of the page as a pdf; with all their images, t
I had this same issue recently and found fpdf to be too complicated when your HTML contains formatted text and images. I had my server admin install Webkit HTML to PDF. It works great.
This package will parse the stylesheet, images, tables, and any other element in the HTML document as if you had opened a web browser using webkit and saved the web page as a PDF.
http://code.google.com/p/wkhtmltopdf/
/**
* Use wkhtmltopdf to convert an HTML file to PDF
*
* @param string URL to web page
* @param string Path to PDF file to be written
*
* @return boolean True if the command succeeded; false otherwise
*/
function htmlToPdf($source, $dest)
{
// Build command
$command = "/usr/bin/wkhtmltopdf $source $dest 2>&1";
exec($command, $output);
$s = sizeof($output) - 1;
if (substr($output[$s], -4, 4) == 'Done')
{
return true;
}
return false;
}