Created
October 21, 2014 16:05
-
-
Save johnballantyne/2989898e2196686388f6 to your computer and use it in GitHub Desktop.
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 | |
} | |
$pdf->MultiCell($w, $h, $text); //Adds the MultiCell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you want MultiCells to be "self aware" and automatically create a new page if they're too big, you could modify the core
MultiCell()
function.A quick and dirty way to do it would be to call my
GetMultiCellHeight()
method from withinMultiCell()
and add the above logic. A better way might be to merge the two methods so that it's more efficient as I'm sure there would be some redundancy.Modifying core methods can be risky, so it'd be wise to copy
MultiCell()
and call the new one something likeSmartMultiCell()