This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function GetMultiCellHeight($w, $h, $txt, $border=null, $align='J') { | |
// Calculate MultiCell with automatic or explicit line breaks height | |
// $border is un-used, but I kept it in the parameters to keep the call | |
// to this function consistent with MultiCell() | |
$cw = &$this->CurrentFont['cw']; | |
if($w==0) | |
$w = $this->w-$this->rMargin-$this->x; | |
$wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; | |
$s = str_replace("\r",'',$txt); | |
$nb = strlen($s); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$text = "This is an an example of a MultiCell"; | |
$h = 14; $w = 28; // Height and width for cells | |
$spaceleft = $pdf->h - $pdf->GetY() - $pdf->bMargin // Calculates the space available on the current page | |
$multiCellHeight = $pdf->GetMultiCellHeight($w, $h, $text); // Calculates what the height of your MultiCell would be | |
if ($multiCellHeight > $spaceleft) { | |
$pdf->AddPage() // Adds a page if there is not enough space available for the MultiCell | |
} |