Comparando archivos fpdf.php y ..\FPDF\fpdf.php ***** fpdf.php * Software: FPDF * * Version: 1.53 * * Date: 2004-12-31 * * Author: Olivier PLATHEY * ***** ..\FPDF\fpdf.php * Software: FPDF * * Version: 1.52 * * Date: 2003-12-30 * * Author: Olivier PLATHEY * ***** ***** fpdf.php * * * You may use, modify and redistribute this software as you wish. * *******************************************************************************/ ***** ..\FPDF\fpdf.php * * * You may use and modify this software as you wish. * *******************************************************************************/ ***** ***** fpdf.php if(!class_exists('FPDF')) ***** ..\FPDF\fpdf.php //define('FPDF_FONTPATH','../fpdf/font/'); // añadido por 'aida' el 1/12/2004 if(!class_exists('FPDF')) ***** ***** fpdf.php { define('FPDF_VERSION','1.53'); ***** ..\FPDF\fpdf.php { define('FPDF_VERSION','1.52'); ***** ***** fpdf.php var $AliasNbPages; //alias for total number of pages var $PDFVersion; //PDF version number ***** ..\FPDF\fpdf.php var $AliasNbPages; //alias for total number of pages ***** ***** fpdf.php $orientation=strtolower($orientation); if($orientation=='p' || $orientation=='portrait') { ***** ..\FPDF\fpdf.php $orientation=strtolower($orientation); if($orientation=='p' or $orientation=='portrait') { ***** ***** fpdf.php } elseif($orientation=='l' || $orientation=='landscape') { ***** ..\FPDF\fpdf.php } elseif($orientation=='l' or $orientation=='landscape') { ***** ***** fpdf.php $this->SetDisplayMode('fullwidth'); //Enable compression $this->SetCompression(true); //Set default PDF version number $this->PDFVersion='1.3'; } ***** ..\FPDF\fpdf.php $this->SetDisplayMode('fullwidth'); //Compression $this->SetCompression(true); } ***** ***** fpdf.php $this->lMargin=$margin; if($this->page>0 && $this->x<$margin) $this->x=$margin; ***** ..\FPDF\fpdf.php $this->lMargin=$margin; if($this->page>0 and $this->x<$margin) $this->x=$margin; ***** ***** fpdf.php //Set display mode in viewer if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom)) $this->ZoomMode=$zoom; ***** ..\FPDF\fpdf.php //Set display mode in viewer if($zoom=='fullpage' or $zoom=='fullwidth' or $zoom=='real' or $zoom=='default' or !is_string($zoom)) $this->ZoomMode=$zoom; ***** ***** fpdf.php $this->Error('Incorrect zoom display mode: '.$zoom); if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') $this->LayoutMode=$layout; ***** ..\FPDF\fpdf.php $this->Error('Incorrect zoom display mode: '.$zoom); if($layout=='single' or $layout=='continuous' or $layout=='two' or $layout=='default') $this->LayoutMode=$layout; ***** ***** fpdf.php //Begin document $this->state=1; } ***** ..\FPDF\fpdf.php //Begin document if($this->state==0) $this->_begindoc(); } ***** ***** fpdf.php //Set color for all stroking operations if(($r==0 && $g==0 && $b==0) || $g==-1) $this->DrawColor=sprintf('%.3f G',$r/255); ***** ..\FPDF\fpdf.php //Set color for all stroking operations if(($r==0 and $g==0 and $b==0) or $g==-1) $this->DrawColor=sprintf('%.3f G',$r/255); ***** ***** fpdf.php //Set color for all filling operations if(($r==0 && $g==0 && $b==0) || $g==-1) $this->FillColor=sprintf('%.3f g',$r/255); ***** ..\FPDF\fpdf.php //Set color for all filling operations if(($r==0 and $g==0 and $b==0) or $g==-1) $this->FillColor=sprintf('%.3f g',$r/255); ***** ***** fpdf.php //Set color for text if(($r==0 && $g==0 && $b==0) || $g==-1) $this->TextColor=sprintf('%.3f g',$r/255); ***** ..\FPDF\fpdf.php //Set color for text if(($r==0 and $g==0 and $b==0) or $g==-1) $this->TextColor=sprintf('%.3f g',$r/255); ***** ***** fpdf.php $op='f'; elseif($style=='FD' || $style=='DF') $op='B'; ***** ..\FPDF\fpdf.php $op='f'; elseif($style=='FD' or $style=='DF') $op='B'; ***** ***** fpdf.php $family=strtolower($family); if($file=='') $file=str_replace(' ','',$family).strtolower($style).'.php'; if($family=='arial') ***** ..\FPDF\fpdf.php $family=strtolower($family); if($family=='arial') ***** ***** fpdf.php $style='BI'; $fontkey=$family.$style; if(isset($this->fonts[$fontkey])) $this->Error('Font already added: '.$family.' '.$style); include($this->_getfontpath().$file); if(!isset($name)) ***** ..\FPDF\fpdf.php $style='BI'; if(isset($this->fonts[$family.$style])) $this->Error('Font already added: '.$family.' '.$style); if($file=='') $file=str_replace(' ','',$family).strtolower($style).'.php'; if(defined('FPDF_FONTPATH')) $file=FPDF_FONTPATH.$file; include($file); if(!isset($name)) ***** ***** fpdf.php $i=count($this->fonts)+1; $this->fonts[$fontkey]=array('i'=>$i,'type'=>$type,'name'=>$name,'desc'=>$desc,'up'=>$up,'ut'=>$ut,'cw'=>$cw,'enc'=>$en ,'file'=>$file); if($diff) ***** ..\FPDF\fpdf.php $i=count($this->fonts)+1; $this->fonts[$family.$style]=array('i'=>$i,'type'=>$type,'name'=>$name,'desc'=>$desc,'up'=>$up,'ut'=>$ut,'cw'=>$cw,'enc =>$enc,'file'=>$file); if($diff) ***** ***** fpdf.php for($i=1;$i<=$nb;$i++) { if($this->diffs[$i]==$diff) ***** ..\FPDF\fpdf.php for($i=1;$i<=$nb;$i++) if($this->diffs[$i]==$diff) ***** ***** fpdf.php } } if($d==0) ***** ..\FPDF\fpdf.php } if($d==0) ***** ***** fpdf.php } $this->fonts[$fontkey]['diff']=$d; } ***** ..\FPDF\fpdf.php } $this->fonts[$family.$style]['diff']=$d; } ***** ***** fpdf.php $family='helvetica'; elseif($family=='symbol' || $family=='zapfdingbats') $style=''; ***** ..\FPDF\fpdf.php $family='helvetica'; elseif($family=='symbol' or $family=='zapfdingbats') $style=''; ***** ***** fpdf.php $style=strtoupper($style); if(strpos($style,'U')!==false) { ***** ..\FPDF\fpdf.php $style=strtoupper($style); if(is_int(strpos($style,'U'))) { ***** ***** fpdf.php //Test if font is already selected if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size) return; ***** ..\FPDF\fpdf.php //Test if font is already selected if($this->FontFamily==$family and $this->FontStyle==$style and $this->FontSizePt==$size) return; ***** ***** fpdf.php $file=$family; if($family=='times' || $family=='helvetica') $file.=strtolower($style); include($this->_getfontpath().$file.'.php'); if(!isset($fpdf_charwidths[$fontkey])) ***** ..\FPDF\fpdf.php $file=$family; if($family=='times' or $family=='helvetica') $file.=strtolower($style); $file.='.php'; if(defined('FPDF_FONTPATH')) $file=FPDF_FONTPATH.$file; include($file); if(!isset($fpdf_charwidths[$fontkey])) ***** ***** fpdf.php $s=sprintf('BT %.2f %.2f Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt)); if($this->underline && $txt!='') $s.=' '.$this->_dounderline($x,$y,$txt); ***** ..\FPDF\fpdf.php $s=sprintf('BT %.2f %.2f Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt)); if($this->underline and $txt!='') $s.=' '.$this->_dounderline($x,$y,$txt); ***** ***** fpdf.php $k=$this->k; if($this->y+$h>$this->PageBreakTrigger && !$this->InFooter && $this->AcceptPageBreak()) { ***** ..\FPDF\fpdf.php $k=$this->k; if($this->y+$h>$this->PageBreakTrigger and !$this->InFooter and $this->AcceptPageBreak()) { ***** ***** fpdf.php $s=''; if($fill==1 || $border==1) { ***** ..\FPDF\fpdf.php $s=''; if($fill==1 or $border==1) { ***** ***** fpdf.php $y=$this->y; if(strpos($border,'L')!==false) $s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k); if(strpos($border,'T')!==false) $s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k); if(strpos($border,'R')!==false) $s.=sprintf('%.2f %.2f m %.2f %.2f l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k); ***** ..\FPDF\fpdf.php $y=$this->y; if(is_int(strpos($border,'L'))) $s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k); if(is_int(strpos($border,'T'))) $s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k); if(is_int(strpos($border,'R'))) $s.=sprintf('%.2f %.2f m %.2f %.2f l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k); ***** ***** fpdf.php if(strpos($border,'B')!==false) $s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k); ***** ..\FPDF\fpdf.php if(is_int(strpos($border,'B'))) $s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k); ***** ***** fpdf.php } if($txt!=='') { ***** ..\FPDF\fpdf.php } if($txt!='') { ***** ***** fpdf.php $nb=strlen($s); if($nb>0 && $s[$nb-1]=="\n") $nb--; ***** ..\FPDF\fpdf.php $nb=strlen($s); if($nb>0 and $s[$nb-1]=="\n") $nb--; ***** ***** fpdf.php $b2=''; if(strpos($border,'L')!==false) $b2.='L'; if(strpos($border,'R')!==false) $b2.='R'; $b=(strpos($border,'T')!==false) ? $b2.'T' : $b2; } ***** ..\FPDF\fpdf.php $b2=''; if(is_int(strpos($border,'L'))) $b2.='L'; if(is_int(strpos($border,'R'))) $b2.='R'; $b=is_int(strpos($border,'T')) ? $b2.'T' : $b2; } ***** ***** fpdf.php $nl++; if($border && $nl==2) $b=$b2; ***** ..\FPDF\fpdf.php $nl++; if($border and $nl==2) $b=$b2; ***** ***** fpdf.php $nl++; if($border && $nl==2) $b=$b2; ***** ..\FPDF\fpdf.php $nl++; if($border and $nl==2) $b=$b2; ***** ***** fpdf.php } if($border && strpos($border,'B')!==false) $b.='B'; ***** ..\FPDF\fpdf.php } if($border and is_int(strpos($border,'B'))) $b.='B'; ***** ***** fpdf.php set_magic_quotes_runtime(0); if($type=='jpg' || $type=='jpeg') $info=$this->_parsejpg($file); ***** ..\FPDF\fpdf.php set_magic_quotes_runtime(0); if($type=='jpg' or $type=='jpeg') $info=$this->_parsejpg($file); ***** ***** fpdf.php //Automatic width and height calculation if needed if($w==0 && $h==0) { ***** ..\FPDF\fpdf.php //Automatic width and height calculation if needed if($w==0 and $h==0) { ***** ***** fpdf.php //Output PDF to some destination //Finish document if necessary ***** ..\FPDF\fpdf.php //Output PDF to some destination global $HTTP_SERVER_VARS; //Finish document if necessary ***** ***** fpdf.php //Send to standard output if(ob_get_contents()) $this->Error('Some data has already been output, can\'t send PDF file'); if(php_sapi_name()!='cli') { ***** ..\FPDF\fpdf.php //Send to standard output if(isset($HTTP_SERVER_VARS['SERVER_NAME'])) { ***** ***** fpdf.php //We send to a browser header('Content-Type: application/pdf'); if(headers_sent()) ***** ..\FPDF\fpdf.php //We send to a browser Header('Content-Type: application/pdf'); if(headers_sent()) ***** ***** fpdf.php $this->Error('Some data has already been output to browser, can\'t send PDF file'); header('Content-Length: '.strlen($this->buffer)); header('Content-disposition: inline; filename="'.$name.'"'); } ***** ..\FPDF\fpdf.php $this->Error('Some data has already been output to browser, can\'t send PDF file'); Header('Content-Length: '.strlen($this->buffer)); Header('Content-disposition: inline; filename='.$name); } ***** ***** fpdf.php //Download file if(ob_get_contents()) $this->Error('Some data has already been output, can\'t send PDF file'); if(isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')) header('Content-Type: application/force-download'); else header('Content-Type: application/octet-stream'); if(headers_sent()) ***** ..\FPDF\fpdf.php //Download file if(isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']) and strpos($HTTP_SERVER_VARS['HTTP_USER_AGENT'],'MSIE')) Header('Content-Type: application/force-download'); else Header('Content-Type: application/octet-stream'); if(headers_sent()) ***** ***** fpdf.php $this->Error('Some data has already been output to browser, can\'t send PDF file'); header('Content-Length: '.strlen($this->buffer)); header('Content-disposition: attachment; filename="'.$name.'"'); echo $this->buffer; ***** ..\FPDF\fpdf.php $this->Error('Some data has already been output to browser, can\'t send PDF file'); Header('Content-Length: '.strlen($this->buffer)); Header('Content-disposition: attachment; filename='.$name); echo $this->buffer; ***** ***** fpdf.php function _getfontpath() { if(!defined('FPDF_FONTPATH') && is_dir(dirname(__FILE__).'/font')) define('FPDF_FONTPATH',dirname(__FILE__).'/font/'); return defined('FPDF_FONTPATH') ? FPDF_FONTPATH : ''; } ***** ..\FPDF\fpdf.php function _begindoc() { //Start document $this->state=1; $this->_out('%PDF-1.3'); } ***** ***** fpdf.php { //Replace number of pages ***** ..\FPDF\fpdf.php { // added by Aida-Set (15/2/2005) to get better align (only aprox) $nb = str_pad($nb,strlen($this->AliasNbPages),' ',STR_PAD_LEFT); // end adding //Replace number of pages ***** ***** fpdf.php $this->FontFiles[$file]['n']=$this->n; $font=''; $f=fopen($this->_getfontpath().$file,'rb',1); if(!$f) $this->Error('Font file not found'); while(!feof($f)) $font.=fread($f,8192); fclose($f); $compressed=(substr($file,-2)=='.z'); if(!$compressed && isset($info['length2'])) { $header=(ord($font{0})==128); if($header) { //Strip first binary header $font=substr($font,6); } if($header && ord($font{$info['length1']})==128) { //Strip second binary header $font=substr($font,0,$info['length1']).substr($font,$info['length1']+6); } } $this->_out('<_out('/Filter /FlateDecode'); ***** ..\FPDF\fpdf.php $this->FontFiles[$file]['n']=$this->n; if(defined('FPDF_FONTPATH')) $file=FPDF_FONTPATH.$file; $size=filesize($file); if(!$size) $this->Error('Font file not found'); $this->_out('<_out('/Filter /FlateDecode'); ***** ***** fpdf.php $this->_out('>>'); $this->_putstream($font); $this->_out('endobj'); ***** ..\FPDF\fpdf.php $this->_out('>>'); $f=fopen($file,'rb'); $this->_putstream(fread($f,$size)); fclose($f); $this->_out('endobj'); ***** ***** fpdf.php $this->_out('/Subtype /Type1'); if($name!='Symbol' && $name!='ZapfDingbats') $this->_out('/Encoding /WinAnsiEncoding'); ***** ..\FPDF\fpdf.php $this->_out('/Subtype /Type1'); if($name!='Symbol' and $name!='ZapfDingbats') $this->_out('/Encoding /WinAnsiEncoding'); ***** ***** fpdf.php } elseif($type=='Type1' || $type=='TrueType') { ***** ..\FPDF\fpdf.php } elseif($type=='Type1' or $type=='TrueType') { ***** ***** fpdf.php $this->_out('/BitsPerComponent '.$info['bpc']); if(isset($info['f'])) $this->_out('/Filter /'.$info['f']); if(isset($info['parms'])) ***** ..\FPDF\fpdf.php $this->_out('/BitsPerComponent '.$info['bpc']); $this->_out('/Filter /'.$info['f']); if(isset($info['parms'])) ***** ***** fpdf.php $this->_out($info['parms']); if(isset($info['trns']) && is_array($info['trns'])) { ***** ..\FPDF\fpdf.php $this->_out($info['parms']); if(isset($info['trns']) and is_array($info['trns'])) { ***** ***** fpdf.php function _putxobjectdict() { foreach($this->images as $image) $this->_out('/I'.$image['i'].' '.$image['n'].' 0 R'); } function _putresourcedict() { $this->_out('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]'); $this->_out('/Font <<'); ***** ..\FPDF\fpdf.php function _putresources() { $this->_putfonts(); $this->_putimages(); //Resource dictionary $this->offsets[2]=strlen($this->buffer); $this->_out('2 0 obj'); $this->_out('<_out('/Font <<'); ***** ***** fpdf.php $this->_out('>>'); $this->_out('/XObject <<'); $this->_putxobjectdict(); $this->_out('>>'); } ***** ..\FPDF\fpdf.php $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'); } ***** ***** fpdf.php function _putresources() { $this->_putfonts(); $this->_putimages(); //Resource dictionary $this->offsets[2]=strlen($this->buffer); $this->_out('2 0 obj'); $this->_out('<<'); $this->_putresourcedict(); $this->_out('>>'); $this->_out('endobj'); } function _putinfo() ***** ..\FPDF\fpdf.php function _putinfo() ***** ***** fpdf.php function _putheader() { $this->_out('%PDF-'.$this->PDFVersion); } function _puttrailer() ***** ..\FPDF\fpdf.php function _puttrailer() ***** ***** fpdf.php { $this->_putheader(); $this->_putpages(); ***** ..\FPDF\fpdf.php { $this->_putpages(); ***** ***** fpdf.php $this->Error('Not a JPEG file: '.$file); if(!isset($a['channels']) || $a['channels']==3) $colspace='DeviceRGB'; ***** ..\FPDF\fpdf.php $this->Error('Not a JPEG file: '.$file); if(!isset($a['channels']) or $a['channels']==3) $colspace='DeviceRGB'; ***** ***** fpdf.php $pos=strpos($t,chr(0)); if($pos!==false) $trns=array($pos); ***** ..\FPDF\fpdf.php $pos=strpos($t,chr(0)); if(is_int($pos)) $trns=array($pos); ***** ***** fpdf.php while($n); if($colspace=='Indexed' && empty($pal)) $this->Error('Missing palette in '.$file); ***** ..\FPDF\fpdf.php while($n); if($colspace=='Indexed' and empty($pal)) $this->Error('Missing palette in '.$file); ***** ***** fpdf.php //Read a 4-byte integer from file $a=unpack('Ni',fread($f,4)); return $a['i']; } ***** ..\FPDF\fpdf.php //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; } ***** Error al volver a sincronizar. Los archivos son demasiado diferentes ***** fpdf.php } //End of class } //Handle special IE contype request if(isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT']=='contype') { header('Content-Type: application/pdf'); exit; } } ?> ***** ..\FPDF\fpdf.php } // añadidos de "David Hernández Sanz" // Sets line style // Parameters: // - style: Line style. Array with keys among the following: // . width: Width of the line in user units // . cap: Type of cap to put on the line (butt, round, square). The difference between 'square' and 'butt' is that 'squar ' projects a flat end past the end of the line. // . join: miter, round or bevel // . dash: Dash pattern. Is 0 (without dash) or array with series of length values, which are the lengths of the on and o f dashes. // For example: (2) represents 2 on, 2 off, 2 on , 2 off ... // (2,1) is 2 on, 1 off, 2 on, 1 off.. etc // . phase: Modifier of the dash pattern which is used to shift the point at which the pattern starts // . color: Draw color. Array with components (red, green, blue) function SetLineStyle($style) { extract($style); if (isset($width)) { $width_prev = $this->LineWidth; $this->SetLineWidth($width); $this->LineWidth = $width_prev; } if (isset($cap)) { $ca = array('butt' => 0, 'round'=> 1, 'square' => 2); if (isset($ca[$cap])) $this->_out($ca[$cap] . ' J'); } if (isset($join)) { $ja = array('miter' => 0, 'round' => 1, 'bevel' => 2); if (isset($ja[$join])) $this->_out($ja[$join] . ' j'); } if (isset($dash)) { $dash_string = ''; if ($dash) { if(ereg('^.+,', $dash)) $tab = explode(',', $dash); else $tab = array($dash); $dash_string = ''; foreach ($tab as $i => $v) { if ($i > 0) $dash_string .= ' '; $dash_string .= sprintf('%.2f', $v); } } if (!isset($phase) || !$dash) $phase = 0; $this->_out(sprintf('[%s] %.2f d', $dash_string, $phase)); } if (isset($color)) { list($r, $g, $b) = $color; $this->SetDrawColor($r, $g, $b); } } // Draws a line // Parameters: // - x1, y1: Start point // - x2, y2: End point // - style: Line style. Array like for SetLineStyle function LineStyle($x1, $y1, $x2, $y2, $style = null) { if ($style) $this->SetLineStyle($style); $this->Line($x1, $y1, $x2, $y2); } // Draws a rectangle // Parameters: // - x, y: Top left corner // - w, h: Width and height // - style: Style of rectangle (draw and/or fill: D, F, DF, FD) // - border_style: Border style of rectangle. Array with some of this index // . all: Line style of all borders. Array like for SetLineStyle // . L: Line style of left border. null (no border) or array like for SetLineStyle // . T: Line style of top border. null (no border) or array like for SetLineStyle // . R: Line style of right border. null (no border) or array like for SetLineStyle // . B: Line style of bottom border. null (no border) or array like for SetLineStyle // - fill_color: Fill color. Array with components (red, green, blue) function RectStyle($x, $y, $w, $h, $style = '', $border_style = null, $fill_color = null) { if (!(false === strpos($style, 'F')) && $fill_color) { list($r, $g, $b) = $fill_color; $this->SetFillColor($r, $g, $b); } switch ($style) { case 'F': $border_style = null; $this->Rect($x, $y, $w, $h, $style); break; case 'DF': case 'FD': if (!$border_style || isset($border_style['all'])) { if (isset($border_style['all'])) { $this->SetLineStyle($border_style['all']); $border_style = null; } } else $style = 'F'; $this->Rect($x, $y, $w, $h, $style); *****