MPDF Do not insert my stylesheet css

0

Good morning, I am working with mpdf to generate pdf files from a document html I have the following structure:

<?php
 require('MPDF57/mpdf.php');
$html='';

$mpdf=new mPDF('c','A4');
$mpdf->writeHTML($html);
$mpdf->Output('prueb.pdf','I');
?>

Within the variable $html add all my html I want to be passed to pdf, I tried adding everything from the html , from head and nothing, but the styles are correctly designated since the same body of the document I have it in another file for tests and it looks perfectly. Does anyone know what it could be? the php , html , css I have them in different files.

    
asked by matteo 20.12.2016 в 19:10
source

1 answer

2

The css you add from instruction in php , not from the html :

<?php
$html = $divPrint;

include('MPDF57/mpdf.php'); // including mpdf.php
$mpdf=new mPDF('c','A4');
$stylesheet = file_get_contents('pdf.css'); // la ruta a tu css
$mpdf->WriteHTML($stylesheet,1);
$mpdf->WriteHTML($html,2);
$mpdf->Output();
exit;
?>

First goes the html in $html , then the file mpdf.php .

    
answered by 20.12.2016 / 20:09
source