updated to 1.53
This commit is contained in:
parent
a2a3fb9bde
commit
14cea94915
702
lam/lib/fpdf.php
702
lam/lib/fpdf.php
|
@ -1,298 +1,244 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/*******************************************************************************
|
||||||
* You may use, modify and redistribute this software as you wish.
|
* Software: FPDF *
|
||||||
* Software: FPDF
|
* Version: 1.53 *
|
||||||
*
|
* Date: 2004-12-31 *
|
||||||
* @author Olivier Plathey
|
* Author: Olivier PLATHEY *
|
||||||
* @version 1.52
|
* License: Freeware *
|
||||||
* @package PDF
|
* *
|
||||||
* @copyright Copyright (C) 2003-2004
|
* You may use, modify and redistribute this software as you wish. *
|
||||||
* @license Freeware
|
*******************************************************************************/
|
||||||
*/
|
|
||||||
|
|
||||||
if(!class_exists('FPDF'))
|
if(!class_exists('FPDF'))
|
||||||
{
|
{
|
||||||
/**
|
define('FPDF_VERSION','1.53');
|
||||||
*
|
|
||||||
*/
|
|
||||||
define('FPDF_VERSION','1.52');
|
|
||||||
|
|
||||||
/**
|
class FPDF
|
||||||
*
|
{
|
||||||
*
|
//Private properties
|
||||||
* @author Olivier Plathey
|
var $page; //current page number
|
||||||
* @version 1.52
|
var $n; //current object number
|
||||||
* @package PDF
|
var $offsets; //array of object offsets
|
||||||
* @copyright Copyright (C) 2003-2004
|
var $buffer; //buffer holding in-memory PDF
|
||||||
* @license Freeware
|
var $pages; //array containing pages
|
||||||
*/
|
var $state; //current document state
|
||||||
class FPDF {
|
var $compress; //compression flag
|
||||||
//Private properties
|
var $DefOrientation; //default orientation
|
||||||
var $page; //current page number
|
var $CurOrientation; //current orientation
|
||||||
var $n; //current object number
|
var $OrientationChanges; //array indicating orientation changes
|
||||||
var $offsets; //array of object offsets
|
var $k; //scale factor (number of points in user unit)
|
||||||
var $buffer; //buffer holding in-memory PDF
|
var $fwPt,$fhPt; //dimensions of page format in points
|
||||||
var $pages; //array containing pages
|
var $fw,$fh; //dimensions of page format in user unit
|
||||||
var $state; //current document state
|
var $wPt,$hPt; //current dimensions of page in points
|
||||||
var $compress; //compression flag
|
var $w,$h; //current dimensions of page in user unit
|
||||||
var $DefOrientation; //default orientation
|
var $lMargin; //left margin
|
||||||
var $CurOrientation; //current orientation
|
var $tMargin; //top margin
|
||||||
var $OrientationChanges; //array indicating orientation changes
|
var $rMargin; //right margin
|
||||||
var $k; //scale factor (number of points in user unit)
|
var $bMargin; //page break margin
|
||||||
var $fwPt,$fhPt; //dimensions of page format in points
|
var $cMargin; //cell margin
|
||||||
var $fw,$fh; //dimensions of page format in user unit
|
var $x,$y; //current position in user unit for cell positioning
|
||||||
var $wPt,$hPt; //current dimensions of page in points
|
var $lasth; //height of last cell printed
|
||||||
var $w,$h; //current dimensions of page in user unit
|
var $LineWidth; //line width in user unit
|
||||||
var $lMargin; //left margin
|
var $CoreFonts; //array of standard font names
|
||||||
var $tMargin; //top margin
|
var $fonts; //array of used fonts
|
||||||
var $rMargin; //right margin
|
var $FontFiles; //array of font files
|
||||||
var $bMargin; //page break margin
|
var $diffs; //array of encoding differences
|
||||||
var $cMargin; //cell margin
|
var $images; //array of used images
|
||||||
var $x,$y; //current position in user unit for cell positioning
|
var $PageLinks; //array of links in pages
|
||||||
var $lasth; //height of last cell printed
|
var $links; //array of internal links
|
||||||
var $LineWidth; //line width in user unit
|
var $FontFamily; //current font family
|
||||||
var $CoreFonts; //array of standard font names
|
var $FontStyle; //current font style
|
||||||
var $fonts; //array of used fonts
|
var $underline; //underlining flag
|
||||||
var $FontFiles; //array of font files
|
var $CurrentFont; //current font info
|
||||||
var $diffs; //array of encoding differences
|
var $FontSizePt; //current font size in points
|
||||||
var $images; //array of used images
|
var $FontSize; //current font size in user unit
|
||||||
var $PageLinks; //array of links in pages
|
var $DrawColor; //commands for drawing color
|
||||||
var $links; //array of internal links
|
var $FillColor; //commands for filling color
|
||||||
var $FontFamily; //current font family
|
var $TextColor; //commands for text color
|
||||||
var $FontStyle; //current font style
|
var $ColorFlag; //indicates whether fill and text colors are different
|
||||||
var $underline; //underlining flag
|
var $ws; //word spacing
|
||||||
var $CurrentFont; //current font info
|
var $AutoPageBreak; //automatic page breaking
|
||||||
var $FontSizePt; //current font size in points
|
var $PageBreakTrigger; //threshold used to trigger page breaks
|
||||||
var $FontSize; //current font size in user unit
|
var $InFooter; //flag set when processing footer
|
||||||
var $DrawColor; //commands for drawing color
|
var $ZoomMode; //zoom display mode
|
||||||
var $FillColor; //commands for filling color
|
var $LayoutMode; //layout display mode
|
||||||
var $TextColor; //commands for text color
|
var $title; //title
|
||||||
var $ColorFlag; //indicates whether fill and text colors are different
|
var $subject; //subject
|
||||||
var $ws; //word spacing
|
var $author; //author
|
||||||
var $AutoPageBreak; //automatic page breaking
|
var $keywords; //keywords
|
||||||
var $PageBreakTrigger; //threshold used to trigger page breaks
|
var $creator; //creator
|
||||||
var $InFooter; //flag set when processing footer
|
var $AliasNbPages; //alias for total number of pages
|
||||||
var $ZoomMode; //zoom display mode
|
var $PDFVersion; //PDF version number
|
||||||
var $LayoutMode; //layout display mode
|
|
||||||
var $title; //title
|
|
||||||
var $subject; //subject
|
|
||||||
var $author; //author
|
|
||||||
var $keywords; //keywords
|
|
||||||
var $creator; //creator
|
|
||||||
var $AliasNbPages; //alias for total number of pages
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* *
|
* *
|
||||||
* Public methods *
|
* Public methods *
|
||||||
* *
|
* *
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
/**
|
function FPDF($orientation='P',$unit='mm',$format='A4')
|
||||||
*
|
{
|
||||||
*
|
//Some checks
|
||||||
* @param string
|
$this->_dochecks();
|
||||||
* @param string
|
//Initialization of properties
|
||||||
* @param string
|
$this->page=0;
|
||||||
*/
|
$this->n=2;
|
||||||
function FPDF($orientation='P',$unit='mm',$format='A4') {
|
$this->buffer='';
|
||||||
//Some checks
|
$this->pages=array();
|
||||||
$this->_dochecks();
|
$this->OrientationChanges=array();
|
||||||
//Initialization of properties
|
$this->state=0;
|
||||||
$this->page=0;
|
$this->fonts=array();
|
||||||
$this->n=2;
|
$this->FontFiles=array();
|
||||||
$this->buffer='';
|
$this->diffs=array();
|
||||||
$this->pages=array();
|
$this->images=array();
|
||||||
$this->OrientationChanges=array();
|
$this->links=array();
|
||||||
$this->state=0;
|
$this->InFooter=false;
|
||||||
$this->fonts=array();
|
$this->lasth=0;
|
||||||
$this->FontFiles=array();
|
$this->FontFamily='';
|
||||||
$this->diffs=array();
|
$this->FontStyle='';
|
||||||
$this->images=array();
|
$this->FontSizePt=12;
|
||||||
$this->links=array();
|
$this->underline=false;
|
||||||
$this->InFooter=false;
|
$this->DrawColor='0 G';
|
||||||
$this->lasth=0;
|
$this->FillColor='0 g';
|
||||||
$this->FontFamily='';
|
$this->TextColor='0 g';
|
||||||
$this->FontStyle='';
|
$this->ColorFlag=false;
|
||||||
$this->FontSizePt=12;
|
$this->ws=0;
|
||||||
$this->underline=false;
|
//Standard fonts
|
||||||
$this->DrawColor='0 G';
|
$this->CoreFonts=array('courier'=>'Courier','courierB'=>'Courier-Bold','courierI'=>'Courier-Oblique','courierBI'=>'Courier-BoldOblique',
|
||||||
$this->FillColor='0 g';
|
'helvetica'=>'Helvetica','helveticaB'=>'Helvetica-Bold','helveticaI'=>'Helvetica-Oblique','helveticaBI'=>'Helvetica-BoldOblique',
|
||||||
$this->TextColor='0 g';
|
'times'=>'Times-Roman','timesB'=>'Times-Bold','timesI'=>'Times-Italic','timesBI'=>'Times-BoldItalic',
|
||||||
$this->ColorFlag=false;
|
'symbol'=>'Symbol','zapfdingbats'=>'ZapfDingbats');
|
||||||
$this->ws=0;
|
//Scale factor
|
||||||
//Standard fonts
|
if($unit=='pt')
|
||||||
$this->CoreFonts=array('courier'=>'Courier','courierB'=>'Courier-Bold','courierI'=>'Courier-Oblique','courierBI'=>'Courier-BoldOblique',
|
$this->k=1;
|
||||||
'helvetica'=>'Helvetica','helveticaB'=>'Helvetica-Bold','helveticaI'=>'Helvetica-Oblique','helveticaBI'=>'Helvetica-BoldOblique',
|
elseif($unit=='mm')
|
||||||
'times'=>'Times-Roman','timesB'=>'Times-Bold','timesI'=>'Times-Italic','timesBI'=>'Times-BoldItalic',
|
$this->k=72/25.4;
|
||||||
'symbol'=>'Symbol','zapfdingbats'=>'ZapfDingbats');
|
elseif($unit=='cm')
|
||||||
//Scale factor
|
$this->k=72/2.54;
|
||||||
if($unit=='pt')
|
elseif($unit=='in')
|
||||||
$this->k=1;
|
$this->k=72;
|
||||||
elseif($unit=='mm')
|
else
|
||||||
$this->k=72/25.4;
|
$this->Error('Incorrect unit: '.$unit);
|
||||||
elseif($unit=='cm')
|
//Page format
|
||||||
$this->k=72/2.54;
|
if(is_string($format))
|
||||||
elseif($unit=='in')
|
{
|
||||||
$this->k=72;
|
$format=strtolower($format);
|
||||||
|
if($format=='a3')
|
||||||
|
$format=array(841.89,1190.55);
|
||||||
|
elseif($format=='a4')
|
||||||
|
$format=array(595.28,841.89);
|
||||||
|
elseif($format=='a5')
|
||||||
|
$format=array(420.94,595.28);
|
||||||
|
elseif($format=='letter')
|
||||||
|
$format=array(612,792);
|
||||||
|
elseif($format=='legal')
|
||||||
|
$format=array(612,1008);
|
||||||
else
|
else
|
||||||
$this->Error('Incorrect unit: '.$unit);
|
$this->Error('Unknown page format: '.$format);
|
||||||
//Page format
|
$this->fwPt=$format[0];
|
||||||
if(is_string($format))
|
$this->fhPt=$format[1];
|
||||||
{
|
|
||||||
$format=strtolower($format);
|
|
||||||
if($format=='a3')
|
|
||||||
$format=array(841.89,1190.55);
|
|
||||||
elseif($format=='a4')
|
|
||||||
$format=array(595.28,841.89);
|
|
||||||
elseif($format=='a5')
|
|
||||||
$format=array(420.94,595.28);
|
|
||||||
elseif($format=='letter')
|
|
||||||
$format=array(612,792);
|
|
||||||
elseif($format=='legal')
|
|
||||||
$format=array(612,1008);
|
|
||||||
else
|
|
||||||
$this->Error('Unknown page format: '.$format);
|
|
||||||
$this->fwPt=$format[0];
|
|
||||||
$this->fhPt=$format[1];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->fwPt=$format[0]*$this->k;
|
|
||||||
$this->fhPt=$format[1]*$this->k;
|
|
||||||
}
|
|
||||||
$this->fw=$this->fwPt/$this->k;
|
|
||||||
$this->fh=$this->fhPt/$this->k;
|
|
||||||
//Page orientation
|
|
||||||
$orientation=strtolower($orientation);
|
|
||||||
if($orientation=='p' or $orientation=='portrait')
|
|
||||||
{
|
|
||||||
$this->DefOrientation='P';
|
|
||||||
$this->wPt=$this->fwPt;
|
|
||||||
$this->hPt=$this->fhPt;
|
|
||||||
}
|
|
||||||
elseif($orientation=='l' or $orientation=='landscape')
|
|
||||||
{
|
|
||||||
$this->DefOrientation='L';
|
|
||||||
$this->wPt=$this->fhPt;
|
|
||||||
$this->hPt=$this->fwPt;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
$this->Error('Incorrect orientation: '.$orientation);
|
|
||||||
$this->CurOrientation=$this->DefOrientation;
|
|
||||||
$this->w=$this->wPt/$this->k;
|
|
||||||
$this->h=$this->hPt/$this->k;
|
|
||||||
//Page margins (1 cm)
|
|
||||||
$margin=28.35/$this->k;
|
|
||||||
$this->SetMargins($margin,$margin);
|
|
||||||
//Interior cell margin (1 mm)
|
|
||||||
$this->cMargin=$margin/10;
|
|
||||||
//Line width (0.2 mm)
|
|
||||||
$this->LineWidth=.567/$this->k;
|
|
||||||
//Automatic page break
|
|
||||||
$this->SetAutoPageBreak(true,2*$margin);
|
|
||||||
//Full width display mode
|
|
||||||
$this->SetDisplayMode('fullwidth');
|
|
||||||
//Compression
|
|
||||||
$this->SetCompression(true);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param int
|
|
||||||
* @param int
|
|
||||||
* @param int
|
|
||||||
*/
|
|
||||||
function SetMargins($left,$top,$right=-1)
|
|
||||||
{
|
{
|
||||||
//Set left, top and right margins
|
$this->fwPt=$format[0]*$this->k;
|
||||||
$this->lMargin=$left;
|
$this->fhPt=$format[1]*$this->k;
|
||||||
$this->tMargin=$top;
|
|
||||||
if($right==-1)
|
|
||||||
$right=$left;
|
|
||||||
$this->rMargin=$right;
|
|
||||||
}
|
}
|
||||||
|
$this->fw=$this->fwPt/$this->k;
|
||||||
/**
|
$this->fh=$this->fhPt/$this->k;
|
||||||
*
|
//Page orientation
|
||||||
*
|
$orientation=strtolower($orientation);
|
||||||
* @param int
|
if($orientation=='p' || $orientation=='portrait')
|
||||||
*/
|
|
||||||
function SetLeftMargin($margin)
|
|
||||||
{
|
{
|
||||||
//Set left margin
|
$this->DefOrientation='P';
|
||||||
$this->lMargin=$margin;
|
$this->wPt=$this->fwPt;
|
||||||
if($this->page>0 and $this->x<$margin)
|
$this->hPt=$this->fhPt;
|
||||||
$this->x=$margin;
|
|
||||||
}
|
}
|
||||||
|
elseif($orientation=='l' || $orientation=='landscape')
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param int
|
|
||||||
*/
|
|
||||||
function SetTopMargin($margin)
|
|
||||||
{
|
{
|
||||||
//Set top margin
|
$this->DefOrientation='L';
|
||||||
$this->tMargin=$margin;
|
$this->wPt=$this->fhPt;
|
||||||
}
|
$this->hPt=$this->fwPt;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param int
|
|
||||||
*/
|
|
||||||
function SetRightMargin($margin)
|
|
||||||
{
|
|
||||||
//Set right margin
|
|
||||||
$this->rMargin=$margin;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param boolean
|
|
||||||
* @param int
|
|
||||||
*/
|
|
||||||
function SetAutoPageBreak($auto,$margin=0)
|
|
||||||
{
|
|
||||||
//Set auto page break mode and triggering margin
|
|
||||||
$this->AutoPageBreak=$auto;
|
|
||||||
$this->bMargin=$margin;
|
|
||||||
$this->PageBreakTrigger=$this->h-$margin;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param string
|
|
||||||
* @param string
|
|
||||||
*/
|
|
||||||
function SetDisplayMode($zoom,$layout='continuous')
|
|
||||||
{
|
|
||||||
//Set display mode in viewer
|
|
||||||
if($zoom=='fullpage' or $zoom=='fullwidth' or $zoom=='real' or $zoom=='default' or !is_string($zoom))
|
|
||||||
$this->ZoomMode=$zoom;
|
|
||||||
else
|
|
||||||
$this->Error('Incorrect zoom display mode: '.$zoom);
|
|
||||||
if($layout=='single' or $layout=='continuous' or $layout=='two' or $layout=='default')
|
|
||||||
$this->LayoutMode=$layout;
|
|
||||||
else
|
|
||||||
$this->Error('Incorrect layout display mode: '.$layout);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param string
|
|
||||||
*/
|
|
||||||
function SetCompression($compress)
|
|
||||||
{
|
|
||||||
//Set page compression
|
|
||||||
if(function_exists('gzcompress'))
|
|
||||||
$this->compress=$compress;
|
|
||||||
else
|
|
||||||
$this->compress=false;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
$this->Error('Incorrect orientation: '.$orientation);
|
||||||
|
$this->CurOrientation=$this->DefOrientation;
|
||||||
|
$this->w=$this->wPt/$this->k;
|
||||||
|
$this->h=$this->hPt/$this->k;
|
||||||
|
//Page margins (1 cm)
|
||||||
|
$margin=28.35/$this->k;
|
||||||
|
$this->SetMargins($margin,$margin);
|
||||||
|
//Interior cell margin (1 mm)
|
||||||
|
$this->cMargin=$margin/10;
|
||||||
|
//Line width (0.2 mm)
|
||||||
|
$this->LineWidth=.567/$this->k;
|
||||||
|
//Automatic page break
|
||||||
|
$this->SetAutoPageBreak(true,2*$margin);
|
||||||
|
//Full width display mode
|
||||||
|
$this->SetDisplayMode('fullwidth');
|
||||||
|
//Enable compression
|
||||||
|
$this->SetCompression(true);
|
||||||
|
//Set default PDF version number
|
||||||
|
$this->PDFVersion='1.3';
|
||||||
|
}
|
||||||
|
|
||||||
|
function SetMargins($left,$top,$right=-1)
|
||||||
|
{
|
||||||
|
//Set left, top and right margins
|
||||||
|
$this->lMargin=$left;
|
||||||
|
$this->tMargin=$top;
|
||||||
|
if($right==-1)
|
||||||
|
$right=$left;
|
||||||
|
$this->rMargin=$right;
|
||||||
|
}
|
||||||
|
|
||||||
|
function SetLeftMargin($margin)
|
||||||
|
{
|
||||||
|
//Set left margin
|
||||||
|
$this->lMargin=$margin;
|
||||||
|
if($this->page>0 && $this->x<$margin)
|
||||||
|
$this->x=$margin;
|
||||||
|
}
|
||||||
|
|
||||||
|
function SetTopMargin($margin)
|
||||||
|
{
|
||||||
|
//Set top margin
|
||||||
|
$this->tMargin=$margin;
|
||||||
|
}
|
||||||
|
|
||||||
|
function SetRightMargin($margin)
|
||||||
|
{
|
||||||
|
//Set right margin
|
||||||
|
$this->rMargin=$margin;
|
||||||
|
}
|
||||||
|
|
||||||
|
function SetAutoPageBreak($auto,$margin=0)
|
||||||
|
{
|
||||||
|
//Set auto page break mode and triggering margin
|
||||||
|
$this->AutoPageBreak=$auto;
|
||||||
|
$this->bMargin=$margin;
|
||||||
|
$this->PageBreakTrigger=$this->h-$margin;
|
||||||
|
}
|
||||||
|
|
||||||
|
function SetDisplayMode($zoom,$layout='continuous')
|
||||||
|
{
|
||||||
|
//Set display mode in viewer
|
||||||
|
if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom))
|
||||||
|
$this->ZoomMode=$zoom;
|
||||||
|
else
|
||||||
|
$this->Error('Incorrect zoom display mode: '.$zoom);
|
||||||
|
if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default')
|
||||||
|
$this->LayoutMode=$layout;
|
||||||
|
else
|
||||||
|
$this->Error('Incorrect layout display mode: '.$layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
function SetCompression($compress)
|
||||||
|
{
|
||||||
|
//Set page compression
|
||||||
|
if(function_exists('gzcompress'))
|
||||||
|
$this->compress=$compress;
|
||||||
|
else
|
||||||
|
$this->compress=false;
|
||||||
|
}
|
||||||
|
|
||||||
function SetTitle($title)
|
function SetTitle($title)
|
||||||
{
|
{
|
||||||
|
@ -339,8 +285,7 @@ function Error($msg)
|
||||||
function Open()
|
function Open()
|
||||||
{
|
{
|
||||||
//Begin document
|
//Begin document
|
||||||
if($this->state==0)
|
$this->state=1;
|
||||||
$this->_begindoc();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function Close()
|
function Close()
|
||||||
|
@ -446,7 +391,7 @@ function PageNo()
|
||||||
function SetDrawColor($r,$g=-1,$b=-1)
|
function SetDrawColor($r,$g=-1,$b=-1)
|
||||||
{
|
{
|
||||||
//Set color for all stroking operations
|
//Set color for all stroking operations
|
||||||
if(($r==0 and $g==0 and $b==0) or $g==-1)
|
if(($r==0 && $g==0 && $b==0) || $g==-1)
|
||||||
$this->DrawColor=sprintf('%.3f G',$r/255);
|
$this->DrawColor=sprintf('%.3f G',$r/255);
|
||||||
else
|
else
|
||||||
$this->DrawColor=sprintf('%.3f %.3f %.3f RG',$r/255,$g/255,$b/255);
|
$this->DrawColor=sprintf('%.3f %.3f %.3f RG',$r/255,$g/255,$b/255);
|
||||||
|
@ -457,7 +402,7 @@ function SetDrawColor($r,$g=-1,$b=-1)
|
||||||
function SetFillColor($r,$g=-1,$b=-1)
|
function SetFillColor($r,$g=-1,$b=-1)
|
||||||
{
|
{
|
||||||
//Set color for all filling operations
|
//Set color for all filling operations
|
||||||
if(($r==0 and $g==0 and $b==0) or $g==-1)
|
if(($r==0 && $g==0 && $b==0) || $g==-1)
|
||||||
$this->FillColor=sprintf('%.3f g',$r/255);
|
$this->FillColor=sprintf('%.3f g',$r/255);
|
||||||
else
|
else
|
||||||
$this->FillColor=sprintf('%.3f %.3f %.3f rg',$r/255,$g/255,$b/255);
|
$this->FillColor=sprintf('%.3f %.3f %.3f rg',$r/255,$g/255,$b/255);
|
||||||
|
@ -469,7 +414,7 @@ function SetFillColor($r,$g=-1,$b=-1)
|
||||||
function SetTextColor($r,$g=-1,$b=-1)
|
function SetTextColor($r,$g=-1,$b=-1)
|
||||||
{
|
{
|
||||||
//Set color for text
|
//Set color for text
|
||||||
if(($r==0 and $g==0 and $b==0) or $g==-1)
|
if(($r==0 && $g==0 && $b==0) || $g==-1)
|
||||||
$this->TextColor=sprintf('%.3f g',$r/255);
|
$this->TextColor=sprintf('%.3f g',$r/255);
|
||||||
else
|
else
|
||||||
$this->TextColor=sprintf('%.3f %.3f %.3f rg',$r/255,$g/255,$b/255);
|
$this->TextColor=sprintf('%.3f %.3f %.3f rg',$r/255,$g/255,$b/255);
|
||||||
|
@ -507,7 +452,7 @@ function Rect($x,$y,$w,$h,$style='')
|
||||||
//Draw a rectangle
|
//Draw a rectangle
|
||||||
if($style=='F')
|
if($style=='F')
|
||||||
$op='f';
|
$op='f';
|
||||||
elseif($style=='FD' or $style=='DF')
|
elseif($style=='FD' || $style=='DF')
|
||||||
$op='B';
|
$op='B';
|
||||||
else
|
else
|
||||||
$op='S';
|
$op='S';
|
||||||
|
@ -518,39 +463,40 @@ function AddFont($family,$style='',$file='')
|
||||||
{
|
{
|
||||||
//Add a TrueType or Type1 font
|
//Add a TrueType or Type1 font
|
||||||
$family=strtolower($family);
|
$family=strtolower($family);
|
||||||
|
if($file=='')
|
||||||
|
$file=str_replace(' ','',$family).strtolower($style).'.php';
|
||||||
if($family=='arial')
|
if($family=='arial')
|
||||||
$family='helvetica';
|
$family='helvetica';
|
||||||
$style=strtoupper($style);
|
$style=strtoupper($style);
|
||||||
if($style=='IB')
|
if($style=='IB')
|
||||||
$style='BI';
|
$style='BI';
|
||||||
if(isset($this->fonts[$family.$style]))
|
$fontkey=$family.$style;
|
||||||
|
if(isset($this->fonts[$fontkey]))
|
||||||
$this->Error('Font already added: '.$family.' '.$style);
|
$this->Error('Font already added: '.$family.' '.$style);
|
||||||
if($file=='')
|
include($this->_getfontpath().$file);
|
||||||
$file=str_replace(' ','',$family).strtolower($style).'.php';
|
|
||||||
if(defined('FPDF_FONTPATH'))
|
|
||||||
$file=FPDF_FONTPATH.$file;
|
|
||||||
include($file);
|
|
||||||
if(!isset($name))
|
if(!isset($name))
|
||||||
$this->Error('Could not include font definition file');
|
$this->Error('Could not include font definition file');
|
||||||
$i=count($this->fonts)+1;
|
$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);
|
$this->fonts[$fontkey]=array('i'=>$i,'type'=>$type,'name'=>$name,'desc'=>$desc,'up'=>$up,'ut'=>$ut,'cw'=>$cw,'enc'=>$enc,'file'=>$file);
|
||||||
if($diff)
|
if($diff)
|
||||||
{
|
{
|
||||||
//Search existing encodings
|
//Search existing encodings
|
||||||
$d=0;
|
$d=0;
|
||||||
$nb=count($this->diffs);
|
$nb=count($this->diffs);
|
||||||
for($i=1;$i<=$nb;$i++)
|
for($i=1;$i<=$nb;$i++)
|
||||||
|
{
|
||||||
if($this->diffs[$i]==$diff)
|
if($this->diffs[$i]==$diff)
|
||||||
{
|
{
|
||||||
$d=$i;
|
$d=$i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if($d==0)
|
if($d==0)
|
||||||
{
|
{
|
||||||
$d=$nb+1;
|
$d=$nb+1;
|
||||||
$this->diffs[$d]=$diff;
|
$this->diffs[$d]=$diff;
|
||||||
}
|
}
|
||||||
$this->fonts[$family.$style]['diff']=$d;
|
$this->fonts[$fontkey]['diff']=$d;
|
||||||
}
|
}
|
||||||
if($file)
|
if($file)
|
||||||
{
|
{
|
||||||
|
@ -571,10 +517,10 @@ function SetFont($family,$style='',$size=0)
|
||||||
$family=$this->FontFamily;
|
$family=$this->FontFamily;
|
||||||
if($family=='arial')
|
if($family=='arial')
|
||||||
$family='helvetica';
|
$family='helvetica';
|
||||||
elseif($family=='symbol' or $family=='zapfdingbats')
|
elseif($family=='symbol' || $family=='zapfdingbats')
|
||||||
$style='';
|
$style='';
|
||||||
$style=strtoupper($style);
|
$style=strtoupper($style);
|
||||||
if(is_int(strpos($style,'U')))
|
if(strpos($style,'U')!==false)
|
||||||
{
|
{
|
||||||
$this->underline=true;
|
$this->underline=true;
|
||||||
$style=str_replace('U','',$style);
|
$style=str_replace('U','',$style);
|
||||||
|
@ -586,7 +532,7 @@ function SetFont($family,$style='',$size=0)
|
||||||
if($size==0)
|
if($size==0)
|
||||||
$size=$this->FontSizePt;
|
$size=$this->FontSizePt;
|
||||||
//Test if font is already selected
|
//Test if font is already selected
|
||||||
if($this->FontFamily==$family and $this->FontStyle==$style and $this->FontSizePt==$size)
|
if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size)
|
||||||
return;
|
return;
|
||||||
//Test if used for the first time
|
//Test if used for the first time
|
||||||
$fontkey=$family.$style;
|
$fontkey=$family.$style;
|
||||||
|
@ -599,12 +545,9 @@ function SetFont($family,$style='',$size=0)
|
||||||
{
|
{
|
||||||
//Load metric file
|
//Load metric file
|
||||||
$file=$family;
|
$file=$family;
|
||||||
if($family=='times' or $family=='helvetica')
|
if($family=='times' || $family=='helvetica')
|
||||||
$file.=strtolower($style);
|
$file.=strtolower($style);
|
||||||
$file.='.php';
|
include($this->_getfontpath().$file.'.php');
|
||||||
if(defined('FPDF_FONTPATH'))
|
|
||||||
$file=FPDF_FONTPATH.$file;
|
|
||||||
include($file);
|
|
||||||
if(!isset($fpdf_charwidths[$fontkey]))
|
if(!isset($fpdf_charwidths[$fontkey]))
|
||||||
$this->Error('Could not include font metric file');
|
$this->Error('Could not include font metric file');
|
||||||
}
|
}
|
||||||
|
@ -663,7 +606,7 @@ function Text($x,$y,$txt)
|
||||||
{
|
{
|
||||||
//Output a string
|
//Output a string
|
||||||
$s=sprintf('BT %.2f %.2f Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt));
|
$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!='')
|
if($this->underline && $txt!='')
|
||||||
$s.=' '.$this->_dounderline($x,$y,$txt);
|
$s.=' '.$this->_dounderline($x,$y,$txt);
|
||||||
if($this->ColorFlag)
|
if($this->ColorFlag)
|
||||||
$s='q '.$this->TextColor.' '.$s.' Q';
|
$s='q '.$this->TextColor.' '.$s.' Q';
|
||||||
|
@ -680,7 +623,7 @@ function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='')
|
||||||
{
|
{
|
||||||
//Output a cell
|
//Output a cell
|
||||||
$k=$this->k;
|
$k=$this->k;
|
||||||
if($this->y+$h>$this->PageBreakTrigger and !$this->InFooter and $this->AcceptPageBreak())
|
if($this->y+$h>$this->PageBreakTrigger && !$this->InFooter && $this->AcceptPageBreak())
|
||||||
{
|
{
|
||||||
//Automatic page break
|
//Automatic page break
|
||||||
$x=$this->x;
|
$x=$this->x;
|
||||||
|
@ -701,7 +644,7 @@ function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='')
|
||||||
if($w==0)
|
if($w==0)
|
||||||
$w=$this->w-$this->rMargin-$this->x;
|
$w=$this->w-$this->rMargin-$this->x;
|
||||||
$s='';
|
$s='';
|
||||||
if($fill==1 or $border==1)
|
if($fill==1 || $border==1)
|
||||||
{
|
{
|
||||||
if($fill==1)
|
if($fill==1)
|
||||||
$op=($border==1) ? 'B' : 'f';
|
$op=($border==1) ? 'B' : 'f';
|
||||||
|
@ -713,16 +656,16 @@ function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='')
|
||||||
{
|
{
|
||||||
$x=$this->x;
|
$x=$this->x;
|
||||||
$y=$this->y;
|
$y=$this->y;
|
||||||
if(is_int(strpos($border,'L')))
|
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);
|
$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')))
|
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);
|
$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')))
|
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);
|
$s.=sprintf('%.2f %.2f m %.2f %.2f l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
|
||||||
if(is_int(strpos($border,'B')))
|
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);
|
$s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
|
||||||
}
|
}
|
||||||
if($txt!='')
|
if($txt!=='')
|
||||||
{
|
{
|
||||||
if($align=='R')
|
if($align=='R')
|
||||||
$dx=$w-$this->cMargin-$this->GetStringWidth($txt);
|
$dx=$w-$this->cMargin-$this->GetStringWidth($txt);
|
||||||
|
@ -764,7 +707,7 @@ function MultiCell($w,$h,$txt,$border=0,$align='J',$fill=0)
|
||||||
$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
|
$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
|
||||||
$s=str_replace("\r",'',$txt);
|
$s=str_replace("\r",'',$txt);
|
||||||
$nb=strlen($s);
|
$nb=strlen($s);
|
||||||
if($nb>0 and $s[$nb-1]=="\n")
|
if($nb>0 && $s[$nb-1]=="\n")
|
||||||
$nb--;
|
$nb--;
|
||||||
$b=0;
|
$b=0;
|
||||||
if($border)
|
if($border)
|
||||||
|
@ -778,11 +721,11 @@ function MultiCell($w,$h,$txt,$border=0,$align='J',$fill=0)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$b2='';
|
$b2='';
|
||||||
if(is_int(strpos($border,'L')))
|
if(strpos($border,'L')!==false)
|
||||||
$b2.='L';
|
$b2.='L';
|
||||||
if(is_int(strpos($border,'R')))
|
if(strpos($border,'R')!==false)
|
||||||
$b2.='R';
|
$b2.='R';
|
||||||
$b=is_int(strpos($border,'T')) ? $b2.'T' : $b2;
|
$b=(strpos($border,'T')!==false) ? $b2.'T' : $b2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sep=-1;
|
$sep=-1;
|
||||||
|
@ -810,7 +753,7 @@ function MultiCell($w,$h,$txt,$border=0,$align='J',$fill=0)
|
||||||
$l=0;
|
$l=0;
|
||||||
$ns=0;
|
$ns=0;
|
||||||
$nl++;
|
$nl++;
|
||||||
if($border and $nl==2)
|
if($border && $nl==2)
|
||||||
$b=$b2;
|
$b=$b2;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -850,7 +793,7 @@ function MultiCell($w,$h,$txt,$border=0,$align='J',$fill=0)
|
||||||
$l=0;
|
$l=0;
|
||||||
$ns=0;
|
$ns=0;
|
||||||
$nl++;
|
$nl++;
|
||||||
if($border and $nl==2)
|
if($border && $nl==2)
|
||||||
$b=$b2;
|
$b=$b2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -862,7 +805,7 @@ function MultiCell($w,$h,$txt,$border=0,$align='J',$fill=0)
|
||||||
$this->ws=0;
|
$this->ws=0;
|
||||||
$this->_out('0 Tw');
|
$this->_out('0 Tw');
|
||||||
}
|
}
|
||||||
if($border and is_int(strpos($border,'B')))
|
if($border && strpos($border,'B')!==false)
|
||||||
$b.='B';
|
$b.='B';
|
||||||
$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
|
$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
|
||||||
$this->x=$this->lMargin;
|
$this->x=$this->lMargin;
|
||||||
|
@ -965,7 +908,7 @@ function Image($file,$x,$y,$w=0,$h=0,$type='',$link='')
|
||||||
$type=strtolower($type);
|
$type=strtolower($type);
|
||||||
$mqr=get_magic_quotes_runtime();
|
$mqr=get_magic_quotes_runtime();
|
||||||
set_magic_quotes_runtime(0);
|
set_magic_quotes_runtime(0);
|
||||||
if($type=='jpg' or $type=='jpeg')
|
if($type=='jpg' || $type=='jpeg')
|
||||||
$info=$this->_parsejpg($file);
|
$info=$this->_parsejpg($file);
|
||||||
elseif($type=='png')
|
elseif($type=='png')
|
||||||
$info=$this->_parsepng($file);
|
$info=$this->_parsepng($file);
|
||||||
|
@ -984,7 +927,7 @@ function Image($file,$x,$y,$w=0,$h=0,$type='',$link='')
|
||||||
else
|
else
|
||||||
$info=$this->images[$file];
|
$info=$this->images[$file];
|
||||||
//Automatic width and height calculation if needed
|
//Automatic width and height calculation if needed
|
||||||
if($w==0 and $h==0)
|
if($w==0 && $h==0)
|
||||||
{
|
{
|
||||||
//Put image at 72 dpi
|
//Put image at 72 dpi
|
||||||
$w=$info['w']/$this->k;
|
$w=$info['w']/$this->k;
|
||||||
|
@ -1050,8 +993,6 @@ function SetXY($x,$y)
|
||||||
function Output($name='',$dest='')
|
function Output($name='',$dest='')
|
||||||
{
|
{
|
||||||
//Output PDF to some destination
|
//Output PDF to some destination
|
||||||
global $HTTP_SERVER_VARS;
|
|
||||||
|
|
||||||
//Finish document if necessary
|
//Finish document if necessary
|
||||||
if($this->state<3)
|
if($this->state<3)
|
||||||
$this->Close();
|
$this->Close();
|
||||||
|
@ -1073,27 +1014,31 @@ function Output($name='',$dest='')
|
||||||
{
|
{
|
||||||
case 'I':
|
case 'I':
|
||||||
//Send to standard output
|
//Send to standard output
|
||||||
if(isset($HTTP_SERVER_VARS['SERVER_NAME']))
|
if(ob_get_contents())
|
||||||
|
$this->Error('Some data has already been output, can\'t send PDF file');
|
||||||
|
if(php_sapi_name()!='cli')
|
||||||
{
|
{
|
||||||
//We send to a browser
|
//We send to a browser
|
||||||
Header('Content-Type: application/pdf');
|
header('Content-Type: application/pdf');
|
||||||
if(headers_sent())
|
if(headers_sent())
|
||||||
$this->Error('Some data has already been output to browser, can\'t send PDF file');
|
$this->Error('Some data has already been output to browser, can\'t send PDF file');
|
||||||
Header('Content-Length: '.strlen($this->buffer));
|
header('Content-Length: '.strlen($this->buffer));
|
||||||
Header('Content-disposition: inline; filename='.$name);
|
header('Content-disposition: inline; filename="'.$name.'"');
|
||||||
}
|
}
|
||||||
echo $this->buffer;
|
echo $this->buffer;
|
||||||
break;
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
//Download file
|
//Download file
|
||||||
if(isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']) and strpos($HTTP_SERVER_VARS['HTTP_USER_AGENT'],'MSIE'))
|
if(ob_get_contents())
|
||||||
Header('Content-Type: application/force-download');
|
$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
|
else
|
||||||
Header('Content-Type: application/octet-stream');
|
header('Content-Type: application/octet-stream');
|
||||||
if(headers_sent())
|
if(headers_sent())
|
||||||
$this->Error('Some data has already been output to browser, can\'t send PDF file');
|
$this->Error('Some data has already been output to browser, can\'t send PDF file');
|
||||||
Header('Content-Length: '.strlen($this->buffer));
|
header('Content-Length: '.strlen($this->buffer));
|
||||||
Header('Content-disposition: attachment; filename='.$name);
|
header('Content-disposition: attachment; filename="'.$name.'"');
|
||||||
echo $this->buffer;
|
echo $this->buffer;
|
||||||
break;
|
break;
|
||||||
case 'F':
|
case 'F':
|
||||||
|
@ -1128,11 +1073,11 @@ function _dochecks()
|
||||||
setlocale(LC_NUMERIC,'C');
|
setlocale(LC_NUMERIC,'C');
|
||||||
}
|
}
|
||||||
|
|
||||||
function _begindoc()
|
function _getfontpath()
|
||||||
{
|
{
|
||||||
//Start document
|
if(!defined('FPDF_FONTPATH') && is_dir(dirname(__FILE__).'/font'))
|
||||||
$this->state=1;
|
define('FPDF_FONTPATH',dirname(__FILE__).'/font/');
|
||||||
$this->_out('%PDF-1.3');
|
return defined('FPDF_FONTPATH') ? FPDF_FONTPATH : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function _putpages()
|
function _putpages()
|
||||||
|
@ -1223,21 +1168,36 @@ function _putfonts()
|
||||||
//Font file embedding
|
//Font file embedding
|
||||||
$this->_newobj();
|
$this->_newobj();
|
||||||
$this->FontFiles[$file]['n']=$this->n;
|
$this->FontFiles[$file]['n']=$this->n;
|
||||||
if(defined('FPDF_FONTPATH'))
|
$font='';
|
||||||
$file=FPDF_FONTPATH.$file;
|
$f=fopen($this->_getfontpath().$file,'rb',1);
|
||||||
$size=filesize($file);
|
if(!$f)
|
||||||
if(!$size)
|
|
||||||
$this->Error('Font file not found');
|
$this->Error('Font file not found');
|
||||||
$this->_out('<</Length '.$size);
|
while(!feof($f))
|
||||||
if(substr($file,-2)=='.z')
|
$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('<</Length '.strlen($font));
|
||||||
|
if($compressed)
|
||||||
$this->_out('/Filter /FlateDecode');
|
$this->_out('/Filter /FlateDecode');
|
||||||
$this->_out('/Length1 '.$info['length1']);
|
$this->_out('/Length1 '.$info['length1']);
|
||||||
if(isset($info['length2']))
|
if(isset($info['length2']))
|
||||||
$this->_out('/Length2 '.$info['length2'].' /Length3 0');
|
$this->_out('/Length2 '.$info['length2'].' /Length3 0');
|
||||||
$this->_out('>>');
|
$this->_out('>>');
|
||||||
$f=fopen($file,'rb');
|
$this->_putstream($font);
|
||||||
$this->_putstream(fread($f,$size));
|
|
||||||
fclose($f);
|
|
||||||
$this->_out('endobj');
|
$this->_out('endobj');
|
||||||
}
|
}
|
||||||
set_magic_quotes_runtime($mqr);
|
set_magic_quotes_runtime($mqr);
|
||||||
|
@ -1254,12 +1214,12 @@ function _putfonts()
|
||||||
$this->_out('<</Type /Font');
|
$this->_out('<</Type /Font');
|
||||||
$this->_out('/BaseFont /'.$name);
|
$this->_out('/BaseFont /'.$name);
|
||||||
$this->_out('/Subtype /Type1');
|
$this->_out('/Subtype /Type1');
|
||||||
if($name!='Symbol' and $name!='ZapfDingbats')
|
if($name!='Symbol' && $name!='ZapfDingbats')
|
||||||
$this->_out('/Encoding /WinAnsiEncoding');
|
$this->_out('/Encoding /WinAnsiEncoding');
|
||||||
$this->_out('>>');
|
$this->_out('>>');
|
||||||
$this->_out('endobj');
|
$this->_out('endobj');
|
||||||
}
|
}
|
||||||
elseif($type=='Type1' or $type=='TrueType')
|
elseif($type=='Type1' || $type=='TrueType')
|
||||||
{
|
{
|
||||||
//Additional Type1 or TrueType font
|
//Additional Type1 or TrueType font
|
||||||
$this->_newobj();
|
$this->_newobj();
|
||||||
|
@ -1329,10 +1289,11 @@ function _putimages()
|
||||||
$this->_out('/Decode [1 0 1 0 1 0 1 0]');
|
$this->_out('/Decode [1 0 1 0 1 0 1 0]');
|
||||||
}
|
}
|
||||||
$this->_out('/BitsPerComponent '.$info['bpc']);
|
$this->_out('/BitsPerComponent '.$info['bpc']);
|
||||||
$this->_out('/Filter /'.$info['f']);
|
if(isset($info['f']))
|
||||||
|
$this->_out('/Filter /'.$info['f']);
|
||||||
if(isset($info['parms']))
|
if(isset($info['parms']))
|
||||||
$this->_out($info['parms']);
|
$this->_out($info['parms']);
|
||||||
if(isset($info['trns']) and is_array($info['trns']))
|
if(isset($info['trns']) && is_array($info['trns']))
|
||||||
{
|
{
|
||||||
$trns='';
|
$trns='';
|
||||||
for($i=0;$i<count($info['trns']);$i++)
|
for($i=0;$i<count($info['trns']);$i++)
|
||||||
|
@ -1355,6 +1316,24 @@ function _putimages()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 <<');
|
||||||
|
foreach($this->fonts as $font)
|
||||||
|
$this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
|
||||||
|
$this->_out('>>');
|
||||||
|
$this->_out('/XObject <<');
|
||||||
|
$this->_putxobjectdict();
|
||||||
|
$this->_out('>>');
|
||||||
|
}
|
||||||
|
|
||||||
function _putresources()
|
function _putresources()
|
||||||
{
|
{
|
||||||
$this->_putfonts();
|
$this->_putfonts();
|
||||||
|
@ -1362,18 +1341,8 @@ function _putresources()
|
||||||
//Resource dictionary
|
//Resource dictionary
|
||||||
$this->offsets[2]=strlen($this->buffer);
|
$this->offsets[2]=strlen($this->buffer);
|
||||||
$this->_out('2 0 obj');
|
$this->_out('2 0 obj');
|
||||||
$this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
|
$this->_out('<<');
|
||||||
$this->_out('/Font <<');
|
$this->_putresourcedict();
|
||||||
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('>>');
|
||||||
$this->_out('endobj');
|
$this->_out('endobj');
|
||||||
}
|
}
|
||||||
|
@ -1414,6 +1383,11 @@ function _putcatalog()
|
||||||
$this->_out('/PageLayout /TwoColumnLeft');
|
$this->_out('/PageLayout /TwoColumnLeft');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _putheader()
|
||||||
|
{
|
||||||
|
$this->_out('%PDF-'.$this->PDFVersion);
|
||||||
|
}
|
||||||
|
|
||||||
function _puttrailer()
|
function _puttrailer()
|
||||||
{
|
{
|
||||||
$this->_out('/Size '.($this->n+1));
|
$this->_out('/Size '.($this->n+1));
|
||||||
|
@ -1423,6 +1397,7 @@ function _puttrailer()
|
||||||
|
|
||||||
function _enddoc()
|
function _enddoc()
|
||||||
{
|
{
|
||||||
|
$this->_putheader();
|
||||||
$this->_putpages();
|
$this->_putpages();
|
||||||
$this->_putresources();
|
$this->_putresources();
|
||||||
//Info
|
//Info
|
||||||
|
@ -1525,7 +1500,7 @@ function _parsejpg($file)
|
||||||
$this->Error('Missing or incorrect image file: '.$file);
|
$this->Error('Missing or incorrect image file: '.$file);
|
||||||
if($a[2]!=2)
|
if($a[2]!=2)
|
||||||
$this->Error('Not a JPEG file: '.$file);
|
$this->Error('Not a JPEG file: '.$file);
|
||||||
if(!isset($a['channels']) or $a['channels']==3)
|
if(!isset($a['channels']) || $a['channels']==3)
|
||||||
$colspace='DeviceRGB';
|
$colspace='DeviceRGB';
|
||||||
elseif($a['channels']==4)
|
elseif($a['channels']==4)
|
||||||
$colspace='DeviceCMYK';
|
$colspace='DeviceCMYK';
|
||||||
|
@ -1601,7 +1576,7 @@ function _parsepng($file)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$pos=strpos($t,chr(0));
|
$pos=strpos($t,chr(0));
|
||||||
if(is_int($pos))
|
if($pos!==false)
|
||||||
$trns=array($pos);
|
$trns=array($pos);
|
||||||
}
|
}
|
||||||
fread($f,4);
|
fread($f,4);
|
||||||
|
@ -1618,7 +1593,7 @@ function _parsepng($file)
|
||||||
fread($f,$n+4);
|
fread($f,$n+4);
|
||||||
}
|
}
|
||||||
while($n);
|
while($n);
|
||||||
if($colspace=='Indexed' and empty($pal))
|
if($colspace=='Indexed' && empty($pal))
|
||||||
$this->Error('Missing palette in '.$file);
|
$this->Error('Missing palette in '.$file);
|
||||||
fclose($f);
|
fclose($f);
|
||||||
return array('w'=>$w,'h'=>$h,'cs'=>$colspace,'bpc'=>$bpc,'f'=>'FlateDecode','parms'=>$parms,'pal'=>$pal,'trns'=>$trns,'data'=>$data);
|
return array('w'=>$w,'h'=>$h,'cs'=>$colspace,'bpc'=>$bpc,'f'=>'FlateDecode','parms'=>$parms,'pal'=>$pal,'trns'=>$trns,'data'=>$data);
|
||||||
|
@ -1627,11 +1602,8 @@ function _parsepng($file)
|
||||||
function _freadint($f)
|
function _freadint($f)
|
||||||
{
|
{
|
||||||
//Read a 4-byte integer from file
|
//Read a 4-byte integer from file
|
||||||
$i=ord(fread($f,1))<<24;
|
$a=unpack('Ni',fread($f,4));
|
||||||
$i+=ord(fread($f,1))<<16;
|
return $a['i'];
|
||||||
$i+=ord(fread($f,1))<<8;
|
|
||||||
$i+=ord(fread($f,1));
|
|
||||||
return $i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function _textstring($s)
|
function _textstring($s)
|
||||||
|
@ -1665,9 +1637,9 @@ function _out($s)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Handle special IE contype request
|
//Handle special IE contype request
|
||||||
if(isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']) and $HTTP_SERVER_VARS['HTTP_USER_AGENT']=='contype')
|
if(isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT']=='contype')
|
||||||
{
|
{
|
||||||
Header('Content-Type: application/pdf');
|
header('Content-Type: application/pdf');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue