4

Using:

  • PHP 7.1
  • mPDF 6.1.0

I'm currently trying to attach CSS to my mPDF files, but i'm coming across the problem that the CSS doesn't apply but it just adds new pages? It is quite confusing.

I'm first getting all the CSS content which i want to append, then I require in the mpdf classes. I'm adding the the style to sub 1 because that's where CSS is supposed to be appended, afterwards I add the HTML to the PDF.

        $style = '';
        $style .=  file_get_contents(__DIR__ . '/assets/vendor/bootstrap/css/bootstrap.min.css');
        $style .= file_get_contents(__DIR__ . '/assets/css/style.violet.css');
        $style .= file_get_contents(__DIR__ . '/assets/vendor/datatables/datatables.min.css');
        $style .= file_get_contents(__DIR__ . '/assets/vendor/datatables/DataTables-1.10.16/css/dataTables.bootstrap4.css');

        require_once __DIR__ . '/private/vendor/mpdf/mpdf.php';
        $mpdf = new mPDF();



        $mpdf->WriteHTML($style, 1);

        $mpdf->WriteHTML($pdfText, 2);

        $mpdf->Output();

What i get is the following:

enter image description here

18 Empty pages? Quite strange. If i remove the style part, or just echo it all out, i will get the normal data as intended. Why is this caused? The other people had their solutions provided this way, mine however did not get solved by the other questions like the ones below:

Thank you in advance!

pandaJuan
  • 91
  • 1
  • 11

0 Answers0