Answer the question
In order to leave comments, you need to log in
Why doesn't a file from mPDF open in Chrome?
Good afternoon.
I generate a pdf file via mPDF (v6.0):
$file = 'file.pdf';
header("Cache-Control: maxage=1");
header("Pragma: public");
header("Content-type: application/octet-stream");
header("Content-Description: PHP Generated Data");
header("Content-Transfer-Encoding: binary");
header('Accept-Ranges: bytes');
header("Content-Disposition:inline;filename='$file");
include 'vendor/autoload.php';
ob_start();
require 'pdf-template.php';
$html = utf8_encode(ob_get_contents());
$css = file_get_contents('css/all.css') . PHP_EOL . file_get_contents('css/pdf.css');
$mpdf = new mPDF('utf-8', 'A4', '8', '', 10, 10, 7, 7, 10, 10);
$mpdf->list_indent_first_level = 0;
$mpdf->WriteHTML($css, 1);
$mpdf->WriteHTML($html);
$mpdf->Output($file, 'D');
exit;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question