How to get MPDF to create Bootstrap table styles

I have been trying for some time to create a pdf boot page with mpdf and not lose the table and other style. From what I read on mpdf, I support the styles I'm talking about, so I'm not sure what the problem is. A different style is applied. Just not these table classes.

The following classes are in tables: "table table-striped table-responsive small"

Bootstrap 3.3.1 and mPDF 5.7 and 6

The page is displayed in the browser, as expected, but the pdf format does not have a table style and causes readability problems.

I tried to remove @print from bootstrap.min.css, as mentioned here: https://stackoverflow.com/a/412960/2129 , but it doesn't matter.

Thanks in advance for any input you offer.

+5
source share
2 answers

I ran into this problem when I create an invoice using mpdf. it cannot apply the css specified in the .css file or in the tag. but the displayed format is correct in the browser depending on what I installed.

so I tried to give css as inline for example:

<div style="display:block;color:#000;"></div> 

And it works and solves my problem.

Secondly, this method will also help you:

 $mpdf=new mPDF(); $stylesheet = file_get_contents('stylesheet.css'); // external css $mpdf->WriteHTML($stylesheet,1); $mpdf->WriteHTML($html,2); //$html contain your html code to display in pdf. $mpdf->Output(); 
0
source

You can use the following css to layout the table.

  <style> tr:nth-child(even) { background-color: #f2f2f2; } </style> 
0
source

All Articles