mPDF Manual – What Else Can I Do

Saving to a database

If you want to save the created file to a database (not necessarily recommended), one user has suggested the following:


$s = $mpdf->Output('','S');

$data = bin2hex($s);

$query = "INSERT INTO aaa SET content=0x".$data." ";

When you want to output the PDf file:


// Get the database content into the variable $data

$pdf = pack("H*" , $data ); 

header('Content-Type: application/pdf');

header('Content-Length: '.strlen($pdf));

header('Content-disposition: inline; filename="'.$name.'"');

header('Cache-Control: public, must-revalidate, max-age=0'); 

header('Pragma: public');

header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); 

header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');

echo $pdf;