- Add a bold font option to pdf generation

This commit is contained in:
dave 2007-12-10 21:28:17 +00:00
parent 5d8632b07e
commit a62a8bbbfb

View File

@ -56,6 +56,9 @@ class lpdf
var $currentFontSize=12;
var $normalfont;
var $boldfont;
function loc($inch)
{
return $inch*72;
@ -145,7 +148,18 @@ class lpdf
pdf_set_value($this->pdf,"leading",$leading);
}
function addText($text,$align="left")
function setFontBold()
{
pdf_setfont($this->pdf, $this->boldfont, $this->currentFontSize);
}
function setFontNormal()
{
pdf_setfont($this->pdf, $this->normalfont, $this->currentFontSize);
}
function addText($text,$align="left", $xloc=0)
{
$fontsize=pdf_get_value($this->pdf,"fontsize",0);
$lineheight=ceil($fontsize*1.3);
@ -154,6 +168,15 @@ class lpdf
$textstr=$text;
if($xloc == 0) {
$xloc = $this->page_margin;
$content_width = $this->content_width;
} else {
$content_width = $this->content_width - $xloc;
}
$this->yloc += $lineheight/72;
$nr=0;
$prevnr=-1;
do
@ -171,11 +194,10 @@ class lpdf
$nl=true;
}
if(!$nl)
$this->yloc-=$lineheight/72;
if($nl == false) $this->yloc-=$lineheight/72;
$nr=pdf_show_boxed($this->pdf,$textstr, $this->loc($this->page_margin),$this->loc($this->yloc),$this->loc($this->content_width),$lineheight,$align,null);
$nr=pdf_show_boxed($this->pdf,$textstr, $this->loc($xloc),$this->loc($this->yloc),$this->loc($content_width),$lineheight,$align,null);
if($this->yloc< (0.9 + $lineheight/72) )
$this->newPage();
@ -764,6 +786,7 @@ class lpdf
// pdf_set_parameter($this->pdf, "FontOutline", "Arial=/home/sfiab/www.sfiab.ca/sfiab/arial.ttf");
//$arial=pdf_findfont($this->pdf,"Arial","host",1);
$this->normalfont=pdf_findfont($this->pdf,"Times-Roman","host",0);
$this->boldfont=pdf_findfont($this->pdf,"Times-Bold","host",0);
$this->headerfont=pdf_findfont($this->pdf,"Times-Bold","host",0);
if(file_exists($logo))