tecnickcom / TCPDF

Official clone of PHP library to generate PDF documents and barcodes
https://tcpdf.org
Other
4.22k stars 1.52k forks source link

Table indent problem #416

Open it-can opened 3 years ago

it-can commented 3 years ago

taken from: https://stackoverflow.com/questions/42129383/tcpdf-indentation-issue-after-line-break

if you have this type of HTML...

<table border="0" cellspacing="0" cellpadding="4">
    <tr>
        <td>
            My Company Equipement<br>
            France
        </td>
        <td bgcolor="green" cellpadding="0">
            <b>Addresse de livraison</b>
            <br>
            <br>
            Team Adamon FIGHTING ACADEMY
            38 chemin de Tomasenea<br>
            Zone de Berrouetta<br>
            26000 URRUGNE<br>
            France
        </td>
        <td align="left" style="margin:0;padding:0;text-indent: 0;">
            <b>Addresse de livraison</b>
            <br>
            <br>
            Team Adamon FIGHTING ACADEMY
            38 chemin de Tomasenea<br>
            Zone de Berrouetta<br>
            26000 URRUGNE<br>
            France
        </td>
    </tr>
</table>
<p>
    Team Adamon FIGHTING ACADEMY
    Team Adamon FIGHTING ACADEMY
    Team Adamon FIGHTING ACADEMY
    Team Adamon FIGHTING ACADEMY
    <br>
    Team Adamon FIGHTING ACADEMY<br>
    Team Adamon FIGHTING ACADEMY<br>
</p>

alt text

It will indent the lines... does anyone have a fix for this?

williamdes commented 3 years ago

Bonjour,

Maybe use some &nbsp; ?

it-can commented 3 years ago

No i am expecting that the indentation does not happen, so it should should all be correct aligned.

williamdes commented 3 years ago

Maybe https://developer.mozilla.org/docs/Web/CSS/white-space could help

it-can commented 3 years ago

I “fix” the html before passing it to writeHtml()

with this code https://github.com/it-can/laravel-helpers/blob/f77f8e88f9da65adbab515264ebb154a694cfe3f/src/helpers.php#L732