⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fpdf.php

📁 架設ROSE私服必備之物 ROSE數據庫
💻 PHP
📖 第 1 页 / 共 4 页
字号:
            {                if(isset($font['diff']))                    $this->_out('/Encoding '.($nf+$font['diff']).' 0 R');                else                    $this->_out('/Encoding /WinAnsiEncoding');            }            $this->_out('>>');            $this->_out('endobj');            //Widths            $this->_newobj();            $cw=&$font['cw'];            $s='[';            for($i=32;$i<=255;$i++)                $s.=$cw[chr($i)].' ';            $this->_out($s.']');            $this->_out('endobj');            //Descriptor            $this->_newobj();            $s='<</Type /FontDescriptor /FontName /'.$name;            foreach($font['desc'] as $k=>$v)                $s.=' /'.$k.' '.$v;            $file=$font['file'];            if($file)                $s.=' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R';            $this->_out($s.'>>');            $this->_out('endobj');        }        else        {            //Allow for additional types            $mtd='_put'.strtolower($type);            if(!method_exists($this,$mtd))                $this->Error('Unsupported font type: '.$type);            $this->$mtd($font);        }    }}function _putimages(){    $filter=($this->compress) ? '/Filter /FlateDecode ' : '';    reset($this->images);    while(list($file,$info)=each($this->images))    {        $this->_newobj();        $this->images[$file]['n']=$this->n;        $this->_out('<</Type /XObject');        $this->_out('/Subtype /Image');        $this->_out('/Width '.$info['w']);        $this->_out('/Height '.$info['h']);        if($info['cs']=='Indexed')            $this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]');        else        {            $this->_out('/ColorSpace /'.$info['cs']);            if($info['cs']=='DeviceCMYK')                $this->_out('/Decode [1 0 1 0 1 0 1 0]');        }        $this->_out('/BitsPerComponent '.$info['bpc']);        $this->_out('/Filter /'.$info['f']);        if(isset($info['parms']))            $this->_out($info['parms']);        if(isset($info['trns']) and is_array($info['trns']))        {            $trns='';            for($i=0;$i<count($info['trns']);$i++)                $trns.=$info['trns'][$i].' '.$info['trns'][$i].' ';            $this->_out('/Mask ['.$trns.']');        }        $this->_out('/Length '.strlen($info['data']).'>>');        $this->_putstream($info['data']);        unset($this->images[$file]['data']);        $this->_out('endobj');        //Palette        if($info['cs']=='Indexed')        {            $this->_newobj();            $pal=($this->compress) ? gzcompress($info['pal']) : $info['pal'];            $this->_out('<<'.$filter.'/Length '.strlen($pal).'>>');            $this->_putstream($pal);            $this->_out('endobj');        }    }}function _putresources(){    $this->_putfonts();    $this->_putimages();    //Resource dictionary    $this->offsets[2]=strlen($this->buffer);    $this->_out('2 0 obj');    $this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');    $this->_out('/Font <<');    foreach($this->fonts as $font)        $this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');    $this->_out('>>');    if(count($this->images))    {        $this->_out('/XObject <<');        foreach($this->images as $image)            $this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');        $this->_out('>>');    }    $this->_out('>>');    $this->_out('endobj');}function _putinfo(){    $this->_out('/Producer '.$this->_textstring('FPDF '.FPDF_VERSION));    if(!empty($this->title))        $this->_out('/Title '.$this->_textstring($this->title));    if(!empty($this->subject))        $this->_out('/Subject '.$this->_textstring($this->subject));    if(!empty($this->author))        $this->_out('/Author '.$this->_textstring($this->author));    if(!empty($this->keywords))        $this->_out('/Keywords '.$this->_textstring($this->keywords));    if(!empty($this->creator))        $this->_out('/Creator '.$this->_textstring($this->creator));    $this->_out('/CreationDate '.$this->_textstring('D:'.date('YmdHis')));}function _putcatalog(){    $this->_out('/Type /Catalog');    $this->_out('/Pages 1 0 R');    if($this->ZoomMode=='fullpage')        $this->_out('/OpenAction [3 0 R /Fit]');    elseif($this->ZoomMode=='fullwidth')        $this->_out('/OpenAction [3 0 R /FitH null]');    elseif($this->ZoomMode=='real')        $this->_out('/OpenAction [3 0 R /XYZ null null 1]');    elseif(!is_string($this->ZoomMode))        $this->_out('/OpenAction [3 0 R /XYZ null null '.($this->ZoomMode/100).']');    if($this->LayoutMode=='single')        $this->_out('/PageLayout /SinglePage');    elseif($this->LayoutMode=='continuous')        $this->_out('/PageLayout /OneColumn');    elseif($this->LayoutMode=='two')        $this->_out('/PageLayout /TwoColumnLeft');}function _puttrailer(){    $this->_out('/Size '.($this->n+1));    $this->_out('/Root '.$this->n.' 0 R');    $this->_out('/Info '.($this->n-1).' 0 R');}function _enddoc(){    $this->_putpages();    $this->_putresources();    //Info    $this->_newobj();    $this->_out('<<');    $this->_putinfo();    $this->_out('>>');    $this->_out('endobj');    //Catalog    $this->_newobj();    $this->_out('<<');    $this->_putcatalog();    $this->_out('>>');    $this->_out('endobj');    //Cross-ref    $o=strlen($this->buffer);    $this->_out('xref');    $this->_out('0 '.($this->n+1));    $this->_out('0000000000 65535 f ');    for($i=1;$i<=$this->n;$i++)        $this->_out(sprintf('%010d 00000 n ',$this->offsets[$i]));    //Trailer    $this->_out('trailer');    $this->_out('<<');    $this->_puttrailer();    $this->_out('>>');    $this->_out('startxref');    $this->_out($o);    $this->_out('%%EOF');    $this->state=3;}function _beginpage($orientation){    $this->page++;    $this->pages[$this->page]='';    $this->state=2;    $this->x=$this->lMargin;    $this->y=$this->tMargin;    $this->FontFamily='';    //Page orientation    if(!$orientation)        $orientation=$this->DefOrientation;    else    {        $orientation=strtoupper($orientation{0});        if($orientation!=$this->DefOrientation)            $this->OrientationChanges[$this->page]=true;    }    if($orientation!=$this->CurOrientation)    {        //Change orientation        if($orientation=='P')        {            $this->wPt=$this->fwPt;            $this->hPt=$this->fhPt;            $this->w=$this->fw;            $this->h=$this->fh;        }        else        {            $this->wPt=$this->fhPt;            $this->hPt=$this->fwPt;            $this->w=$this->fh;            $this->h=$this->fw;        }        $this->PageBreakTrigger=$this->h-$this->bMargin;        $this->CurOrientation=$orientation;    }}function _endpage(){    //End of page contents    $this->state=1;}function _newobj(){    //Begin a new object    $this->n++;    $this->offsets[$this->n]=strlen($this->buffer);    $this->_out($this->n.' 0 obj');}function _dounderline($x,$y,$txt){    //Underline text    $up=$this->CurrentFont['up'];    $ut=$this->CurrentFont['ut'];    $w=$this->GetStringWidth($txt)+$this->ws*substr_count($txt,' ');    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);}function _parsejpg($file){    //Extract info from a JPEG file    $a=GetImageSize($file);    if(!$a)        $this->Error('Missing or incorrect image file: '.$file);    if($a[2]!=2)        $this->Error('Not a JPEG file: '.$file);    if(!isset($a['channels']) or $a['channels']==3)        $colspace='DeviceRGB';    elseif($a['channels']==4)        $colspace='DeviceCMYK';    else        $colspace='DeviceGray';    $bpc=isset($a['bits']) ? $a['bits'] : 8;    //Read whole file    $f=fopen($file,'rb');    $data='';    while(!feof($f))        $data.=fread($f,4096);    fclose($f);    return array('w'=>$a[0],'h'=>$a[1],'cs'=>$colspace,'bpc'=>$bpc,'f'=>'DCTDecode','data'=>$data);}function _parsepng($file){    //Extract info from a PNG file    $f=fopen($file,'rb');    if(!$f)        $this->Error('Can\'t open image file: '.$file);    //Check signature    if(fread($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10))        $this->Error('Not a PNG file: '.$file);    //Read header chunk    fread($f,4);    if(fread($f,4)!='IHDR')        $this->Error('Incorrect PNG file: '.$file);    $w=$this->_freadint($f);    $h=$this->_freadint($f);    $bpc=ord(fread($f,1));    if($bpc>8)        $this->Error('16-bit depth not supported: '.$file);    $ct=ord(fread($f,1));    if($ct==0)        $colspace='DeviceGray';    elseif($ct==2)        $colspace='DeviceRGB';    elseif($ct==3)        $colspace='Indexed';    else        $this->Error('Alpha channel not supported: '.$file);    if(ord(fread($f,1))!=0)        $this->Error('Unknown compression method: '.$file);    if(ord(fread($f,1))!=0)        $this->Error('Unknown filter method: '.$file);    if(ord(fread($f,1))!=0)        $this->Error('Interlacing not supported: '.$file);    fread($f,4);    $parms='/DecodeParms <</Predictor 15 /Colors '.($ct==2 ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w.'>>';    //Scan chunks looking for palette, transparency and image data    $pal='';    $trns='';    $data='';    do    {        $n=$this->_freadint($f);        $type=fread($f,4);        if($type=='PLTE')        {            //Read palette            $pal=fread($f,$n);            fread($f,4);        }        elseif($type=='tRNS')        {            //Read transparency info            $t=fread($f,$n);            if($ct==0)                $trns=array(ord(substr($t,1,1)));            elseif($ct==2)                $trns=array(ord(substr($t,1,1)),ord(substr($t,3,1)),ord(substr($t,5,1)));            else            {                $pos=strpos($t,chr(0));                if(is_int($pos))                    $trns=array($pos);            }            fread($f,4);        }        elseif($type=='IDAT')        {            //Read image data block            $data.=fread($f,$n);            fread($f,4);        }        elseif($type=='IEND')            break;        else            fread($f,$n+4);    }    while($n);    if($colspace=='Indexed' and empty($pal))        $this->Error('Missing palette in '.$file);    fclose($f);    return array('w'=>$w,'h'=>$h,'cs'=>$colspace,'bpc'=>$bpc,'f'=>'FlateDecode','parms'=>$parms,'pal'=>$pal,'trns'=>$trns,'data'=>$data);}function _freadint($f){    //Read a 4-byte integer from file    $i=ord(fread($f,1))<<24;    $i+=ord(fread($f,1))<<16;    $i+=ord(fread($f,1))<<8;    $i+=ord(fread($f,1));    return $i;}function _textstring($s){    //Format a text string    return '('.$this->_escape($s).')';}function _escape($s){    //Add \ before \, ( and )    return str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$s)));}function _putstream($s){    $this->_out('stream');    $this->_out($s);    $this->_out('endstream');}function _out($s){    //Add a line to the document    if($this->state==2)        $this->pages[$this->page].=$s."\n";    else        $this->buffer.=$s."\n";}//End of class}//Handle special IE contype request// lem9//if(isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']) and $HTTP_SERVER_VARS['HTTP_USER_AGENT']=='contype')if(PMA_getenv('HTTP_USER_AGENT') == 'contype'){    Header('Content-Type: application/pdf');    exit;}}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -