How to add multiple css files to mpdf

I am trying to convert my html page to pdf format using mpdf. the problem is that I cannot apply more than one css to a pdf file .. here is my php code

<?php $html =file_get_contents('mpdf/test.html'); include("../mpdf.php"); $mpdf=new mPDF(); $mpdf->SetDisplayMode('fullpage','two'); // LOAD a stylesheet 1 $stylesheet = file_get_contents('assets/css/main.css'); $mpdf->WriteHTML($stylesheet,1); // The parameter 1 tells that this is css/style only and no body/html/text // LOAD a stylesheet 2 $stylesheetextra = file_get_contents('assets/css/test.css'); $mpdf->WriteHTML($stylesheetextra ,1); // The parameter 1 tells that this is css/style only and no body/html/text $mpdf->WriteHTML($html,2); $mpdf->Output(); exit; ?> 

The output it gives does not come with test.css. main.css correctly applies to a pdf file, but test.css does not apply .please Help me? thank you in advance

+6
source share
2 answers

You can simply save the CSS content in a single variable, for example:

 $stylesheet = ''; $stylesheet .= file_get_contents('css/bootstrap.min.css'); $stylesheet .= file_get_contents('css/style.css'); $stylesheet .= file_get_contents('css/impressao_ctr.css'); 
+3
source

It might be an ugly solution, but I have come across a similar problem before. What I did, since it was not a big problem, I took all the css from the second one, which I could not add, and added it to "main.css".

+1
source

All Articles