Wednesday, 9 March 2011

ezPDF - adding a horizontal rule

The ezPdf class for PHP is fairly basic, but none the worse for that. I found I couldn't get a Horizontal Rule to go below the text I'd just output, but it was very easy to write a function that would do it:

function ezHR($lineThickness){
//writes horizontal rule of given thickness, respecting left and right margins
$this->setLineStyle($lineThickness);
$y=$this->ezGetDy()-10;
$r=$this->ez['pageWidth']-$this->ez['rightMargin'];
$this->line($this->ez['leftMargin'],$y,$r,$y);
}


Add this to class.ezpdf.php and then call it with 
$pdf->ezHR(2);

No comments: