0

I want to know the height of specific HTML content so I can fix the position of an HTML table.

$htmlDatatable = "<table>
<thead>
<tr>
<td width='100'>Sr. No</td>
<td width='200'>Name</td>
<td width='100'>Addr</td>
</tr>
</thead>
<tbody>
<tr><td>1</td><td>Abc</td><td>Mumbai</td></tr>
<tr><td>2</td><td>Pqr</td><td>Mumbai</td></tr>
<tr><td>3</td><td>Lmn</td><td>Mumbai</td></tr>
<tr><td>4</td><td>Xyz</td><td>Mumbai</td></tr>
</tbody>
</table>";
$pdf->writeHTMLCell(0, 0, x,y, $htmlDatatable);

The getStringHeight() function calculates the wrong height. I want to set table bottom to top. The point (x,y) should be placed at the bottom right. How can I do that?

Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
lbm gplus
  • 55
  • 6

2 Answers2

0

Unless you specifically set a height per each row, I don't think there is such an option. Set each row height of 20/30px, calculate in php 20/30px multiplied by the number of rows you have and that's your number.

AdrianRO
  • 31
  • 8
0

Accordingly to getStringHeight TCPDF documentation, this method return the estimated needed height for print a simple text string in Multicell() method.

It won't give you the size of the Html Table, however, this page gives you a piece of code to compute the height of a block of content

yunandtidus
  • 3,847
  • 3
  • 29
  • 42