Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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="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.

like image 648
Lucky Ali Avatar asked Jul 16 '13 06:07

Lucky Ali


2 Answers

Adding the following CSS to your td should work:

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

See a fiddle of it working.

like image 74
naththedeveloper Avatar answered Oct 31 '22 14:10

naththedeveloper


Did you check image alignment?

<img align=center src="abc.jpg" width="20" height="20" >
like image 28
Reza Saberi Avatar answered Oct 31 '22 15:10

Reza Saberi