From a7da6089823eb4e780bafab7409a1e8101e473cf Mon Sep 17 00:00:00 2001 From: james Date: Tue, 4 Mar 2008 21:57:49 +0000 Subject: [PATCH] Switch heading() to use addText() so it implements line-wrapping for super-long headings --- lpdf.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lpdf.php b/lpdf.php index bcea2b3..eaac41c 100644 --- a/lpdf.php +++ b/lpdf.php @@ -165,12 +165,12 @@ class lpdf } - function addText($text,$align="left", $xloc=0) + function addText($text,$align="left", $xloc=0, $displayfont="normalfont") { $fontsize=pdf_get_value($this->pdf,"fontsize",0); $lineheight=ceil($fontsize*1.3); //the line height should be 1.2 * fontsize (approx) - $stringwidth=pdf_stringwidth($this->pdf,$text,$this->normalfont,$fontsize); + $stringwidth=pdf_stringwidth($this->pdf,$text,$this->$displayfont,$fontsize); $textstr=$text; @@ -558,9 +558,7 @@ class lpdf $this->newPage(); pdf_setfont($this->pdf,$this->headerfont,12); - //move down the full line height - $this->yloc-=12/72; - pdf_show_xy($this->pdf,$text,$this->loc($this->page_margin),$this->loc($this->yloc)); + $this->addText($text,"left",0,"headerfont"); 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;