Q:

How to get HTML element height in PHP

I have a PHP code which produces a HTML table like:
I want to cut this table somewhere when the PDF page length I'm producing is reached.

<table border="1">
  <tr>
    <td>1</td>
    <td>some text</td>
  </tr>
  <tr>
    <td>2</td>
    <td>column two</td>
  </tr>
  <tr>
    <td>3</td>
    <td>here have more text<br>set more text<br>get this tr tag Height</td>
  </tr>
  <tr>
    <td>4</td>
    <td>this tr's height is not same<br>like column three</td>
  </tr>
  <tr>
    <td>5</td>
    <td>5</td>
  </tr>
</table>

I want to get height for each tr tags.
How to do this question with javascript?
In addition, if this table is writen using PHP...
How to solve this question?

A:

By counting the character amount for each td of a row and a calculation to estimate line amount.
You can have the character count.
Using PHP explode() on the td content by spaces, you'll have the word count.
An estimate can be used... About word average char length to obtain the line count.
I attempted a calcuation about it ($acpw below)... But you could use a constant instead.
So this, multiplied by the known CSS line height, you know this td height.
(($acpw*$wc)/$tw)*&lh = $tdh

This would be a way to approach the PHP task, since you create a PDF on PHP side.  (seen in comments)
This is just a starter... Since you provided no code.
;)

<?php

// Declare a result array 
$row_height=[];

// Average char per word === Estimated constant.
$acpw = 8;

// Td width, should be known
$tw = 140; // in px.

// Line-height, should be known
&lh = 16; // in px.

// while parsing each th in a row
$i=0;
while($td_content=$something){
  $ca = strlen($td_content['string'])
  // word count
  $wc = $td_content['string'].explode(" ");

  // Average Char count per word calculation attemp, can be commented to use the constant
  $acpw = $ca/$wc;

  // The formula!
  $tdh = (($acpw  * $wc)/$tw)*$lh;

  // Save in array
  $row_height[$i] = $tdh;
  $i++;
}

// Now you know the row height of this row...
$max = max($row_height);

// You have to determine if there is enought space for the next loop.
if($space_left>$max+$footer){
  $space_left = $page_length-$max;

// Else split the table!
}else{
  echo"</table><table>";
}

// There is a couple strings to attach in this code...
?>

And this is not tested.

