Categories
alignment html image php tcpdf

How to align image in table td, tcpdf

I use tcpdf to generate pdf files.

And there’s a problem in aligning image in table td.

I am uising $pdf->writeHTML($html, true, false, true, false, ''); in tcpdf.

enter image description here

html is clear from the image i have shared.
html is just simple as

<table>
<tr>
<td>&nbsp</td>
<td>Picture</td>
.......
</tr>
<tr>
<td>1</td>
<td style="text-align:center"><img src="https://www.faqcode4u.com/faq/414129/abc.jpg" width="20" height="20" ></td>
.......
</tr>
</table>

Note: align=”center”, valign=”middle” , css margin and padding … nothing seems to work I tried on

text-align:center push into center but not vertically.

Adding the following CSS to your td should work:

td {
vertical-align: middle;
text-align:center;
}

See a fiddle of it working.