diff --git a/lpdf.php b/lpdf.php index aacba19..7557730 100644 --- a/lpdf.php +++ b/lpdf.php @@ -178,6 +178,14 @@ class lpdf function heading($text) { + //if we are close to the bottom, lets just move the whole heading to the next page. + //no point putting the heading here then the new text on the next page. + + //12/72 is height of the heading + //4/72 is the space under the heading + if($this->yloc< (1.1 + 12/72 + 4/72) ) + $this->newPage(); + pdf_setfont($this->pdf,$this->headerfont,12); //move down the full line height $this->yloc-=12/72; @@ -185,6 +193,7 @@ class lpdf pdf_setfont($this->pdf,$this->normalfont,$this->currentFontSize); //now leave some space under the heading (4 is 1/3 of 12, so 1/3 of the line height we leave) $this->yloc-=4/72; + } @@ -250,7 +259,7 @@ class lpdf pdf_lineto($this->pdf,$this->loc($xpos_of_table+$table_width),$this->loc($this->yloc)); pdf_stroke($this->pdf); - if($this->yloc<1) + if($this->yloc<1.1) { //now draw all the vertical lines $xpos=$xpos_of_table;