Re: FPDF Help
| From: | Marek Kilimajer | Date: | Fri, 16 Apr 2004 12:35:02 +0000 |
| Subject: | Re: FPDF Help | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-183613@lists.php.net to get a copy of this message | ||
Nathan Mealey wrote:
Anyone who is familiar with using FPDF to generate PDFs, I'd really appreciate some suggestions here: I am using the following code, virtually identical to that used in the FPDF tutorial examples. But I keep getting a parse error for the first line containing the variable $this. In the tutorial they do not declare this variable prior to using it the same way as in the example below, but when I try and do this, it's a no go. Any ideas? Suggestions? the code -- define('FPDF_FONTPATH','../../../font/'); require('../fpdf.php'); class PDF extends FPDF { function Header() {These lines must be outside of the class definition://Arial 12 $this->SetFont('Arial','',12); //Move to the right $this->Cell(80); //Title $this->Cell(30,10,'Title',1,0,'C'); //Line break $this->Ln(20);} function Footer() {//Position at 1.5 cm from bottom $this->SetY(-15); //Arial italic 8 $this->SetFont('Arial','I',8); //Page number $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');}
$pdf=new PDF(); $pdf->AliasNbPages(); $pdf->AddPage(); $pdf->SetFont('Times','',12); for($i=1;$i<=40;$i++) {This is the brace that closes the class definition, move the above lines below this brace:$pdf->Cell(0,10,'Printing line number '.$i,0,1);} $pdf->Output();
} Nathan Mealey Director of Operations Cycle-Smart, Inc. P.O. Box 1482 Northampton, MA 01061-1482 nathan@cycle-smart.com (413) 587-3133 (413) 210-7984 Mobile (512) 681-7043 Fax