How to align image in table td, tcpdf
13,696
Solution 1
Adding the following CSS to your td
should work:
td {
vertical-align: middle;
text-align:center;
}
See a fiddle of it working.
Solution 2
Did you check image alignment?
<img align=center src="abc.jpg" width="20" height="20" >
Author by
Lucky Ali
Updated on June 18, 2022Comments
-
Lucky Ali almost 2 years
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.html is clear from the image i have shared. html is just simple as
<table> <tr> <td> </td> <td>Picture</td> ....... </tr> <tr> <td>1</td> <td style="text-align:center"><img src="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.
-
Peter almost 9 yearsUnfortunatly, work on HTML, but don't work when you throw the HTML to TCPDF. :(
-
Denis Chenu over 8 yearstcpdf, not css. tcpdf don't have margin in writeHtml
-
Denis Chenu over 8 yearstext-align:center is OK. vertical-align: middle; : Not OK. Must try with setHtmlVSpace and a p/div/h5 or h6 inside the cell ....