source: trunk/phpgwapi/inc/fpdf/tutorial/tuto3.php @ 2

Revision 2, 1.7 KB checked in by niltonneto, 17 years ago (diff)

Removida todas as tags usadas pelo CVS ($Id, $Source).
Primeira versão no CVS externo.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2define('FPDF_FONTPATH','../font/');
3require('../fpdf.php');
4
5class PDF extends FPDF
6{
7function Header()
8{
9        global $title;
10
11        //Arial bold 15
12        $this->SetFont('Arial','B',15);
13        //Calculate width of title and position
14        $w=$this->GetStringWidth($title)+6;
15        $this->SetX((210-$w)/2);
16        //Colors of frame, background and text
17        $this->SetDrawColor(0,80,180);
18        $this->SetFillColor(230,230,0);
19        $this->SetTextColor(220,50,50);
20        //Thickness of frame (1 mm)
21        $this->SetLineWidth(1);
22        //Title
23        $this->Cell($w,9,$title,1,1,'C',1);
24        //Line break
25        $this->Ln(10);
26}
27
28function Footer()
29{
30        //Position at 1.5 cm from bottom
31        $this->SetY(-15);
32        //Arial italic 8
33        $this->SetFont('Arial','I',8);
34        //Text color in gray
35        $this->SetTextColor(128);
36        //Page number
37        $this->Cell(0,10,'Page '.$this->PageNo(),0,0,'C');
38}
39
40function ChapterTitle($num,$label)
41{
42        //Arial 12
43        $this->SetFont('Arial','',12);
44        //Background color
45        $this->SetFillColor(200,220,255);
46        //Title
47        $this->Cell(0,6,"Chapter $num : $label",0,1,'L',1);
48        //Line break
49        $this->Ln(4);
50}
51
52function ChapterBody($file)
53{
54        //Read text file
55        $f=fopen($file,'r');
56        $txt=fread($f,filesize($file));
57        fclose($f);
58        //Times 12
59        $this->SetFont('Times','',12);
60        //Output justified text
61        $this->MultiCell(0,5,$txt);
62        //Line break
63        $this->Ln();
64        //Mention in italics
65        $this->SetFont('','I');
66        $this->Cell(0,5,'(end of excerpt)');
67}
68
69function PrintChapter($num,$title,$file)
70{
71        $this->AddPage();
72        $this->ChapterTitle($num,$title);
73        $this->ChapterBody($file);
74}
75}
76
77$pdf=new PDF();
78$title='20000 Leagues Under the Seas';
79$pdf->SetTitle($title);
80$pdf->SetAuthor('Jules Verne');
81$pdf->PrintChapter(1,'A RUNAWAY REEF','20k_c1.txt');
82$pdf->PrintChapter(2,'THE PROS AND CONS','20k_c2.txt');
83$pdf->Output();
84?>
Note: See TracBrowser for help on using the repository browser.