Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

add margin-top and bottom on a div in a table with mpdf

Tags:

css

mpdf

I am facing a problem when i try to add the margin-top or margin-bottom on div elements inside a table for generating pdf with mpdf.

I have something like this:

<table>
<tr>
    <td>
        <div style="margin-top: 20px;">Element1</div>
        <div style="margin-top: 20px;">Element2</div>
        ...
    </td>

    <td>
        <div style="margin-top: 20px;">Element4</div>
        <div style="margin-top: 20px;">Element5</div>
        ...
    </td>
</tr>
</table>

The margin styles are not converted.

I think it could be because there are too many nested elements and mpdf doesnt support them in some cases. Have someone already achieved such a problem?

like image 488
Francis Ngueukam Avatar asked Oct 15 '25 04:10

Francis Ngueukam


1 Answers

Finally i have found another way to achieve this without using margin style. I have just used the simple tag <br> to create space between my elements.

<table>
<tr>
<td>
    <br><br>
    <div>Element1</div>
    <br><br>
    <div>Element2</div>
    ...
</td>

<td>
    <br><br>
    <div>Element4</div>
    <br><br>
    <div>Element5</div>
    ...
</td>
</tr>
</table>

Mpdf has some limitations in CSS. Sometimes to achieve some tasks we have to think another way. Thanks.

like image 61
Francis Ngueukam Avatar answered Oct 16 '25 19:10

Francis Ngueukam