For the generation of the PDF from any HTML page the Qt's webkit can be used. The project home:
http://code.google.com/p/wkhtmltopdf/
It works like a browser, which send the page on virtual pdf printer. The result is very close to the source page.
svn checkout http://wkhtmltopdf.googlecode.com/svn/trunk/ wkhtmltopdf cd wkhtmltopdf cmake -D CMAKE_INSTALL_PREFIX=/usr . make make install
To convert a remote HTML file to PDF:
wkhtmltopdf http://www.google.com google.pdf
To convert a local HTML file to PDF:
wkhtmltopdf my.html my.pdf
You can also convert to PS files if you like:
wkhtmltopdf my.html my.ps
/usr/bin/Xvfb :0 -screen 0 1024x768x24 -ac
DISPLAY=":0.0" wkhtmltopdf http://www.arscommunity.com community.pdf
<?php function func_generate_pdf($in_file, $out_file) { $exec = sprintf('DISPLAY="%s" %s %s %s', ':0.0', 'wkhtmltopdf', $in_file, $out_file); exec($exec, $result); } ?>