La libreria mPDF ci permette di usare un nostro foglio di stile CSS per formattare il layout del PDF generato a partire da una stringa HTML.
La soluzione รจ molto semplice:
require_once( 'mpdf/mpdf.php' );
$pdf = new mPDF();
$html = 'stringa HTML';
$stylesheet = file_get_contents( 'style.css' ); // URL o percorso
$pdf->writeHTML( $stylesheet, 1 );
$pdf->writeHTML( $html );
$pdf->Output();