FPDF Class Reference

Inherited by PDF, and PDF_label.

List of all members.

Public Member Functions

Public Attributes


Detailed Description

Definition at line 12 of file fpdf.php.


Member Function Documentation

FPDF::_beginpage ( orientation,
format 
)

Definition at line 1094 of file fpdf.php.

Referenced by AddPage().

01095 {
01096         $this->page++;
01097         $this->pages[$this->page]='';
01098         $this->state=2;
01099         $this->x=$this->lMargin;
01100         $this->y=$this->tMargin;
01101         $this->FontFamily='';
01102         //Check page size
01103         if($orientation=='')
01104                 $orientation=$this->DefOrientation;
01105         else
01106                 $orientation=strtoupper($orientation[0]);
01107         if($format=='')
01108                 $format=$this->DefPageFormat;
01109         else
01110         {
01111                 if(is_string($format))
01112                         $format=$this->_getpageformat($format);
01113         }
01114         if($orientation!=$this->CurOrientation || $format[0]!=$this->CurPageFormat[0] || $format[1]!=$this->CurPageFormat[1])
01115         {
01116                 //New size
01117                 if($orientation=='P')
01118                 {
01119                         $this->w=$format[0];
01120                         $this->h=$format[1];
01121                 }
01122                 else
01123                 {
01124                         $this->w=$format[1];
01125                         $this->h=$format[0];
01126                 }
01127                 $this->wPt=$this->w*$this->k;
01128                 $this->hPt=$this->h*$this->k;
01129                 $this->PageBreakTrigger=$this->h-$this->bMargin;
01130                 $this->CurOrientation=$orientation;
01131                 $this->CurPageFormat=$format;
01132         }
01133         if($orientation!=$this->DefOrientation || $format[0]!=$this->DefPageFormat[0] || $format[1]!=$this->DefPageFormat[1])
01134                 $this->PageSizes[$this->page]=array($this->wPt, $this->hPt);
01135 }

FPDF::_dochecks (  ) 

Definition at line 1065 of file fpdf.php.

Referenced by FPDF().

01066 {
01067         //Check availability of %F
01068         if(sprintf('%.1F',1.0)!='1.0')
01069                 $this->Error('This version of PHP is not supported');
01070         //Check mbstring overloading
01071         if(ini_get('mbstring.func_overload') & 2)
01072                 $this->Error('mbstring overloading must be disabled');
01073         //Disable runtime magic quotes
01074         if(get_magic_quotes_runtime())
01075                 @set_magic_quotes_runtime(0);
01076 }

FPDF::_dounderline ( x,
y,
txt 
)

Definition at line 1191 of file fpdf.php.

01192 {
01193         //Underline text
01194         $up=$this->CurrentFont['up'];
01195         $ut=$this->CurrentFont['ut'];
01196         $w=$this->GetStringWidth($txt)+$this->ws*substr_count($txt,' ');
01197         return sprintf('%.2F %.2F %.2F %.2F re f',$x*$this->k,($this->h-($y-$up/1000*$this->FontSize))*$this->k,$w*$this->k,-$ut/1000*$this->FontSizePt);
01198 }

FPDF::_enddoc (  ) 

Definition at line 1690 of file fpdf.php.

Referenced by Close().

01691 {
01692         $this->_putheader();
01693         $this->_putpages();
01694         $this->_putresources();
01695         //Info
01696         $this->_newobj();
01697         $this->_out('<<');
01698         $this->_putinfo();
01699         $this->_out('>>');
01700         $this->_out('endobj');
01701         //Catalog
01702         $this->_newobj();
01703         $this->_out('<<');
01704         $this->_putcatalog();
01705         $this->_out('>>');
01706         $this->_out('endobj');
01707         //Cross-ref
01708         $o=strlen($this->buffer);
01709         $this->_out('xref');
01710         $this->_out('0 '.($this->n+1));
01711         $this->_out('0000000000 65535 f ');
01712         for($i=1;$i<=$this->n;$i++)
01713                 $this->_out(sprintf('%010d 00000 n ',$this->offsets[$i]));
01714         //Trailer
01715         $this->_out('trailer');
01716         $this->_out('<<');
01717         $this->_puttrailer();
01718         $this->_out('>>');
01719         $this->_out('startxref');
01720         $this->_out($o);
01721         $this->_out('%%EOF');
01722         $this->state=3;
01723 }

FPDF::_endpage (  ) 

Definition at line 1137 of file fpdf.php.

Referenced by AddPage(), and Close().

01138 {
01139         $this->state=1;
01140 }

FPDF::_escape ( s  ) 

Definition at line 1142 of file fpdf.php.

Referenced by Text().

01143 {
01144         //Escape special characters in strings
01145         $s=str_replace('\\','\\\\',$s);
01146         $s=str_replace('(','\\(',$s);
01147         $s=str_replace(')','\\)',$s);
01148         $s=str_replace("\r",'\\r',$s);
01149         return $s;
01150 }

FPDF::_getfontpath (  ) 

Definition at line 1087 of file fpdf.php.

Referenced by AddFont(), and SetFont().

01088 {
01089         if(!defined('FPDF_FONTPATH') && is_dir(dirname(__FILE__).'/font'))
01090                 define('FPDF_FONTPATH',dirname(__FILE__).'/font/');
01091         return defined('FPDF_FONTPATH') ? FPDF_FONTPATH : '';
01092 }

FPDF::_getpageformat ( format  ) 

Definition at line 1078 of file fpdf.php.

Referenced by _beginpage(), and FPDF().

01079 {
01080         $format=strtolower($format);
01081         if(!isset($this->PageFormats[$format]))
01082                 $this->Error('Unknown page format: '.$format);
01083         $a=$this->PageFormats[$format];
01084         return array($a[0]/$this->k, $a[1]/$this->k);
01085 }

FPDF::_newobj (  ) 

Definition at line 1354 of file fpdf.php.

01355 {
01356         //Begin a new object
01357         $this->n++;
01358         $this->offsets[$this->n]=strlen($this->buffer);
01359         $this->_out($this->n.' 0 obj');
01360 }

FPDF::_out ( s  ) 

Definition at line 1369 of file fpdf.php.

Referenced by PDF_label::_Arc(), PDF::_Arc(), AddPage(), Cell(), Image(), Line(), MultiCell(), Rect(), PDF_label::RoundedRect(), PDF::RoundedRect(), SetDrawColor(), SetFillColor(), SetFont(), SetFontSize(), SetLineWidth(), and Text().

01370 {
01371         //Add a line to the document
01372         if($this->state==2)
01373                 $this->pages[$this->page].=$s."\n";
01374         else
01375                 $this->buffer.=$s."\n";
01376 }

FPDF::_parsegif ( file  ) 

Definition at line 1332 of file fpdf.php.

01333 {
01334         //Extract info from a GIF file (via PNG conversion)
01335         if(!function_exists('imagepng'))
01336                 $this->Error('GD extension is required for GIF support');
01337         if(!function_exists('imagecreatefromgif'))
01338                 $this->Error('GD has no GIF read support');
01339         $im=imagecreatefromgif($file);
01340         if(!$im)
01341                 $this->Error('Missing or incorrect image file: '.$file);
01342         imageinterlace($im,0);
01343         $tmp=tempnam('.','gif');
01344         if(!$tmp)
01345                 $this->Error('Unable to create a temporary file');
01346         if(!imagepng($im,$tmp))
01347                 $this->Error('Error while saving to temporary file');
01348         imagedestroy($im);
01349         $info=$this->_parsepng($tmp);
01350         unlink($tmp);
01351         return $info;
01352 }

FPDF::_parsejpg ( file  ) 

Definition at line 1200 of file fpdf.php.

01201 {
01202         //Extract info from a JPEG file
01203         $a=GetImageSize($file);
01204         if(!$a)
01205                 $this->Error('Missing or incorrect image file: '.$file);
01206         if($a[2]!=2)
01207                 $this->Error('Not a JPEG file: '.$file);
01208         if(!isset($a['channels']) || $a['channels']==3)
01209                 $colspace='DeviceRGB';
01210         elseif($a['channels']==4)
01211                 $colspace='DeviceCMYK';
01212         else
01213                 $colspace='DeviceGray';
01214         $bpc=isset($a['bits']) ? $a['bits'] : 8;
01215         //Read whole file
01216         $f=fopen($file,'rb');
01217         $data='';
01218         while(!feof($f))
01219                 $data.=fread($f,8192);
01220         fclose($f);
01221         return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data);
01222 }

FPDF::_parsepng ( file  ) 

Definition at line 1224 of file fpdf.php.

01225 {
01226         //Extract info from a PNG file
01227         if(!file_exists($file)) return false;
01228         $f=fopen($file,'rb');
01229         if(!$f)
01230                 $this->Error('Can\'t open image file: '.$file);
01231         //Check signature
01232         if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10))
01233                 $this->Error('Not a PNG file: '.$file);
01234         //Read header chunk
01235         $this->_readstream($f,4);
01236         if($this->_readstream($f,4)!='IHDR')
01237                 $this->Error('Incorrect PNG file: '.$file);
01238         $w=$this->_readint($f);
01239         $h=$this->_readint($f);
01240         $bpc=ord($this->_readstream($f,1));
01241         if($bpc>8)
01242                 $this->Error('16-bit depth not supported: '.$file);
01243         $ct=ord($this->_readstream($f,1));
01244         if($ct==0)
01245                 $colspace='DeviceGray';
01246         elseif($ct==2)
01247                 $colspace='DeviceRGB';
01248         elseif($ct==3)
01249                 $colspace='Indexed';
01250         else
01251                 $this->Error('Alpha channel not supported: '.$file);
01252         if(ord($this->_readstream($f,1))!=0)
01253                 $this->Error('Unknown compression method: '.$file);
01254         if(ord($this->_readstream($f,1))!=0)
01255                 $this->Error('Unknown filter method: '.$file);
01256         if(ord($this->_readstream($f,1))!=0)
01257                 $this->Error('Interlacing not supported: '.$file);
01258         $this->_readstream($f,4);
01259         $parms='/DecodeParms <</Predictor 15 /Colors '.($ct==2 ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w.'>>';
01260         //Scan chunks looking for palette, transparency and image data
01261         $pal='';
01262         $trns='';
01263         $data='';
01264         do
01265         {
01266                 $n=$this->_readint($f);
01267                 $type=$this->_readstream($f,4);
01268                 if($type=='PLTE')
01269                 {
01270                         //Read palette
01271                         $pal=$this->_readstream($f,$n);
01272                         $this->_readstream($f,4);
01273                 }
01274                 elseif($type=='tRNS')
01275                 {
01276                         //Read transparency info
01277                         $t=$this->_readstream($f,$n);
01278                         if($ct==0)
01279                                 $trns=array(ord(substr($t,1,1)));
01280                         elseif($ct==2)
01281                                 $trns=array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1)));
01282                         else
01283                         {
01284                                 $pos=strpos($t,chr(0));
01285                                 if($pos!==false)
01286                                         $trns=array($pos);
01287                         }
01288                         $this->_readstream($f,4);
01289                 }
01290                 elseif($type=='IDAT')
01291                 {
01292                         //Read image data block
01293                         $data.=$this->_readstream($f,$n);
01294                         $this->_readstream($f,4);
01295                 }
01296                 elseif($type=='IEND')
01297                         break;
01298                 else
01299                         $this->_readstream($f,$n+4);
01300         }
01301         while($n);
01302         if($colspace=='Indexed' && empty($pal))
01303                 $this->Error('Missing palette in '.$file);
01304         fclose($f);
01305         return array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'parms'=>$parms, 'pal'=>$pal, 'trns'=>$trns, 'data'=>$data);
01306 }

FPDF::_putcatalog (  ) 

Definition at line 1658 of file fpdf.php.

01659 {
01660         $this->_out('/Type /Catalog');
01661         $this->_out('/Pages 1 0 R');
01662         if($this->ZoomMode=='fullpage')
01663                 $this->_out('/OpenAction [3 0 R /Fit]');
01664         elseif($this->ZoomMode=='fullwidth')
01665                 $this->_out('/OpenAction [3 0 R /FitH null]');
01666         elseif($this->ZoomMode=='real')
01667                 $this->_out('/OpenAction [3 0 R /XYZ null null 1]');
01668         elseif(!is_string($this->ZoomMode))
01669                 $this->_out('/OpenAction [3 0 R /XYZ null null '.($this->ZoomMode/100).']');
01670         if($this->LayoutMode=='single')
01671                 $this->_out('/PageLayout /SinglePage');
01672         elseif($this->LayoutMode=='continuous')
01673                 $this->_out('/PageLayout /OneColumn');
01674         elseif($this->LayoutMode=='two')
01675                 $this->_out('/PageLayout /TwoColumnLeft');
01676 }

FPDF::_putfonts (  ) 

Definition at line 1449 of file fpdf.php.

01450 {
01451         $nf=$this->n;
01452         foreach($this->diffs as $diff)
01453         {
01454                 //Encodings
01455                 $this->_newobj();
01456                 $this->_out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$diff.']>>');
01457                 $this->_out('endobj');
01458         }
01459         foreach($this->FontFiles as $file=>$info)
01460         {
01461                 //Font file embedding
01462                 $this->_newobj();
01463                 $this->FontFiles[$file]['n']=$this->n;
01464                 $font='';
01465                 $f=fopen($this->_getfontpath().$file,'rb',1);
01466                 if(!$f)
01467                         $this->Error('Font file not found');
01468                 while(!feof($f))
01469                         $font.=fread($f,8192);
01470                 fclose($f);
01471                 $compressed=(substr($file,-2)=='.z');
01472                 if(!$compressed && isset($info['length2']))
01473                 {
01474                         $header=(ord($font[0])==128);
01475                         if($header)
01476                         {
01477                                 //Strip first binary header
01478                                 $font=substr($font,6);
01479                         }
01480                         if($header && ord($font[$info['length1']])==128)
01481                         {
01482                                 //Strip second binary header
01483                                 $font=substr($font,0,$info['length1']).substr($font,$info['length1']+6);
01484                         }
01485                 }
01486                 $this->_out('<</Length '.strlen($font));
01487                 if($compressed)
01488                         $this->_out('/Filter /FlateDecode');
01489                 $this->_out('/Length1 '.$info['length1']);
01490                 if(isset($info['length2']))
01491                         $this->_out('/Length2 '.$info['length2'].' /Length3 0');
01492                 $this->_out('>>');
01493                 $this->_putstream($font);
01494                 $this->_out('endobj');
01495         }
01496         foreach($this->fonts as $k=>$font)
01497         {
01498                 //Font objects
01499                 $this->fonts[$k]['n']=$this->n+1;
01500                 $type=$font['type'];
01501                 $name=$font['name'];
01502                 if($type=='core')
01503                 {
01504                         //Standard font
01505                         $this->_newobj();
01506                         $this->_out('<</Type /Font');
01507                         $this->_out('/BaseFont /'.$name);
01508                         $this->_out('/Subtype /Type1');
01509                         if($name!='Symbol' && $name!='ZapfDingbats')
01510                                 $this->_out('/Encoding /WinAnsiEncoding');
01511                         $this->_out('>>');
01512                         $this->_out('endobj');
01513                 }
01514                 elseif($type=='Type1' || $type=='TrueType')
01515                 {
01516                         //Additional Type1 or TrueType font
01517                         $this->_newobj();
01518                         $this->_out('<</Type /Font');
01519                         $this->_out('/BaseFont /'.$name);
01520                         $this->_out('/Subtype /'.$type);
01521                         $this->_out('/FirstChar 32 /LastChar 255');
01522                         $this->_out('/Widths '.($this->n+1).' 0 R');
01523                         $this->_out('/FontDescriptor '.($this->n+2).' 0 R');
01524                         if($font['enc'])
01525                         {
01526                                 if(isset($font['diff']))
01527                                         $this->_out('/Encoding '.($nf+$font['diff']).' 0 R');
01528                                 else
01529                                         $this->_out('/Encoding /WinAnsiEncoding');
01530                         }
01531                         $this->_out('>>');
01532                         $this->_out('endobj');
01533                         //Widths
01534                         $this->_newobj();
01535                         $cw=&$font['cw'];
01536                         $s='[';
01537                         for($i=32;$i<=255;$i++)
01538                                 $s.=$cw[chr($i)].' ';
01539                         $this->_out($s.']');
01540                         $this->_out('endobj');
01541                         //Descriptor
01542                         $this->_newobj();
01543                         $s='<</Type /FontDescriptor /FontName /'.$name;
01544                         foreach($font['desc'] as $k=>$v)
01545                                 $s.=' /'.$k.' '.$v;
01546                         $file=$font['file'];
01547                         if($file)
01548                                 $s.=' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R';
01549                         $this->_out($s.'>>');
01550                         $this->_out('endobj');
01551                 }
01552                 else
01553                 {
01554                         //Allow for additional types
01555                         $mtd='_put'.strtolower($type);
01556                         if(!method_exists($this,$mtd))
01557                                 $this->Error('Unsupported font type: '.$type);
01558                         $this->$mtd($font);
01559                 }
01560         }
01561 }

FPDF::_putheader (  ) 

Definition at line 1678 of file fpdf.php.

01679 {
01680         $this->_out('%PDF-'.$this->PDFVersion);
01681 }

FPDF::_putimages (  ) 

Definition at line 1563 of file fpdf.php.

01564 {
01565         $filter=($this->compress) ? '/Filter /FlateDecode ' : '';
01566         reset($this->images);
01567         while(list($file,$info)=each($this->images))
01568         {
01569                 $this->_newobj();
01570                 $this->images[$file]['n']=$this->n;
01571                 $this->_out('<</Type /XObject');
01572                 $this->_out('/Subtype /Image');
01573                 $this->_out('/Width '.$info['w']);
01574                 $this->_out('/Height '.$info['h']);
01575                 if($info['cs']=='Indexed')
01576                         $this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]');
01577                 else
01578                 {
01579                         $this->_out('/ColorSpace /'.$info['cs']);
01580                         if($info['cs']=='DeviceCMYK')
01581                                 $this->_out('/Decode [1 0 1 0 1 0 1 0]');
01582                 }
01583                 $this->_out('/BitsPerComponent '.$info['bpc']);
01584                 if(isset($info['f']))
01585                         $this->_out('/Filter /'.$info['f']);
01586                 if(isset($info['parms']))
01587                         $this->_out($info['parms']);
01588                 if(isset($info['trns']) && is_array($info['trns']))
01589                 {
01590                         $trns='';
01591                         for($i=0;$i<count($info['trns']);$i++)
01592                                 $trns.=$info['trns'][$i].' '.$info['trns'][$i].' ';
01593                         $this->_out('/Mask ['.$trns.']');
01594                 }
01595                 $this->_out('/Length '.strlen($info['data']).'>>');
01596                 $this->_putstream($info['data']);
01597                 unset($this->images[$file]['data']);
01598                 $this->_out('endobj');
01599                 //Palette
01600                 if($info['cs']=='Indexed')
01601                 {
01602                         $this->_newobj();
01603                         $pal=($this->compress) ? gzcompress($info['pal']) : $info['pal'];
01604                         $this->_out('<<'.$filter.'/Length '.strlen($pal).'>>');
01605                         $this->_putstream($pal);
01606                         $this->_out('endobj');
01607                 }
01608         }
01609 }

FPDF::_putinfo (  ) 

Definition at line 1642 of file fpdf.php.

01643 {
01644         $this->_out('/Producer '.$this->_textstring('FPDF '.FPDF_VERSION));
01645         if(!empty($this->title))
01646                 $this->_out('/Title '.$this->_textstring($this->title));
01647         if(!empty($this->subject))
01648                 $this->_out('/Subject '.$this->_textstring($this->subject));
01649         if(!empty($this->author))
01650                 $this->_out('/Author '.$this->_textstring($this->author));
01651         if(!empty($this->keywords))
01652                 $this->_out('/Keywords '.$this->_textstring($this->keywords));
01653         if(!empty($this->creator))
01654                 $this->_out('/Creator '.$this->_textstring($this->creator));
01655         $this->_out('/CreationDate '.$this->_textstring('D:'.@date('YmdHis')));
01656 }

FPDF::_putpages (  ) 

Definition at line 1378 of file fpdf.php.

01379 {
01380         $nb=$this->page;
01381         if(!empty($this->AliasNbPages))
01382         {
01383                 //Replace number of pages
01384                 for($n=1;$n<=$nb;$n++)
01385                         $this->pages[$n]=str_replace($this->AliasNbPages,$nb,$this->pages[$n]);
01386         }
01387         if($this->DefOrientation=='P')
01388         {
01389                 $wPt=$this->DefPageFormat[0]*$this->k;
01390                 $hPt=$this->DefPageFormat[1]*$this->k;
01391         }
01392         else
01393         {
01394                 $wPt=$this->DefPageFormat[1]*$this->k;
01395                 $hPt=$this->DefPageFormat[0]*$this->k;
01396         }
01397         $filter=($this->compress) ? '/Filter /FlateDecode ' : '';
01398         for($n=1;$n<=$nb;$n++)
01399         {
01400                 //Page
01401                 $this->_newobj();
01402                 $this->_out('<</Type /Page');
01403                 $this->_out('/Parent 1 0 R');
01404                 if(isset($this->PageSizes[$n]))
01405                         $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageSizes[$n][0],$this->PageSizes[$n][1]));
01406                 $this->_out('/Resources 2 0 R');
01407                 if(isset($this->PageLinks[$n]))
01408                 {
01409                         //Links
01410                         $annots='/Annots [';
01411                         foreach($this->PageLinks[$n] as $pl)
01412                         {
01413                                 $rect=sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]);
01414                                 $annots.='<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] ';
01415                                 if(is_string($pl[4]))
01416                                         $annots.='/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>';
01417                                 else
01418                                 {
01419                                         $l=$this->links[$pl[4]];
01420                                         $h=isset($this->PageSizes[$l[0]]) ? $this->PageSizes[$l[0]][1] : $hPt;
01421                                         $annots.=sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>',1+2*$l[0],$h-$l[1]*$this->k);
01422                                 }
01423                         }
01424                         $this->_out($annots.']');
01425                 }
01426                 $this->_out('/Contents '.($this->n+1).' 0 R>>');
01427                 $this->_out('endobj');
01428                 //Page content
01429                 $p=($this->compress) ? gzcompress($this->pages[$n]) : $this->pages[$n];
01430                 $this->_newobj();
01431                 $this->_out('<<'.$filter.'/Length '.strlen($p).'>>');
01432                 $this->_putstream($p);
01433                 $this->_out('endobj');
01434         }
01435         //Pages root
01436         $this->offsets[1]=strlen($this->buffer);
01437         $this->_out('1 0 obj');
01438         $this->_out('<</Type /Pages');
01439         $kids='/Kids [';
01440         for($i=0;$i<$nb;$i++)
01441                 $kids.=(3+2*$i).' 0 R ';
01442         $this->_out($kids.']');
01443         $this->_out('/Count '.$nb);
01444         $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$wPt,$hPt));
01445         $this->_out('>>');
01446         $this->_out('endobj');
01447 }

FPDF::_putresourcedict (  ) 

Definition at line 1617 of file fpdf.php.

01618 {
01619         $this->_out('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
01620         $this->_out('/Font <<');
01621         foreach($this->fonts as $font)
01622                 $this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
01623         $this->_out('>>');
01624         $this->_out('/XObject <<');
01625         $this->_putxobjectdict();
01626         $this->_out('>>');
01627 }

FPDF::_putresources (  ) 

Definition at line 1629 of file fpdf.php.

01630 {
01631         $this->_putfonts();
01632         $this->_putimages();
01633         //Resource dictionary
01634         $this->offsets[2]=strlen($this->buffer);
01635         $this->_out('2 0 obj');
01636         $this->_out('<<');
01637         $this->_putresourcedict();
01638         $this->_out('>>');
01639         $this->_out('endobj');
01640 }

FPDF::_putstream ( s  ) 

Definition at line 1362 of file fpdf.php.

01363 {
01364         $this->_out('stream');
01365         $this->_out($s);
01366         $this->_out('endstream');
01367 }

FPDF::_puttrailer (  ) 

Definition at line 1683 of file fpdf.php.

01684 {
01685         $this->_out('/Size '.($this->n+1));
01686         $this->_out('/Root '.$this->n.' 0 R');
01687         $this->_out('/Info '.($this->n-1).' 0 R');
01688 }

FPDF::_putxobjectdict (  ) 

Definition at line 1611 of file fpdf.php.

01612 {
01613         foreach($this->images as $image)
01614                 $this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
01615 }

FPDF::_readint ( f  ) 

Definition at line 1325 of file fpdf.php.

Referenced by _parsepng().

01326 {
01327         //Read a 4-byte integer from stream
01328         $a=unpack('Ni',$this->_readstream($f,4));
01329         return $a['i'];
01330 }

FPDF::_readstream ( f,
n 
)

Definition at line 1308 of file fpdf.php.

Referenced by _parsepng().

01309 {
01310         //Read n bytes from stream
01311         $res='';
01312         while($n>0 && !feof($f))
01313         {
01314                 $s=fread($f,$n);
01315                 if($s===false)
01316                         $this->Error('Error while reading stream');
01317                 $n-=strlen($s);
01318                 $res.=$s;
01319         }
01320         if($n>0)
01321                 $this->Error('Unexpected end of stream');
01322         return $res;
01323 }

FPDF::_textstring ( s  ) 

Definition at line 1152 of file fpdf.php.

01153 {
01154         //Format a text string
01155         return '('.$this->_escape($s).')';
01156 }

FPDF::_UTF8toUTF16 ( s  ) 

Definition at line 1158 of file fpdf.php.

Referenced by SetAuthor(), SetCreator(), SetKeywords(), SetSubject(), and SetTitle().

01159 {
01160         //Convert UTF-8 to UTF-16BE with BOM
01161         $res="\xFE\xFF";
01162         $nb=strlen($s);
01163         $i=0;
01164         while($i<$nb)
01165         {
01166                 $c1=ord($s[$i++]);
01167                 if($c1>=224)
01168                 {
01169                         //3-byte character
01170                         $c2=ord($s[$i++]);
01171                         $c3=ord($s[$i++]);
01172                         $res.=chr((($c1 & 0x0F)<<4) + (($c2 & 0x3C)>>2));
01173                         $res.=chr((($c2 & 0x03)<<6) + ($c3 & 0x3F));
01174                 }
01175                 elseif($c1>=192)
01176                 {
01177                         //2-byte character
01178                         $c2=ord($s[$i++]);
01179                         $res.=chr(($c1 & 0x1C)>>2);
01180                         $res.=chr((($c1 & 0x03)<<6) + ($c2 & 0x3F));
01181                 }
01182                 else
01183                 {
01184                         //Single-byte character
01185                         $res.="\0".chr($c1);
01186                 }
01187         }
01188         return $res;
01189 }

FPDF::AcceptPageBreak (  ) 

Definition at line 609 of file fpdf.php.

Referenced by Cell(), and Image().

00610 {
00611         //Accept automatic page break or not
00612         return $this->AutoPageBreak;
00613 }

FPDF::AddFont ( family,
style = '',
file = '' 
)

Definition at line 453 of file fpdf.php.

00454 {
00455         //Add a TrueType or Type1 font
00456         $family=strtolower($family);
00457         if($file=='')
00458                 $file=str_replace(' ','',$family).strtolower($style).'.php';
00459         if($family=='arial')
00460                 $family='helvetica';
00461         $style=strtoupper($style);
00462         if($style=='IB')
00463                 $style='BI';
00464         $fontkey=$family.$style;
00465         if(isset($this->fonts[$fontkey]))
00466                 return;
00467         include($this->_getfontpath().$file);
00468         if(!isset($name))
00469                 $this->Error('Could not include font definition file');
00470         $i=count($this->fonts)+1;
00471         $this->fonts[$fontkey]=array('i'=>$i, 'type'=>$type, 'name'=>$name, 'desc'=>$desc, 'up'=>$up, 'ut'=>$ut, 'cw'=>$cw, 'enc'=>$enc, 'file'=>$file);
00472         if($diff)
00473         {
00474                 //Search existing encodings
00475                 $d=0;
00476                 $nb=count($this->diffs);
00477                 for($i=1;$i<=$nb;$i++)
00478                 {
00479                         if($this->diffs[$i]==$diff)
00480                         {
00481                                 $d=$i;
00482                                 break;
00483                         }
00484                 }
00485                 if($d==0)
00486                 {
00487                         $d=$nb+1;
00488                         $this->diffs[$d]=$diff;
00489                 }
00490                 $this->fonts[$fontkey]['diff']=$d;
00491         }
00492         if($file)
00493         {
00494                 if($type=='TrueType')
00495                         $this->FontFiles[$file]=array('length1'=>$originalsize);
00496                 else
00497                         $this->FontFiles[$file]=array('length1'=>$size1, 'length2'=>$size2);
00498         }
00499 }

FPDF::AddLink (  ) 

Definition at line 574 of file fpdf.php.

00575 {
00576         //Create a new internal link
00577         $n=count($this->links)+1;
00578         $this->links[$n]=array(0, 0);
00579         return $n;
00580 }

FPDF::AddPage ( orientation = '',
format = '' 
)

Definition at line 297 of file fpdf.php.

Referenced by Cell(), Close(), and Image().

00298 {
00299         //Start a new page
00300         if($this->state==0)
00301                 $this->Open();
00302         $family=$this->FontFamily;
00303         $style=$this->FontStyle.($this->underline ? 'U' : '');
00304         $size=$this->FontSizePt;
00305         $lw=$this->LineWidth;
00306         $dc=$this->DrawColor;
00307         $fc=$this->FillColor;
00308         $tc=$this->TextColor;
00309         $cf=$this->ColorFlag;
00310         if($this->page>0)
00311         {
00312                 //Page footer
00313                 $this->InFooter=true;
00314                 $this->Footer();
00315                 $this->InFooter=false;
00316                 //Close page
00317                 $this->_endpage();
00318         }
00319         //Start new page
00320         $this->_beginpage($orientation,$format);
00321         //Set line cap style to square
00322         $this->_out('2 J');
00323         //Set line width
00324         $this->LineWidth=$lw;
00325         $this->_out(sprintf('%.2F w',$lw*$this->k));
00326         //Set font
00327         if($family)
00328                 $this->SetFont($family,$style,$size);
00329         //Set colors
00330         $this->DrawColor=$dc;
00331         if($dc!='0 G')
00332                 $this->_out($dc);
00333         $this->FillColor=$fc;
00334         if($fc!='0 g')
00335                 $this->_out($fc);
00336         $this->TextColor=$tc;
00337         $this->ColorFlag=$cf;
00338         //Page header
00339         $this->InHeader=true;
00340         $this->Header();
00341         $this->InHeader=false;
00342         //Restore line width
00343         if($this->LineWidth!=$lw)
00344         {
00345                 $this->LineWidth=$lw;
00346                 $this->_out(sprintf('%.2F w',$lw*$this->k));
00347         }
00348         //Restore font
00349         if($family)
00350                 $this->SetFont($family,$style,$size);
00351         //Restore colors
00352         if($this->DrawColor!=$dc)
00353         {
00354                 $this->DrawColor=$dc;
00355                 $this->_out($dc);
00356         }
00357         if($this->FillColor!=$fc)
00358         {
00359                 $this->FillColor=$fc;
00360                 $this->_out($fc);
00361         }
00362         $this->TextColor=$tc;
00363         $this->ColorFlag=$cf;
00364 }

FPDF::AliasNbPages (  ) 

Definition at line 262 of file fpdf.php.

00262                               {nb}')
00263 {
00264         //Define an alias for total number of pages
00265         $this->AliasNbPages=$alias;
00266 }

FPDF::Cell ( w,
h = 0,
txt = '',
border = 0,
ln = 0,
align = '',
fill = false,
link = '' 
)

Definition at line 615 of file fpdf.php.

Referenced by PDF_label::Footer(), PDF::Footer(), PDF::Header(), MultiCell(), and Write().

00616 {
00617         //Output a cell
00618         $k=$this->k;
00619         if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak())
00620         {
00621                 //Automatic page break
00622                 $x=$this->x;
00623                 $ws=$this->ws;
00624                 if($ws>0)
00625                 {
00626                         $this->ws=0;
00627                         $this->_out('0 Tw');
00628                 }
00629                 $this->AddPage($this->CurOrientation,$this->CurPageFormat);
00630                 $this->x=$x;
00631                 if($ws>0)
00632                 {
00633                         $this->ws=$ws;
00634                         $this->_out(sprintf('%.3F Tw',$ws*$k));
00635                 }
00636         }
00637         if($w==0)
00638                 $w=$this->w-$this->rMargin-$this->x;
00639         $s='';
00640         if($fill || $border==1)
00641         {
00642                 if($fill)
00643                         $op=($border==1) ? 'B' : 'f';
00644                 else
00645                         $op='S';
00646                 $s=sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op);
00647         }
00648         if(is_string($border))
00649         {
00650                 $x=$this->x;
00651                 $y=$this->y;
00652                 if(strpos($border,'L')!==false)
00653                         $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k);
00654                 if(strpos($border,'T')!==false)
00655                         $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k);
00656                 if(strpos($border,'R')!==false)
00657                         $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
00658                 if(strpos($border,'B')!==false)
00659                         $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
00660         }
00661         if($txt!=='')
00662         {
00663                 if($align=='R')
00664                         $dx=$w-$this->cMargin-$this->GetStringWidth($txt);
00665                 elseif($align=='C')
00666                         $dx=($w-$this->GetStringWidth($txt))/2;
00667                 else
00668                         $dx=$this->cMargin;
00669                 if($this->ColorFlag)
00670                         $s.='q '.$this->TextColor.' ';
00671                 $txt2=str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$txt)));
00672                 $s.=sprintf('BT %.2F %.2F Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txt2);
00673                 if($this->underline)
00674                         $s.=' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt);
00675                 if($this->ColorFlag)
00676                         $s.=' Q';
00677                 if($link)
00678                         $this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link);
00679         }
00680         if($s)
00681                 $this->_out($s);
00682         $this->lasth=$h;
00683         if($ln>0)
00684         {
00685                 //Go to next line
00686                 $this->y+=$h;
00687                 if($ln==1)
00688                         $this->x=$this->lMargin;
00689         }
00690         else
00691                 $this->x+=$w;
00692 }

FPDF::Close (  ) 

Definition at line 280 of file fpdf.php.

Referenced by Output().

00281 {
00282         //Terminate document
00283         if($this->state==3)
00284                 return;
00285         if($this->page==0)
00286                 $this->AddPage();
00287         //Page footer
00288         $this->InFooter=true;
00289         $this->Footer();
00290         $this->InFooter=false;
00291         //Close page
00292         $this->_endpage();
00293         //Close document
00294         $this->_enddoc();
00295 }

FPDF::Error ( msg  ) 

Definition at line 268 of file fpdf.php.

Referenced by _dochecks(), _getpageformat(), _parsejpg(), _parsepng(), AddFont(), FPDF(), Image(), Output(), SetDisplayMode(), and SetFont().

00269 {
00270         //Fatal error
00271         die('<b>FPDF error:</b> '.$msg);
00272 }

FPDF::Footer (  ) 

Reimplemented in PDF, and PDF_label.

Definition at line 371 of file fpdf.php.

Referenced by AddPage(), and Close().

00372 {
00373         //To be implemented in your own inherited class
00374 }

FPDF::FPDF ( orientation = 'P',
unit = 'mm',
format = 'A4' 
)

Definition at line 75 of file fpdf.php.

00076 {
00077         //Some checks
00078         $this->_dochecks();
00079         //Initialization of properties
00080         $this->page=0;
00081         $this->n=2;
00082         $this->buffer='';
00083         $this->pages=array();
00084         $this->PageSizes=array();
00085         $this->state=0;
00086         $this->fonts=array();
00087         $this->FontFiles=array();
00088         $this->diffs=array();
00089         $this->images=array();
00090         $this->links=array();
00091         $this->InHeader=false;
00092         $this->InFooter=false;
00093         $this->lasth=0;
00094         $this->FontFamily='';
00095         $this->FontStyle='';
00096         $this->FontSizePt=12;
00097         $this->underline=false;
00098         $this->DrawColor='0 G';
00099         $this->FillColor='0 g';
00100         $this->TextColor='0 g';
00101         $this->ColorFlag=false;
00102         $this->ws=0;
00103         //Standard fonts
00104         $this->CoreFonts=array('courier'=>'Courier', 'courierB'=>'Courier-Bold', 'courierI'=>'Courier-Oblique', 'courierBI'=>'Courier-BoldOblique',
00105                 'helvetica'=>'Helvetica', 'helveticaB'=>'Helvetica-Bold', 'helveticaI'=>'Helvetica-Oblique', 'helveticaBI'=>'Helvetica-BoldOblique',
00106                 'times'=>'Times-Roman', 'timesB'=>'Times-Bold', 'timesI'=>'Times-Italic', 'timesBI'=>'Times-BoldItalic',
00107                 'symbol'=>'Symbol', 'zapfdingbats'=>'ZapfDingbats');
00108         //Scale factor
00109         if($unit=='pt')
00110                 $this->k=1;
00111         elseif($unit=='mm')
00112                 $this->k=72/25.4;
00113         elseif($unit=='cm')
00114                 $this->k=72/2.54;
00115         elseif($unit=='in')
00116                 $this->k=72;
00117         else
00118                 $this->Error('Incorrect unit: '.$unit);
00119         //Page format
00120         $this->PageFormats=array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28),
00121                 'letter'=>array(612,792), 'legal'=>array(612,1008));
00122         if(is_string($format))
00123                 $format=$this->_getpageformat($format);
00124         $this->DefPageFormat=$format;
00125         $this->CurPageFormat=$format;
00126         //Page orientation
00127         $orientation=strtolower($orientation);
00128         if($orientation=='p' || $orientation=='portrait')
00129         {
00130                 $this->DefOrientation='P';
00131                 $this->w=$this->DefPageFormat[0];
00132                 $this->h=$this->DefPageFormat[1];
00133         }
00134         elseif($orientation=='l' || $orientation=='landscape')
00135         {
00136                 $this->DefOrientation='L';
00137                 $this->w=$this->DefPageFormat[1];
00138                 $this->h=$this->DefPageFormat[0];
00139         }
00140         else
00141                 $this->Error('Incorrect orientation: '.$orientation);
00142         $this->CurOrientation=$this->DefOrientation;
00143         $this->wPt=$this->w*$this->k;
00144         $this->hPt=$this->h*$this->k;
00145         //Page margins (1 cm)
00146         $margin=28.35/$this->k;
00147         $this->SetMargins($margin,$margin);
00148         //Interior cell margin (1 mm)
00149         $this->cMargin=$margin/10;
00150         //Line width (0.2 mm)
00151         $this->LineWidth=.567/$this->k;
00152         //Automatic page break
00153         $this->SetAutoPageBreak(true,2*$margin);
00154         //Full width display mode
00155         $this->SetDisplayMode('fullwidth');
00156         //Enable compression
00157         $this->SetCompression(true);
00158         //Set default PDF version number
00159         $this->PDFVersion='1.3';
00160 }

FPDF::GetStringWidth ( s  ) 

Definition at line 415 of file fpdf.php.

Referenced by _dounderline(), and Cell().

00416 {
00417         //Get width of a string in the current font
00418         $s=(string)$s;
00419         $cw=&$this->CurrentFont['cw'];
00420         $w=0;
00421         $l=strlen($s);
00422         for($i=0;$i<$l;$i++)
00423                 $w+=$cw[$s[$i]];
00424         return $w*$this->FontSize/1000;
00425 }

FPDF::GetX (  ) 

Definition at line 955 of file fpdf.php.

00956 {
00957         //Get x position
00958         return $this->x;
00959 }

FPDF::GetY (  ) 

Definition at line 970 of file fpdf.php.

00971 {
00972         //Get y position
00973         return $this->y;
00974 }

FPDF::Header (  ) 

Reimplemented in PDF, and PDF_label.

Definition at line 366 of file fpdf.php.

Referenced by AddPage().

00367 {
00368         //To be implemented in your own inherited class
00369 }

FPDF::Image ( file,
x = null,
y = null,
w = 0,
h = 0,
type = '',
link = '' 
)

Definition at line 898 of file fpdf.php.

Referenced by PDF_label::Header(), and PDF::Header().

00899 {
00900         //Put an image on the page
00901         if(!empty($file) && !@fopen($file,'r')) return null;
00902         if(!isset($this->images[$file]))
00903         {
00904                 //First use of this image, get info
00905                 if($type=='')
00906                 {
00907                         $pos=strrpos($file,'.');
00908                         if(!$pos)
00909                                 $this->Error('Image file has no extension and no type was specified: '.$file);
00910                         $type=substr($file,$pos+1);
00911                 }
00912                 $type=strtolower($type);
00913                 if($type=='jpeg')
00914                         $type='jpg';
00915                 $mtd='_parse'.$type;
00916                 if(!method_exists($this,$mtd))
00917                         $this->Error('Unsupported image type: '.$type);
00918                 $info=$this->$mtd($file);
00919                 $info['i']=count($this->images)+1;
00920                 $this->images[$file]=$info;
00921         }
00922         else
00923                 $info=$this->images[$file];
00924         //Automatic width and height calculation if needed
00925         if($w==0 && $h==0)
00926         {
00927                 //Put image at 72 dpi
00928                 $w=$info['w']/$this->k;
00929                 $h=$info['h']/$this->k;
00930         }
00931         elseif($w==0)
00932                 $w=$h*$info['w']/$info['h'];
00933         elseif($h==0)
00934                 $h=$w*$info['h']/$info['w'];
00935         //Flowing mode
00936         if($y===null)
00937         {
00938                 if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak())
00939                 {
00940                         //Automatic page break
00941                         $x2=$this->x;
00942                         $this->AddPage($this->CurOrientation,$this->CurPageFormat);
00943                         $this->x=$x2;
00944                 }
00945                 $y=$this->y;
00946                 $this->y+=$h;
00947         }
00948         if($x===null)
00949                 $x=$this->x;
00950         $this->_out(sprintf('q %.2F 0 0 %.2F %.2F %.2F cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i']));
00951         if($link)
00952                 $this->Link($x,$y,$w,$h,$link);
00953 }

FPDF::Line ( x1,
y1,
x2,
y2 
)

Definition at line 435 of file fpdf.php.

00436 {
00437         //Draw a line
00438         $this->_out(sprintf('%.2F %.2F m %.2F %.2F l S',$x1*$this->k,($this->h-$y1)*$this->k,$x2*$this->k,($this->h-$y2)*$this->k));
00439 }

FPDF::Link ( x,
y,
w,
h,
link 
)

Definition at line 592 of file fpdf.php.

Referenced by Cell(), and Image().

00593 {
00594         //Put a link on the page
00595         $this->PageLinks[$this->page][]=array($x*$this->k, $this->hPt-$y*$this->k, $w*$this->k, $h*$this->k, $link);
00596 }

FPDF::Ln ( h = null  ) 

Definition at line 888 of file fpdf.php.

Referenced by PDF::Header(), and PDF::OpenTag().

00889 {
00890         //Line feed; default value is last cell height
00891         $this->x=$this->lMargin;
00892         if($h===null)
00893                 $this->y+=$this->lasth;
00894         else
00895                 $this->y+=$h;
00896 }

FPDF::MultiCell ( w,
h,
txt,
border = 0,
align = 'J',
fill = false 
)

Definition at line 694 of file fpdf.php.

Referenced by PDF::Header().

00695 {
00696         //Output text with automatic or explicit line breaks
00697         $cw=&$this->CurrentFont['cw'];
00698         if($w==0)
00699                 $w=$this->w-$this->rMargin-$this->x;
00700         $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
00701         $s=str_replace("\r",'',$txt);
00702         $nb=strlen($s);
00703         if($nb>0 && $s[$nb-1]=="\n")
00704                 $nb--;
00705         $b=0;
00706         if($border)
00707         {
00708                 if($border==1)
00709                 {
00710                         $border='LTRB';
00711                         $b='LRT';
00712                         $b2='LR';
00713                 }
00714                 else
00715                 {
00716                         $b2='';
00717                         if(strpos($border,'L')!==false)
00718                                 $b2.='L';
00719                         if(strpos($border,'R')!==false)
00720                                 $b2.='R';
00721                         $b=(strpos($border,'T')!==false) ? $b2.'T' : $b2;
00722                 }
00723         }
00724         $sep=-1;
00725         $i=0;
00726         $j=0;
00727         $l=0;
00728         $ns=0;
00729         $nl=1;
00730         while($i<$nb)
00731         {
00732                 //Get next character
00733                 $c=$s[$i];
00734                 if($c=="\n")
00735                 {
00736                         //Explicit line break
00737                         if($this->ws>0)
00738                         {
00739                                 $this->ws=0;
00740                                 $this->_out('0 Tw');
00741                         }
00742                         $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
00743                         $i++;
00744                         $sep=-1;
00745                         $j=$i;
00746                         $l=0;
00747                         $ns=0;
00748                         $nl++;
00749                         if($border && $nl==2)
00750                                 $b=$b2;
00751                         continue;
00752                 }
00753                 if($c==' ')
00754                 {
00755                         $sep=$i;
00756                         $ls=$l;
00757                         $ns++;
00758                 }
00759                 $l+=$cw[$c];
00760                 if($l>$wmax)
00761                 {
00762                         //Automatic line break
00763                         if($sep==-1)
00764                         {
00765                                 if($i==$j)
00766                                         $i++;
00767                                 if($this->ws>0)
00768                                 {
00769                                         $this->ws=0;
00770                                         $this->_out('0 Tw');
00771                                 }
00772                                 $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
00773                         }
00774                         else
00775                         {
00776                                 if($align=='J')
00777                                 {
00778                                         $this->ws=($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0;
00779                                         $this->_out(sprintf('%.3F Tw',$this->ws*$this->k));
00780                                 }
00781                                 $this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill);
00782                                 $i=$sep+1;
00783                         }
00784                         $sep=-1;
00785                         $j=$i;
00786                         $l=0;
00787                         $ns=0;
00788                         $nl++;
00789                         if($border && $nl==2)
00790                                 $b=$b2;
00791                 }
00792                 else
00793                         $i++;
00794         }
00795         //Last chunk
00796         if($this->ws>0)
00797         {
00798                 $this->ws=0;
00799                 $this->_out('0 Tw');
00800         }
00801         if($border && strpos($border,'B')!==false)
00802                 $b.='B';
00803         $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
00804         $this->x=$this->lMargin;
00805 }

FPDF::Open (  ) 

Definition at line 274 of file fpdf.php.

Referenced by AddPage().

00275 {
00276         //Begin document
00277         $this->state=1;
00278 }

FPDF::Output ( name = '',
dest = '' 
)

Definition at line 993 of file fpdf.php.

00994 {
00995         //Output PDF to some destination
00996         if($this->state<3)
00997                 $this->Close();
00998         $dest=strtoupper($dest);
00999         if($dest=='')
01000         {
01001                 if($name=='')
01002                 {
01003                         $name='doc.pdf';
01004                         $dest='I';
01005                 }
01006                 else
01007                         $dest='F';
01008         }
01009         switch($dest)
01010         {
01011                 case 'I':
01012                         //Send to standard output
01013                         if(ob_get_length())
01014                                 $this->Error('Some data has already been output, can\'t send PDF file');
01015                         if(php_sapi_name()!='cli')
01016                         {
01017                                 //We send to a browser
01018                                 header('Content-Type: application/pdf');
01019                                 if(headers_sent())
01020                                         $this->Error('Some data has already been output, can\'t send PDF file');
01021                                 header('Content-Length: '.strlen($this->buffer));
01022                                 header('Content-Disposition: inline; filename="'.$name.'"');
01023                                 header('Cache-Control: private, max-age=0, must-revalidate');
01024                                 header('Pragma: public');
01025                                 ini_set('zlib.output_compression','0');
01026                         }
01027                         echo $this->buffer;
01028                         break;
01029                 case 'D':
01030                         //Download file
01031                         if(ob_get_length())
01032                                 $this->Error('Some data has already been output, can\'t send PDF file');
01033                         header('Content-Type: application/x-download');
01034                         if(headers_sent())
01035                                 $this->Error('Some data has already been output, can\'t send PDF file');
01036                         header('Content-Length: '.strlen($this->buffer));
01037                         header('Content-Disposition: attachment; filename="'.$name.'"');
01038                         header('Cache-Control: private, max-age=0, must-revalidate');
01039                         header('Pragma: public');
01040                         ini_set('zlib.output_compression','0');
01041                         echo $this->buffer;
01042                         break;
01043                 case 'F':
01044                         //Save to local file
01045                         $f=fopen($name,'wb');
01046                         if(!$f)
01047                                 $this->Error('Unable to create output file: '.$name);
01048                         fwrite($f,$this->buffer,strlen($this->buffer));
01049                         fclose($f);
01050                         break;
01051                 case 'S':
01052                         //Return as a string
01053                         return $this->buffer;
01054                 default:
01055                         $this->Error('Incorrect output destination: '.$dest);
01056         }
01057         return '';
01058 }

FPDF::PageNo (  ) 

Definition at line 376 of file fpdf.php.

00377 {
00378         //Get current page number
00379         return $this->page;
00380 }

FPDF::Rect ( x,
y,
w,
h,
style = '' 
)

Definition at line 441 of file fpdf.php.

00442 {
00443         //Draw a rectangle
00444         if($style=='F')
00445                 $op='f';
00446         elseif($style=='FD' || $style=='DF')
00447                 $op='B';
00448         else
00449                 $op='S';
00450         $this->_out(sprintf('%.2F %.2F %.2F %.2F re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op));
00451 }

FPDF::SetAuthor ( author,
isUTF8 = false 
)

Definition at line 238 of file fpdf.php.

00239 {
00240         //Author of document
00241         if($isUTF8)
00242                 $author=$this->_UTF8toUTF16($author);
00243         $this->author=$author;
00244 }

FPDF::SetAutoPageBreak ( auto,
margin = 0 
)

Definition at line 192 of file fpdf.php.

Referenced by FPDF().

00193 {
00194         //Set auto page break mode and triggering margin
00195         $this->AutoPageBreak=$auto;
00196         $this->bMargin=$margin;
00197         $this->PageBreakTrigger=$this->h-$margin;
00198 }

FPDF::SetCompression ( compress  ) 

Definition at line 213 of file fpdf.php.

Referenced by FPDF().

00214 {
00215         //Set page compression
00216         if(function_exists('gzcompress'))
00217                 $this->compress=$compress;
00218         else
00219                 $this->compress=false;
00220 }

FPDF::SetCreator ( creator,
isUTF8 = false 
)

Definition at line 254 of file fpdf.php.

00255 {
00256         //Creator of document
00257         if($isUTF8)
00258                 $creator=$this->_UTF8toUTF16($creator);
00259         $this->creator=$creator;
00260 }

FPDF::SetDisplayMode ( zoom,
layout = 'continuous' 
)

Definition at line 200 of file fpdf.php.

Referenced by FPDF().

00201 {
00202         //Set display mode in viewer
00203         if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom))
00204                 $this->ZoomMode=$zoom;
00205         else
00206                 $this->Error('Incorrect zoom display mode: '.$zoom);
00207         if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default')
00208                 $this->LayoutMode=$layout;
00209         else
00210                 $this->Error('Incorrect layout display mode: '.$layout);
00211 }

FPDF::SetDrawColor ( r,
g = null,
b = null 
)

Definition at line 382 of file fpdf.php.

00383 {
00384         //Set color for all stroking operations
00385         if(($r==0 && $g==0 && $b==0) || $g===null)
00386                 $this->DrawColor=sprintf('%.3F G',$r/255);
00387         else
00388                 $this->DrawColor=sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255);
00389         if($this->page>0)
00390                 $this->_out($this->DrawColor);
00391 }

FPDF::SetFillColor ( r,
g = null,
b = null 
)

Definition at line 393 of file fpdf.php.

Referenced by PDF_label::Footer(), and PDF::Footer().

00394 {
00395         //Set color for all filling operations
00396         if(($r==0 && $g==0 && $b==0) || $g===null)
00397                 $this->FillColor=sprintf('%.3F g',$r/255);
00398         else
00399                 $this->FillColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
00400         $this->ColorFlag=($this->FillColor!=$this->TextColor);
00401         if($this->page>0)
00402                 $this->_out($this->FillColor);
00403 }

FPDF::SetFont ( family,
style = '',
size = 0 
)

Definition at line 501 of file fpdf.php.

Referenced by AddPage(), PDF_label::Footer(), PDF::Footer(), and PDF::Header().

00502 {
00503         //Select a font; size given in points
00504         global $fpdf_charwidths;
00505 
00506         $family=strtolower($family);
00507         if($family=='')
00508                 $family=$this->FontFamily;
00509         if($family=='arial')
00510                 $family='helvetica';
00511         elseif($family=='symbol' || $family=='zapfdingbats')
00512                 $style='';
00513         $style=strtoupper($style);
00514         if(strpos($style,'U')!==false)
00515         {
00516                 $this->underline=true;
00517                 $style=str_replace('U','',$style);
00518         }
00519         else
00520                 $this->underline=false;
00521         if($style=='IB')
00522                 $style='BI';
00523         if($size==0)
00524                 $size=$this->FontSizePt;
00525         //Test if font is already selected
00526         if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size)
00527                 return;
00528         //Test if used for the first time
00529         $fontkey=$family.$style;
00530         if(!isset($this->fonts[$fontkey]))
00531         {
00532                 //Check if one of the standard fonts
00533                 if(isset($this->CoreFonts[$fontkey]))
00534                 {
00535                         if(!isset($fpdf_charwidths[$fontkey]))
00536                         {
00537                                 //Load metric file
00538                                 $file=$family;
00539                                 if($family=='times' || $family=='helvetica')
00540                                         $file.=strtolower($style);
00541                                 include($this->_getfontpath().$file.'.php');
00542                                 if(!isset($fpdf_charwidths[$fontkey]))
00543                                         $this->Error('Could not include font metric file');
00544                         }
00545                         $i=count($this->fonts)+1;
00546                         $name=$this->CoreFonts[$fontkey];
00547                         $cw=$fpdf_charwidths[$fontkey];
00548                         $this->fonts[$fontkey]=array('i'=>$i, 'type'=>'core', 'name'=>$name, 'up'=>-100, 'ut'=>50, 'cw'=>$cw);
00549                 }
00550                 else
00551                         $this->Error('Undefined font: '.$family.' '.$style);
00552         }
00553         //Select it
00554         $this->FontFamily=$family;
00555         $this->FontStyle=$style;
00556         $this->FontSizePt=$size;
00557         $this->FontSize=$size/$this->k;
00558         $this->CurrentFont=&$this->fonts[$fontkey];
00559         if($this->page>0)
00560                 $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
00561 }

FPDF::SetFontSize ( size  ) 

Definition at line 563 of file fpdf.php.

00564 {
00565         //Set font size in points
00566         if($this->FontSizePt==$size)
00567                 return;
00568         $this->FontSizePt=$size;
00569         $this->FontSize=$size/$this->k;
00570         if($this->page>0)
00571                 $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
00572 }

FPDF::SetKeywords ( keywords,
isUTF8 = false 
)

Definition at line 246 of file fpdf.php.

00247 {
00248         //Keywords of document
00249         if($isUTF8)
00250                 $keywords=$this->_UTF8toUTF16($keywords);
00251         $this->keywords=$keywords;
00252 }

FPDF::SetLeftMargin ( margin  ) 

Definition at line 172 of file fpdf.php.

00173 {
00174         //Set left margin
00175         $this->lMargin=$margin;
00176         if($this->page>0 && $this->x<$margin)
00177                 $this->x=$margin;
00178 }

FPDF::SetLineWidth ( width  ) 

Definition at line 427 of file fpdf.php.

00428 {
00429         //Set line width
00430         $this->LineWidth=$width;
00431         if($this->page>0)
00432                 $this->_out(sprintf('%.2F w',$width*$this->k));
00433 }

FPDF::SetLink ( link,
y = 0,
page = -1 
)

Definition at line 582 of file fpdf.php.

00583 {
00584         //Set destination of internal link
00585         if($y==-1)
00586                 $y=$this->y;
00587         if($page==-1)
00588                 $page=$this->page;
00589         $this->links[$link]=array($page, $y);
00590 }

FPDF::SetMargins ( left,
top,
right = null 
)

Definition at line 162 of file fpdf.php.

Referenced by FPDF().

00163 {
00164         //Set left, top and right margins
00165         $this->lMargin=$left;
00166         $this->tMargin=$top;
00167         if($right===null)
00168                 $right=$left;
00169         $this->rMargin=$right;
00170 }

FPDF::SetRightMargin ( margin  ) 

Definition at line 186 of file fpdf.php.

00187 {
00188         //Set right margin
00189         $this->rMargin=$margin;
00190 }

FPDF::SetSubject ( subject,
isUTF8 = false 
)

Definition at line 230 of file fpdf.php.

00231 {
00232         //Subject of document
00233         if($isUTF8)
00234                 $subject=$this->_UTF8toUTF16($subject);
00235         $this->subject=$subject;
00236 }

FPDF::SetTextColor ( r,
g = null,
b = null 
)

Definition at line 405 of file fpdf.php.

Referenced by PDF::Header(), and PDF::PutLink().

00406 {
00407         //Set color for text
00408         if(($r==0 && $g==0 && $b==0) || $g===null)
00409                 $this->TextColor=sprintf('%.3F g',$r/255);
00410         else
00411                 $this->TextColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
00412         $this->ColorFlag=($this->FillColor!=$this->TextColor);
00413 }

FPDF::SetTitle ( title,
isUTF8 = false 
)

Definition at line 222 of file fpdf.php.

00223 {
00224         //Title of document
00225         if($isUTF8)
00226                 $title=$this->_UTF8toUTF16($title);
00227         $this->title=$title;
00228 }

FPDF::SetTopMargin ( margin  ) 

Definition at line 180 of file fpdf.php.

00181 {
00182         //Set top margin
00183         $this->tMargin=$margin;
00184 }

FPDF::SetX ( x  ) 

Definition at line 961 of file fpdf.php.

Referenced by PDF_label::Footer(), PDF::Footer(), PDF::Header(), and SetXY().

00962 {
00963         //Set x position
00964         if($x>=0)
00965                 $this->x=$x;
00966         else
00967                 $this->x=$this->w+$x;
00968 }

FPDF::SetXY ( x,
y 
)

Definition at line 986 of file fpdf.php.

00987 {
00988         //Set x and y positions
00989         $this->SetY($y);
00990         $this->SetX($x);
00991 }

FPDF::SetY ( y  ) 

Definition at line 976 of file fpdf.php.

Referenced by PDF_label::Footer(), PDF::Footer(), PDF::Header(), and SetXY().

00977 {
00978         //Set y position and reset x
00979         $this->x=$this->lMargin;
00980         if($y>=0)
00981                 $this->y=$y;
00982         else
00983                 $this->y=$this->h+$y;
00984 }

FPDF::Text ( x,
y,
txt 
)

Definition at line 598 of file fpdf.php.

00599 {
00600         //Output a string
00601         $s=sprintf('BT %.2F %.2F Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt));
00602         if($this->underline && $txt!='')
00603                 $s.=' '.$this->_dounderline($x,$y,$txt);
00604         if($this->ColorFlag)
00605                 $s='q '.$this->TextColor.' '.$s.' Q';
00606         $this->_out($s);
00607 }

FPDF::Write ( h,
txt,
link = '' 
)

Definition at line 807 of file fpdf.php.

Referenced by PDF::PutLink(), and PDF::WriteHTML().

00808 {
00809         //Output text in flowing mode
00810         $cw=&$this->CurrentFont['cw'];
00811         $w=$this->w-$this->rMargin-$this->x;
00812         $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
00813         $s=str_replace("\r",'',$txt);
00814         $nb=strlen($s);
00815         $sep=-1;
00816         $i=0;
00817         $j=0;
00818         $l=0;
00819         $nl=1;
00820         while($i<$nb)
00821         {
00822                 //Get next character
00823                 $c=$s[$i];
00824                 if($c=="\n")
00825                 {
00826                         //Explicit line break
00827                         $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
00828                         $i++;
00829                         $sep=-1;
00830                         $j=$i;
00831                         $l=0;
00832                         if($nl==1)
00833                         {
00834                                 $this->x=$this->lMargin;
00835                                 $w=$this->w-$this->rMargin-$this->x;
00836                                 $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
00837                         }
00838                         $nl++;
00839                         continue;
00840                 }
00841                 if($c==' ')
00842                         $sep=$i;
00843                 $l+=$cw[$c];
00844                 if($l>$wmax)
00845                 {
00846                         //Automatic line break
00847                         if($sep==-1)
00848                         {
00849                                 if($this->x>$this->lMargin)
00850                                 {
00851                                         //Move to next line
00852                                         $this->x=$this->lMargin;
00853                                         $this->y+=$h;
00854                                         $w=$this->w-$this->rMargin-$this->x;
00855                                         $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
00856                                         $i++;
00857                                         $nl++;
00858                                         continue;
00859                                 }
00860                                 if($i==$j)
00861                                         $i++;
00862                                 $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
00863                         }
00864                         else
00865                         {
00866                                 $this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',0,$link);
00867                                 $i=$sep+1;
00868                         }
00869                         $sep=-1;
00870                         $j=$i;
00871                         $l=0;
00872                         if($nl==1)
00873                         {
00874                                 $this->x=$this->lMargin;
00875                                 $w=$this->w-$this->rMargin-$this->x;
00876                                 $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
00877                         }
00878                         $nl++;
00879                 }
00880                 else
00881                         $i++;
00882         }
00883         //Last chunk
00884         if($i!=$j)
00885                 $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',0,$link);
00886 }


Member Data Documentation

FPDF::$AliasNbPages

Definition at line 67 of file fpdf.php.

FPDF::$author

Definition at line 64 of file fpdf.php.

Referenced by SetAuthor().

FPDF::$AutoPageBreak

Definition at line 56 of file fpdf.php.

FPDF::$bMargin

Definition at line 33 of file fpdf.php.

FPDF::$buffer

Definition at line 17 of file fpdf.php.

FPDF::$cMargin

Definition at line 34 of file fpdf.php.

FPDF::$ColorFlag

Definition at line 51 of file fpdf.php.

FPDF::$compress

Definition at line 20 of file fpdf.php.

Referenced by SetCompression().

FPDF::$CoreFonts

Definition at line 38 of file fpdf.php.

FPDF::$creator

Definition at line 66 of file fpdf.php.

Referenced by SetCreator().

FPDF::$CurOrientation

Definition at line 23 of file fpdf.php.

FPDF::$CurPageFormat

Definition at line 26 of file fpdf.php.

FPDF::$CurrentFont

Definition at line 45 of file fpdf.php.

FPDF::$DefOrientation

Definition at line 22 of file fpdf.php.

FPDF::$DefPageFormat

Definition at line 25 of file fpdf.php.

FPDF::$diffs

Definition at line 41 of file fpdf.php.

FPDF::$DrawColor

Definition at line 48 of file fpdf.php.

FPDF::$FillColor

Definition at line 49 of file fpdf.php.

FPDF::$FontFamily

Definition at line 42 of file fpdf.php.

FPDF::$FontFiles

Definition at line 40 of file fpdf.php.

FPDF::$fonts

Definition at line 39 of file fpdf.php.

FPDF::$FontSize

Definition at line 47 of file fpdf.php.

FPDF::$FontSizePt

Definition at line 46 of file fpdf.php.

FPDF::$FontStyle

Definition at line 43 of file fpdf.php.

FPDF::$hPt

Definition at line 28 of file fpdf.php.

FPDF::$images

Definition at line 53 of file fpdf.php.

FPDF::$InFooter

Definition at line 59 of file fpdf.php.

FPDF::$InHeader

Definition at line 58 of file fpdf.php.

FPDF::$k

Definition at line 21 of file fpdf.php.

Referenced by Cell(), PDF_label::RoundedRect(), and PDF::RoundedRect().

FPDF::$keywords

Definition at line 65 of file fpdf.php.

Referenced by SetKeywords().

FPDF::$lasth

Definition at line 36 of file fpdf.php.

FPDF::$LayoutMode

Definition at line 61 of file fpdf.php.

FPDF::$LineWidth

Definition at line 37 of file fpdf.php.

FPDF::$links

Definition at line 55 of file fpdf.php.

FPDF::$lMargin

Definition at line 30 of file fpdf.php.

FPDF::$n

Definition at line 15 of file fpdf.php.

Referenced by _parsepng(), and AddLink().

FPDF::$offsets

Definition at line 16 of file fpdf.php.

FPDF::$page

Definition at line 14 of file fpdf.php.

Referenced by SetLink().

FPDF::$PageBreakTrigger

Definition at line 57 of file fpdf.php.

FPDF::$PageFormats

Definition at line 24 of file fpdf.php.

FPDF::$PageLinks

Definition at line 54 of file fpdf.php.

FPDF::$pages

Definition at line 18 of file fpdf.php.

FPDF::$PageSizes

Definition at line 27 of file fpdf.php.

FPDF::$PDFVersion

Definition at line 68 of file fpdf.php.

FPDF::$rMargin

Definition at line 32 of file fpdf.php.

FPDF::$state

Definition at line 19 of file fpdf.php.

FPDF::$subject

Definition at line 63 of file fpdf.php.

Referenced by SetSubject().

FPDF::$TextColor

Definition at line 50 of file fpdf.php.

FPDF::$title

Definition at line 62 of file fpdf.php.

Referenced by SetTitle().

FPDF::$tMargin

Definition at line 31 of file fpdf.php.

FPDF::$underline

Definition at line 44 of file fpdf.php.

FPDF::$wPt

Definition at line 28 of file fpdf.php.

FPDF::$ws

Definition at line 52 of file fpdf.php.

Referenced by Cell().

FPDF::$x
FPDF::$ZoomMode

Definition at line 60 of file fpdf.php.


The documentation for this class was generated from the following file: