new FPDF version
This commit is contained in:
parent
84d74d8577
commit
5c58f917f1
|
@ -8,7 +8,7 @@ Homepage: http://www.ldap-account-manager.org/
|
||||||
|
|
||||||
Package: ldap-account-manager
|
Package: ldap-account-manager
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Depends: php5 (>= 5.2.4), php5-ldap, php5-gd, apache2 | httpd, php-fpdf (>= 1.6), debconf (>= 0.2.26) | debconf-2.0, ${misc:Depends}
|
Depends: php5 (>= 5.2.4), php5-ldap, php5-gd, apache2 | httpd, php-fpdf (>= 1.7), debconf (>= 0.2.26) | debconf-2.0, ${misc:Depends}
|
||||||
Suggests: ldap-server, php5-mcrypt, ldap-account-manager-lamdaemon, perl
|
Suggests: ldap-server, php5-mcrypt, ldap-account-manager-lamdaemon, perl
|
||||||
Description: webfrontend for managing accounts in an LDAP directory
|
Description: webfrontend for managing accounts in an LDAP directory
|
||||||
LDAP Account Manager (LAM) runs on an existing webserver.
|
LDAP Account Manager (LAM) runs on an existing webserver.
|
||||||
|
|
452
lam/lib/fpdf.php
452
lam/lib/fpdf.php
|
@ -2,12 +2,12 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* FPDF *
|
* FPDF *
|
||||||
* *
|
* *
|
||||||
* Version: 1.6 *
|
* Version: 1.7 *
|
||||||
* Date: 2008-08-03 *
|
* Date: 2011-06-18 *
|
||||||
* Author: Olivier PLATHEY *
|
* Author: Olivier PLATHEY *
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
define('FPDF_VERSION','1.6');
|
define('FPDF_VERSION','1.7');
|
||||||
|
|
||||||
class FPDF
|
class FPDF
|
||||||
{
|
{
|
||||||
|
@ -21,10 +21,10 @@ var $compress; //compression flag
|
||||||
var $k; // scale factor (number of points in user unit)
|
var $k; // scale factor (number of points in user unit)
|
||||||
var $DefOrientation; // default orientation
|
var $DefOrientation; // default orientation
|
||||||
var $CurOrientation; // current orientation
|
var $CurOrientation; // current orientation
|
||||||
var $PageFormats; //available page formats
|
var $StdPageSizes; // standard page sizes
|
||||||
var $DefPageFormat; //default page format
|
var $DefPageSize; // default page size
|
||||||
var $CurPageFormat; //current page format
|
var $CurPageSize; // current page size
|
||||||
var $PageSizes; //array storing non-default page sizes
|
var $PageSizes; // used for pages with non default sizes or orientations
|
||||||
var $wPt, $hPt; // dimensions of current page in points
|
var $wPt, $hPt; // dimensions of current page in points
|
||||||
var $w, $h; // dimensions of current page in user unit
|
var $w, $h; // dimensions of current page in user unit
|
||||||
var $lMargin; // left margin
|
var $lMargin; // left margin
|
||||||
|
@ -35,7 +35,8 @@ var $cMargin; //cell margin
|
||||||
var $x, $y; // current position in user unit
|
var $x, $y; // current position in user unit
|
||||||
var $lasth; // height of last printed cell
|
var $lasth; // height of last printed cell
|
||||||
var $LineWidth; // line width in user unit
|
var $LineWidth; // line width in user unit
|
||||||
var $CoreFonts; //array of standard font names
|
var $fontpath; // path containing fonts
|
||||||
|
var $CoreFonts; // array of core font names
|
||||||
var $fonts; // array of used fonts
|
var $fonts; // array of used fonts
|
||||||
var $FontFiles; // array of font files
|
var $FontFiles; // array of font files
|
||||||
var $diffs; // array of encoding differences
|
var $diffs; // array of encoding differences
|
||||||
|
@ -72,7 +73,7 @@ var $PDFVersion; //PDF version number
|
||||||
* Public methods *
|
* Public methods *
|
||||||
* *
|
* *
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
function FPDF($orientation='P', $unit='mm', $format='A4')
|
function FPDF($orientation='P', $unit='mm', $size='A4')
|
||||||
{
|
{
|
||||||
// Some checks
|
// Some checks
|
||||||
$this->_dochecks();
|
$this->_dochecks();
|
||||||
|
@ -100,11 +101,19 @@ function FPDF($orientation='P', $unit='mm', $format='A4')
|
||||||
$this->TextColor = '0 g';
|
$this->TextColor = '0 g';
|
||||||
$this->ColorFlag = false;
|
$this->ColorFlag = false;
|
||||||
$this->ws = 0;
|
$this->ws = 0;
|
||||||
//Standard fonts
|
// Font path
|
||||||
$this->CoreFonts=array('courier'=>'Courier', 'courierB'=>'Courier-Bold', 'courierI'=>'Courier-Oblique', 'courierBI'=>'Courier-BoldOblique',
|
if(defined('FPDF_FONTPATH'))
|
||||||
'helvetica'=>'Helvetica', 'helveticaB'=>'Helvetica-Bold', 'helveticaI'=>'Helvetica-Oblique', 'helveticaBI'=>'Helvetica-BoldOblique',
|
{
|
||||||
'times'=>'Times-Roman', 'timesB'=>'Times-Bold', 'timesI'=>'Times-Italic', 'timesBI'=>'Times-BoldItalic',
|
$this->fontpath = FPDF_FONTPATH;
|
||||||
'symbol'=>'Symbol', 'zapfdingbats'=>'ZapfDingbats');
|
if(substr($this->fontpath,-1)!='/' && substr($this->fontpath,-1)!='\\')
|
||||||
|
$this->fontpath .= '/';
|
||||||
|
}
|
||||||
|
elseif(is_dir(dirname(__FILE__).'/font'))
|
||||||
|
$this->fontpath = dirname(__FILE__).'/font/';
|
||||||
|
else
|
||||||
|
$this->fontpath = '';
|
||||||
|
// Core fonts
|
||||||
|
$this->CoreFonts = array('courier', 'helvetica', 'times', 'symbol', 'zapfdingbats');
|
||||||
// Scale factor
|
// Scale factor
|
||||||
if($unit=='pt')
|
if($unit=='pt')
|
||||||
$this->k = 1;
|
$this->k = 1;
|
||||||
|
@ -116,26 +125,25 @@ function FPDF($orientation='P', $unit='mm', $format='A4')
|
||||||
$this->k = 72;
|
$this->k = 72;
|
||||||
else
|
else
|
||||||
$this->Error('Incorrect unit: '.$unit);
|
$this->Error('Incorrect unit: '.$unit);
|
||||||
//Page format
|
// Page sizes
|
||||||
$this->PageFormats=array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28),
|
$this->StdPageSizes = array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28),
|
||||||
'letter'=>array(612,792), 'legal'=>array(612,1008));
|
'letter'=>array(612,792), 'legal'=>array(612,1008));
|
||||||
if(is_string($format))
|
$size = $this->_getpagesize($size);
|
||||||
$format=$this->_getpageformat($format);
|
$this->DefPageSize = $size;
|
||||||
$this->DefPageFormat=$format;
|
$this->CurPageSize = $size;
|
||||||
$this->CurPageFormat=$format;
|
|
||||||
// Page orientation
|
// Page orientation
|
||||||
$orientation = strtolower($orientation);
|
$orientation = strtolower($orientation);
|
||||||
if($orientation=='p' || $orientation=='portrait')
|
if($orientation=='p' || $orientation=='portrait')
|
||||||
{
|
{
|
||||||
$this->DefOrientation = 'P';
|
$this->DefOrientation = 'P';
|
||||||
$this->w=$this->DefPageFormat[0];
|
$this->w = $size[0];
|
||||||
$this->h=$this->DefPageFormat[1];
|
$this->h = $size[1];
|
||||||
}
|
}
|
||||||
elseif($orientation=='l' || $orientation=='landscape')
|
elseif($orientation=='l' || $orientation=='landscape')
|
||||||
{
|
{
|
||||||
$this->DefOrientation = 'L';
|
$this->DefOrientation = 'L';
|
||||||
$this->w=$this->DefPageFormat[1];
|
$this->w = $size[1];
|
||||||
$this->h=$this->DefPageFormat[0];
|
$this->h = $size[0];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$this->Error('Incorrect orientation: '.$orientation);
|
$this->Error('Incorrect orientation: '.$orientation);
|
||||||
|
@ -151,8 +159,8 @@ function FPDF($orientation='P', $unit='mm', $format='A4')
|
||||||
$this->LineWidth = .567/$this->k;
|
$this->LineWidth = .567/$this->k;
|
||||||
// Automatic page break
|
// Automatic page break
|
||||||
$this->SetAutoPageBreak(true,2*$margin);
|
$this->SetAutoPageBreak(true,2*$margin);
|
||||||
//Full width display mode
|
// Default display mode
|
||||||
$this->SetDisplayMode('fullwidth');
|
$this->SetDisplayMode('default');
|
||||||
// Enable compression
|
// Enable compression
|
||||||
$this->SetCompression(true);
|
$this->SetCompression(true);
|
||||||
// Set default PDF version number
|
// Set default PDF version number
|
||||||
|
@ -197,7 +205,7 @@ function SetAutoPageBreak($auto, $margin=0)
|
||||||
$this->PageBreakTrigger = $this->h-$margin;
|
$this->PageBreakTrigger = $this->h-$margin;
|
||||||
}
|
}
|
||||||
|
|
||||||
function SetDisplayMode($zoom, $layout='continuous')
|
function SetDisplayMode($zoom, $layout='default')
|
||||||
{
|
{
|
||||||
// Set display mode in viewer
|
// Set display mode in viewer
|
||||||
if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom))
|
if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom))
|
||||||
|
@ -294,14 +302,14 @@ function Close()
|
||||||
$this->_enddoc();
|
$this->_enddoc();
|
||||||
}
|
}
|
||||||
|
|
||||||
function AddPage($orientation='', $format='')
|
function AddPage($orientation='', $size='')
|
||||||
{
|
{
|
||||||
// Start a new page
|
// Start a new page
|
||||||
if($this->state==0)
|
if($this->state==0)
|
||||||
$this->Open();
|
$this->Open();
|
||||||
$family = $this->FontFamily;
|
$family = $this->FontFamily;
|
||||||
$style = $this->FontStyle.($this->underline ? 'U' : '');
|
$style = $this->FontStyle.($this->underline ? 'U' : '');
|
||||||
$size=$this->FontSizePt;
|
$fontsize = $this->FontSizePt;
|
||||||
$lw = $this->LineWidth;
|
$lw = $this->LineWidth;
|
||||||
$dc = $this->DrawColor;
|
$dc = $this->DrawColor;
|
||||||
$fc = $this->FillColor;
|
$fc = $this->FillColor;
|
||||||
|
@ -317,7 +325,7 @@ function AddPage($orientation='', $format='')
|
||||||
$this->_endpage();
|
$this->_endpage();
|
||||||
}
|
}
|
||||||
// Start new page
|
// Start new page
|
||||||
$this->_beginpage($orientation,$format);
|
$this->_beginpage($orientation,$size);
|
||||||
// Set line cap style to square
|
// Set line cap style to square
|
||||||
$this->_out('2 J');
|
$this->_out('2 J');
|
||||||
// Set line width
|
// Set line width
|
||||||
|
@ -325,7 +333,7 @@ function AddPage($orientation='', $format='')
|
||||||
$this->_out(sprintf('%.2F w',$lw*$this->k));
|
$this->_out(sprintf('%.2F w',$lw*$this->k));
|
||||||
// Set font
|
// Set font
|
||||||
if($family)
|
if($family)
|
||||||
$this->SetFont($family,$style,$size);
|
$this->SetFont($family,$style,$fontsize);
|
||||||
// Set colors
|
// Set colors
|
||||||
$this->DrawColor = $dc;
|
$this->DrawColor = $dc;
|
||||||
if($dc!='0 G')
|
if($dc!='0 G')
|
||||||
|
@ -347,7 +355,7 @@ function AddPage($orientation='', $format='')
|
||||||
}
|
}
|
||||||
// Restore font
|
// Restore font
|
||||||
if($family)
|
if($family)
|
||||||
$this->SetFont($family,$style,$size);
|
$this->SetFont($family,$style,$fontsize);
|
||||||
// Restore colors
|
// Restore colors
|
||||||
if($this->DrawColor!=$dc)
|
if($this->DrawColor!=$dc)
|
||||||
{
|
{
|
||||||
|
@ -452,64 +460,47 @@ function Rect($x, $y, $w, $h, $style='')
|
||||||
|
|
||||||
function AddFont($family, $style='', $file='')
|
function AddFont($family, $style='', $file='')
|
||||||
{
|
{
|
||||||
//Add a TrueType or Type1 font
|
// Add a TrueType, OpenType or Type1 font
|
||||||
$family = strtolower($family);
|
$family = strtolower($family);
|
||||||
if($file=='')
|
if($file=='')
|
||||||
$file = str_replace(' ','',$family).strtolower($style).'.php';
|
$file = str_replace(' ','',$family).strtolower($style).'.php';
|
||||||
if($family=='arial')
|
|
||||||
$family='helvetica';
|
|
||||||
$style = strtoupper($style);
|
$style = strtoupper($style);
|
||||||
if($style=='IB')
|
if($style=='IB')
|
||||||
$style = 'BI';
|
$style = 'BI';
|
||||||
$fontkey = $family.$style;
|
$fontkey = $family.$style;
|
||||||
if(isset($this->fonts[$fontkey]))
|
if(isset($this->fonts[$fontkey]))
|
||||||
return;
|
return;
|
||||||
include($this->_getfontpath().$file);
|
$info = $this->_loadfont($file);
|
||||||
if(!isset($name))
|
$info['i'] = count($this->fonts)+1;
|
||||||
$this->Error('Could not include font definition file');
|
if(!empty($info['diff']))
|
||||||
$i=count($this->fonts)+1;
|
|
||||||
$this->fonts[$fontkey]=array('i'=>$i, 'type'=>$type, 'name'=>$name, 'desc'=>$desc, 'up'=>$up, 'ut'=>$ut, 'cw'=>$cw, 'enc'=>$enc, 'file'=>$file);
|
|
||||||
if($diff)
|
|
||||||
{
|
{
|
||||||
// Search existing encodings
|
// Search existing encodings
|
||||||
$d=0;
|
$n = array_search($info['diff'],$this->diffs);
|
||||||
$nb=count($this->diffs);
|
if(!$n)
|
||||||
for($i=1;$i<=$nb;$i++)
|
|
||||||
{
|
{
|
||||||
if($this->diffs[$i]==$diff)
|
$n = count($this->diffs)+1;
|
||||||
|
$this->diffs[$n] = $info['diff'];
|
||||||
|
}
|
||||||
|
$info['diffn'] = $n;
|
||||||
|
}
|
||||||
|
if(!empty($info['file']))
|
||||||
{
|
{
|
||||||
$d=$i;
|
// Embedded font
|
||||||
break;
|
if($info['type']=='TrueType')
|
||||||
}
|
$this->FontFiles[$info['file']] = array('length1'=>$info['originalsize']);
|
||||||
}
|
|
||||||
if($d==0)
|
|
||||||
{
|
|
||||||
$d=$nb+1;
|
|
||||||
$this->diffs[$d]=$diff;
|
|
||||||
}
|
|
||||||
$this->fonts[$fontkey]['diff']=$d;
|
|
||||||
}
|
|
||||||
if($file)
|
|
||||||
{
|
|
||||||
if($type=='TrueType')
|
|
||||||
$this->FontFiles[$file]=array('length1'=>$originalsize);
|
|
||||||
else
|
else
|
||||||
$this->FontFiles[$file]=array('length1'=>$size1, 'length2'=>$size2);
|
$this->FontFiles[$info['file']] = array('length1'=>$info['size1'], 'length2'=>$info['size2']);
|
||||||
}
|
}
|
||||||
|
$this->fonts[$fontkey] = $info;
|
||||||
}
|
}
|
||||||
|
|
||||||
function SetFont($family, $style='', $size=0)
|
function SetFont($family, $style='', $size=0)
|
||||||
{
|
{
|
||||||
// Select a font; size given in points
|
// Select a font; size given in points
|
||||||
global $fpdf_charwidths;
|
|
||||||
|
|
||||||
$family=strtolower($family);
|
|
||||||
if($family=='')
|
if($family=='')
|
||||||
$family = $this->FontFamily;
|
$family = $this->FontFamily;
|
||||||
if($family=='arial')
|
else
|
||||||
$family='helvetica';
|
$family = strtolower($family);
|
||||||
elseif($family=='symbol' || $family=='zapfdingbats')
|
|
||||||
$style='';
|
|
||||||
$style = strtoupper($style);
|
$style = strtoupper($style);
|
||||||
if(strpos($style,'U')!==false)
|
if(strpos($style,'U')!==false)
|
||||||
{
|
{
|
||||||
|
@ -525,27 +516,20 @@ function SetFont($family, $style='', $size=0)
|
||||||
// Test if font is already selected
|
// Test if font is already selected
|
||||||
if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size)
|
if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size)
|
||||||
return;
|
return;
|
||||||
//Test if used for the first time
|
// Test if font is already loaded
|
||||||
$fontkey = $family.$style;
|
$fontkey = $family.$style;
|
||||||
if(!isset($this->fonts[$fontkey]))
|
if(!isset($this->fonts[$fontkey]))
|
||||||
{
|
{
|
||||||
//Check if one of the standard fonts
|
// Test if one of the core fonts
|
||||||
if(isset($this->CoreFonts[$fontkey]))
|
if($family=='arial')
|
||||||
|
$family = 'helvetica';
|
||||||
|
if(in_array($family,$this->CoreFonts))
|
||||||
{
|
{
|
||||||
if(!isset($fpdf_charwidths[$fontkey]))
|
if($family=='symbol' || $family=='zapfdingbats')
|
||||||
{
|
$style = '';
|
||||||
//Load metric file
|
$fontkey = $family.$style;
|
||||||
$file=$family;
|
if(!isset($this->fonts[$fontkey]))
|
||||||
if($family=='times' || $family=='helvetica')
|
$this->AddFont($family,$style);
|
||||||
$file.=strtolower($style);
|
|
||||||
include($this->_getfontpath().$file.'.php');
|
|
||||||
if(!isset($fpdf_charwidths[$fontkey]))
|
|
||||||
$this->Error('Could not include font metric file');
|
|
||||||
}
|
|
||||||
$i=count($this->fonts)+1;
|
|
||||||
$name=$this->CoreFonts[$fontkey];
|
|
||||||
$cw=$fpdf_charwidths[$fontkey];
|
|
||||||
$this->fonts[$fontkey]=array('i'=>$i, 'type'=>'core', 'name'=>$name, 'up'=>-100, 'ut'=>50, 'cw'=>$cw);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$this->Error('Undefined font: '.$family.' '.$style);
|
$this->Error('Undefined font: '.$family.' '.$style);
|
||||||
|
@ -626,7 +610,7 @@ function Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link
|
||||||
$this->ws = 0;
|
$this->ws = 0;
|
||||||
$this->_out('0 Tw');
|
$this->_out('0 Tw');
|
||||||
}
|
}
|
||||||
$this->AddPage($this->CurOrientation,$this->CurPageFormat);
|
$this->AddPage($this->CurOrientation,$this->CurPageSize);
|
||||||
$this->x = $x;
|
$this->x = $x;
|
||||||
if($ws>0)
|
if($ws>0)
|
||||||
{
|
{
|
||||||
|
@ -920,17 +904,23 @@ function Image($file, $x=null, $y=null, $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 && $h==0)
|
if($w==0 && $h==0)
|
||||||
{
|
{
|
||||||
//Put image at 72 dpi
|
// Put image at 96 dpi
|
||||||
$w=$info['w']/$this->k;
|
$w = -96;
|
||||||
$h=$info['h']/$this->k;
|
$h = -96;
|
||||||
}
|
}
|
||||||
elseif($w==0)
|
if($w<0)
|
||||||
|
$w = -$info['w']*72/$w/$this->k;
|
||||||
|
if($h<0)
|
||||||
|
$h = -$info['h']*72/$h/$this->k;
|
||||||
|
if($w==0)
|
||||||
$w = $h*$info['w']/$info['h'];
|
$w = $h*$info['w']/$info['h'];
|
||||||
elseif($h==0)
|
if($h==0)
|
||||||
$h = $w*$info['h']/$info['w'];
|
$h = $w*$info['h']/$info['w'];
|
||||||
|
|
||||||
// Flowing mode
|
// Flowing mode
|
||||||
if($y===null)
|
if($y===null)
|
||||||
{
|
{
|
||||||
|
@ -938,12 +928,13 @@ function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='')
|
||||||
{
|
{
|
||||||
// Automatic page break
|
// Automatic page break
|
||||||
$x2 = $this->x;
|
$x2 = $this->x;
|
||||||
$this->AddPage($this->CurOrientation,$this->CurPageFormat);
|
$this->AddPage($this->CurOrientation,$this->CurPageSize);
|
||||||
$this->x = $x2;
|
$this->x = $x2;
|
||||||
}
|
}
|
||||||
$y = $this->y;
|
$y = $this->y;
|
||||||
$this->y += $h;
|
$this->y += $h;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($x===null)
|
if($x===null)
|
||||||
$x = $this->x;
|
$x = $this->x;
|
||||||
$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']));
|
$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']));
|
||||||
|
@ -1009,34 +1000,24 @@ function Output($name='', $dest='')
|
||||||
{
|
{
|
||||||
case 'I':
|
case 'I':
|
||||||
// Send to standard output
|
// Send to standard output
|
||||||
if(ob_get_length())
|
$this->_checkoutput();
|
||||||
$this->Error('Some data has already been output, can\'t send PDF file');
|
if(PHP_SAPI!='cli')
|
||||||
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())
|
|
||||||
$this->Error('Some data has already been output, can\'t send PDF file');
|
|
||||||
header('Content-Length: '.strlen($this->buffer));
|
|
||||||
header('Content-Disposition: inline; filename="'.$name.'"');
|
header('Content-Disposition: inline; filename="'.$name.'"');
|
||||||
header('Cache-Control: private, max-age=0, must-revalidate');
|
header('Cache-Control: private, max-age=0, must-revalidate');
|
||||||
header('Pragma: public');
|
header('Pragma: public');
|
||||||
ini_set('zlib.output_compression','0');
|
|
||||||
}
|
}
|
||||||
echo $this->buffer;
|
echo $this->buffer;
|
||||||
break;
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
// Download file
|
// Download file
|
||||||
if(ob_get_length())
|
$this->_checkoutput();
|
||||||
$this->Error('Some data has already been output, can\'t send PDF file');
|
|
||||||
header('Content-Type: application/x-download');
|
header('Content-Type: application/x-download');
|
||||||
if(headers_sent())
|
|
||||||
$this->Error('Some data has already been output, can\'t send PDF file');
|
|
||||||
header('Content-Length: '.strlen($this->buffer));
|
|
||||||
header('Content-Disposition: attachment; filename="'.$name.'"');
|
header('Content-Disposition: attachment; filename="'.$name.'"');
|
||||||
header('Cache-Control: private, max-age=0, must-revalidate');
|
header('Cache-Control: private, max-age=0, must-revalidate');
|
||||||
header('Pragma: public');
|
header('Pragma: public');
|
||||||
ini_set('zlib.output_compression','0');
|
|
||||||
echo $this->buffer;
|
echo $this->buffer;
|
||||||
break;
|
break;
|
||||||
case 'F':
|
case 'F':
|
||||||
|
@ -1069,28 +1050,51 @@ function _dochecks()
|
||||||
// Check mbstring overloading
|
// Check mbstring overloading
|
||||||
if(ini_get('mbstring.func_overload') & 2)
|
if(ini_get('mbstring.func_overload') & 2)
|
||||||
$this->Error('mbstring overloading must be disabled');
|
$this->Error('mbstring overloading must be disabled');
|
||||||
//Disable runtime magic quotes
|
// Ensure runtime magic quotes are disabled
|
||||||
if(get_magic_quotes_runtime())
|
if(get_magic_quotes_runtime())
|
||||||
@set_magic_quotes_runtime(0);
|
@set_magic_quotes_runtime(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _getpageformat($format)
|
function _checkoutput()
|
||||||
{
|
{
|
||||||
$format=strtolower($format);
|
if(PHP_SAPI!='cli')
|
||||||
if(!isset($this->PageFormats[$format]))
|
{
|
||||||
$this->Error('Unknown page format: '.$format);
|
if(headers_sent($file,$line))
|
||||||
$a=$this->PageFormats[$format];
|
$this->Error("Some data has already been output, can't send PDF file (output started at $file:$line)");
|
||||||
|
}
|
||||||
|
if(ob_get_length())
|
||||||
|
{
|
||||||
|
// The output buffer is not empty
|
||||||
|
if(preg_match('/^(\xEF\xBB\xBF)?\s*$/',ob_get_contents()))
|
||||||
|
{
|
||||||
|
// It contains only a UTF-8 BOM and/or whitespace, let's clean it
|
||||||
|
ob_clean();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$this->Error("Some data has already been output, can't send PDF file");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function _getpagesize($size)
|
||||||
|
{
|
||||||
|
if(is_string($size))
|
||||||
|
{
|
||||||
|
$size = strtolower($size);
|
||||||
|
if(!isset($this->StdPageSizes[$size]))
|
||||||
|
$this->Error('Unknown page size: '.$size);
|
||||||
|
$a = $this->StdPageSizes[$size];
|
||||||
return array($a[0]/$this->k, $a[1]/$this->k);
|
return array($a[0]/$this->k, $a[1]/$this->k);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
function _getfontpath()
|
|
||||||
{
|
{
|
||||||
if(!defined('FPDF_FONTPATH') && is_dir(dirname(__FILE__).'/font'))
|
if($size[0]>$size[1])
|
||||||
define('FPDF_FONTPATH',dirname(__FILE__).'/font/');
|
return array($size[1], $size[0]);
|
||||||
return defined('FPDF_FONTPATH') ? FPDF_FONTPATH : '';
|
else
|
||||||
|
return $size;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function _beginpage($orientation, $format)
|
function _beginpage($orientation, $size)
|
||||||
{
|
{
|
||||||
$this->page++;
|
$this->page++;
|
||||||
$this->pages[$this->page] = '';
|
$this->pages[$this->page] = '';
|
||||||
|
@ -1098,38 +1102,35 @@ function _beginpage($orientation, $format)
|
||||||
$this->x = $this->lMargin;
|
$this->x = $this->lMargin;
|
||||||
$this->y = $this->tMargin;
|
$this->y = $this->tMargin;
|
||||||
$this->FontFamily = '';
|
$this->FontFamily = '';
|
||||||
//Check page size
|
// Check page size and orientation
|
||||||
if($orientation=='')
|
if($orientation=='')
|
||||||
$orientation = $this->DefOrientation;
|
$orientation = $this->DefOrientation;
|
||||||
else
|
else
|
||||||
$orientation = strtoupper($orientation[0]);
|
$orientation = strtoupper($orientation[0]);
|
||||||
if($format=='')
|
if($size=='')
|
||||||
$format=$this->DefPageFormat;
|
$size = $this->DefPageSize;
|
||||||
else
|
else
|
||||||
|
$size = $this->_getpagesize($size);
|
||||||
|
if($orientation!=$this->CurOrientation || $size[0]!=$this->CurPageSize[0] || $size[1]!=$this->CurPageSize[1])
|
||||||
{
|
{
|
||||||
if(is_string($format))
|
// New size or orientation
|
||||||
$format=$this->_getpageformat($format);
|
|
||||||
}
|
|
||||||
if($orientation!=$this->CurOrientation || $format[0]!=$this->CurPageFormat[0] || $format[1]!=$this->CurPageFormat[1])
|
|
||||||
{
|
|
||||||
//New size
|
|
||||||
if($orientation=='P')
|
if($orientation=='P')
|
||||||
{
|
{
|
||||||
$this->w=$format[0];
|
$this->w = $size[0];
|
||||||
$this->h=$format[1];
|
$this->h = $size[1];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->w=$format[1];
|
$this->w = $size[1];
|
||||||
$this->h=$format[0];
|
$this->h = $size[0];
|
||||||
}
|
}
|
||||||
$this->wPt = $this->w*$this->k;
|
$this->wPt = $this->w*$this->k;
|
||||||
$this->hPt = $this->h*$this->k;
|
$this->hPt = $this->h*$this->k;
|
||||||
$this->PageBreakTrigger = $this->h-$this->bMargin;
|
$this->PageBreakTrigger = $this->h-$this->bMargin;
|
||||||
$this->CurOrientation = $orientation;
|
$this->CurOrientation = $orientation;
|
||||||
$this->CurPageFormat=$format;
|
$this->CurPageSize = $size;
|
||||||
}
|
}
|
||||||
if($orientation!=$this->DefOrientation || $format[0]!=$this->DefPageFormat[0] || $format[1]!=$this->DefPageFormat[1])
|
if($orientation!=$this->DefOrientation || $size[0]!=$this->DefPageSize[0] || $size[1]!=$this->DefPageSize[1])
|
||||||
$this->PageSizes[$this->page] = array($this->wPt, $this->hPt);
|
$this->PageSizes[$this->page] = array($this->wPt, $this->hPt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1138,6 +1139,16 @@ function _endpage()
|
||||||
$this->state = 1;
|
$this->state = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _loadfont($font)
|
||||||
|
{
|
||||||
|
// Load a font definition file from the font directory
|
||||||
|
include($this->fontpath.$font);
|
||||||
|
$a = get_defined_vars();
|
||||||
|
if(!isset($a['name']))
|
||||||
|
$this->Error('Could not include font definition file');
|
||||||
|
return $a;
|
||||||
|
}
|
||||||
|
|
||||||
function _escape($s)
|
function _escape($s)
|
||||||
{
|
{
|
||||||
// Escape special characters in strings
|
// Escape special characters in strings
|
||||||
|
@ -1199,7 +1210,7 @@ function _dounderline($x, $y, $txt)
|
||||||
function _parsejpg($file)
|
function _parsejpg($file)
|
||||||
{
|
{
|
||||||
// Extract info from a JPEG file
|
// Extract info from a JPEG file
|
||||||
$a=GetImageSize($file);
|
$a = getimagesize($file);
|
||||||
if(!$a)
|
if(!$a)
|
||||||
$this->Error('Missing or incorrect image file: '.$file);
|
$this->Error('Missing or incorrect image file: '.$file);
|
||||||
if($a[2]!=2)
|
if($a[2]!=2)
|
||||||
|
@ -1211,12 +1222,7 @@ function _parsejpg($file)
|
||||||
else
|
else
|
||||||
$colspace = 'DeviceGray';
|
$colspace = 'DeviceGray';
|
||||||
$bpc = isset($a['bits']) ? $a['bits'] : 8;
|
$bpc = isset($a['bits']) ? $a['bits'] : 8;
|
||||||
//Read whole file
|
$data = file_get_contents($file);
|
||||||
$f=fopen($file,'rb');
|
|
||||||
$data='';
|
|
||||||
while(!feof($f))
|
|
||||||
$data.=fread($f,8192);
|
|
||||||
fclose($f);
|
|
||||||
return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data);
|
return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1226,9 +1232,17 @@ function _parsepng($file)
|
||||||
$f = fopen($file,'rb');
|
$f = fopen($file,'rb');
|
||||||
if(!$f)
|
if(!$f)
|
||||||
$this->Error('Can\'t open image file: '.$file);
|
$this->Error('Can\'t open image file: '.$file);
|
||||||
|
$info = $this->_parsepngstream($f,$file);
|
||||||
|
fclose($f);
|
||||||
|
return $info;
|
||||||
|
}
|
||||||
|
|
||||||
|
function _parsepngstream($f, $file)
|
||||||
|
{
|
||||||
// Check signature
|
// Check signature
|
||||||
if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10))
|
if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10))
|
||||||
$this->Error('Not a PNG file: '.$file);
|
$this->Error('Not a PNG file: '.$file);
|
||||||
|
|
||||||
// Read header chunk
|
// Read header chunk
|
||||||
$this->_readstream($f,4);
|
$this->_readstream($f,4);
|
||||||
if($this->_readstream($f,4)!='IHDR')
|
if($this->_readstream($f,4)!='IHDR')
|
||||||
|
@ -1239,14 +1253,14 @@ function _parsepng($file)
|
||||||
if($bpc>8)
|
if($bpc>8)
|
||||||
$this->Error('16-bit depth not supported: '.$file);
|
$this->Error('16-bit depth not supported: '.$file);
|
||||||
$ct = ord($this->_readstream($f,1));
|
$ct = ord($this->_readstream($f,1));
|
||||||
if($ct==0)
|
if($ct==0 || $ct==4)
|
||||||
$colspace = 'DeviceGray';
|
$colspace = 'DeviceGray';
|
||||||
elseif($ct==2)
|
elseif($ct==2 || $ct==6)
|
||||||
$colspace = 'DeviceRGB';
|
$colspace = 'DeviceRGB';
|
||||||
elseif($ct==3)
|
elseif($ct==3)
|
||||||
$colspace = 'Indexed';
|
$colspace = 'Indexed';
|
||||||
else
|
else
|
||||||
$this->Error('Alpha channel not supported: '.$file);
|
$this->Error('Unknown color type: '.$file);
|
||||||
if(ord($this->_readstream($f,1))!=0)
|
if(ord($this->_readstream($f,1))!=0)
|
||||||
$this->Error('Unknown compression method: '.$file);
|
$this->Error('Unknown compression method: '.$file);
|
||||||
if(ord($this->_readstream($f,1))!=0)
|
if(ord($this->_readstream($f,1))!=0)
|
||||||
|
@ -1254,7 +1268,8 @@ function _parsepng($file)
|
||||||
if(ord($this->_readstream($f,1))!=0)
|
if(ord($this->_readstream($f,1))!=0)
|
||||||
$this->Error('Interlacing not supported: '.$file);
|
$this->Error('Interlacing not supported: '.$file);
|
||||||
$this->_readstream($f,4);
|
$this->_readstream($f,4);
|
||||||
$parms='/DecodeParms <</Predictor 15 /Colors '.($ct==2 ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w.'>>';
|
$dp = '/Predictor 15 /Colors '.($colspace=='DeviceRGB' ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w;
|
||||||
|
|
||||||
// Scan chunks looking for palette, transparency and image data
|
// Scan chunks looking for palette, transparency and image data
|
||||||
$pal = '';
|
$pal = '';
|
||||||
$trns = '';
|
$trns = '';
|
||||||
|
@ -1297,10 +1312,54 @@ function _parsepng($file)
|
||||||
$this->_readstream($f,$n+4);
|
$this->_readstream($f,$n+4);
|
||||||
}
|
}
|
||||||
while($n);
|
while($n);
|
||||||
|
|
||||||
if($colspace=='Indexed' && empty($pal))
|
if($colspace=='Indexed' && empty($pal))
|
||||||
$this->Error('Missing palette in '.$file);
|
$this->Error('Missing palette in '.$file);
|
||||||
fclose($f);
|
$info = array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'dp'=>$dp, 'pal'=>$pal, 'trns'=>$trns);
|
||||||
return array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'parms'=>$parms, 'pal'=>$pal, 'trns'=>$trns, 'data'=>$data);
|
if($ct>=4)
|
||||||
|
{
|
||||||
|
// Extract alpha channel
|
||||||
|
if(!function_exists('gzuncompress'))
|
||||||
|
$this->Error('Zlib not available, can\'t handle alpha channel: '.$file);
|
||||||
|
$data = gzuncompress($data);
|
||||||
|
$color = '';
|
||||||
|
$alpha = '';
|
||||||
|
if($ct==4)
|
||||||
|
{
|
||||||
|
// Gray image
|
||||||
|
$len = 2*$w;
|
||||||
|
for($i=0;$i<$h;$i++)
|
||||||
|
{
|
||||||
|
$pos = (1+$len)*$i;
|
||||||
|
$color .= $data[$pos];
|
||||||
|
$alpha .= $data[$pos];
|
||||||
|
$line = substr($data,$pos+1,$len);
|
||||||
|
$color .= preg_replace('/(.)./s','$1',$line);
|
||||||
|
$alpha .= preg_replace('/.(.)/s','$1',$line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// RGB image
|
||||||
|
$len = 4*$w;
|
||||||
|
for($i=0;$i<$h;$i++)
|
||||||
|
{
|
||||||
|
$pos = (1+$len)*$i;
|
||||||
|
$color .= $data[$pos];
|
||||||
|
$alpha .= $data[$pos];
|
||||||
|
$line = substr($data,$pos+1,$len);
|
||||||
|
$color .= preg_replace('/(.{3})./s','$1',$line);
|
||||||
|
$alpha .= preg_replace('/.{3}(.)/s','$1',$line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unset($data);
|
||||||
|
$data = gzcompress($color);
|
||||||
|
$info['smask'] = gzcompress($alpha);
|
||||||
|
if($this->PDFVersion<'1.4')
|
||||||
|
$this->PDFVersion = '1.4';
|
||||||
|
}
|
||||||
|
$info['data'] = $data;
|
||||||
|
return $info;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _readstream($f, $n)
|
function _readstream($f, $n)
|
||||||
|
@ -1338,6 +1397,22 @@ function _parsegif($file)
|
||||||
if(!$im)
|
if(!$im)
|
||||||
$this->Error('Missing or incorrect image file: '.$file);
|
$this->Error('Missing or incorrect image file: '.$file);
|
||||||
imageinterlace($im,0);
|
imageinterlace($im,0);
|
||||||
|
$f = @fopen('php://temp','rb+');
|
||||||
|
if($f)
|
||||||
|
{
|
||||||
|
// Perform conversion in memory
|
||||||
|
ob_start();
|
||||||
|
imagepng($im);
|
||||||
|
$data = ob_get_clean();
|
||||||
|
imagedestroy($im);
|
||||||
|
fwrite($f,$data);
|
||||||
|
rewind($f);
|
||||||
|
$info = $this->_parsepngstream($f,$file);
|
||||||
|
fclose($f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Use temporary file
|
||||||
$tmp = tempnam('.','gif');
|
$tmp = tempnam('.','gif');
|
||||||
if(!$tmp)
|
if(!$tmp)
|
||||||
$this->Error('Unable to create a temporary file');
|
$this->Error('Unable to create a temporary file');
|
||||||
|
@ -1346,6 +1421,7 @@ function _parsegif($file)
|
||||||
imagedestroy($im);
|
imagedestroy($im);
|
||||||
$info = $this->_parsepng($tmp);
|
$info = $this->_parsepng($tmp);
|
||||||
unlink($tmp);
|
unlink($tmp);
|
||||||
|
}
|
||||||
return $info;
|
return $info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1384,13 +1460,13 @@ function _putpages()
|
||||||
}
|
}
|
||||||
if($this->DefOrientation=='P')
|
if($this->DefOrientation=='P')
|
||||||
{
|
{
|
||||||
$wPt=$this->DefPageFormat[0]*$this->k;
|
$wPt = $this->DefPageSize[0]*$this->k;
|
||||||
$hPt=$this->DefPageFormat[1]*$this->k;
|
$hPt = $this->DefPageSize[1]*$this->k;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$wPt=$this->DefPageFormat[1]*$this->k;
|
$wPt = $this->DefPageSize[1]*$this->k;
|
||||||
$hPt=$this->DefPageFormat[0]*$this->k;
|
$hPt = $this->DefPageSize[0]*$this->k;
|
||||||
}
|
}
|
||||||
$filter = ($this->compress) ? '/Filter /FlateDecode ' : '';
|
$filter = ($this->compress) ? '/Filter /FlateDecode ' : '';
|
||||||
for($n=1;$n<=$nb;$n++)
|
for($n=1;$n<=$nb;$n++)
|
||||||
|
@ -1421,6 +1497,8 @@ function _putpages()
|
||||||
}
|
}
|
||||||
$this->_out($annots.']');
|
$this->_out($annots.']');
|
||||||
}
|
}
|
||||||
|
if($this->PDFVersion>'1.3')
|
||||||
|
$this->_out('/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>');
|
||||||
$this->_out('/Contents '.($this->n+1).' 0 R>>');
|
$this->_out('/Contents '.($this->n+1).' 0 R>>');
|
||||||
$this->_out('endobj');
|
$this->_out('endobj');
|
||||||
// Page content
|
// Page content
|
||||||
|
@ -1459,28 +1537,12 @@ function _putfonts()
|
||||||
// Font file embedding
|
// Font file embedding
|
||||||
$this->_newobj();
|
$this->_newobj();
|
||||||
$this->FontFiles[$file]['n'] = $this->n;
|
$this->FontFiles[$file]['n'] = $this->n;
|
||||||
$font='';
|
$font = file_get_contents($this->fontpath.$file,true);
|
||||||
$f=fopen($this->_getfontpath().$file,'rb',1);
|
if(!$font)
|
||||||
if(!$f)
|
$this->Error('Font file not found: '.$file);
|
||||||
$this->Error('Font file not found');
|
|
||||||
while(!feof($f))
|
|
||||||
$font.=fread($f,8192);
|
|
||||||
fclose($f);
|
|
||||||
$compressed = (substr($file,-2)=='.z');
|
$compressed = (substr($file,-2)=='.z');
|
||||||
if(!$compressed && isset($info['length2']))
|
if(!$compressed && isset($info['length2']))
|
||||||
{
|
$font = substr($font,6,$info['length1']).substr($font,6+$info['length1']+6,$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));
|
$this->_out('<</Length '.strlen($font));
|
||||||
if($compressed)
|
if($compressed)
|
||||||
$this->_out('/Filter /FlateDecode');
|
$this->_out('/Filter /FlateDecode');
|
||||||
|
@ -1497,9 +1559,9 @@ function _putfonts()
|
||||||
$this->fonts[$k]['n'] = $this->n+1;
|
$this->fonts[$k]['n'] = $this->n+1;
|
||||||
$type = $font['type'];
|
$type = $font['type'];
|
||||||
$name = $font['name'];
|
$name = $font['name'];
|
||||||
if($type=='core')
|
if($type=='Core')
|
||||||
{
|
{
|
||||||
//Standard font
|
// Core font
|
||||||
$this->_newobj();
|
$this->_newobj();
|
||||||
$this->_out('<</Type /Font');
|
$this->_out('<</Type /Font');
|
||||||
$this->_out('/BaseFont /'.$name);
|
$this->_out('/BaseFont /'.$name);
|
||||||
|
@ -1511,7 +1573,7 @@ function _putfonts()
|
||||||
}
|
}
|
||||||
elseif($type=='Type1' || $type=='TrueType')
|
elseif($type=='Type1' || $type=='TrueType')
|
||||||
{
|
{
|
||||||
//Additional Type1 or TrueType font
|
// Additional Type1 or TrueType/OpenType font
|
||||||
$this->_newobj();
|
$this->_newobj();
|
||||||
$this->_out('<</Type /Font');
|
$this->_out('<</Type /Font');
|
||||||
$this->_out('/BaseFont /'.$name);
|
$this->_out('/BaseFont /'.$name);
|
||||||
|
@ -1519,13 +1581,10 @@ function _putfonts()
|
||||||
$this->_out('/FirstChar 32 /LastChar 255');
|
$this->_out('/FirstChar 32 /LastChar 255');
|
||||||
$this->_out('/Widths '.($this->n+1).' 0 R');
|
$this->_out('/Widths '.($this->n+1).' 0 R');
|
||||||
$this->_out('/FontDescriptor '.($this->n+2).' 0 R');
|
$this->_out('/FontDescriptor '.($this->n+2).' 0 R');
|
||||||
if($font['enc'])
|
if(isset($font['diffn']))
|
||||||
{
|
$this->_out('/Encoding '.($nf+$font['diffn']).' 0 R');
|
||||||
if(isset($font['diff']))
|
|
||||||
$this->_out('/Encoding '.($nf+$font['diff']).' 0 R');
|
|
||||||
else
|
else
|
||||||
$this->_out('/Encoding /WinAnsiEncoding');
|
$this->_out('/Encoding /WinAnsiEncoding');
|
||||||
}
|
|
||||||
$this->_out('>>');
|
$this->_out('>>');
|
||||||
$this->_out('endobj');
|
$this->_out('endobj');
|
||||||
// Widths
|
// Widths
|
||||||
|
@ -1541,9 +1600,8 @@ function _putfonts()
|
||||||
$s = '<</Type /FontDescriptor /FontName /'.$name;
|
$s = '<</Type /FontDescriptor /FontName /'.$name;
|
||||||
foreach($font['desc'] as $k=>$v)
|
foreach($font['desc'] as $k=>$v)
|
||||||
$s .= ' /'.$k.' '.$v;
|
$s .= ' /'.$k.' '.$v;
|
||||||
$file=$font['file'];
|
if(!empty($font['file']))
|
||||||
if($file)
|
$s .= ' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$font['file']]['n'].' 0 R';
|
||||||
$s.=' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R';
|
|
||||||
$this->_out($s.'>>');
|
$this->_out($s.'>>');
|
||||||
$this->_out('endobj');
|
$this->_out('endobj');
|
||||||
}
|
}
|
||||||
|
@ -1560,12 +1618,18 @@ function _putfonts()
|
||||||
|
|
||||||
function _putimages()
|
function _putimages()
|
||||||
{
|
{
|
||||||
$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
|
foreach(array_keys($this->images) as $file)
|
||||||
reset($this->images);
|
{
|
||||||
while(list($file,$info)=each($this->images))
|
$this->_putimage($this->images[$file]);
|
||||||
|
unset($this->images[$file]['data']);
|
||||||
|
unset($this->images[$file]['smask']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function _putimage(&$info)
|
||||||
{
|
{
|
||||||
$this->_newobj();
|
$this->_newobj();
|
||||||
$this->images[$file]['n']=$this->n;
|
$info['n'] = $this->n;
|
||||||
$this->_out('<</Type /XObject');
|
$this->_out('<</Type /XObject');
|
||||||
$this->_out('/Subtype /Image');
|
$this->_out('/Subtype /Image');
|
||||||
$this->_out('/Width '.$info['w']);
|
$this->_out('/Width '.$info['w']);
|
||||||
|
@ -1581,8 +1645,8 @@ function _putimages()
|
||||||
$this->_out('/BitsPerComponent '.$info['bpc']);
|
$this->_out('/BitsPerComponent '.$info['bpc']);
|
||||||
if(isset($info['f']))
|
if(isset($info['f']))
|
||||||
$this->_out('/Filter /'.$info['f']);
|
$this->_out('/Filter /'.$info['f']);
|
||||||
if(isset($info['parms']))
|
if(isset($info['dp']))
|
||||||
$this->_out($info['parms']);
|
$this->_out('/DecodeParms <<'.$info['dp'].'>>');
|
||||||
if(isset($info['trns']) && is_array($info['trns']))
|
if(isset($info['trns']) && is_array($info['trns']))
|
||||||
{
|
{
|
||||||
$trns = '';
|
$trns = '';
|
||||||
|
@ -1590,21 +1654,29 @@ function _putimages()
|
||||||
$trns .= $info['trns'][$i].' '.$info['trns'][$i].' ';
|
$trns .= $info['trns'][$i].' '.$info['trns'][$i].' ';
|
||||||
$this->_out('/Mask ['.$trns.']');
|
$this->_out('/Mask ['.$trns.']');
|
||||||
}
|
}
|
||||||
|
if(isset($info['smask']))
|
||||||
|
$this->_out('/SMask '.($this->n+1).' 0 R');
|
||||||
$this->_out('/Length '.strlen($info['data']).'>>');
|
$this->_out('/Length '.strlen($info['data']).'>>');
|
||||||
$this->_putstream($info['data']);
|
$this->_putstream($info['data']);
|
||||||
unset($this->images[$file]['data']);
|
|
||||||
$this->_out('endobj');
|
$this->_out('endobj');
|
||||||
|
// Soft mask
|
||||||
|
if(isset($info['smask']))
|
||||||
|
{
|
||||||
|
$dp = '/Predictor 15 /Colors 1 /BitsPerComponent 8 /Columns '.$info['w'];
|
||||||
|
$smask = array('w'=>$info['w'], 'h'=>$info['h'], 'cs'=>'DeviceGray', 'bpc'=>8, 'f'=>$info['f'], 'dp'=>$dp, 'data'=>$info['smask']);
|
||||||
|
$this->_putimage($smask);
|
||||||
|
}
|
||||||
// Palette
|
// Palette
|
||||||
if($info['cs']=='Indexed')
|
if($info['cs']=='Indexed')
|
||||||
{
|
{
|
||||||
$this->_newobj();
|
$filter = ($this->compress) ? '/Filter /FlateDecode ' : '';
|
||||||
$pal = ($this->compress) ? gzcompress($info['pal']) : $info['pal'];
|
$pal = ($this->compress) ? gzcompress($info['pal']) : $info['pal'];
|
||||||
|
$this->_newobj();
|
||||||
$this->_out('<<'.$filter.'/Length '.strlen($pal).'>>');
|
$this->_out('<<'.$filter.'/Length '.strlen($pal).'>>');
|
||||||
$this->_putstream($pal);
|
$this->_putstream($pal);
|
||||||
$this->_out('endobj');
|
$this->_out('endobj');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function _putxobjectdict()
|
function _putxobjectdict()
|
||||||
{
|
{
|
||||||
|
@ -1664,7 +1736,7 @@ function _putcatalog()
|
||||||
elseif($this->ZoomMode=='real')
|
elseif($this->ZoomMode=='real')
|
||||||
$this->_out('/OpenAction [3 0 R /XYZ null null 1]');
|
$this->_out('/OpenAction [3 0 R /XYZ null null 1]');
|
||||||
elseif(!is_string($this->ZoomMode))
|
elseif(!is_string($this->ZoomMode))
|
||||||
$this->_out('/OpenAction [3 0 R /XYZ null null '.($this->ZoomMode/100).']');
|
$this->_out('/OpenAction [3 0 R /XYZ null null '.sprintf('%.2F',$this->ZoomMode/100).']');
|
||||||
if($this->LayoutMode=='single')
|
if($this->LayoutMode=='single')
|
||||||
$this->_out('/PageLayout /SinglePage');
|
$this->_out('/PageLayout /SinglePage');
|
||||||
elseif($this->LayoutMode=='continuous')
|
elseif($this->LayoutMode=='continuous')
|
||||||
|
|
|
@ -54,7 +54,7 @@ $line_width = LAMPDF_LINEWIDTH;
|
||||||
function createModulePDF($accounts,$pdf_structure="default") {
|
function createModulePDF($accounts,$pdf_structure="default") {
|
||||||
|
|
||||||
/** PDF generator class */
|
/** PDF generator class */
|
||||||
include_once(dirname(__FILE__) . "/fpdf.php");
|
include_once("fpdf.php");
|
||||||
/** Unicode support for FPDF */
|
/** Unicode support for FPDF */
|
||||||
include_once("ufpdf.php");
|
include_once("ufpdf.php");
|
||||||
/** LAM PDF generator class */
|
/** LAM PDF generator class */
|
||||||
|
|
|
@ -128,7 +128,7 @@ function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='J',$fill=0,$link='')
|
||||||
$this->ws=0;
|
$this->ws=0;
|
||||||
$this->_out('0 Tw');
|
$this->_out('0 Tw');
|
||||||
}
|
}
|
||||||
$this->AddPage($this->CurOrientation, $this->CurPageFormat);
|
$this->AddPage($this->CurOrientation, $this->CurPageSize);
|
||||||
$this->x=$x;
|
$this->x=$x;
|
||||||
if($ws>0)
|
if($ws>0)
|
||||||
{
|
{
|
||||||
|
@ -530,13 +530,13 @@ function _putpages()
|
||||||
}
|
}
|
||||||
if($this->DefOrientation=='P')
|
if($this->DefOrientation=='P')
|
||||||
{
|
{
|
||||||
$wPt=$this->DefPageFormat[0]*$this->k;
|
$wPt=$this->DefPageSize[0]*$this->k;
|
||||||
$hPt=$this->DefPageFormat[1]*$this->k;
|
$hPt=$this->DefPageSize[1]*$this->k;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$wPt=$this->DefPageFormat[1]*$this->k;
|
$wPt=$this->DefPageSize[1]*$this->k;
|
||||||
$hPt=$this->DefPageFormat[0]*$this->k;
|
$hPt=$this->DefPageSize[0]*$this->k;
|
||||||
}
|
}
|
||||||
$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
|
$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
|
||||||
for($n=1;$n<=$nb;$n++)
|
for($n=1;$n<=$nb;$n++)
|
||||||
|
|
Loading…
Reference in New Issue