00001 <?php
00002 require('../fpdf.php');
00003
00004 class PDF extends FPDF
00005 {
00006 function Header()
00007 {
00008 global $title;
00009
00010
00011 $this->SetFont('Arial','B',15);
00012
00013 $w=$this->GetStringWidth($title)+6;
00014 $this->SetX((210-$w)/2);
00015
00016 $this->SetDrawColor(0,80,180);
00017 $this->SetFillColor(230,230,0);
00018 $this->SetTextColor(220,50,50);
00019
00020 $this->SetLineWidth(1);
00021
00022 $this->Cell($w,9,$title,1,1,'C',true);
00023
00024 $this->Ln(10);
00025 }
00026
00027 function Footer()
00028 {
00029
00030 $this->SetY(-15);
00031
00032 $this->SetFont('Arial','I',8);
00033
00034 $this->SetTextColor(128);
00035
00036 $this->Cell(0,10,'Page '.$this->PageNo(),0,0,'C');
00037 }
00038
00039 function ChapterTitle($num,$label)
00040 {
00041
00042 $this->SetFont('Arial','',12);
00043
00044 $this->SetFillColor(200,220,255);
00045
00046 $this->Cell(0,6,"Chapter $num : $label",0,1,'L',true);
00047
00048 $this->Ln(4);
00049 }
00050
00051 function ChapterBody($file)
00052 {
00053
00054 $f=fopen($file,'r');
00055 $txt=fread($f,filesize($file));
00056 fclose($f);
00057
00058 $this->SetFont('Times','',12);
00059
00060 $this->MultiCell(0,5,$txt);
00061
00062 $this->Ln();
00063
00064 $this->SetFont('','I');
00065 $this->Cell(0,5,'(end of excerpt)');
00066 }
00067
00068 function PrintChapter($num,$title,$file)
00069 {
00070 $this->AddPage();
00071 $this->ChapterTitle($num,$title);
00072 $this->ChapterBody($file);
00073 }
00074 }
00075
00076 $pdf=new PDF();
00077 $title='20000 Leagues Under the Seas';
00078 $pdf->SetTitle($title);
00079 $pdf->SetAuthor('Jules Verne');
00080 $pdf->PrintChapter(1,'A RUNAWAY REEF','20k_c1.txt');
00081 $pdf->PrintChapter(2,'THE PROS AND CONS','20k_c2.txt');
00082 $pdf->Output();
00083 ?>