The Prince PHP wrapper
includes methods for converting files or strings into PDF. However, you probably have some PHP pages generating invoices for the browser, and you want to return a PDF instead. We don't yet offer a one-line call to do this, but it should be possible to do it using the ob_start
functions, like this:
// your code to generate invoice HTML goes here
$out = ob_get_clean();
$prince = new Prince('/usr/bin/prince');
The ob_start function begins output buffering, so PHP will buffer up the HTML internally instead of returning it to the browser, then ob_get_clean wipes the buffer and returns it as a string so that the generated HTML can be converted to PDF by Prince and the PDF returned to the browser with an appropriate content-type so that the browser knows what to do with it.
How is that?