/ Published in: PHP
Wkhtmltopdf (http://code.google.com/p/wkhtmltopdf/) is a open source html to pdf converter. This snippet shows how to use it in a php script.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// content var $content = 'content'; // generate pdf from contents $file_name = 'example.pdf'; ); // wkhtmltopdf must be in PATH var! // $pipes now looks like this: // 0 => writeable handle connected to child stdin // 1 => readable handle connected to child stdout // Any error output will be appended to /tmp/error-output.txt // echo stream_get_contents($pipes[1]); // fclose($pipes[1]); // It is important that you close any pipes before calling // proc_close in order to avoid a deadlock echo "command returned $return_value\n"; }