Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MPDF div not working inside table

I am working on mpdf and it is a good library to convert html page to pdf, but when I put block element e.g <div><p> inside table cell it doesn't behave like a block element, it behaves like inline element.

code:

 <td><div>Block Element</div></td>

or

 <td><p>Block Element</p></td>

Is there a way to make it block element?

Or should I use other library?

Thanks in advance.

like image 838
angel enanod Avatar asked Apr 06 '16 01:04

angel enanod


1 Answers

Looking for solutions to the same problem I just realized that according to the documentation, it's not a bug, it's a feature limitation:

Block-level tags (DIV, P etc) are ignored inside tables, including any CSS styles - inline CSS or stylesheet classes, id etc. To set text characteristics within a table/cell, either define the CSS for the table/cell, or use in-line tags e.g. <SPAN style=”…“>

Seems like there's currently no way around it. In my case I had to use &nbsp;s to indent (fake-center) a <h4> headline.

See https://mpdf.github.io/tables/tables.html

like image 156
Christian Avatar answered Sep 28 '22 04:09

Christian