mPDF Manual – What Else Can I Do

Capture HTML output

One way of outputting a webpage to mPDF without re-writing your scripts too much, is to buffer the output:


// Require composer autoload
require_once __DIR__ . '/vendor/autoload.php';

$mpdf = new mPDF();

// Buffer the following html with PHP so we can store it to a variable later


// This is where your script would normally output the HTML using echo or print

// Now collect the output buffer into a variable

$html = ob_get_contents();


// send the captured HTML from the output buffer to the mPDF class for processing