Search code examples
phppdfpdf-generationezpdf

How can you determine remaining space on page with ezpdf?


I'm using rospdf/php-pdf - the middle of the pdf is a table of variable length. I want to make sure there is enough space to print the final section on the page, if not I want to add a new page. I'd like to do something like this but $position has no value. How can I find out the current position?

$position = $pdf->ezSetDy;

if($position < 100){
    $pdf->ezNewPage();
}

Solution

  • You can try the following:

    $yPos = $pdf->y - $pdf->ez['bottomMargin'];
    if ($yPos < 100) {
        $pdf->ezNewPage();
    }