Ignore:
Timestamp:
2010/12/11 12:15:20 (13 years ago)
Author:
Seasoft
Message:

#403(インクルードしているライブラリ群をバージョンアップする)

  • FPDF関連 (PHP4について、動作環境無く未確認)
Location:
branches/version-2_5-dev/data/module/fpdf
Files:
1 added
1 moved

Legend:

Unmodified
Added
Removed
  • branches/version-2_5-dev/data/module/fpdf/fpdf.php

    r17259 r19716  
    11<?php 
    22/******************************************************************************* 
    3 * Software: FPDF                                                               * 
    4 * Version:  1.53                                                               * 
    5 * Date:     2004-12-31                                                         * 
    6 * Author:   Olivier PLATHEY                                                    * 
    7 * License:  Freeware                                                           * 
     3* FPDF                                                                         * 
    84*                                                                              * 
    9 * You may use, modify and redistribute this software as you wish.              * 
     5* Version: 1.6                                                                 * 
     6* Date:    2008-08-03                                                          * 
     7* Author:  Olivier PLATHEY                                                     * 
    108*******************************************************************************/ 
    119 
    12 if(!class_exists('FPDF')) 
    13 { 
    14 define('FPDF_VERSION','1.53'); 
     10define('FPDF_VERSION','1.6'); 
    1511 
    1612class FPDF 
    1713{ 
    18 //Private properties 
    1914var $page;               //current page number 
    2015var $n;                  //current object number 
     
    2419var $state;              //current document state 
    2520var $compress;           //compression flag 
     21var $k;                  //scale factor (number of points in user unit) 
    2622var $DefOrientation;     //default orientation 
    2723var $CurOrientation;     //current orientation 
    28 var $OrientationChanges; //array indicating orientation changes 
    29 var $k;                  //scale factor (number of points in user unit) 
    30 var $fwPt,$fhPt;         //dimensions of page format in points 
    31 var $fw,$fh;             //dimensions of page format in user unit 
    32 var $wPt,$hPt;           //current dimensions of page in points 
    33 var $w,$h;               //current dimensions of page in user unit 
     24var $PageFormats;        //available page formats 
     25var $DefPageFormat;      //default page format 
     26var $CurPageFormat;      //current page format 
     27var $PageSizes;          //array storing non-default page sizes 
     28var $wPt,$hPt;           //dimensions of current page in points 
     29var $w,$h;               //dimensions of current page in user unit 
    3430var $lMargin;            //left margin 
    3531var $tMargin;            //top margin 
     
    3733var $bMargin;            //page break margin 
    3834var $cMargin;            //cell margin 
    39 var $x,$y;               //current position in user unit for cell positioning 
    40 var $lasth;              //height of last cell printed 
     35var $x,$y;               //current position in user unit 
     36var $lasth;              //height of last printed cell 
    4137var $LineWidth;          //line width in user unit 
    4238var $CoreFonts;          //array of standard font names 
     
    4440var $FontFiles;          //array of font files 
    4541var $diffs;              //array of encoding differences 
    46 var $images;             //array of used images 
    47 var $PageLinks;          //array of links in pages 
    48 var $links;              //array of internal links 
    4942var $FontFamily;         //current font family 
    5043var $FontStyle;          //current font style 
     
    5851var $ColorFlag;          //indicates whether fill and text colors are different 
    5952var $ws;                 //word spacing 
     53var $images;             //array of used images 
     54var $PageLinks;          //array of links in pages 
     55var $links;              //array of internal links 
    6056var $AutoPageBreak;      //automatic page breaking 
    6157var $PageBreakTrigger;   //threshold used to trigger page breaks 
     58var $InHeader;           //flag set when processing header 
    6259var $InFooter;           //flag set when processing footer 
    6360var $ZoomMode;           //zoom display mode 
     
    7673*                                                                              * 
    7774*******************************************************************************/ 
    78 function FPDF($orientation='P',$unit='mm',$format='A4') 
     75function FPDF($orientation='P', $unit='mm', $format='A4') 
    7976{ 
    8077    //Some checks 
     
    8582    $this->buffer=''; 
    8683    $this->pages=array(); 
    87     $this->OrientationChanges=array(); 
     84    $this->PageSizes=array(); 
    8885    $this->state=0; 
    8986    $this->fonts=array(); 
     
    9289    $this->images=array(); 
    9390    $this->links=array(); 
     91    $this->InHeader=false; 
    9492    $this->InFooter=false; 
    9593    $this->lasth=0; 
     
    104102    $this->ws=0; 
    105103    //Standard fonts 
    106     $this->CoreFonts=array('courier'=>'Courier','courierB'=>'Courier-Bold','courierI'=>'Courier-Oblique','courierBI'=>'Courier-BoldOblique', 
    107         'helvetica'=>'Helvetica','helveticaB'=>'Helvetica-Bold','helveticaI'=>'Helvetica-Oblique','helveticaBI'=>'Helvetica-BoldOblique', 
    108         'times'=>'Times-Roman','timesB'=>'Times-Bold','timesI'=>'Times-Italic','timesBI'=>'Times-BoldItalic', 
    109         'symbol'=>'Symbol','zapfdingbats'=>'ZapfDingbats'); 
     104    $this->CoreFonts=array('courier'=>'Courier', 'courierB'=>'Courier-Bold', 'courierI'=>'Courier-Oblique', 'courierBI'=>'Courier-BoldOblique', 
     105        'helvetica'=>'Helvetica', 'helveticaB'=>'Helvetica-Bold', 'helveticaI'=>'Helvetica-Oblique', 'helveticaBI'=>'Helvetica-BoldOblique', 
     106        'times'=>'Times-Roman', 'timesB'=>'Times-Bold', 'timesI'=>'Times-Italic', 'timesBI'=>'Times-BoldItalic', 
     107        'symbol'=>'Symbol', 'zapfdingbats'=>'ZapfDingbats'); 
    110108    //Scale factor 
    111109    if($unit=='pt') 
     
    120118        $this->Error('Incorrect unit: '.$unit); 
    121119    //Page format 
     120    $this->PageFormats=array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28), 
     121        'letter'=>array(612,792), 'legal'=>array(612,1008)); 
    122122    if(is_string($format)) 
    123     { 
    124         $format=strtolower($format); 
    125         if($format=='a3') 
    126             $format=array(841.89,1190.55); 
    127         elseif($format=='a4') 
    128             $format=array(595.28,841.89); 
    129         elseif($format=='a5') 
    130             $format=array(420.94,595.28); 
    131         elseif($format=='letter') 
    132             $format=array(612,792); 
    133         elseif($format=='legal') 
    134             $format=array(612,1008); 
    135         else 
    136             $this->Error('Unknown page format: '.$format); 
    137         $this->fwPt=$format[0]; 
    138         $this->fhPt=$format[1]; 
    139     } 
    140     else 
    141     { 
    142         $this->fwPt=$format[0]*$this->k; 
    143         $this->fhPt=$format[1]*$this->k; 
    144     } 
    145     $this->fw=$this->fwPt/$this->k; 
    146     $this->fh=$this->fhPt/$this->k; 
     123        $format=$this->_getpageformat($format); 
     124    $this->DefPageFormat=$format; 
     125    $this->CurPageFormat=$format; 
    147126    //Page orientation 
    148127    $orientation=strtolower($orientation); 
     
    150129    { 
    151130        $this->DefOrientation='P'; 
    152         $this->wPt=$this->fwPt; 
    153         $this->hPt=$this->fhPt; 
     131        $this->w=$this->DefPageFormat[0]; 
     132        $this->h=$this->DefPageFormat[1]; 
    154133    } 
    155134    elseif($orientation=='l' || $orientation=='landscape') 
    156135    { 
    157136        $this->DefOrientation='L'; 
    158         $this->wPt=$this->fhPt; 
    159         $this->hPt=$this->fwPt; 
     137        $this->w=$this->DefPageFormat[1]; 
     138        $this->h=$this->DefPageFormat[0]; 
    160139    } 
    161140    else 
    162141        $this->Error('Incorrect orientation: '.$orientation); 
    163142    $this->CurOrientation=$this->DefOrientation; 
    164     $this->w=$this->wPt/$this->k; 
    165     $this->h=$this->hPt/$this->k; 
     143    $this->wPt=$this->w*$this->k; 
     144    $this->hPt=$this->h*$this->k; 
    166145    //Page margins (1 cm) 
    167146    $margin=28.35/$this->k; 
     
    181160} 
    182161 
    183 function SetMargins($left,$top,$right=-1) 
     162function SetMargins($left, $top, $right=null) 
    184163{ 
    185164    //Set left, top and right margins 
    186165    $this->lMargin=$left; 
    187166    $this->tMargin=$top; 
    188     if($right==-1) 
     167    if($right===null) 
    189168        $right=$left; 
    190169    $this->rMargin=$right; 
     
    211190} 
    212191 
    213 function SetAutoPageBreak($auto,$margin=0) 
     192function SetAutoPageBreak($auto, $margin=0) 
    214193{ 
    215194    //Set auto page break mode and triggering margin 
     
    219198} 
    220199 
    221 function SetDisplayMode($zoom,$layout='continuous') 
     200function SetDisplayMode($zoom, $layout='continuous') 
    222201{ 
    223202    //Set display mode in viewer 
     
    241220} 
    242221 
    243 function SetTitle($title) 
     222function SetTitle($title, $isUTF8=false) 
    244223{ 
    245224    //Title of document 
     225    if($isUTF8) 
     226        $title=$this->_UTF8toUTF16($title); 
    246227    $this->title=$title; 
    247228} 
    248229 
    249 function SetSubject($subject) 
     230function SetSubject($subject, $isUTF8=false) 
    250231{ 
    251232    //Subject of document 
     233    if($isUTF8) 
     234        $subject=$this->_UTF8toUTF16($subject); 
    252235    $this->subject=$subject; 
    253236} 
    254237 
    255 function SetAuthor($author) 
     238function SetAuthor($author, $isUTF8=false) 
    256239{ 
    257240    //Author of document 
     241    if($isUTF8) 
     242        $author=$this->_UTF8toUTF16($author); 
    258243    $this->author=$author; 
    259244} 
    260245 
    261 function SetKeywords($keywords) 
     246function SetKeywords($keywords, $isUTF8=false) 
    262247{ 
    263248    //Keywords of document 
     249    if($isUTF8) 
     250        $keywords=$this->_UTF8toUTF16($keywords); 
    264251    $this->keywords=$keywords; 
    265252} 
    266253 
    267 function SetCreator($creator) 
     254function SetCreator($creator, $isUTF8=false) 
    268255{ 
    269256    //Creator of document 
     257    if($isUTF8) 
     258        $creator=$this->_UTF8toUTF16($creator); 
    270259    $this->creator=$creator; 
    271260} 
     
    280269{ 
    281270    //Fatal error 
    282     die('<B>FPDF error: </B>'.$msg); 
     271    die('<b>FPDF error:</b> '.$msg); 
    283272} 
    284273 
     
    306295} 
    307296 
    308 function AddPage($orientation='') 
     297function AddPage($orientation='', $format='') 
    309298{ 
    310299    //Start a new page 
     
    329318    } 
    330319    //Start new page 
    331     $this->_beginpage($orientation); 
     320    $this->_beginpage($orientation,$format); 
    332321    //Set line cap style to square 
    333322    $this->_out('2 J'); 
    334323    //Set line width 
    335324    $this->LineWidth=$lw; 
    336     $this->_out(sprintf('%.2f w',$lw*$this->k)); 
     325    $this->_out(sprintf('%.2F w',$lw*$this->k)); 
    337326    //Set font 
    338327    if($family) 
     
    348337    $this->ColorFlag=$cf; 
    349338    //Page header 
     339    $this->InHeader=true; 
    350340    $this->Header(); 
     341    $this->InHeader=false; 
    351342    //Restore line width 
    352343    if($this->LineWidth!=$lw) 
    353344    { 
    354345        $this->LineWidth=$lw; 
    355         $this->_out(sprintf('%.2f w',$lw*$this->k)); 
     346        $this->_out(sprintf('%.2F w',$lw*$this->k)); 
    356347    } 
    357348    //Restore font 
     
    389380} 
    390381 
    391 function SetDrawColor($r,$g=-1,$b=-1) 
     382function SetDrawColor($r, $g=null, $b=null) 
    392383{ 
    393384    //Set color for all stroking operations 
    394     if(($r==0 && $g==0 && $b==0) || $g==-1) 
    395         $this->DrawColor=sprintf('%.3f G',$r/255); 
    396     else 
    397         $this->DrawColor=sprintf('%.3f %.3f %.3f RG',$r/255,$g/255,$b/255); 
     385    if(($r==0 && $g==0 && $b==0) || $g===null) 
     386        $this->DrawColor=sprintf('%.3F G',$r/255); 
     387    else 
     388        $this->DrawColor=sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255); 
    398389    if($this->page>0) 
    399390        $this->_out($this->DrawColor); 
    400391} 
    401392 
    402 function SetFillColor($r,$g=-1,$b=-1) 
     393function SetFillColor($r, $g=null, $b=null) 
    403394{ 
    404395    //Set color for all filling operations 
    405     if(($r==0 && $g==0 && $b==0) || $g==-1) 
    406         $this->FillColor=sprintf('%.3f g',$r/255); 
    407     else 
    408         $this->FillColor=sprintf('%.3f %.3f %.3f rg',$r/255,$g/255,$b/255); 
     396    if(($r==0 && $g==0 && $b==0) || $g===null) 
     397        $this->FillColor=sprintf('%.3F g',$r/255); 
     398    else 
     399        $this->FillColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); 
    409400    $this->ColorFlag=($this->FillColor!=$this->TextColor); 
    410401    if($this->page>0) 
     
    412403} 
    413404 
    414 function SetTextColor($r,$g=-1,$b=-1) 
     405function SetTextColor($r, $g=null, $b=null) 
    415406{ 
    416407    //Set color for text 
    417     if(($r==0 && $g==0 && $b==0) || $g==-1) 
    418         $this->TextColor=sprintf('%.3f g',$r/255); 
    419     else 
    420         $this->TextColor=sprintf('%.3f %.3f %.3f rg',$r/255,$g/255,$b/255); 
     408    if(($r==0 && $g==0 && $b==0) || $g===null) 
     409        $this->TextColor=sprintf('%.3F g',$r/255); 
     410    else 
     411        $this->TextColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); 
    421412    $this->ColorFlag=($this->FillColor!=$this->TextColor); 
    422413} 
     
    430421    $l=strlen($s); 
    431422    for($i=0;$i<$l;$i++) 
    432         $w+=$cw[$s{$i}]; 
     423        $w+=$cw[$s[$i]]; 
    433424    return $w*$this->FontSize/1000; 
    434425} 
     
    439430    $this->LineWidth=$width; 
    440431    if($this->page>0) 
    441         $this->_out(sprintf('%.2f w',$width*$this->k)); 
    442 } 
    443  
    444 function Line($x1,$y1,$x2,$y2) 
     432        $this->_out(sprintf('%.2F w',$width*$this->k)); 
     433} 
     434 
     435function Line($x1, $y1, $x2, $y2) 
    445436{ 
    446437    //Draw a line 
    447     $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)); 
    448 } 
    449  
    450 function Rect($x,$y,$w,$h,$style='') 
     438    $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)); 
     439} 
     440 
     441function Rect($x, $y, $w, $h, $style='') 
    451442{ 
    452443    //Draw a rectangle 
     
    457448    else 
    458449        $op='S'; 
    459     $this->_out(sprintf('%.2f %.2f %.2f %.2f re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op)); 
    460 } 
    461  
    462 function AddFont($family,$style='',$file='') 
     450    $this->_out(sprintf('%.2F %.2F %.2F %.2F re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op)); 
     451} 
     452 
     453function AddFont($family, $style='', $file='') 
    463454{ 
    464455    //Add a TrueType or Type1 font 
     
    473464    $fontkey=$family.$style; 
    474465    if(isset($this->fonts[$fontkey])) 
    475         $this->Error('Font already added: '.$family.' '.$style); 
     466        return; 
    476467    include($this->_getfontpath().$file); 
    477468    if(!isset($name)) 
    478469        $this->Error('Could not include font definition file'); 
    479470    $i=count($this->fonts)+1; 
    480     $this->fonts[$fontkey]=array('i'=>$i,'type'=>$type,'name'=>$name,'desc'=>$desc,'up'=>$up,'ut'=>$ut,'cw'=>$cw,'enc'=>$enc,'file'=>$file); 
     471    $this->fonts[$fontkey]=array('i'=>$i, 'type'=>$type, 'name'=>$name, 'desc'=>$desc, 'up'=>$up, 'ut'=>$ut, 'cw'=>$cw, 'enc'=>$enc, 'file'=>$file); 
    481472    if($diff) 
    482473    { 
     
    504495            $this->FontFiles[$file]=array('length1'=>$originalsize); 
    505496        else 
    506             $this->FontFiles[$file]=array('length1'=>$size1,'length2'=>$size2); 
    507     } 
    508 } 
    509  
    510 function SetFont($family,$style='',$size=0) 
     497            $this->FontFiles[$file]=array('length1'=>$size1, 'length2'=>$size2); 
     498    } 
     499} 
     500 
     501function SetFont($family, $style='', $size=0) 
    511502{ 
    512503    //Select a font; size given in points 
     
    553544            } 
    554545            $i=count($this->fonts)+1; 
    555             $this->fonts[$fontkey]=array('i'=>$i,'type'=>'core','name'=>$this->CoreFonts[$fontkey],'up'=>-100,'ut'=>50,'cw'=>$fpdf_charwidths[$fontkey]); 
     546            $name=$this->CoreFonts[$fontkey]; 
     547            $cw=$fpdf_charwidths[$fontkey]; 
     548            $this->fonts[$fontkey]=array('i'=>$i, 'type'=>'core', 'name'=>$name, 'up'=>-100, 'ut'=>50, 'cw'=>$cw); 
    556549        } 
    557550        else 
     
    565558    $this->CurrentFont=&$this->fonts[$fontkey]; 
    566559    if($this->page>0) 
    567         $this->_out(sprintf('BT /F%d %.2f Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); 
     560        $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); 
    568561} 
    569562 
     
    576569    $this->FontSize=$size/$this->k; 
    577570    if($this->page>0) 
    578         $this->_out(sprintf('BT /F%d %.2f Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); 
     571        $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); 
    579572} 
    580573 
     
    583576    //Create a new internal link 
    584577    $n=count($this->links)+1; 
    585     $this->links[$n]=array(0,0); 
     578    $this->links[$n]=array(0, 0); 
    586579    return $n; 
    587580} 
    588581 
    589 function SetLink($link,$y=0,$page=-1) 
     582function SetLink($link, $y=0, $page=-1) 
    590583{ 
    591584    //Set destination of internal link 
     
    594587    if($page==-1) 
    595588        $page=$this->page; 
    596     $this->links[$link]=array($page,$y); 
    597 } 
    598  
    599 function Link($x,$y,$w,$h,$link) 
     589    $this->links[$link]=array($page, $y); 
     590} 
     591 
     592function Link($x, $y, $w, $h, $link) 
    600593{ 
    601594    //Put a link on the page 
    602     $this->PageLinks[$this->page][]=array($x*$this->k,$this->hPt-$y*$this->k,$w*$this->k,$h*$this->k,$link); 
    603 } 
    604  
    605 function Text($x,$y,$txt) 
     595    $this->PageLinks[$this->page][]=array($x*$this->k, $this->hPt-$y*$this->k, $w*$this->k, $h*$this->k, $link); 
     596} 
     597 
     598function Text($x, $y, $txt) 
    606599{ 
    607600    //Output a string 
    608     $s=sprintf('BT %.2f %.2f Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt)); 
     601    $s=sprintf('BT %.2F %.2F Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt)); 
    609602    if($this->underline && $txt!='') 
    610603        $s.=' '.$this->_dounderline($x,$y,$txt); 
     
    620613} 
    621614 
    622 function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='') 
     615function Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='') 
    623616{ 
    624617    //Output a cell 
    625618    $k=$this->k; 
    626     if($this->y+$h>$this->PageBreakTrigger && !$this->InFooter && $this->AcceptPageBreak()) 
     619    if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak()) 
    627620    { 
    628621        //Automatic page break 
     
    634627            $this->_out('0 Tw'); 
    635628        } 
    636         $this->AddPage($this->CurOrientation); 
     629        $this->AddPage($this->CurOrientation,$this->CurPageFormat); 
    637630        $this->x=$x; 
    638631        if($ws>0) 
    639632        { 
    640633            $this->ws=$ws; 
    641             $this->_out(sprintf('%.3f Tw',$ws*$k)); 
     634            $this->_out(sprintf('%.3F Tw',$ws*$k)); 
    642635        } 
    643636    } 
     
    645638        $w=$this->w-$this->rMargin-$this->x; 
    646639    $s=''; 
    647     if($fill==1 || $border==1) 
    648     { 
    649         if($fill==1) 
     640    if($fill || $border==1) 
     641    { 
     642        if($fill) 
    650643            $op=($border==1) ? 'B' : 'f'; 
    651644        else 
    652645            $op='S'; 
    653         $s=sprintf('%.2f %.2f %.2f %.2f re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op); 
     646        $s=sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op); 
    654647    } 
    655648    if(is_string($border)) 
     
    658651        $y=$this->y; 
    659652        if(strpos($border,'L')!==false) 
    660             $s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k); 
     653            $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k); 
    661654        if(strpos($border,'T')!==false) 
    662             $s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k); 
     655            $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k); 
    663656        if(strpos($border,'R')!==false) 
    664             $s.=sprintf('%.2f %.2f m %.2f %.2f l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k); 
     657            $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k); 
    665658        if(strpos($border,'B')!==false) 
    666             $s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k); 
     659            $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k); 
    667660    } 
    668661    if($txt!=='') 
     
    677670            $s.='q '.$this->TextColor.' '; 
    678671        $txt2=str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$txt))); 
    679         $s.=sprintf('BT %.2f %.2f Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txt2); 
     672        $s.=sprintf('BT %.2F %.2F Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txt2); 
    680673        if($this->underline) 
    681674            $s.=' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt); 
     
    699692} 
    700693 
    701 function MultiCell($w,$h,$txt,$border=0,$align='J',$fill=0, $ln = 2) 
     694function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false) 
    702695{ 
    703696    //Output text with automatic or explicit line breaks 
     
    735728    $ns=0; 
    736729    $nl=1; 
    737     $this->rise_h = 0; //‚‚³ŒvŽZ—p 
    738      
    739730    while($i<$nb) 
    740731    { 
    741732        //Get next character 
    742         $c=$s{$i}; 
     733        $c=$s[$i]; 
    743734        if($c=="\n") 
    744735        { 
     
    756747            $ns=0; 
    757748            $nl++; 
    758             $this->rise_h += $h; //‚‚³ŒvŽZ—p 
    759              
    760749            if($border && $nl==2) 
    761750                $b=$b2; 
     
    788777                { 
    789778                    $this->ws=($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0; 
    790                     $this->_out(sprintf('%.3f Tw',$this->ws*$this->k)); 
     779                    $this->_out(sprintf('%.3F Tw',$this->ws*$this->k)); 
    791780                } 
    792781                $this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill); 
    793782                $i=$sep+1; 
    794783            } 
    795             $this->rise_h += $h; //‚‚³ŒvŽZ—p 
    796784            $sep=-1; 
    797785            $j=$i; 
     
    813801    if($border && strpos($border,'B')!==false) 
    814802        $b.='B'; 
    815     $this->Cell($w,$h,substr($s,$j,$i-$j),$b,$ln,$align,$fill); 
    816     $this->rise_h += $h; //‘‰Á•ª‚̍‚‚³‚ðŒvŽZ 
    817     //‰üs‚È‚µÝ’è‚©‚A‚‚³‚ª‹K’è‚̍‚‚³ˆÈã‚Å‚ ‚ê‚ÎYŽ²‚ðÝ’肵‚È‚¨‚·B 
    818     if($ln == 0 and $h < $this->rise_h) { 
    819       $this->y = $this->y - $this->rise_h + $h; 
    820     } 
    821      
    822     //$this->x=$this->lMargin; 
    823 } 
    824  
    825 function Write($h,$txt,$link='') 
     803    $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); 
     804    $this->x=$this->lMargin; 
     805} 
     806 
     807function Write($h, $txt, $link='') 
    826808{ 
    827809    //Output text in flowing mode 
     
    839821    { 
    840822        //Get next character 
    841         $c=$s{$i}; 
     823        $c=$s[$i]; 
    842824        if($c=="\n") 
    843825        { 
     
    904886} 
    905887 
    906 function Image($file,$x,$y,$w=0,$h=0,$type='',$link='') 
     888function Ln($h=null) 
     889{ 
     890    //Line feed; default value is last cell height 
     891    $this->x=$this->lMargin; 
     892    if($h===null) 
     893        $this->y+=$this->lasth; 
     894    else 
     895        $this->y+=$h; 
     896} 
     897 
     898function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='') 
    907899{ 
    908900    //Put an image on the page 
    909901    if(!isset($this->images[$file])) 
    910902    { 
    911         //First use of image, get info 
     903        //First use of this image, get info 
    912904        if($type=='') 
    913905        { 
     
    918910        } 
    919911        $type=strtolower($type); 
    920         $mqr=get_magic_quotes_runtime(); 
    921         set_magic_quotes_runtime(0); 
    922         if($type=='jpg' || $type=='jpeg') 
    923             $info=$this->_parsejpg($file); 
    924         elseif($type=='png') 
    925             $info=$this->_parsepng($file); 
    926         else 
    927         { 
    928             //Allow for additional formats 
    929             $mtd='_parse'.$type; 
    930             if(!method_exists($this,$mtd)) 
    931                 $this->Error('Unsupported image type: '.$type); 
    932             $info=$this->$mtd($file); 
    933         } 
    934         set_magic_quotes_runtime($mqr); 
     912        if($type=='jpeg') 
     913            $type='jpg'; 
     914        $mtd='_parse'.$type; 
     915        if(!method_exists($this,$mtd)) 
     916            $this->Error('Unsupported image type: '.$type); 
     917        $info=$this->$mtd($file); 
    935918        $info['i']=count($this->images)+1; 
    936919        $this->images[$file]=$info; 
     
    945928        $h=$info['h']/$this->k; 
    946929    } 
    947     if($w==0) 
     930    elseif($w==0) 
    948931        $w=$h*$info['w']/$info['h']; 
    949     if($h==0) 
     932    elseif($h==0) 
    950933        $h=$w*$info['h']/$info['w']; 
    951     $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'])); 
     934    //Flowing mode 
     935    if($y===null) 
     936    { 
     937        if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak()) 
     938        { 
     939            //Automatic page break 
     940            $x2=$this->x; 
     941            $this->AddPage($this->CurOrientation,$this->CurPageFormat); 
     942            $this->x=$x2; 
     943        } 
     944        $y=$this->y; 
     945        $this->y+=$h; 
     946    } 
     947    if($x===null) 
     948        $x=$this->x; 
     949    $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'])); 
    952950    if($link) 
    953951        $this->Link($x,$y,$w,$h,$link); 
    954 } 
    955  
    956 function Ln($h='') 
    957 { 
    958     //Line feed; default value is last cell height 
    959     $this->x=$this->lMargin; 
    960     if(is_string($h)) 
    961         $this->y+=$this->lasth; 
    962     else 
    963         $this->y+=$h; 
    964952} 
    965953 
     
    995983} 
    996984 
    997 function SetXY($x,$y) 
     985function SetXY($x, $y) 
    998986{ 
    999987    //Set x and y positions 
     
    1002990} 
    1003991 
    1004 function Output($name='',$dest='') 
     992function Output($name='', $dest='') 
    1005993{ 
    1006994    //Output PDF to some destination 
    1007     //Finish document if necessary 
    1008995    if($this->state<3) 
    1009996        $this->Close(); 
    1010     //Normalize parameters 
    1011     if(is_bool($dest)) 
    1012         $dest=$dest ? 'D' : 'F'; 
    1013997    $dest=strtoupper($dest); 
    1014998    if($dest=='') 
     
    10261010        case 'I': 
    10271011            //Send to standard output 
    1028             if(ob_get_contents()) 
     1012            if(ob_get_length()) 
    10291013                $this->Error('Some data has already been output, can\'t send PDF file'); 
    10301014            if(php_sapi_name()!='cli') 
    10311015            { 
    10321016                //We send to a browser 
    1033                 if(isset($_SERVER['HTTP_USER_AGENT']) and strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')) { header('Pragma:'); } 
    10341017                header('Content-Type: application/pdf'); 
    10351018                if(headers_sent()) 
    1036                     $this->Error('Some data has already been output to browser, can\'t send PDF file'); 
     1019                    $this->Error('Some data has already been output, can\'t send PDF file'); 
    10371020                header('Content-Length: '.strlen($this->buffer)); 
    1038                 header('Content-disposition: inline; filename="'.$name.'"'); 
     1021                header('Content-Disposition: inline; filename="'.$name.'"'); 
     1022                header('Cache-Control: private, max-age=0, must-revalidate'); 
     1023                header('Pragma: public'); 
     1024                ini_set('zlib.output_compression','0'); 
    10391025            } 
    10401026            echo $this->buffer; 
     
    10421028        case 'D': 
    10431029            //Download file 
    1044             if(ob_get_contents()) 
     1030            if(ob_get_length()) 
    10451031                $this->Error('Some data has already been output, can\'t send PDF file'); 
    1046             if(isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')) { 
    1047                 header('Pragma:'); 
    1048                 header('Content-Type: application/force-download'); 
    1049             } 
    1050             else 
    1051                 header('Content-Type: application/octet-stream'); 
     1032            header('Content-Type: application/x-download'); 
    10521033            if(headers_sent()) 
    1053                 $this->Error('Some data has already been output to browser, can\'t send PDF file'); 
     1034                $this->Error('Some data has already been output, can\'t send PDF file'); 
    10541035            header('Content-Length: '.strlen($this->buffer)); 
    1055             header('Content-disposition: attachment; filename="'.$name.'"'); 
     1036            header('Content-Disposition: attachment; filename="'.$name.'"'); 
     1037            header('Cache-Control: private, max-age=0, must-revalidate'); 
     1038            header('Pragma: public'); 
     1039            ini_set('zlib.output_compression','0'); 
    10561040            echo $this->buffer; 
    10571041            break; 
     
    10801064function _dochecks() 
    10811065{ 
    1082     //Check for locale-related bug 
    1083     if(1.1==1) 
    1084         $this->Error('Don\'t alter the locale before including class file'); 
    1085     //Check for decimal separator 
    1086     if(sprintf('%.1f',1.0)!='1.0') 
    1087         setlocale(LC_NUMERIC,'C'); 
     1066    //Check availability of %F 
     1067    if(sprintf('%.1F',1.0)!='1.0') 
     1068        $this->Error('This version of PHP is not supported'); 
     1069    //Check mbstring overloading 
     1070    if(ini_get('mbstring.func_overload') & 2) 
     1071        $this->Error('mbstring overloading must be disabled'); 
     1072    //Disable runtime magic quotes 
     1073    if(get_magic_quotes_runtime()) 
     1074        @set_magic_quotes_runtime(0); 
     1075} 
     1076 
     1077function _getpageformat($format) 
     1078{ 
     1079    $format=strtolower($format); 
     1080    if(!isset($this->PageFormats[$format])) 
     1081        $this->Error('Unknown page format: '.$format); 
     1082    $a=$this->PageFormats[$format]; 
     1083    return array($a[0]/$this->k, $a[1]/$this->k); 
    10881084} 
    10891085 
     
    10951091} 
    10961092 
     1093function _beginpage($orientation, $format) 
     1094{ 
     1095    $this->page++; 
     1096    $this->pages[$this->page]=''; 
     1097    $this->state=2; 
     1098    $this->x=$this->lMargin; 
     1099    $this->y=$this->tMargin; 
     1100    $this->FontFamily=''; 
     1101    //Check page size 
     1102    if($orientation=='') 
     1103        $orientation=$this->DefOrientation; 
     1104    else 
     1105        $orientation=strtoupper($orientation[0]); 
     1106    if($format=='') 
     1107        $format=$this->DefPageFormat; 
     1108    else 
     1109    { 
     1110        if(is_string($format)) 
     1111            $format=$this->_getpageformat($format); 
     1112    } 
     1113    if($orientation!=$this->CurOrientation || $format[0]!=$this->CurPageFormat[0] || $format[1]!=$this->CurPageFormat[1]) 
     1114    { 
     1115        //New size 
     1116        if($orientation=='P') 
     1117        { 
     1118            $this->w=$format[0]; 
     1119            $this->h=$format[1]; 
     1120        } 
     1121        else 
     1122        { 
     1123            $this->w=$format[1]; 
     1124            $this->h=$format[0]; 
     1125        } 
     1126        $this->wPt=$this->w*$this->k; 
     1127        $this->hPt=$this->h*$this->k; 
     1128        $this->PageBreakTrigger=$this->h-$this->bMargin; 
     1129        $this->CurOrientation=$orientation; 
     1130        $this->CurPageFormat=$format; 
     1131    } 
     1132    if($orientation!=$this->DefOrientation || $format[0]!=$this->DefPageFormat[0] || $format[1]!=$this->DefPageFormat[1]) 
     1133        $this->PageSizes[$this->page]=array($this->wPt, $this->hPt); 
     1134} 
     1135 
     1136function _endpage() 
     1137{ 
     1138    $this->state=1; 
     1139} 
     1140 
     1141function _escape($s) 
     1142{ 
     1143    //Escape special characters in strings 
     1144    $s=str_replace('\\','\\\\',$s); 
     1145    $s=str_replace('(','\\(',$s); 
     1146    $s=str_replace(')','\\)',$s); 
     1147    $s=str_replace("\r",'\\r',$s); 
     1148    return $s; 
     1149} 
     1150 
     1151function _textstring($s) 
     1152{ 
     1153    //Format a text string 
     1154    return '('.$this->_escape($s).')'; 
     1155} 
     1156 
     1157function _UTF8toUTF16($s) 
     1158{ 
     1159    //Convert UTF-8 to UTF-16BE with BOM 
     1160    $res="\xFE\xFF"; 
     1161    $nb=strlen($s); 
     1162    $i=0; 
     1163    while($i<$nb) 
     1164    { 
     1165        $c1=ord($s[$i++]); 
     1166        if($c1>=224) 
     1167        { 
     1168            //3-byte character 
     1169            $c2=ord($s[$i++]); 
     1170            $c3=ord($s[$i++]); 
     1171            $res.=chr((($c1 & 0x0F)<<4) + (($c2 & 0x3C)>>2)); 
     1172            $res.=chr((($c2 & 0x03)<<6) + ($c3 & 0x3F)); 
     1173        } 
     1174        elseif($c1>=192) 
     1175        { 
     1176            //2-byte character 
     1177            $c2=ord($s[$i++]); 
     1178            $res.=chr(($c1 & 0x1C)>>2); 
     1179            $res.=chr((($c1 & 0x03)<<6) + ($c2 & 0x3F)); 
     1180        } 
     1181        else 
     1182        { 
     1183            //Single-byte character 
     1184            $res.="\0".chr($c1); 
     1185        } 
     1186    } 
     1187    return $res; 
     1188} 
     1189 
     1190function _dounderline($x, $y, $txt) 
     1191{ 
     1192    //Underline text 
     1193    $up=$this->CurrentFont['up']; 
     1194    $ut=$this->CurrentFont['ut']; 
     1195    $w=$this->GetStringWidth($txt)+$this->ws*substr_count($txt,' '); 
     1196    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); 
     1197} 
     1198 
     1199function _parsejpg($file) 
     1200{ 
     1201    //Extract info from a JPEG file 
     1202    $a=GetImageSize($file); 
     1203    if(!$a) 
     1204        $this->Error('Missing or incorrect image file: '.$file); 
     1205    if($a[2]!=2) 
     1206        $this->Error('Not a JPEG file: '.$file); 
     1207    if(!isset($a['channels']) || $a['channels']==3) 
     1208        $colspace='DeviceRGB'; 
     1209    elseif($a['channels']==4) 
     1210        $colspace='DeviceCMYK'; 
     1211    else 
     1212        $colspace='DeviceGray'; 
     1213    $bpc=isset($a['bits']) ? $a['bits'] : 8; 
     1214    //Read whole file 
     1215    $f=fopen($file,'rb'); 
     1216    $data=''; 
     1217    while(!feof($f)) 
     1218        $data.=fread($f,8192); 
     1219    fclose($f); 
     1220    return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data); 
     1221} 
     1222 
     1223function _parsepng($file) 
     1224{ 
     1225    //Extract info from a PNG file 
     1226    $f=fopen($file,'rb'); 
     1227    if(!$f) 
     1228        $this->Error('Can\'t open image file: '.$file); 
     1229    //Check signature 
     1230    if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) 
     1231        $this->Error('Not a PNG file: '.$file); 
     1232    //Read header chunk 
     1233    $this->_readstream($f,4); 
     1234    if($this->_readstream($f,4)!='IHDR') 
     1235        $this->Error('Incorrect PNG file: '.$file); 
     1236    $w=$this->_readint($f); 
     1237    $h=$this->_readint($f); 
     1238    $bpc=ord($this->_readstream($f,1)); 
     1239    if($bpc>8) 
     1240        $this->Error('16-bit depth not supported: '.$file); 
     1241    $ct=ord($this->_readstream($f,1)); 
     1242    if($ct==0) 
     1243        $colspace='DeviceGray'; 
     1244    elseif($ct==2) 
     1245        $colspace='DeviceRGB'; 
     1246    elseif($ct==3) 
     1247        $colspace='Indexed'; 
     1248    else 
     1249        $this->Error('Alpha channel not supported: '.$file); 
     1250    if(ord($this->_readstream($f,1))!=0) 
     1251        $this->Error('Unknown compression method: '.$file); 
     1252    if(ord($this->_readstream($f,1))!=0) 
     1253        $this->Error('Unknown filter method: '.$file); 
     1254    if(ord($this->_readstream($f,1))!=0) 
     1255        $this->Error('Interlacing not supported: '.$file); 
     1256    $this->_readstream($f,4); 
     1257    $parms='/DecodeParms <</Predictor 15 /Colors '.($ct==2 ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w.'>>'; 
     1258    //Scan chunks looking for palette, transparency and image data 
     1259    $pal=''; 
     1260    $trns=''; 
     1261    $data=''; 
     1262    do 
     1263    { 
     1264        $n=$this->_readint($f); 
     1265        $type=$this->_readstream($f,4); 
     1266        if($type=='PLTE') 
     1267        { 
     1268            //Read palette 
     1269            $pal=$this->_readstream($f,$n); 
     1270            $this->_readstream($f,4); 
     1271        } 
     1272        elseif($type=='tRNS') 
     1273        { 
     1274            //Read transparency info 
     1275            $t=$this->_readstream($f,$n); 
     1276            if($ct==0) 
     1277                $trns=array(ord(substr($t,1,1))); 
     1278            elseif($ct==2) 
     1279                $trns=array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1))); 
     1280            else 
     1281            { 
     1282                $pos=strpos($t,chr(0)); 
     1283                if($pos!==false) 
     1284                    $trns=array($pos); 
     1285            } 
     1286            $this->_readstream($f,4); 
     1287        } 
     1288        elseif($type=='IDAT') 
     1289        { 
     1290            //Read image data block 
     1291            $data.=$this->_readstream($f,$n); 
     1292            $this->_readstream($f,4); 
     1293        } 
     1294        elseif($type=='IEND') 
     1295            break; 
     1296        else 
     1297            $this->_readstream($f,$n+4); 
     1298    } 
     1299    while($n); 
     1300    if($colspace=='Indexed' && empty($pal)) 
     1301        $this->Error('Missing palette in '.$file); 
     1302    fclose($f); 
     1303    return array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'parms'=>$parms, 'pal'=>$pal, 'trns'=>$trns, 'data'=>$data); 
     1304} 
     1305 
     1306function _readstream($f, $n) 
     1307{ 
     1308    //Read n bytes from stream 
     1309    $res=''; 
     1310    while($n>0 && !feof($f)) 
     1311    { 
     1312        $s=fread($f,$n); 
     1313        if($s===false) 
     1314            $this->Error('Error while reading stream'); 
     1315        $n-=strlen($s); 
     1316        $res.=$s; 
     1317    } 
     1318    if($n>0) 
     1319        $this->Error('Unexpected end of stream'); 
     1320    return $res; 
     1321} 
     1322 
     1323function _readint($f) 
     1324{ 
     1325    //Read a 4-byte integer from stream 
     1326    $a=unpack('Ni',$this->_readstream($f,4)); 
     1327    return $a['i']; 
     1328} 
     1329 
     1330function _parsegif($file) 
     1331{ 
     1332    //Extract info from a GIF file (via PNG conversion) 
     1333    if(!function_exists('imagepng')) 
     1334        $this->Error('GD extension is required for GIF support'); 
     1335    if(!function_exists('imagecreatefromgif')) 
     1336        $this->Error('GD has no GIF read support'); 
     1337    $im=imagecreatefromgif($file); 
     1338    if(!$im) 
     1339        $this->Error('Missing or incorrect image file: '.$file); 
     1340    imageinterlace($im,0); 
     1341    $tmp=tempnam('.','gif'); 
     1342    if(!$tmp) 
     1343        $this->Error('Unable to create a temporary file'); 
     1344    if(!imagepng($im,$tmp)) 
     1345        $this->Error('Error while saving to temporary file'); 
     1346    imagedestroy($im); 
     1347    $info=$this->_parsepng($tmp); 
     1348    unlink($tmp); 
     1349    return $info; 
     1350} 
     1351 
     1352function _newobj() 
     1353{ 
     1354    //Begin a new object 
     1355    $this->n++; 
     1356    $this->offsets[$this->n]=strlen($this->buffer); 
     1357    $this->_out($this->n.' 0 obj'); 
     1358} 
     1359 
     1360function _putstream($s) 
     1361{ 
     1362    $this->_out('stream'); 
     1363    $this->_out($s); 
     1364    $this->_out('endstream'); 
     1365} 
     1366 
     1367function _out($s) 
     1368{ 
     1369    //Add a line to the document 
     1370    if($this->state==2) 
     1371        $this->pages[$this->page].=$s."\n"; 
     1372    else 
     1373        $this->buffer.=$s."\n"; 
     1374} 
     1375 
    10971376function _putpages() 
    10981377{ 
     
    11061385    if($this->DefOrientation=='P') 
    11071386    { 
    1108         $wPt=$this->fwPt; 
    1109         $hPt=$this->fhPt; 
    1110     } 
    1111     else 
    1112     { 
    1113         $wPt=$this->fhPt; 
    1114         $hPt=$this->fwPt; 
     1387        $wPt=$this->DefPageFormat[0]*$this->k; 
     1388        $hPt=$this->DefPageFormat[1]*$this->k; 
     1389    } 
     1390    else 
     1391    { 
     1392        $wPt=$this->DefPageFormat[1]*$this->k; 
     1393        $hPt=$this->DefPageFormat[0]*$this->k; 
    11151394    } 
    11161395    $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; 
     
    11211400        $this->_out('<</Type /Page'); 
    11221401        $this->_out('/Parent 1 0 R'); 
    1123         if(isset($this->OrientationChanges[$n])) 
    1124             $this->_out(sprintf('/MediaBox [0 0 %.2f %.2f]',$hPt,$wPt)); 
     1402        if(isset($this->PageSizes[$n])) 
     1403            $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageSizes[$n][0],$this->PageSizes[$n][1])); 
    11251404        $this->_out('/Resources 2 0 R'); 
    11261405        if(isset($this->PageLinks[$n])) 
     
    11301409            foreach($this->PageLinks[$n] as $pl) 
    11311410            { 
    1132                 $rect=sprintf('%.2f %.2f %.2f %.2f',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]); 
     1411                $rect=sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]); 
    11331412                $annots.='<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] '; 
    11341413                if(is_string($pl[4])) 
     
    11371416                { 
    11381417                    $l=$this->links[$pl[4]]; 
    1139                     $h=isset($this->OrientationChanges[$l[0]]) ? $wPt : $hPt; 
    1140                     $annots.=sprintf('/Dest [%d 0 R /XYZ 0 %.2f null]>>',1+2*$l[0],$h-$l[1]*$this->k); 
     1418                    $h=isset($this->PageSizes[$l[0]]) ? $this->PageSizes[$l[0]][1] : $hPt; 
     1419                    $annots.=sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>',1+2*$l[0],$h-$l[1]*$this->k); 
    11411420                } 
    11421421            } 
     
    11611440    $this->_out($kids.']'); 
    11621441    $this->_out('/Count '.$nb); 
    1163     $this->_out(sprintf('/MediaBox [0 0 %.2f %.2f]',$wPt,$hPt)); 
     1442    $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$wPt,$hPt)); 
    11641443    $this->_out('>>'); 
    11651444    $this->_out('endobj'); 
     
    11761455        $this->_out('endobj'); 
    11771456    } 
    1178     $mqr=get_magic_quotes_runtime(); 
    1179     set_magic_quotes_runtime(0); 
    11801457    foreach($this->FontFiles as $file=>$info) 
    11811458    { 
     
    11931470        if(!$compressed && isset($info['length2'])) 
    11941471        { 
    1195             $header=(ord($font{0})==128); 
     1472            $header=(ord($font[0])==128); 
    11961473            if($header) 
    11971474            { 
     
    11991476                $font=substr($font,6); 
    12001477            } 
    1201             if($header && ord($font{$info['length1']})==128) 
     1478            if($header && ord($font[$info['length1']])==128) 
    12021479            { 
    12031480                //Strip second binary header 
     
    12151492        $this->_out('endobj'); 
    12161493    } 
    1217     set_magic_quotes_runtime($mqr); 
    12181494    foreach($this->fonts as $k=>$font) 
    12191495    { 
     
    13751651    if(!empty($this->creator)) 
    13761652        $this->_out('/Creator '.$this->_textstring($this->creator)); 
    1377     $this->_out('/CreationDate '.$this->_textstring('D:'.date('YmdHis'))); 
     1653    $this->_out('/CreationDate '.$this->_textstring('D:'.@date('YmdHis'))); 
    13781654} 
    13791655 
     
    14441720    $this->state=3; 
    14451721} 
    1446  
    1447 function _beginpage($orientation) 
    1448 { 
    1449     $this->page++; 
    1450     $this->pages[$this->page]=''; 
    1451     $this->state=2; 
    1452     $this->x=$this->lMargin; 
    1453     $this->y=$this->tMargin; 
    1454     $this->FontFamily=''; 
    1455     //Page orientation 
    1456     if(!$orientation) 
    1457         $orientation=$this->DefOrientation; 
    1458     else 
    1459     { 
    1460         $orientation=strtoupper($orientation{0}); 
    1461         if($orientation!=$this->DefOrientation) 
    1462             $this->OrientationChanges[$this->page]=true; 
    1463     } 
    1464     if($orientation!=$this->CurOrientation) 
    1465     { 
    1466         //Change orientation 
    1467         if($orientation=='P') 
    1468         { 
    1469             $this->wPt=$this->fwPt; 
    1470             $this->hPt=$this->fhPt; 
    1471             $this->w=$this->fw; 
    1472             $this->h=$this->fh; 
    1473         } 
    1474         else 
    1475         { 
    1476             $this->wPt=$this->fhPt; 
    1477             $this->hPt=$this->fwPt; 
    1478             $this->w=$this->fh; 
    1479             $this->h=$this->fw; 
    1480         } 
    1481         $this->PageBreakTrigger=$this->h-$this->bMargin; 
    1482         $this->CurOrientation=$orientation; 
    1483     } 
    1484 } 
    1485  
    1486 function _endpage() 
    1487 { 
    1488     //End of page contents 
    1489     $this->state=1; 
    1490 } 
    1491  
    1492 function _newobj() 
    1493 { 
    1494     //Begin a new object 
    1495     $this->n++; 
    1496     $this->offsets[$this->n]=strlen($this->buffer); 
    1497     $this->_out($this->n.' 0 obj'); 
    1498 } 
    1499  
    1500 function _dounderline($x,$y,$txt) 
    1501 { 
    1502     //Underline text 
    1503     $up=$this->CurrentFont['up']; 
    1504     $ut=$this->CurrentFont['ut']; 
    1505     $w=$this->GetStringWidth($txt)+$this->ws*substr_count($txt,' '); 
    1506     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); 
    1507 } 
    1508  
    1509 function _parsejpg($file) 
    1510 { 
    1511     //Extract info from a JPEG file 
    1512     $a=GetImageSize($file); 
    1513     if(!$a) 
    1514         $this->Error('Missing or incorrect image file: '.$file); 
    1515     if($a[2]!=2) 
    1516         $this->Error('Not a JPEG file: '.$file); 
    1517     if(!isset($a['channels']) || $a['channels']==3) 
    1518         $colspace='DeviceRGB'; 
    1519     elseif($a['channels']==4) 
    1520         $colspace='DeviceCMYK'; 
    1521     else 
    1522         $colspace='DeviceGray'; 
    1523     $bpc=isset($a['bits']) ? $a['bits'] : 8; 
    1524     //Read whole file 
    1525     $f=fopen($file,'rb'); 
    1526     $data=''; 
    1527     while(!feof($f)) 
    1528         $data.=fread($f,4096); 
    1529     fclose($f); 
    1530     return array('w'=>$a[0],'h'=>$a[1],'cs'=>$colspace,'bpc'=>$bpc,'f'=>'DCTDecode','data'=>$data); 
    1531 } 
    1532  
    1533 function _parsepng($file) 
    1534 { 
    1535     //Extract info from a PNG file 
    1536     $f=fopen($file,'rb'); 
    1537     if(!$f) 
    1538         $this->Error('Can\'t open image file: '.$file); 
    1539     //Check signature 
    1540     if(fread($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) 
    1541         $this->Error('Not a PNG file: '.$file); 
    1542     //Read header chunk 
    1543     fread($f,4); 
    1544     if(fread($f,4)!='IHDR') 
    1545         $this->Error('Incorrect PNG file: '.$file); 
    1546     $w=$this->_freadint($f); 
    1547     $h=$this->_freadint($f); 
    1548     $bpc=ord(fread($f,1)); 
    1549     if($bpc>8) 
    1550         $this->Error('16-bit depth not supported: '.$file); 
    1551     $ct=ord(fread($f,1)); 
    1552     if($ct==0) 
    1553         $colspace='DeviceGray'; 
    1554     elseif($ct==2) 
    1555         $colspace='DeviceRGB'; 
    1556     elseif($ct==3) 
    1557         $colspace='Indexed'; 
    1558     else 
    1559         $this->Error('Alpha channel not supported: '.$file); 
    1560     if(ord(fread($f,1))!=0) 
    1561         $this->Error('Unknown compression method: '.$file); 
    1562     if(ord(fread($f,1))!=0) 
    1563         $this->Error('Unknown filter method: '.$file); 
    1564     if(ord(fread($f,1))!=0) 
    1565         $this->Error('Interlacing not supported: '.$file); 
    1566     fread($f,4); 
    1567     $parms='/DecodeParms <</Predictor 15 /Colors '.($ct==2 ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w.'>>'; 
    1568     //Scan chunks looking for palette, transparency and image data 
    1569     $pal=''; 
    1570     $trns=''; 
    1571     $data=''; 
    1572     do 
    1573     { 
    1574         $n=$this->_freadint($f); 
    1575         $type=fread($f,4); 
    1576         if($type=='PLTE') 
    1577         { 
    1578             //Read palette 
    1579             $pal=fread($f,$n); 
    1580             fread($f,4); 
    1581         } 
    1582         elseif($type=='tRNS') 
    1583         { 
    1584             //Read transparency info 
    1585             $t=fread($f,$n); 
    1586             if($ct==0) 
    1587                 $trns=array(ord(substr($t,1,1))); 
    1588             elseif($ct==2) 
    1589                 $trns=array(ord(substr($t,1,1)),ord(substr($t,3,1)),ord(substr($t,5,1))); 
    1590             else 
    1591             { 
    1592                 $pos=strpos($t,chr(0)); 
    1593                 if($pos!==false) 
    1594                     $trns=array($pos); 
    1595             } 
    1596             fread($f,4); 
    1597         } 
    1598         elseif($type=='IDAT') 
    1599         { 
    1600             //Read image data block 
    1601             $data.=fread($f,$n); 
    1602             fread($f,4); 
    1603         } 
    1604         elseif($type=='IEND') 
    1605             break; 
    1606         else 
    1607             fread($f,$n+4); 
    1608     } 
    1609     while($n); 
    1610     if($colspace=='Indexed' && empty($pal)) 
    1611         $this->Error('Missing palette in '.$file); 
    1612     fclose($f); 
    1613     return array('w'=>$w,'h'=>$h,'cs'=>$colspace,'bpc'=>$bpc,'f'=>'FlateDecode','parms'=>$parms,'pal'=>$pal,'trns'=>$trns,'data'=>$data); 
    1614 } 
    1615  
    1616 function _freadint($f) 
    1617 { 
    1618     //Read a 4-byte integer from file 
    1619     $a=unpack('Ni',fread($f,4)); 
    1620     return $a['i']; 
    1621 } 
    1622  
    1623 function _textstring($s) 
    1624 { 
    1625     //Format a text string 
    1626     return '('.$this->_escape($s).')'; 
    1627 } 
    1628  
    1629 function _escape($s) 
    1630 { 
    1631     //Add \ before \, ( and ) 
    1632     return str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$s))); 
    1633 } 
    1634  
    1635 function _putstream($s) 
    1636 { 
    1637     $this->_out('stream'); 
    1638     $this->_out($s); 
    1639     $this->_out('endstream'); 
    1640 } 
    1641  
    1642 function _out($s) 
    1643 { 
    1644     //Add a line to the document 
    1645     if($this->state==2) 
    1646         $this->pages[$this->page].=$s."\n"; 
    1647     else 
    1648         $this->buffer.=$s."\n"; 
    1649 } 
    16501722//End of class 
    16511723} 
     
    16581730} 
    16591731 
    1660 } 
    16611732?> 
Note: See TracChangeset for help on using the changeset viewer.