Source for file class.FPDF.php

Documentation is available at class.FPDF.php

  1. <?php
  2.  
  3. /**
  4.  * Erstellt PDF-Dokumente
  5.  *
  6.  * @author Olivier PLATHEY
  7.  * @package src
  8.  * @subpackage pdf
  9.  * @version 1.52
  10.  */
  11.  
  12. if (version_compare(PHP_VERSION'5')) {
  13.    die('This file was generated for PHP 5');
  14. }
  15.  
  16. /**
  17. *  @staticvar string Versionsnummer
  18. */
  19. define('FPDF_VERSION''1.53');
  20. /**
  21.  * src_pdf_FPDF
  22.  *
  23.  * @package src
  24.  * @subpackage pdf
  25.  * @author Olivier PLATHEY
  26.  * @copyright Copyright (c) 2005
  27.  * @version 1.52
  28.  * @access public
  29.  ***/
  30. class src_pdf_FPDF {
  31.    // --- ATTRIBUTES ---
  32.    // Private properties
  33.       protected $page//current page number
  34.       protected $n//current object number
  35.       protected $offsets//array of object offsets
  36.       protected $buffer//buffer holding in-memory PDF
  37.       protected $pages//array containing pages
  38.       protected $state//current document state
  39.       protected $compress//compression flag
  40.       protected $DefOrientation//default orientation
  41.       protected $CurOrientation//current orientation
  42.       protected $OrientationChanges//array indicating orientation changes
  43.       protected $k//scale factor (number of points in user unit)
  44.       protected $fwPt$fhPt//dimensions of page format in points
  45.       protected $fw$fh//dimensions of page format in user unit
  46.       protected $wPt$hPt//current dimensions of page in points
  47.       protected $w$h//current dimensions of page in user unit
  48.       protected $lMargin//left margin
  49.       protected $tMargin//top margin
  50.       protected $rMargin//right margin
  51.       protected $bMargin//page break margin
  52.       protected $cMargin//cell margin
  53.       protected $x$y//current position in user unit for cell positioning
  54.       protected $lasth//height of last cell printed
  55.       protected $LineWidth//line width in user unit
  56.       protected $CoreFonts//array of standard font names
  57.       protected $fonts//array of used fonts
  58.       protected $FontFiles//array of font files
  59.       protected $diffs//array of encoding differences
  60.       protected $images//array of used images
  61.       protected $PageLinks//array of links in pages
  62.       protected $links//array of internal links
  63.       protected $FontFamily//current font family
  64.       protected $FontStyle//current font style
  65.       protected $underline//underlining flag
  66.       protected $CurrentFont//current font info
  67.       public $FontSizePt//current font size in points
  68.       public $FontSize//current font size in user unit
  69.       protected $DrawColor//commands for drawing color
  70.       protected $FillColor//commands for filling color
  71.       protected $TextColor//commands for text color
  72.       protected $ColorFlag//indicates whether fill and text colors are different
  73.       protected $ws//word spacing
  74.       protected $AutoPageBreak//automatic page breaking
  75.       public $PageBreakTrigger//threshold used to trigger page breaks
  76.       protected $InFooter//flag set when processing footer
  77.       protected $ZoomMode//zoom display mode
  78.       protected $LayoutMode//layout display mode
  79.       protected $title//title
  80.       protected $subject//subject
  81.       protected $author//author
  82.       protected $keywords//keywords
  83.       protected $creator//creator
  84.       protected $AliasNbPages//alias for total number of pages
  85.       protected $PDFVersion//PDF version number
  86.  
  87.    // --- OPERATIONS ---
  88.       /**
  89.     * src_pdf_FPDF::__construct()
  90.     *
  91.     * @param string $orientation 
  92.     * @param string $unit 
  93.     * @param string $format 
  94.     * @return void 
  95.     ***/
  96.    public function __construct($orientation 'P'$unit 'mm'$format 'A4'{
  97.       // Some checks
  98.       $this->_dochecks();
  99.       // Initialization of properties
  100.       $this->page = 0;
  101.       $this->n = 2;
  102.       $this->buffer = '';
  103.       $this->pages = array ();
  104.       $this->OrientationChanges = array ();
  105.       $this->state = 0;
  106.       $this->fonts = array ();
  107.       $this->FontFiles = array ();
  108.       $this->diffs = array ();
  109.       $this->images = array ();
  110.       $this->links = array ();
  111.       $this->InFooter = false;
  112.       $this->lasth = 0;
  113.       $this->FontFamily = '';
  114.       $this->FontStyle = '';
  115.       $this->FontSizePt = 12;
  116.       $this->underline = false;
  117.       $this->DrawColor = '0 G';
  118.       $this->FillColor = '0 g';
  119.       $this->TextColor = '0 g';
  120.       $this->ColorFlag = false;
  121.       $this->ws = 0;
  122.       // Standard fonts
  123.       $this->CoreFonts = array (
  124.          'courier' => 'Courier',
  125.          'courierB' => 'Courier-Bold',
  126.          'courierI' => 'Courier-Oblique',
  127.          'courierBI' => 'Courier-BoldOblique',
  128.          'helvetica' => 'Helvetica',
  129.          'helveticaB' => 'Helvetica-Bold',
  130.          'helveticaI' => 'Helvetica-Oblique',
  131.          'helveticaBI' => 'Helvetica-BoldOblique',
  132.          'times' => 'Times-Roman',
  133.          'timesB' => 'Times-Bold',
  134.          'timesI' => 'Times-Italic',
  135.          'timesBI' => 'Times-BoldItalic',
  136.          'symbol' => 'Symbol',
  137.          'zapfdingbats' => 'ZapfDingbats'
  138.       );
  139.       // Scale factor
  140.       if ($unit == 'pt')
  141.          $this->k = 1;
  142.       elseif ($unit == 'mm'$this->k = 72 25.4;
  143.       elseif ($unit == 'cm'$this->k = 72 2.54;
  144.       elseif ($unit == 'in'$this->k = 72;
  145.       else
  146.          $this->Error('Incorrect unit: ' $unit);
  147.       // Page format
  148.       if (is_string($format)) {
  149.          $format strtolower($format);
  150.          if ($format == 'a3')
  151.             $format array (
  152.                841.89,
  153.                1190.55
  154.             );
  155.          elseif ($format == 'a4'$format array (
  156.             595.28,
  157.             841.89
  158.          );
  159.          elseif ($format == 'a5'$format array (
  160.             420.94,
  161.             595.28
  162.          );
  163.          elseif ($format == 'letter'$format array (
  164.             612,
  165.             792
  166.          );
  167.          elseif ($format == 'legal'$format array (
  168.             612,
  169.             1008
  170.          );
  171.          else
  172.             $this->Error('Unknown page format: ' $format);
  173.          $this->fwPt = $format[0];
  174.          $this->fhPt = $format[1];
  175.       else {
  176.          $this->fwPt = $format[0$this->k;
  177.          $this->fhPt = $format[1$this->k;
  178.       }
  179.       $this->fw = $this->fwPt / $this->k;
  180.       $this->fh = $this->fhPt / $this->k;
  181.       // Page orientation
  182.       $orientation strtolower($orientation);
  183.       if ($orientation == 'p' || $orientation == 'portrait'{
  184.          $this->DefOrientation = 'P';
  185.          $this->wPt = $this->fwPt;
  186.          $this->hPt = $this->fhPt;
  187.       }
  188.       elseif ($orientation == 'l' || $orientation == 'landscape'{
  189.          $this->DefOrientation = 'L';
  190.          $this->wPt = $this->fhPt;
  191.          $this->hPt = $this->fwPt;
  192.       else
  193.          $this->Error('Incorrect orientation: ' $orientation);
  194.       $this->CurOrientation = $this->DefOrientation;
  195.       $this->w = $this->wPt / $this->k;
  196.       $this->h = $this->hPt / $this->k;
  197.       // Page margins (1 cm)
  198.       $margin 28.35 $this->k;
  199.       $this->SetMargins($margin$margin);
  200.       // Interior cell margin (1 mm)
  201.       $this->cMargin = $margin 10;
  202.       // Line width (0.2 mm)
  203.       $this->LineWidth = .567 $this->k;
  204.       // Automatic page break
  205.       $this->SetAutoPageBreak(true$margin);
  206.       // Full width display mode
  207.       $this->SetDisplayMode('fullwidth');
  208.       // Enable compression
  209.       $this->SetCompression(true);
  210.       // Set default PDF version number
  211.       $this->PDFVersion = '1.3';
  212.    }
  213.  
  214.    /**
  215.     * src_pdf_FPDF::SetMargins()
  216.     *
  217.     * @param mixed $left 
  218.     * @param mixed $top 
  219.     * @param mixed $right 
  220.     * @return void 
  221.     ***/
  222.    public function SetMargins($left$top$right = -1{
  223.       // Set left, top and right margins
  224.       $this->lMargin = $left;
  225.       $this->tMargin = $top;
  226.       if ($right == -1)
  227.          $right $left;
  228.       $this->rMargin = $right;
  229.    }
  230.  
  231.    /**
  232.     * src_pdf_FPDF::SetLeftMargin()
  233.     *
  234.     * @param mixed $margin 
  235.     * @return void 
  236.     ***/
  237.    public function SetLeftMargin($margin{
  238.       // Set left margin
  239.       $this->lMargin = $margin;
  240.       if ($this->page > && $this->x < $margin)
  241.          $this->x = $margin;
  242.    }
  243.  
  244.    /**
  245.     * src_pdf_FPDF::SetTopMargin()
  246.     *
  247.     * @param mixed $margin 
  248.     * @return void 
  249.     ***/
  250.    public function SetTopMargin($margin{
  251.       // Set top margin
  252.       $this->tMargin = $margin;
  253.    }
  254.  
  255.    /**
  256.     * src_pdf_FPDF::SetRightMargin()
  257.     *
  258.     * @param mixed $margin 
  259.     * @return void 
  260.     ***/
  261.    public function SetRightMargin($margin{
  262.       // Set right margin
  263.       $this->rMargin = $margin;
  264.    }
  265.  
  266.    /**
  267.     * src_pdf_FPDF::SetAutoPageBreak()
  268.     *
  269.     * @param mixed $auto 
  270.     * @param integer $margin 
  271.     * @return void 
  272.     ***/
  273.    public function SetAutoPageBreak($auto$margin 0{
  274.       // Set auto page break mode and triggering margin
  275.       $this->AutoPageBreak = $auto;
  276.       $this->bMargin = $margin;
  277.       $this->PageBreakTrigger = $this->h - $margin;
  278.    }
  279.  
  280.    /**
  281.     * src_pdf_FPDF::SetDisplayMode()
  282.     *
  283.     * @param mixed $zoom 
  284.     * @param string $layout 
  285.     * @return void 
  286.     ***/
  287.    public function SetDisplayMode($zoom$layout 'continuous'{
  288.       // Set display mode in viewer
  289.       if ($zoom == 'fullpage' || $zoom == 'fullwidth' || $zoom == 'real' || $zoom == 'default' || !is_string($zoom))
  290.          $this->ZoomMode = $zoom;
  291.       else
  292.          $this->Error('Incorrect zoom display mode: ' $zoom);
  293.       if ($layout == 'single' || $layout == 'continuous' || $layout == 'two' || $layout == 'default')
  294.          $this->LayoutMode = $layout;
  295.       else
  296.          $this->Error('Incorrect layout display mode: ' $layout);
  297.    }
  298.  
  299.    /**
  300.     * src_pdf_FPDF::SetCompression()
  301.     *
  302.     * @param mixed $compress 
  303.     * @return void 
  304.     ***/
  305.    public function SetCompression($compress{
  306.       // Set page compression
  307.       if (function_exists('gzcompress'))
  308.          $this->compress = $compress;
  309.       else
  310.          $this->compress = false;
  311.    }
  312.  
  313.    /**
  314.     * src_pdf_FPDF::SetTitle()
  315.     *
  316.     * @param mixed $title 
  317.     * @return void 
  318.     ***/
  319.    public function SetTitle($title{
  320.       // Title of document
  321.       $this->title = $title;
  322.    }
  323.  
  324.    /**
  325.     * src_pdf_FPDF::SetSubject()
  326.     *
  327.     * @param mixed $subject 
  328.     * @return void 
  329.     ***/
  330.    public function SetSubject($subject{
  331.       // Subject of document
  332.       $this->subject = $subject;
  333.    }
  334.  
  335.    /**
  336.     * src_pdf_FPDF::SetAuthor()
  337.     *
  338.     * @return void 
  339.     ***/
  340.    public function SetAuthor($author{
  341.       // Author of document
  342.       $this->author = $author;
  343.    }
  344.  
  345.    /**
  346.     * src_pdf_FPDF::SetKeywords()
  347.     *
  348.     * @param mixed $keywords 
  349.     * @return void 
  350.     ***/
  351.    public function SetKeywords($keywords{
  352.       // Keywords of document
  353.       $this->keywords = $keywords;
  354.    }
  355.  
  356.    /**
  357.     * src_pdf_FPDF::SetCreator()
  358.     *
  359.     * @param mixed $creator 
  360.     * @return void 
  361.     ***/
  362.    public function SetCreator($creator{
  363.       // Creator of document
  364.       $this->creator = $creator;
  365.    }
  366.  
  367.    /**
  368.     * src_pdf_FPDF::AliasNbPages()
  369.     *
  370.     * @param string $alias 
  371.     * @return void 
  372.     ***/
  373.    public function AliasNbPages($alias '{nb}'{
  374.       // Define an alias for total number of pages
  375.       $this->AliasNbPages = $alias;
  376.    }
  377.  
  378.    /**
  379.     * src_pdf_FPDF::Error()
  380.     *
  381.     * @param mixed $msg 
  382.     * @return void 
  383.     ***/
  384.    public function Error($msg{
  385.       // Fatal error
  386.       die('<B>FPDF error: </B>' $msg);
  387.    }
  388.  
  389.    /**
  390.     * src_pdf_FPDF::Open()
  391.     *
  392.     * @return void 
  393.     ***/
  394.    public function Open({
  395.       // Begin document
  396.       $this->state = 1;
  397.    }
  398.  
  399.    /**
  400.     * src_pdf_FPDF::Close()
  401.     *
  402.     * @return void 
  403.     ***/
  404.    public function Close({
  405.       // Terminate document
  406.       if ($this->state == 3)
  407.          return;
  408.       if ($this->page == 0)
  409.          $this->AddPage();
  410.       // Page footer
  411.       $this->InFooter = true;
  412.       $this->Footer();
  413.       $this->InFooter = false;
  414.       // Close page
  415.       $this->_endpage();
  416.       // Close document
  417.       $this->_enddoc();
  418.    }
  419.  
  420.    /**
  421.     * src_pdf_FPDF::AddPage()
  422.     *
  423.     * @param string $orientation 
  424.     * @return void 
  425.     ***/
  426.    public function AddPage($orientation ''{
  427.       // Start a new page
  428.       if ($this->state == 0)
  429.          $this->Open();
  430.       $family $this->FontFamily;
  431.       $style $this->FontStyle . ($this->underline ? 'U' '');
  432.       $size $this->FontSizePt;
  433.       $lw $this->LineWidth;
  434.       $dc $this->DrawColor;
  435.       $fc $this->FillColor;
  436.       $tc $this->TextColor;
  437.       $cf $this->ColorFlag;
  438.       if ($this->page > 0{
  439.          // Page footer
  440.          $this->InFooter = true;
  441.          $this->Footer();
  442.          $this->InFooter = false;
  443.          // Close page
  444.          $this->_endpage();
  445.       }
  446.       // Start new page
  447.       $this->_beginpage($orientation);
  448.       // Set line cap style to square
  449.       $this->_out('2 J');
  450.       // Set line width
  451.       $this->LineWidth = $lw;
  452.       $this->_out(sprintf('%.2f w'$lw $this->k));
  453.       // Set font
  454.       if ($family)
  455.          $this->SetFont($family$style$size);
  456.       // Set colors
  457.       $this->DrawColor = $dc;
  458.       if ($dc != '0 G')
  459.          $this->_out($dc);
  460.       $this->FillColor = $fc;
  461.       if ($fc != '0 g')
  462.          $this->_out($fc);
  463.       $this->TextColor = $tc;
  464.       $this->ColorFlag = $cf;
  465.       // Page header
  466.       $this->Header();
  467.       // Restore line width
  468.       if ($this->LineWidth != $lw{
  469.          $this->LineWidth = $lw;
  470.          $this->_out(sprintf('%.2f w'$lw $this->k));
  471.       }
  472.       // Restore font
  473.       if ($family)
  474.          $this->SetFont($family$style$size);
  475.       // Restore colors
  476.       if ($this->DrawColor != $dc{
  477.          $this->DrawColor = $dc;
  478.          $this->_out($dc);
  479.       }
  480.       if ($this->FillColor != $fc{
  481.          $this->FillColor = $fc;
  482.          $this->_out($fc);
  483.       }
  484.       $this->TextColor = $tc;
  485.       $this->ColorFlag = $cf;
  486.    }
  487.  
  488.    /**
  489.     * src_pdf_FPDF::Header()
  490.     *
  491.     * @return void 
  492.     ***/
  493.    public function Header({
  494.       // To be implemented in your own inherited class
  495.    }
  496.  
  497.    /**
  498.     * src_pdf_FPDF::Footer()
  499.     *
  500.     * @return void 
  501.     ***/
  502.    public function Footer({
  503.       // To be implemented in your own inherited class
  504.    }
  505.  
  506.    /**
  507.     * src_pdf_FPDF::PageNo()
  508.     *
  509.     * @return int 
  510.     ***/
  511.    public function PageNo({
  512.       // Get current page number
  513.       return $this->page;
  514.    }
  515.  
  516.    /**
  517.     * src_pdf_FPDF::SetDrawColor()
  518.     *
  519.     * @param mixed $r 
  520.     * @param mixed $g 
  521.     * @param mixed $b 
  522.     * @return void 
  523.     ***/
  524.    public function SetDrawColor($r$g = -1$b = -1{
  525.       // Set color for all stroking operations
  526.       if (($r == && $g == && $b == 0|| $g == -1)
  527.          $this->DrawColor = sprintf('%.3f G'$r 255);
  528.       else
  529.          $this->DrawColor = sprintf('%.3f %.3f %.3f RG'$r 255$g 255$b 255);
  530.       if ($this->page > 0)
  531.          $this->_out($this->DrawColor);
  532.    }
  533.  
  534.    /**
  535.     * src_pdf_FPDF::SetFillColor()
  536.     *
  537.     * @param mixed $r 
  538.     * @param mixed $g 
  539.     * @param mixed $b 
  540.     * @return void 
  541.     ***/
  542.    public function SetFillColor($r$g = -1$b = -1{
  543.       // Set color for all filling operations
  544.       if (($r == && $g == && $b == 0|| $g == -1)
  545.          $this->FillColor = sprintf('%.3f g'$r 255);
  546.       else
  547.          $this->FillColor = sprintf('%.3f %.3f %.3f rg'$r 255$g 255$b 255);
  548.       $this->ColorFlag = ($this->FillColor != $this->TextColor);
  549.       if ($this->page > 0)
  550.          $this->_out($this->FillColor);
  551.    }
  552.  
  553.    /**
  554.     * src_pdf_FPDF::SetTextColor()
  555.     *
  556.     * @param mixed $r 
  557.     * @param mixed $g 
  558.     * @param mixed $b 
  559.     * @return void 
  560.     ***/
  561.    public function SetTextColor($r$g = -1$b = -1{
  562.       // Set color for text
  563.       if (($r == && $g == && $b == 0|| $g == -1)
  564.          $this->TextColor = sprintf('%.3f g'$r 255);
  565.       else
  566.          $this->TextColor = sprintf('%.3f %.3f %.3f rg'$r 255$g 255$b 255);
  567.       $this->ColorFlag = ($this->FillColor != $this->TextColor);
  568.    }
  569.  
  570.    /**
  571.     * src_pdf_FPDF::GetStringWidth()
  572.     *
  573.     * @param mixed $s 
  574.     * @return int 
  575.     ***/
  576.    public function GetStringWidth($s{
  577.       // Get width of a string in the current font
  578.       $s = (string) $s;
  579.       $cw $this->CurrentFont['cw'];
  580.       $w 0;
  581.       $l strlen($s);
  582.       for ($i 0$i $l$i++)
  583.          $w += $cw[$s {
  584.          $i }
  585.       ];
  586.       return $w $this->FontSize / 1000;
  587.    }
  588.  
  589.    /**
  590.     * src_pdf_FPDF::SetLineWidth()
  591.     *
  592.     * @param mixed $width 
  593.     * @return void 
  594.     ***/
  595.    public function SetLineWidth($width{
  596.       // Set line width
  597.       $this->LineWidth = $width;
  598.       if ($this->page > 0)
  599.          $this->_out(sprintf('%.2f w'$width $this->k));
  600.    }
  601.  
  602.    /**
  603.     * src_pdf_FPDF::Line()
  604.     *
  605.     * @param mixed $x1 
  606.     * @param mixed $y1 
  607.     * @param mixed $x2 
  608.     * @param mixed $y2 
  609.     * @return void 
  610.     ***/
  611.    public function Line($x1$y1$x2$y2{
  612.       // Draw a line
  613.       $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));
  614.    }
  615.  
  616.    /**
  617.     * src_pdf_FPDF::Rect()
  618.     *
  619.     * @param mixed $x 
  620.     * @param mixed $y 
  621.     * @param mixed $w 
  622.     * @param mixed $h 
  623.     * @param string $style 
  624.     * @return void 
  625.     ***/
  626.    public function Rect($x$y$w$h$style ''{
  627.       // Draw a rectangle
  628.       if ($style == 'F')
  629.          $op 'f';
  630.       elseif ($style == 'FD' || $style == 'DF'$op 'B';
  631.       else
  632.          $op 'S';
  633.       $this->_out(sprintf('%.2f %.2f %.2f %.2f re %s'$x $this->k($this->h - $y$this->k$w $this->k$h $this->k$op));
  634.    }
  635.  
  636.    /**
  637.     * src_pdf_FPDF::AddFont()
  638.     *
  639.     * @param mixed $family 
  640.     * @param string $style 
  641.     * @param string $file 
  642.     * @return void 
  643.     ***/
  644.    public function AddFont($family$style ''$file ''{
  645.       /**
  646.        * nicht initilisierte Variablen
  647.       $type="";
  648.       $desc="";
  649.       $up="";
  650.       $ut="";
  651.       $diff="";
  652.       $cw="";
  653.       $enc="";
  654.       $originalsize="";
  655.       $size1="";
  656.       $size2="";
  657.       */
  658.       // Add a TrueType or Type1 font
  659.       $family strtolower($family);
  660.       if ($file == '')
  661.          $file str_replace(' '''$familystrtolower($style'.php';
  662.       if ($family == 'arial')
  663.          $family 'helvetica';
  664.       $style strtoupper($style);
  665.       if ($style == 'IB')
  666.          $style 'BI';
  667.       $fontkey $family $style;
  668.       if (isset ($this->fonts[$fontkey]))
  669.          $this->Error('Font already added: ' $family ' ' $style);
  670.       include ($this->_getfontpath($file);
  671.       if (!isset ($name))
  672.          $this->Error('Could not include font definition file');
  673.       $i count($this->fonts1;
  674.       $this->fonts[$fontkeyarray (
  675.          'i' => $i,
  676.          'type' => $type,
  677.          'name' => $name,
  678.          'desc' => $desc,
  679.          'up' => $up,
  680.          'ut' => $ut,
  681.          'cw' => $cw,
  682.          'enc' => $enc,
  683.          'file' => $file
  684.       );
  685.       if ($diff{
  686.          // Search existing encodings
  687.          $d 0;
  688.          $nb count($this->diffs);
  689.          for ($i 1$i <= $nb$i++{
  690.             if ($this->diffs[$i== $diff{
  691.                $d $i;
  692.                break;
  693.             }
  694.          }
  695.          if ($d == 0{
  696.             $d $nb +1;
  697.             $this->diffs[$d$diff;
  698.          }
  699.          $this->fonts[$fontkey]['diff'$d;
  700.       }
  701.       if ($file{
  702.          if ($type == 'TrueType')
  703.             $this->FontFiles[$filearray (
  704.                'length1' => $originalsize
  705.             );
  706.          else
  707.             $this->FontFiles[$filearray (
  708.                'length1' => $size1,
  709.                'length2' => $size2
  710.             );
  711.       }
  712.    }
  713.  
  714.    /**
  715.     * src_pdf_FPDF::SetFont()
  716.     *
  717.     * @param mixed $family 
  718.     * @param string $style 
  719.     * @param integer $size 
  720.     * @return void 
  721.     ***/
  722.    public function SetFont($family$style ''$size 0{
  723.       // Select a font; size given in points
  724.       global $fpdf_charwidths;
  725.  
  726.       $family strtolower($family);
  727.       if ($family == '')
  728.          $family $this->FontFamily;
  729.       if ($family == 'arial')
  730.          $family 'helvetica';
  731.       elseif ($family == 'symbol' || $family == 'zapfdingbats'$style '';
  732.       $style strtoupper($style);
  733.       if (strpos($style'U'!== false{
  734.          $this->underline = true;
  735.          $style str_replace('U'''$style);
  736.       else
  737.          $this->underline = false;
  738.       if ($style == 'IB')
  739.          $style 'BI';
  740.       if ($size == 0)
  741.          $size $this->FontSizePt;
  742.       // Test if font is already selected
  743.       if ($this->FontFamily == $family && $this->FontStyle == $style && $this->FontSizePt == $size)
  744.          return;
  745.       // Test if used for the first time
  746.       $fontkey $family $style;
  747.       if (!isset ($this->fonts[$fontkey])) {
  748.          // Check if one of the standard fonts
  749.          if (isset ($this->CoreFonts[$fontkey])) {
  750.             if (!isset ($fpdf_charwidths[$fontkey])) {
  751.                // Load metric file
  752.                $file $family;
  753.                if ($family == 'times' || $family == 'helvetica')
  754.                   $file .= strtolower($style);
  755.                include ($this->_getfontpath($file '.php');
  756.                if (!isset ($fpdf_charwidths[$fontkey]))
  757.                   $this->Error('Could not include font metric file');
  758.             }
  759.             $i count($this->fonts1;
  760.             $this->fonts[$fontkeyarray (
  761.                'i' => $i,
  762.                'type' => 'core',
  763.                'name' => $this->CoreFonts[$fontkey],
  764.                'up' => -100,
  765.                'ut' => 50,
  766.                'cw' => $fpdf_charwidths[$fontkey]
  767.             );
  768.          else
  769.             $this->Error('Undefined font: ' $family ' ' $style);
  770.       }
  771.       // Select it
  772.       $this->FontFamily = $family;
  773.       $this->FontStyle = $style;
  774.       $this->FontSizePt = $size;
  775.       $this->FontSize = $size $this->k;
  776.       $this->CurrentFont = $this->fonts[$fontkey];
  777.       if ($this->page > 0)
  778.          $this->_out(sprintf('BT /F%d %.2f Tf ET'$this->CurrentFont['i']$this->FontSizePt));
  779.    }
  780.  
  781.    /**
  782.     * src_pdf_FPDF::SetFontSize()
  783.     *
  784.     * @param mixed $size 
  785.     * @return void 
  786.     ***/
  787.    public function SetFontSize($size{
  788.       // Set font size in points
  789.       if ($this->FontSizePt == $size)
  790.          return;
  791.       $this->FontSizePt = $size;
  792.       $this->FontSize = $size $this->k;
  793.       if ($this->page > 0)
  794.          $this->_out(sprintf('BT /F%d %.2f Tf ET'$this->CurrentFont['i']$this->FontSizePt));
  795.    }
  796.  
  797.    /**
  798.     * src_pdf_FPDF::AddLink()
  799.     *
  800.     * @return int 
  801.     ***/
  802.    public function AddLink({
  803.       // Create a new internal link
  804.       $n count($this->links1;
  805.       $this->links[$narray (
  806.          0,
  807.          0
  808.       );
  809.       return $n;
  810.    }
  811.  
  812.    /**
  813.     * src_pdf_FPDF::SetLink()
  814.     *
  815.     * @param mixed $link 
  816.     * @param integer $y 
  817.     * @param mixed $page 
  818.     * @return void 
  819.     ***/
  820.    public function SetLink($link$y 0$page = -1{
  821.       // Set destination of internal link
  822.       if ($y == -1)
  823.          $y $this->y;
  824.       if ($page == -1)
  825.          $page $this->page;
  826.       $this->links[$linkarray (
  827.          $page,
  828.          $y
  829.       );
  830.    }
  831.  
  832.    /**
  833.     * src_pdf_FPDF::Link()
  834.     *
  835.     * @param mixed $x 
  836.     * @param mixed $y 
  837.     * @param mixed $w 
  838.     * @param mixed $h 
  839.     * @param mixed $link 
  840.     * @return void 
  841.     ***/
  842.    public function Link($x$y$w$h$link{
  843.       // Put a link on the page
  844.       $this->PageLinks[$this->page][array (
  845.          $x $this->k,
  846.          $this->hPt - $y $this->k,
  847.          $w $this->k,
  848.          $h $this->k,
  849.          $link
  850.       );
  851.    }
  852.  
  853.    /**
  854.     * src_pdf_FPDF::Text()
  855.     *
  856.     * @param mixed $x 
  857.     * @param mixed $y 
  858.     * @param mixed $txt 
  859.     * @return void 
  860.     ***/
  861.    public function Text($x$y$txt{
  862.       // Output a string
  863.       $s sprintf('BT %.2f %.2f Td (%s) Tj ET'$x $this->k($this->h - $y$this->k$this->_escape($txt));
  864.       if ($this->underline && $txt != '')
  865.          $s .= ' ' $this->_dounderline($x$y$txt);
  866.       if ($this->ColorFlag)
  867.          $s 'q ' $this->TextColor . ' ' $s ' Q';
  868.       $this->_out($s);
  869.    }
  870.  
  871.    /**
  872.     * src_pdf_FPDF::AcceptPageBreak()
  873.     *
  874.     * @return boolean 
  875.     ***/
  876.    public function AcceptPageBreak({
  877.       // Accept automatic page break or not
  878.       return $this->AutoPageBreak;
  879.    }
  880.  
  881.    /**
  882.     * src_pdf_FPDF::Cell()
  883.     *
  884.     * @param mixed $w 
  885.     * @param integer $h 
  886.     * @param string $txt 
  887.     * @param integer $border 
  888.     * @param integer $ln 
  889.     * @param string $align 
  890.     * @param integer $fill 
  891.     * @param string $link 
  892.     * @return void 
  893.     ***/
  894.    public function Cell($w$h 0$txt ''$border 0$ln 0$align ''$fill 0$link ''{
  895.       // Output a cell
  896.       $k $this->k;
  897.       if ($this->y + $h $this->PageBreakTrigger && !$this->InFooter && $this->AcceptPageBreak()) {
  898.          // Automatic page break
  899.          $x $this->x;
  900.          $ws $this->ws;
  901.          if ($ws 0{
  902.             $this->ws = 0;
  903.             $this->_out('0 Tw');
  904.          }
  905.          $this->AddPage($this->CurOrientation);
  906.          $this->x = $x;
  907.          if ($ws 0{
  908.             $this->ws = $ws;
  909.             $this->_out(sprintf('%.3f Tw'$ws $k));
  910.          }
  911.       }
  912.       if ($w == 0)
  913.          $w $this->w - $this->rMargin - $this->x;
  914.       $s '';
  915.       if ($fill == || $border == 1{
  916.          if ($fill == 1)
  917.             $op ($border == 1'B' 'f';
  918.          else
  919.             $op 'S';
  920.          $s sprintf('%.2f %.2f %.2f %.2f re %s '$this->x * $k($this->h - $this->y$k$w $k$h $k$op);
  921.       }
  922.       if (is_string($border)) {
  923.          $x $this->x;
  924.          $y $this->y;
  925.          if (strpos($border'L'!== false)
  926.             $s .= sprintf('%.2f %.2f m %.2f %.2f l S '$x $k($this->h - $y$k$x $k($this->h - ($y $h)) $k);
  927.          if (strpos($border'T'!== false)
  928.             $s .= sprintf('%.2f %.2f m %.2f %.2f l S '$x $k($this->h - $y$k($x $w$k($this->h - $y$k);
  929.          if (strpos($border'R'!== false)
  930.             $s .= sprintf('%.2f %.2f m %.2f %.2f l S '($x $w$k($this->h - $y$k($x $w$k($this->h - ($y $h)) $k);
  931.          if (strpos($border'B'!== false)
  932.             $s .= sprintf('%.2f %.2f m %.2f %.2f l S '$x $k($this->h - ($y $h)) $k($x $w$k($this->h - ($y $h)) $k);
  933.       }
  934.       if ($txt !== ''{
  935.          if ($align == 'R')
  936.             $dx $w $this->cMargin - $this->GetStringWidth($txt);
  937.          elseif ($align == 'C'$dx ($w $this->GetStringWidth($txt)) 2;
  938.          else
  939.             $dx $this->cMargin;
  940.          if ($this->ColorFlag)
  941.             $s .= 'q ' $this->TextColor . ' ';
  942.          $txt2 str_replace(')''\\)'str_replace('(''\\('str_replace('\\''\\\\'$txt)));
  943.          $s .= sprintf('BT %.2f %.2f Td (%s) Tj ET'($this->x + $dx$k($this->h - ($this->y + .5 $h +.3 $this->FontSize)) $k$txt2);
  944.          if ($this->underline)
  945.             $s .= ' ' $this->_dounderline($this->x + $dx$this->y + .5 $h +.3 $this->FontSize$txt);
  946.          if ($this->ColorFlag)
  947.             $s .= ' Q';
  948.          if ($link)
  949.             $this->Link($this->x + $dx$this->y + .5 $h -.5 $this->FontSize$this->GetStringWidth($txt)$this->FontSize$link);
  950.       }
  951.       if ($s)
  952.          $this->_out($s);
  953.       $this->lasth = $h;
  954.       if ($ln 0{
  955.          // Go to next line
  956.          $this->y += $h;
  957.          if ($ln == 1)
  958.             $this->x = $this->lMargin;
  959.       else
  960.          $this->x += $w;
  961.    }
  962.  
  963.    /**
  964.     * src_pdf_FPDF::MultiCell()
  965.     *
  966.     * @param mixed $w 
  967.     * @param mixed $h 
  968.     * @param mixed $txt 
  969.     * @param integer $border 
  970.     * @param string $align 
  971.     * @param integer $fill 
  972.     * @return void 
  973.     ***/
  974.    public function MultiCell($w$h$txt$border 0$align 'J'$fill 0{
  975.       // Output text with automatic or explicit line breaks
  976.       $cw $this->CurrentFont['cw'];
  977.       if ($w == 0)
  978.          $w $this->w - $this->rMargin - $this->x;
  979.       $wmax ($w -$this->cMargin1000 $this->FontSize;
  980.       $s str_replace("\r"''$txt);
  981.       $nb strlen($s);
  982.       if ($nb && $s[$nb -1== "\n")
  983.          $nb--;
  984.       $b 0;
  985.       if ($border{
  986.          if ($border == 1{
  987.             $border 'LTRB';
  988.             $b 'LRT';
  989.             $b2 'LR';
  990.          else {
  991.             $b2 '';
  992.             if (strpos($border'L'!== false)
  993.                $b2 .= 'L';
  994.             if (strpos($border'R'!== false)
  995.                $b2 .= 'R';
  996.             $b (strpos($border'T'!== false$b2 'T' $b2;
  997.          }
  998.       }
  999.       $sep = -1;
  1000.       $i 0;
  1001.       $j 0;
  1002.       $l 0;
  1003.       $ns 0;
  1004.       $nl 1;
  1005.       while ($i $nb{
  1006.          // Get next character
  1007.          $c $s {
  1008.             $i };
  1009.          if ($c == "\n"{
  1010.             // Explicit line break
  1011.             if ($this->ws > 0{
  1012.                $this->ws = 0;
  1013.                $this->_out('0 Tw');
  1014.             }
  1015.             $this->Cell($w$hsubstr($s$j$i $j)$b2$align$fill);
  1016.             $i++;
  1017.             $sep = -1;
  1018.             $j $i;
  1019.             $l 0;
  1020.             $ns 0;
  1021.             $nl++;
  1022.             if ($border && $nl == 2)
  1023.                $b $b2;
  1024.             continue;
  1025.          }
  1026.          if ($c == ' '{
  1027.             $sep $i;
  1028.             $ls $l;
  1029.             $ns++;
  1030.          }
  1031.          $l += $cw[$c];
  1032.          if ($l $wmax{
  1033.             // Automatic line break
  1034.             if ($sep == -1{
  1035.                if ($i == $j)
  1036.                   $i++;
  1037.                if ($this->ws > 0{
  1038.                   $this->ws = 0;
  1039.                   $this->_out('0 Tw');
  1040.                }
  1041.                $this->Cell($w$hsubstr($s$j$i $j)$b2$align$fill);
  1042.             else {
  1043.                if ($align == 'J'{
  1044.                   $this->ws = ($ns 1($wmax $ls1000 $this->FontSize / ($ns -10;
  1045.                   $this->_out(sprintf('%.3f Tw'$this->ws * $this->k));
  1046.                }
  1047.                $this->Cell($w$hsubstr($s$j$sep $j)$b2$align$fill);
  1048.                $i $sep +1;
  1049.             }
  1050.             $sep = -1;
  1051.             $j $i;
  1052.             $l 0;
  1053.             $ns 0;
  1054.             $nl++;
  1055.             if ($border && $nl == 2)
  1056.                $b $b2;
  1057.          else
  1058.             $i++;
  1059.       }
  1060.       // Last chunk
  1061.       if ($this->ws > 0{
  1062.          $this->ws = 0;
  1063.          $this->_out('0 Tw');
  1064.       }
  1065.       if ($border && strpos($border'B'!== false)
  1066.          $b .= 'B';
  1067.       $this->Cell($w$hsubstr($s$j$i $j)$b2$align$fill);
  1068.       $this->x = $this->lMargin;
  1069.    }
  1070.  
  1071.    /**
  1072.     * src_pdf_FPDF::Write()
  1073.     *
  1074.     * @param mixed $h 
  1075.     * @param mixed $txt 
  1076.     * @param string $link 
  1077.     * @return void 
  1078.     ***/
  1079.    public function Write($h$txt$link ''{
  1080.       // Output text in flowing mode
  1081.       $cw $this->CurrentFont['cw'];
  1082.       $w $this->w - $this->rMargin - $this->x;
  1083.       $wmax ($w -$this->cMargin1000 $this->FontSize;
  1084.       $s str_replace("\r"''$txt);
  1085.       $nb strlen($s);
  1086.       $sep = -1;
  1087.       $i 0;
  1088.       $j 0;
  1089.       $l 0;
  1090.       $nl 1;
  1091.       while ($i $nb{
  1092.          // Get next character
  1093.          $c $s {
  1094.             $i };
  1095.          if ($c == "\n"{
  1096.             // Explicit line break
  1097.             $this->Cell($w$hsubstr($s$j$i $j)02''0$link);
  1098.             $i++;
  1099.             $sep = -1;
  1100.             $j $i;
  1101.             $l 0;
  1102.             if ($nl == 1{
  1103.                $this->x = $this->lMargin;
  1104.                $w $this->w - $this->rMargin - $this->x;
  1105.                $wmax ($w -$this->cMargin1000 $this->FontSize;
  1106.             }
  1107.             $nl++;
  1108.             continue;
  1109.          }
  1110.          if ($c == ' ')
  1111.             $sep $i;
  1112.          $l += $cw[$c];
  1113.          if ($l $wmax{
  1114.             // Automatic line break
  1115.             if ($sep == -1{
  1116.                if ($this->x > $this->lMargin{
  1117.                   // Move to next line
  1118.                   $this->x = $this->lMargin;
  1119.                   $this->y += $h;
  1120.                   $w $this->w - $this->rMargin - $this->x;
  1121.                   $wmax ($w -$this->cMargin1000 $this->FontSize;
  1122.                   $i++;
  1123.                   $nl++;
  1124.                   continue;
  1125.                }
  1126.                if ($i == $j)
  1127.                   $i++;
  1128.                $this->Cell($w$hsubstr($s$j$i $j)02''0$link);
  1129.             else {
  1130.                $this->Cell($w$hsubstr($s$j$sep $j)02''0$link);
  1131.                $i $sep +1;
  1132.             }
  1133.             $sep = -1;
  1134.             $j $i;
  1135.             $l 0;
  1136.             if ($nl == 1{
  1137.                $this->x = $this->lMargin;
  1138.                $w $this->w - $this->rMargin - $this->x;
  1139.                $wmax ($w -$this->cMargin1000 $this->FontSize;
  1140.             }
  1141.             $nl++;
  1142.          else
  1143.             $i++;
  1144.       }
  1145.       // Last chunk
  1146.       if ($i != $j)
  1147.          $this->Cell($l 1000 $this->FontSize$hsubstr($s$j)00''0$link);
  1148.    }
  1149.  
  1150.    /**
  1151.     * src_pdf_FPDF::Image()
  1152.     *
  1153.     * @param mixed $file 
  1154.     * @param mixed $x 
  1155.     * @param mixed $y 
  1156.     * @param integer $w 
  1157.     * @param integer $h 
  1158.     * @param string $type 
  1159.     * @param string $link 
  1160.     * @return void 
  1161.     ***/
  1162.    public function Image($file$x$y$w 0$h 0$type ''$link ''{
  1163.       // Put an image on the page
  1164.       if (!isset ($this->images[$file])) {
  1165.          // First use of image, get info
  1166.          if ($type == ''{
  1167.             $pos strrpos($file'.');
  1168.             if (!$pos)
  1169.                $this->Error('Image file has no extension and no type was specified: ' $file);
  1170.             $type substr($file$pos +1);
  1171.          }
  1172.          $type strtolower($type);
  1173.          $mqr get_magic_quotes_runtime();
  1174.          set_magic_quotes_runtime(0);
  1175.          if ($type == 'jpg' || $type == 'jpeg')
  1176.             $info $this->_parsejpg($file);
  1177.          elseif ($type == 'png'$info $this->_parsepng($file);
  1178.          else {
  1179.             // Allow for additional formats
  1180.             $mtd '_parse' $type;
  1181.             if (!method_exists($this$mtd))
  1182.                $this->Error('Unsupported image type: ' $type);
  1183.             $info $this-> $mtd ($file);
  1184.          }
  1185.          set_magic_quotes_runtime($mqr);
  1186.          $info['i'count($this->images1;
  1187.          $this->images[$file$info;
  1188.       else
  1189.          $info $this->images[$file];
  1190.       // Automatic width and height calculation if needed
  1191.       if ($w == && $h == 0{
  1192.          // Put image at 72 dpi
  1193.          $w $info['w'$this->k;
  1194.          $h $info['h'$this->k;
  1195.       }
  1196.       if ($w == 0)
  1197.          $w $h $info['w'$info['h'];
  1198.       if ($h == 0)
  1199.          $h $w $info['h'$info['w'];
  1200.       $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']));
  1201.       if ($link)
  1202.          $this->Link($x$y$w$h$link);
  1203.    }
  1204.  
  1205.    /**
  1206.     * src_pdf_FPDF::Ln()
  1207.     *
  1208.     * @param string $h 
  1209.     * @return void 
  1210.     ***/
  1211.    public function Ln($h ''{
  1212.       // Line feed; default value is last cell height
  1213.       $this->x = $this->lMargin;
  1214.       if (is_string($h))
  1215.          $this->y += $this->lasth;
  1216.       else
  1217.          $this->y += $h;
  1218.    }
  1219.  
  1220.    /**
  1221.     * src_pdf_FPDF::GetX()
  1222.     *
  1223.     * @return int 
  1224.     ***/
  1225.    public function GetX({
  1226.       // Get x position
  1227.       return $this->x;
  1228.    }
  1229.  
  1230.    /**
  1231.     * src_pdf_FPDF::SetX()
  1232.     *
  1233.     * @param mixed $x 
  1234.     * @return void 
  1235.     ***/
  1236.    public function SetX($x{
  1237.       // Set x position
  1238.       if ($x >= 0)
  1239.          $this->x = $x;
  1240.       else
  1241.          $this->x = $this->w + $x;
  1242.    }
  1243.  
  1244.    /**
  1245.     * src_pdf_FPDF::GetY()
  1246.     *
  1247.     * @return int 
  1248.     ***/
  1249.    public function GetY({
  1250.       // Get y position
  1251.       return $this->y;
  1252.    }
  1253.  
  1254.    /**
  1255.     * src_pdf_FPDF::SetY()
  1256.     *
  1257.     * @param mixed $y 
  1258.     * @return void 
  1259.     ***/
  1260.    public function SetY($y{
  1261.       // Set y position and reset x
  1262.       $this->x = $this->lMargin;
  1263.       if ($y >= 0)
  1264.          $this->y = $y;
  1265.       else
  1266.          $this->y = $this->h + $y;
  1267.    }
  1268.  
  1269.    /**
  1270.     * src_pdf_FPDF::SetXY()
  1271.     *
  1272.     * @param mixed $x 
  1273.     * @param mixed $y 
  1274.     * @return void 
  1275.     ***/
  1276.    public function SetXY($x$y{
  1277.       // Set x and y positions
  1278.       $this->SetY($y);
  1279.       $this->SetX($x);
  1280.    }
  1281.  
  1282.    /**
  1283.     * src_pdf_FPDF::Output()
  1284.     *
  1285.     * @param string $name 
  1286.     * @param string $dest 
  1287.     * @return string 
  1288.     ***/
  1289.    public function Output($name ''$dest ''{
  1290.       // Output PDF to some destination
  1291.       // Finish document if necessary
  1292.       if ($this->state < 3)
  1293.          $this->Close();
  1294.       // Normalize parameters
  1295.       if (is_bool($dest))
  1296.          $dest $dest 'D' 'F';
  1297.       $dest strtoupper($dest);
  1298.       if ($dest == ''{
  1299.          if ($name == ''{
  1300.             $name 'doc.pdf';
  1301.             $dest 'I';
  1302.          else
  1303.             $dest 'F';
  1304.       }
  1305.       switch ($dest{
  1306.          case 'I' :
  1307.             // Send to standard output
  1308.             if (ob_get_contents())
  1309.                $this->Error('Some data has already been output, can\'t send PDF file');
  1310.             if (php_sapi_name(!= 'cli'{
  1311.                // We send to a browser
  1312.                header('Content-Type: application/pdf');
  1313.                if (headers_sent())
  1314.                   $this->Error('Some data has already been output to browser, can\'t send PDF file');
  1315.                header('Content-Length: ' strlen($this->buffer));
  1316.                header('Content-disposition: inline; filename="' $name '"');
  1317.             }
  1318.             echo $this->buffer;
  1319.             break;
  1320.          case 'D' :
  1321.             // Download file
  1322.             if (ob_get_contents())
  1323.                $this->Error('Some data has already been output, can\'t send PDF file');
  1324.             if (isset ($_SERVER['HTTP_USER_AGENT']&& strpos($_SERVER['HTTP_USER_AGENT']'MSIE'))
  1325.                header('Content-Type: application/force-download');
  1326.             else
  1327.                header('Content-Type: application/octet-stream');
  1328.             if (headers_sent())
  1329.                $this->Error('Some data has already been output to browser, can\'t send PDF file');
  1330.             header('Content-Length: ' strlen($this->buffer));
  1331.             header('Content-disposition: attachment; filename="' $name '"');
  1332.             echo $this->buffer;
  1333.             break;
  1334.          case 'F' :
  1335.             // Save to local file
  1336.             $f fopen($name'wb');
  1337.             if (!$f)
  1338.                $this->Error('Unable to create output file: ' $name);
  1339.             fwrite($f$this->bufferstrlen($this->buffer));
  1340.             fclose($f);
  1341.             break;
  1342.          case 'S' :
  1343.             // Return as a string
  1344.             return $this->buffer;
  1345.          default :
  1346.             $this->Error('Incorrect output destination: ' $dest);
  1347.       }
  1348.       return true;
  1349.    }
  1350.    /**
  1351.     * src_pdf_FPDF::_dochecks()
  1352.     *
  1353.     * @return void 
  1354.     ***/
  1355.    public function _dochecks({
  1356.       // Check for locale-related bug
  1357.       if (1.1 == 1)
  1358.          $this->Error('Don\'t alter the locale before including class file');
  1359.       // Check for decimal separator
  1360.       if (sprintf('%.1f'1.0!= '1.0')
  1361.          setlocale(LC_NUMERIC'C');
  1362.    }
  1363.  
  1364.    /**
  1365.     * src_pdf_FPDF::_getfontpath()
  1366.     *
  1367.     * @return string 
  1368.     ***/
  1369.    protected function _getfontpath({
  1370.       if (!defined('FPDF_FONTPATH'&& is_dir(dirname(__FILE__'/font'))
  1371.          define('FPDF_FONTPATH'dirname(__FILE__'/font/');
  1372.       return defined('FPDF_FONTPATH'FPDF_FONTPATH '';
  1373.    }
  1374.  
  1375.    /**
  1376.     * src_pdf_FPDF::_putpages()
  1377.     *
  1378.     * @return void 
  1379.     ***/
  1380.    protected function _putpages({
  1381.       $nb $this->page;
  1382.       if (!empty ($this->AliasNbPages)) {
  1383.          // Replace number of pages
  1384.          for ($n 1$n <= $nb$n++)
  1385.             $this->pages[$nstr_replace($this->AliasNbPages$nb$this->pages[$n]);
  1386.       }
  1387.       if ($this->DefOrientation == 'P'{
  1388.          $wPt $this->fwPt;
  1389.          $hPt $this->fhPt;
  1390.       else {
  1391.          $wPt $this->fhPt;
  1392.          $hPt $this->fwPt;
  1393.       }
  1394.       $filter ($this->compress'/Filter /FlateDecode ' '';
  1395.       for ($n 1$n <= $nb$n++{
  1396.          // Page
  1397.          $this->_newobj();
  1398.          $this->_out('<</Type /Page');
  1399.          $this->_out('/Parent 1 0 R');
  1400.          if (isset ($this->OrientationChanges[$n]))
  1401.             $this->_out(sprintf('/MediaBox [0 0 %.2f %.2f]'$hPt$wPt));
  1402.          $this->_out('/Resources 2 0 R');
  1403.          if (isset ($this->PageLinks[$n])) {
  1404.             // Links
  1405.             $annots '/Annots [';
  1406.             foreach ($this->PageLinks[$nas $pl{
  1407.                $rect sprintf('%.2f %.2f %.2f %.2f'$pl[0]$pl[1]$pl[0$pl[2]$pl[1$pl[3]);
  1408.                $annots .= '<</Type /Annot /Subtype /Link /Rect [' $rect '] /Border [0 0 0] ';
  1409.                if (is_string($pl[4]))
  1410.                   $annots .= '/A <</S /URI /URI ' $this->_textstring($pl[4]'>>>>';
  1411.                else {
  1412.                   $l $this->links[$pl[4]];
  1413.                   $h = isset ($this->OrientationChanges[$l[0]]$wPt $hPt;
  1414.                   $annots .= sprintf('/Dest [%d 0 R /XYZ 0 %.2f null]>>'$l[0]$h $l[1$this->k);
  1415.                }
  1416.             }
  1417.             $this->_out($annots ']');
  1418.          }
  1419.          $this->_out('/Contents ' ($this->n + 1' 0 R>>');
  1420.          $this->_out('endobj');
  1421.          // Page content
  1422.          $p ($this->compressgzcompress($this->pages[$n]$this->pages[$n];
  1423.          $this->_newobj();
  1424.          $this->_out('<<' $filter '/Length ' strlen($p'>>');
  1425.          $this->_putstream($p);
  1426.          $this->_out('endobj');
  1427.       }
  1428.       // Pages root
  1429.       $this->offsets[1strlen($this->buffer);
  1430.       $this->_out('1 0 obj');
  1431.       $this->_out('<</Type /Pages');
  1432.       $kids '/Kids [';
  1433.       for ($i 0$i $nb$i++)
  1434.          $kids .= ($i' 0 R ';
  1435.       $this->_out($kids ']');
  1436.       $this->_out('/Count ' $nb);
  1437.       $this->_out(sprintf('/MediaBox [0 0 %.2f %.2f]'$wPt$hPt));
  1438.       $this->_out('>>');
  1439.       $this->_out('endobj');
  1440.    }
  1441.  
  1442.    /**
  1443.     * src_pdf_FPDF::_putfonts()
  1444.     *
  1445.     * @return void 
  1446.     ***/
  1447.    protected function _putfonts({
  1448.       $nf $this->n;
  1449.       foreach ($this->diffs as $diff{
  1450.          // Encodings
  1451.          $this->_newobj();
  1452.          $this->_out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences [' $diff ']>>');
  1453.          $this->_out('endobj');
  1454.       }
  1455.       $mqr get_magic_quotes_runtime();
  1456.       set_magic_quotes_runtime(0);
  1457.       foreach ($this->FontFiles as $file => $info{
  1458.          // Font file embedding
  1459.          $this->_newobj();
  1460.          $this->FontFiles[$file]['n'$this->n;
  1461.          $font '';
  1462.          $f fopen($this->_getfontpath($file'rb'1);
  1463.          if (!$f)
  1464.             $this->Error('Font file not found');
  1465.          while (!feof($f))
  1466.             $font .= fread($f8192);
  1467.          fclose($f);
  1468.          $compressed (substr($file-2== '.z');
  1469.          if (!$compressed && isset ($info['length2'])) {
  1470.             $header (ord($font {
  1471.                }== 128);
  1472.             if ($header{
  1473.                // Strip first binary header
  1474.                $font substr($font6);
  1475.             }
  1476.             if ($header && ord($font {
  1477.                $info['length1'}== 128{
  1478.                // Strip second binary header
  1479.                $font substr($font0$info['length1']substr($font$info['length1'6);
  1480.             }
  1481.          }
  1482.          $this->_out('<</Length ' strlen($font));
  1483.          if ($compressed)
  1484.             $this->_out('/Filter /FlateDecode');
  1485.          $this->_out('/Length1 ' $info['length1']);
  1486.          if (isset ($info['length2']))
  1487.             $this->_out('/Length2 ' $info['length2'' /Length3 0');
  1488.          $this->_out('>>');
  1489.          $this->_putstream($font);
  1490.          $this->_out('endobj');
  1491.       }
  1492.       set_magic_quotes_runtime($mqr);
  1493.       foreach ($this->fonts as $k => $font{
  1494.          // Font objects
  1495.          $this->fonts[$k]['n'$this->n + 1;
  1496.          $type $font['type'];
  1497.          $name $font['name'];
  1498.          if ($type == 'core'{
  1499.             // Standard font
  1500.             $this->_newobj();
  1501.             $this->_out('<</Type /Font');
  1502.             $this->_out('/BaseFont /' $name);
  1503.             $this->_out('/Subtype /Type1');
  1504.             if ($name != 'Symbol' && $name != 'ZapfDingbats')
  1505.                $this->_out('/Encoding /WinAnsiEncoding');
  1506.             $this->_out('>>');
  1507.             $this->_out('endobj');
  1508.          }
  1509.          elseif ($type == 'Type1' || $type == 'TrueType'{
  1510.             // Additional Type1 or TrueType font
  1511.             $this->_newobj();
  1512.             $this->_out('<</Type /Font');
  1513.             $this->_out('/BaseFont /' $name);
  1514.             $this->_out('/Subtype /' $type);
  1515.             $this->_out('/FirstChar 32 /LastChar 255');
  1516.             $this->_out('/Widths ' ($this->n + 1' 0 R');
  1517.             $this->_out('/FontDescriptor ' ($this->n + 2' 0 R');
  1518.             if ($font['enc']{
  1519.                if (isset ($font['diff']))
  1520.                   $this->_out('/Encoding ' ($nf $font['diff']' 0 R');
  1521.                else
  1522.                   $this->_out('/Encoding /WinAnsiEncoding');
  1523.             }
  1524.             $this->_out('>>');
  1525.             $this->_out('endobj');
  1526.             // Widths
  1527.             $this->_newobj();
  1528.             $cw $font['cw'];
  1529.             $s '[';
  1530.             for ($i 32$i <= 255$i++)
  1531.                $s .= $cw[chr($i)' ';
  1532.             $this->_out($s ']');
  1533.             $this->_out('endobj');
  1534.             // Descriptor
  1535.             $this->_newobj();
  1536.             $s '<</Type /FontDescriptor /FontName /' $name;
  1537.             foreach ($font['desc'as $k => $v)
  1538.                $s .= ' /' $k ' ' $v;
  1539.             $file $font['file'];
  1540.             if ($file)
  1541.                $s .= ' /FontFile' ($type == 'Type1' '' '2'' ' $this->FontFiles[$file]['n'' 0 R';
  1542.             $this->_out($s '>>');
  1543.             $this->_out('endobj');
  1544.          else {
  1545.             // Allow for additional types
  1546.             $mtd '_put' strtolower($type);
  1547.             if (!method_exists($this$mtd))
  1548.                $this->Error('Unsupported font type: ' $type);
  1549.             $this-> $mtd ($font);
  1550.          }
  1551.       }
  1552.    }
  1553.  
  1554.    /**
  1555.     * src_pdf_FPDF::_putimages()
  1556.     *
  1557.     * @return void 
  1558.     ***/
  1559.    protected function _putimages({
  1560.       $filter ($this->compress'/Filter /FlateDecode ' '';
  1561.       reset($this->images);
  1562.       while (list ($file$infoeach($this->images)) {
  1563.          $this->_newobj();
  1564.          $this->images[$file]['n'$this->n;
  1565.          $this->_out('<</Type /XObject');
  1566.          $this->_out('/Subtype /Image');
  1567.          $this->_out('/Width ' $info['w']);
  1568.          $this->_out('/Height ' $info['h']);
  1569.          if ($info['cs'== 'Indexed')
  1570.             $this->_out('/ColorSpace [/Indexed /DeviceRGB ' (strlen($info['pal']1' ' ($this->n + 1' 0 R]');
  1571.          else {
  1572.             $this->_out('/ColorSpace /' $info['cs']);
  1573.             if ($info['cs'== 'DeviceCMYK')
  1574.                $this->_out('/Decode [1 0 1 0 1 0 1 0]');
  1575.          }
  1576.          $this->_out('/BitsPerComponent ' $info['bpc']);
  1577.          if (isset ($info['f']))
  1578.             $this->_out('/Filter /' $info['f']);
  1579.          if (isset ($info['parms']))
  1580.             $this->_out($info['parms']);
  1581.          if (isset ($info['trns']&& is_array($info['trns'])) {
  1582.             $trns '';
  1583.             for ($i 0$i count($info['trns'])$i++)
  1584.                $trns .= $info['trns'][$i' ' $info['trns'][$i' ';
  1585.             $this->_out('/Mask [' $trns ']');
  1586.          }
  1587.          $this->_out('/Length ' strlen($info['data']'>>');
  1588.          $this->_putstream($info['data']);
  1589.          unset ($this->images[$file]['data']);
  1590.          $this->_out('endobj');
  1591.          // Palette
  1592.          if ($info['cs'== 'Indexed'{
  1593.             $this->_newobj();
  1594.             $pal ($this->compressgzcompress($info['pal']$info['pal'];
  1595.             $this->_out('<<' $filter '/Length ' strlen($pal'>>');
  1596.             $this->_putstream($pal);
  1597.             $this->_out('endobj');
  1598.          }
  1599.       }
  1600.    }
  1601.  
  1602.    /**
  1603.     * src_pdf_FPDF::_putxobjectdict()
  1604.     *
  1605.     * @return void 
  1606.     ***/
  1607.    protected function _putxobjectdict({
  1608.       foreach ($this->images as $image)
  1609.          $this->_out('/I' $image['i'' ' $image['n'' 0 R');
  1610.    }
  1611.  
  1612.    /**
  1613.     * src_pdf_FPDF::_putresourcedict()
  1614.     *
  1615.     * @return void 
  1616.     ***/
  1617.    protected function _putresourcedict({
  1618.       $this->_out('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
  1619.       $this->_out('/Font <<');
  1620.       foreach ($this->fonts as $font)
  1621.          $this->_out('/F' $font['i'' ' $font['n'' 0 R');
  1622.       $this->_out('>>');
  1623.       $this->_out('/XObject <<');
  1624.       $this->_putxobjectdict();
  1625.       $this->_out('>>');
  1626.    }
  1627.  
  1628.    /**
  1629.     * src_pdf_FPDF::_putresources()
  1630.     *
  1631.     * @return void 
  1632.     ***/
  1633.    protected function _putresources({
  1634.       $this->_putfonts();
  1635.       $this->_putimages();
  1636.       // Resource dictionary
  1637.       $this->offsets[2strlen($this->buffer);
  1638.       $this->_out('2 0 obj');
  1639.       $this->_out('<<');
  1640.       $this->_putresourcedict();
  1641.       $this->_out('>>');
  1642.       $this->_out('endobj');
  1643.    }
  1644.  
  1645.    /**
  1646.     * src_pdf_FPDF::_putinfo()
  1647.     *
  1648.     * @return void 
  1649.     ***/
  1650.    protected function _putinfo({
  1651.       $this->_out('/Producer ' $this->_textstring('FPDF ' FPDF_VERSION));
  1652.       if (!empty ($this->title))
  1653.          $this->_out('/Title ' $this->_textstring($this->title));
  1654.       if (!empty ($this->subject))
  1655.          $this->_out('/Subject ' $this->_textstring($this->subject));
  1656.       if (!empty ($this->author))
  1657.          $this->_out('/Author ' $this->_textstring($this->author));
  1658.       if (!empty ($this->keywords))
  1659.          $this->_out('/Keywords ' $this->_textstring($this->keywords));
  1660.       if (!empty ($this->creator))
  1661.          $this->_out('/Creator ' $this->_textstring($this->creator));
  1662.       $this->_out('/CreationDate ' $this->_textstring('D:' date('YmdHis')));
  1663.    }
  1664.  
  1665.    /**
  1666.     * src_pdf_FPDF::_putcatalog()
  1667.     *
  1668.     * @return void 
  1669.     ***/
  1670.    protected function _putcatalog({
  1671.       $this->_out('/Type /Catalog');
  1672.       $this->_out('/Pages 1 0 R');
  1673.       if ($this->ZoomMode == 'fullpage')
  1674.          $this->_out('/OpenAction [3 0 R /Fit]');
  1675.       elseif ($this->ZoomMode == 'fullwidth'$this->_out('/OpenAction [3 0 R /FitH null]');
  1676.       elseif ($this->ZoomMode == 'real'$this->_out('/OpenAction [3 0 R /XYZ null null 1]');
  1677.       elseif (!is_string($this->ZoomMode)) $this->_out('/OpenAction [3 0 R /XYZ null null ' ($this->ZoomMode / 100']');
  1678.       if ($this->LayoutMode == 'single')
  1679.          $this->_out('/PageLayout /SinglePage');
  1680.       elseif ($this->LayoutMode == 'continuous'$this->_out('/PageLayout /OneColumn');
  1681.       elseif ($this->LayoutMode == 'two'$this->_out('/PageLayout /TwoColumnLeft');
  1682.    }
  1683.  
  1684.    /**
  1685.     * src_pdf_FPDF::_putheader()
  1686.     *
  1687.     * @return void 
  1688.     ***/
  1689.    protected function _putheader({
  1690.       $this->_out('%PDF-' $this->PDFVersion);
  1691.    }
  1692.  
  1693.    /**
  1694.     * src_pdf_FPDF::_puttrailer()
  1695.     *
  1696.     * @return void 
  1697.     ***/
  1698.    protected function _puttrailer({
  1699.       $this->_out('/Size ' ($this->n + 1));
  1700.       $this->_out('/Root ' $this->n . ' 0 R');
  1701.       $this->_out('/Info ' ($this->n - 1' 0 R');
  1702.    }
  1703.  
  1704.    /**
  1705.     * src_pdf_FPDF::_enddoc()
  1706.     *
  1707.     * @return void 
  1708.     ***/
  1709.    protected function _enddoc({
  1710.       $this->_putheader();
  1711.       $this->_putpages();
  1712.       $this->_putresources();
  1713.       // Info
  1714.       $this->_newobj();
  1715.       $this->_out('<<');
  1716.       $this->_putinfo();
  1717.       $this->_out('>>');
  1718.       $this->_out('endobj');
  1719.       // Catalog
  1720.       $this->_newobj();
  1721.       $this->_out('<<');
  1722.       $this->_putcatalog();
  1723.       $this->_out('>>');
  1724.       $this->_out('endobj');
  1725.       // Cross-ref
  1726.       $o strlen($this->buffer);
  1727.       $this->_out('xref');
  1728.       $this->_out('0 ' ($this->n + 1));
  1729.       $this->_out('0000000000 65535 f ');
  1730.       for ($i 1$i <= $this->n$i++)
  1731.          $this->_out(sprintf('%010d 00000 n '$this->offsets[$i]));
  1732.       // Trailer
  1733.       $this->_out('trailer');
  1734.       $this->_out('<<');
  1735.       $this->_puttrailer();
  1736.       $this->_out('>>');
  1737.       $this->_out('startxref');
  1738.       $this->_out($o);
  1739.       $this->_out('%%EOF');
  1740.       $this->state = 3;
  1741.    }
  1742.  
  1743.    /**
  1744.     * src_pdf_FPDF::_beginpage()
  1745.     *
  1746.     * @param mixed $orientation 
  1747.     * @return void 
  1748.     ***/
  1749.    protected function _beginpage($orientation{
  1750.       $this->page++;
  1751.       $this->pages[$this->page'';
  1752.       $this->state = 2;
  1753.       $this->x = $this->lMargin;
  1754.       $this->y = $this->tMargin;
  1755.       $this->FontFamily = '';
  1756.       // Page orientation
  1757.       if (!$orientation)
  1758.          $orientation $this->DefOrientation;
  1759.       else {
  1760.          $orientation strtoupper($orientation {
  1761.             });
  1762.          if ($orientation != $this->DefOrientation)
  1763.             $this->OrientationChanges[$this->pagetrue;
  1764.       }
  1765.       if ($orientation != $this->CurOrientation{
  1766.          // Change orientation
  1767.          if ($orientation == 'P'{
  1768.             $this->wPt = $this->fwPt;
  1769.             $this->hPt = $this->fhPt;
  1770.             $this->w = $this->fw;
  1771.             $this->h = $this->fh;
  1772.          else {
  1773.             $this->wPt = $this->fhPt;
  1774.             $this->hPt = $this->fwPt;
  1775.             $this->w = $this->fh;
  1776.             $this->h = $this->fw;
  1777.          }
  1778.          $this->PageBreakTrigger = $this->h - $this->bMargin;
  1779.          $this->CurOrientation = $orientation;
  1780.       }
  1781.    }
  1782.  
  1783.    /**
  1784.     * src_pdf_FPDF::_endpage()
  1785.     *
  1786.     * @return void 
  1787.     ***/
  1788.    protected function _endpage({
  1789.       // End of page contents
  1790.       $this->state = 1;
  1791.    }
  1792.  
  1793.    /**
  1794.     * src_pdf_FPDF::_newobj()
  1795.     *
  1796.     * @return void 
  1797.     ***/
  1798.    protected function _newobj({
  1799.       // Begin a new object
  1800.       $this->n++;
  1801.       $this->offsets[$this->nstrlen($this->buffer);
  1802.       $this->_out($this->n . ' 0 obj');
  1803.    }
  1804.  
  1805.    /**
  1806.     * src_pdf_FPDF::_dounderline()
  1807.     *
  1808.     * @param mixed $x 
  1809.     * @param mixed $y 
  1810.     * @param mixed $txt 
  1811.     * @return string 
  1812.     ***/
  1813.    protected function _dounderline($x$y$txt{
  1814.       // Underline text
  1815.       $up $this->CurrentFont['up'];
  1816.       $ut $this->CurrentFont['ut'];
  1817.       $w $this->GetStringWidth($txt$this->ws * substr_count($txt' ');
  1818.       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);
  1819.    }
  1820.  
  1821.    /**
  1822.     * src_pdf_FPDF::_parsejpg()
  1823.     *
  1824.     * @param mixed $file 
  1825.     * @return array 
  1826.     ***/
  1827.    protected function _parsejpg($file{
  1828.       // Extract info from a JPEG file
  1829.       $a GetImageSize($file);
  1830.       if (!$a)
  1831.          $this->Error('Missing or incorrect image file: ' $file);
  1832.       if ($a[2!= 2)
  1833.          $this->Error('Not a JPEG file: ' $file);
  1834.       if (!isset ($a['channels']|| $a['channels'== 3)
  1835.          $colspace 'DeviceRGB';
  1836.       elseif ($a['channels'== 4$colspace 'DeviceCMYK';
  1837.       else
  1838.          $colspace 'DeviceGray';
  1839.       $bpc = isset ($a['bits']$a['bits'8;
  1840.       // Read whole file
  1841.       $f fopen($file'rb');
  1842.       $data '';
  1843.       while (!feof($f))
  1844.          $data .= fread($f4096);
  1845.       fclose($f);
  1846.       return array (
  1847.          'w' => $a[0],
  1848.          'h' => $a[1],
  1849.          'cs' => $colspace,
  1850.          'bpc' => $bpc,
  1851.          'f' => 'DCTDecode',
  1852.          'data' => $data
  1853.       );
  1854.    }
  1855.  
  1856.    /**
  1857.     * src_pdf_FPDF::_parsepng()
  1858.     *
  1859.     * @param mixed $file 
  1860.     * @return array 
  1861.     ***/
  1862.    protected function _parsepng($file{
  1863.       // Extract info from a PNG file
  1864.       $f fopen($file'rb');
  1865.       if (!$f)
  1866.          $this->Error('Can\'t open image file: ' $file);
  1867.       // Check signature
  1868.       if (fread($f8!= chr(137'PNG' chr(13chr(10chr(26chr(10))
  1869.          $this->Error('Not a PNG file: ' $file);
  1870.       // Read header chunk
  1871.       fread($f4);
  1872.       if (fread($f4!= 'IHDR')
  1873.          $this->Error('Incorrect PNG file: ' $file);
  1874.       $w $this->_freadint($f);
  1875.       $h $this->_freadint($f);
  1876.       $bpc ord(fread($f1));
  1877.       if ($bpc 8)
  1878.          $this->Error('16-bit depth not supported: ' $file);
  1879.       $ct ord(fread($f1));
  1880.       if ($ct == 0)
  1881.          $colspace 'DeviceGray';
  1882.       elseif ($ct == 2$colspace 'DeviceRGB';
  1883.       elseif ($ct == 3$colspace 'Indexed';
  1884.       else
  1885.          $this->Error('Alpha channel not supported: ' $file);
  1886.       if (ord(fread($f1)) != 0)
  1887.          $this->Error('Unknown compression method: ' $file);
  1888.       if (ord(fread($f1)) != 0)
  1889.          $this->Error('Unknown filter method: ' $file);
  1890.       if (ord(fread($f1)) != 0)
  1891.          $this->Error('Interlacing not supported: ' $file);
  1892.       fread($f4);
  1893.       $parms '/DecodeParms <</Predictor 15 /Colors ' ($ct == 1' /BitsPerComponent ' $bpc ' /Columns ' $w '>>';
  1894.       // Scan chunks looking for palette, transparency and image data
  1895.       $pal '';
  1896.       $trns '';
  1897.       $data '';
  1898.       do {
  1899.          $n $this->_freadint($f);
  1900.          $type fread($f4);
  1901.          if ($type == 'PLTE'{
  1902.             // Read palette
  1903.             $pal fread($f$n);
  1904.             fread($f4);
  1905.          }
  1906.          elseif ($type == 'tRNS'{
  1907.             // Read transparency info
  1908.             $t fread($f$n);
  1909.             if ($ct == 0)
  1910.                $trns array (
  1911.                   ord(substr($t,
  1912.                   1,
  1913.                   1
  1914.                )));
  1915.             elseif ($ct == 2$trns array (
  1916.                ord(substr($t,
  1917.                1,
  1918.                1
  1919.             ))ord(substr($t31))ord(substr($t51)));
  1920.             else {
  1921.                $pos strpos($tchr(0));
  1922.                if ($pos !== false)
  1923.                   $trns array (
  1924.                      $pos
  1925.                   );
  1926.             }
  1927.             fread($f4);
  1928.          }
  1929.          elseif ($type == 'IDAT'{
  1930.             // Read image data block
  1931.             $data .= fread($f$n);
  1932.             fread($f4);
  1933.          }
  1934.          elseif ($type == 'IEND'break;
  1935.          else
  1936.             fread($f$n +4);
  1937.       while ($n);
  1938.       if ($colspace == 'Indexed' && empty ($pal))
  1939.          $this->Error('Missing palette in ' $file);
  1940.       fclose($f);
  1941.       return array (
  1942.          'w' => $w,
  1943.          'h' => $h,
  1944.          'cs' => $colspace,
  1945.          'bpc' => $bpc,
  1946.          'f' => 'FlateDecode',
  1947.          'parms' => $parms,
  1948.          'pal' => $pal,
  1949.          'trns' => $trns,
  1950.          'data' => $data
  1951.       );
  1952.    }
  1953.  
  1954.    /**
  1955.     * src_pdf_FPDF::_freadint()
  1956.     *
  1957.     * @param mixed $f 
  1958.     * @return int 
  1959.     ***/
  1960.    protected function _freadint($f{
  1961.       // Read a 4-byte integer from file
  1962.       $a unpack('Ni'fread($f4));
  1963.       return $a['i'];
  1964.    }
  1965.  
  1966.    /**
  1967.     * src_pdf_FPDF::_textstring()
  1968.     *
  1969.     * @param mixed $s 
  1970.     * @return string 
  1971.     ***/
  1972.    protected function _textstring($s{
  1973.       // Format a text string
  1974.       return '(' $this->_escape($s')';
  1975.    }
  1976.  
  1977.    /**
  1978.     * src_pdf_FPDF::_escape()
  1979.     *
  1980.     * @param mixed $s 
  1981.     * @return string 
  1982.     ***/
  1983.    protected function _escape($s{
  1984.       // Add \ before \, ( and )
  1985.       return str_replace(')''\\)'str_replace('(''\\('str_replace('\\''\\\\'$s)));
  1986.    }
  1987.  
  1988.    /**
  1989.     * src_pdf_FPDF::_putstream()
  1990.     *
  1991.     * @param mixed $s 
  1992.     * @return void 
  1993.     ***/
  1994.    protected function _putstream($s{
  1995.       $this->_out('stream');
  1996.       $this->_out($s);
  1997.       $this->_out('endstream');
  1998.    }
  1999.  
  2000.    /**
  2001.     * src_pdf_FPDF::_out()
  2002.     *
  2003.     * @param mixed $s 
  2004.     * @return void 
  2005.     ***/
  2006.    protected function _out($s{
  2007.       // Add a line to the document
  2008.       if ($this->state == 2)
  2009.          $this->pages[$this->page.= $s "\n";
  2010.       else
  2011.          $this->buffer .= $s "\n";
  2012.    }
  2013.    // End of class
  2014. }
  2015. // Handle special IE contype request
  2016. if (isset ($_SERVER['HTTP_USER_AGENT']&& $_SERVER['HTTP_USER_AGENT'== 'contype'{
  2017.    header('Content-Type: application/pdf');
  2018.    exit;
  2019. }
  2020.  
  2021. /**
  2022.  * end of class src_FPDF
  2023.  */
  2024. ?>

Documentation generated on Sat, 24 Mar 2007 09:59:17 +0100 by phpDocumentor 1.3.1