1

I am using mPDF to generate pdf files from html. Now I also want to load some external CSS files and found in a couple of questions/answers on here that you are able to do that.

So I tried this:

$mpdf = new \Mpdf\Mpdf();
$stylesheet .= file_get_contents('../css/bootstrap.css');
$stylesheet .= file_get_contents('../css/custom.css');
$mpdf->WriteHTML($stylesheet, 1);
$mpdf->WriteHTML($html, 2);
$mpdf->Output($rootpad.'/uren.pdf','F');

But this gives me the following error:

[13-Nov-2019 10:56:05 UTC] PHP Notice:  Undefined variable: html in /home/dropfaci/public_html/includes/pdf.php on line 47

When I remove some code and end up with the following code, a pdf is generated just fine but without css:

$mpdf = new \Mpdf\Mpdf();
$mpdf->WriteHTML($html);
$mpdf->Output($rootpad.'/uren.pdf','F');

Why is it not working?

twan
  • 2,450
  • 10
  • 32
  • 92

0 Answers0