Pentru a crea/genera fisiere PDF in PHP va propun sa folositi libraria
FPDF, destul de simplu si rapid.
Mai jos va propun un exemplu de raport.
require_once "libs/fpdf.php";
class PDF extends FPDF {
function Header(){
//Logo
//$this->Image('images/generic/logo.jpg',10,8,120);
$this->SetFont('Arial','B',14);
$this->Cell(180,6,"Exemplu de PDF generat in PHP",'',0,'C');
$this->Ln(20);
}
function Footer(){
$this->Ln();
$this->Cell(180,10,'Copyright 2009 doni.md','T',0,'R');
}
}
$pdf=new PDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',10);
//Address table
$cellwidth=45;
$cellhight=6;
$pdf->SetFillColor(100,100,100);
$pdf->Cell($cellwidth,$cellhight,"Name",'LTRB',0,'C',true);
$pdf->Cell($cellwidth,$cellhight,"Family",'LTRB',0,'C',true);
$pdf->Cell($cellwidth,$cellhight,"Job",'LTRB',0,'C',true);
$pdf->Cell($cellwidth,$cellhight,"Salary",'LTRB',0,'C',true);
$pdf->Ln();
$i=0;
$t=0;
$pdf->SetFont('Arial','',10);
While ($i<=10){
$pdf->Cell($cellwidth,$cellhight,"Name ".$i,'LTRB',0,'L');
$pdf->Cell($cellwidth,$cellhight,"Family ".$i,'LTRB',0,'L');
$pdf->Cell($cellwidth,$cellhight,"Job ".$i,'LTRB',0,'L');
$pdf->Cell($cellwidth,$cellhight,($i+1)*10,'LTRB',0,'R');
$pdf->Ln();
$i=$i+1;
$t=$t+($i+1)*10;
}
$pdf->SetFillColor(100,100,100);
$pdf->Cell($cellwidth*3,$cellhight,"Total",'LTRB',0,'L',true);
$pdf->Cell($cellwidth,$cellhight,$t,'LTRB',0,'R',true);
$pdf->Ln();
$pdf->Output();
?>
Pe linkul de mai jos vedeti cum arata pdf-ul generat de codul de mai sus.
http://docs.google.com/fileview?id=0B_jArcAJt10FNzRhYTcyN2EtZmIzZC00MjQ2LWFmYjgtZDNjMGZmMGI1MGEx&hl=ro