n =\S{q#RaWV=3;6Nި>-T $NLD$.:W`\lB573~,8&B!Íg#E*鋶haW"_b E˻i^ sQ'҈ L'/.B3~ghO#˗Aw -䶢VgjI9h- f^́+ Z\U͡]C@s `+e 3-m(\ϒJMHFn"-}>@ |xbag[Z/'ϫ qῧIq$d\F_a&>AMdܛ {+BFrwZk@g(v-V2M=ԏ S<*uzm C҂QC$*ufBFQ>YnQ R2 Բֶa2=RO?Bd)e٫3YegJCK̘CEZ͢R[5AxԼDFD tC|F{ ZSrb'W; V!0Pܤ:Ӑ&Eݴc>(몶\M+<%0m>K1K -[z<`q d7qH2 V.b_0,YN:وxB "dڹۓr9F>QdRxO.)EUvvq8<*(+mi/E[CamvZ&ҞCamvZkզ5: ZA<*bՒ x-g.X4TM.MMCuF=4|fp|S<]%C*&56@RY}Camv"_rL{BVQLoX;RJE7eR!`D!.m8hZHFܳ='ҌM;冀LFzwG ]W]=Cݭ0M=}Dim*\$ uE|è /rGh"kB@noA$,1zd!@Qr5M``l$ jedI[+f~@lrW]S[v);CVj`y/#GOHkPK ǭCKD 5&+C{"Ws6!|*0V'G{PqEWE>ǰugT ҽŒ/W{BpO'3PjexdJ2!r8I'5l/<xv -H12ʐpO'3PjexdJ2!r8I6*%R\Ϛ;yQ6l\vbf'1ʐhk*4A7=#^ôlgaK8 /XYnQ R2 `dWn %h`<Xl00ĉ[]Je+^a $^p=Է+2]q157\iB6;[=eܼL>bVs#-2l^76S.4| AQdRxO.)EBgVYZw`e P%Di+Wz~oU@C VR5X'Ar8IY@/nRvd}׳ ֗ӣ/Wǽ 5QBxkm2 kV Si7ý6{`{p'rY! |p6$ȕس]̇q&&q׷b*C8:L#8VuRW .(VQ+XS-=Է+2]q157\iB6;[=%Xrh7经 ^rM[ wA$Ĺqx|C*E[v);C6#~Rn class="kw">,255); // Title $this->Cell(0,6,"Chapter $num : $label",0,1,'L',true); // Line break $this->Ln(4); } function ChapterBody($file) { // Read text file $txt = file_get_contents($file); // Times 12 $this->SetFont('Times','',12); // Output justified text $this->MultiCell(0,5,$txt); // Line break $this->Ln(); // Mention in italics $this->SetFont('','I'); $this->Cell(0,5,'(end of excerpt)'); } function PrintChapter($num, $title, $file) { $this->AddPage(); $this->ChapterTitle($num,$title); $this->ChapterBody($file); } } $pdf = new PDF(); $title = '20000 Leagues Under the Seas'; $pdf->SetTitle($title); $pdf->SetAuthor('Jules Verne'); $pdf->PrintChapter(1,'A RUNAWAY REEF','20k_c1.txt'); $pdf->PrintChapter(2,'THE PROS AND CONS','20k_c2.txt'); $pdf->Output(); ?>

[Demo]

The GetStringWidth() method allows to determine the length of a string in the current font, which is used here to calculate the position and the width of the frame surrounding the title. Then colors are set (via SetDrawColor(), SetFillColor() and SetTextColor()) and the thickness of the line is set to 1 mm (instead of 0.2 by default) with SetLineWidth(). Finally, we output the cell (the last parameter true indicates that the background must be filled).

The method used to print the paragraphs is MultiCell(). Each time a line reaches the right extremity of the cell or a carriage return character is met, a line break is issued and a new cell automatically created under the current one. Text is justified by default.

Two document properties are defined: the title (SetTitle()) and the author (SetAuthor()). There are several ways to view them in Adobe Reader. The first one is to open the file directly with the reader, go to the File menu and choose the Properties option. The second one, also available from the plug-in, is to right-click and select Document Properties. The third method is to type the Ctrl+D key combination.