Fix: modification du chemin
This commit is contained in:
parent
41fb66b438
commit
3444ec3239
@ -1,446 +1,446 @@
|
|||||||
<?php
|
<?php
|
||||||
//
|
//
|
||||||
// fpdf_tpl - Version 1.0.2
|
// fpdf_tpl - Version 1.0.2
|
||||||
//
|
//
|
||||||
// Copyright 2004,2005 Setasign - Jan Slabon
|
// Copyright 2004,2005 Setasign - Jan Slabon
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
//
|
//
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
//
|
//
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
|
||||||
require_once("fpdf.php");
|
require_once(FPDF_PATH.'fpdf.php');
|
||||||
|
|
||||||
class fpdf_tpl extends fpdf {
|
class fpdf_tpl extends fpdf {
|
||||||
/**
|
/**
|
||||||
* Array of Tpl-Data
|
* Array of Tpl-Data
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $tpls = array();
|
var $tpls = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Current Template-ID
|
* Current Template-ID
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
var $tpl = 0;
|
var $tpl = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "In Template"-Flag
|
* "In Template"-Flag
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
var $intpl = false;
|
var $intpl = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Nameprefix of Templates used in Resources-Dictonary
|
* Nameprefix of Templates used in Resources-Dictonary
|
||||||
* @var string A String defining the Prefix used as Template-Object-Names. Have to beginn with an /
|
* @var string A String defining the Prefix used as Template-Object-Names. Have to beginn with an /
|
||||||
*/
|
*/
|
||||||
var $tplprefix = "/TPL";
|
var $tplprefix = "/TPL";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Nameprefix of Fonts used in Resources-Dictonary
|
* Nameprefix of Fonts used in Resources-Dictonary
|
||||||
* (not realy needed, but for future versions with import-function needed)
|
* (not realy needed, but for future versions with import-function needed)
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $fontprefix = "/F";
|
var $fontprefix = "/F";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resources used By Templates and Pages
|
* Resources used By Templates and Pages
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $res = array();
|
var $res = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* See FPDF-Documentation
|
* See FPDF-Documentation
|
||||||
* @param string $orientation
|
* @param string $orientation
|
||||||
* @param string $unit
|
* @param string $unit
|
||||||
* @param mixed $format
|
* @param mixed $format
|
||||||
*/
|
*/
|
||||||
function fpdf_tpl($orientation='P',$unit='mm',$format='A4') {
|
function fpdf_tpl($orientation='P',$unit='mm',$format='A4') {
|
||||||
parent::fpdf($orientation,$unit,$format);
|
parent::fpdf($orientation,$unit,$format);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start a Template
|
* Start a Template
|
||||||
*
|
*
|
||||||
* This method starts a template. You can give own coordinates to build an own sized
|
* This method starts a template. You can give own coordinates to build an own sized
|
||||||
* Template. Pay attention, that the margins are adapted to the new templatesize.
|
* Template. Pay attention, that the margins are adapted to the new templatesize.
|
||||||
* If you want to write outside the template, for example to build a clipped Template,
|
* If you want to write outside the template, for example to build a clipped Template,
|
||||||
* you have to set the Margins and "Cursor"-Position manual after beginTemplate-Call.
|
* you have to set the Margins and "Cursor"-Position manual after beginTemplate-Call.
|
||||||
*
|
*
|
||||||
* If no parameter is given, the template uses the current page-size.
|
* If no parameter is given, the template uses the current page-size.
|
||||||
* The Method returns an ID of the current Template. This ID is used later for using this template.
|
* The Method returns an ID of the current Template. This ID is used later for using this template.
|
||||||
* Warning: A created Template is used in PDF at all events. Still if you don't use it after creation!
|
* Warning: A created Template is used in PDF at all events. Still if you don't use it after creation!
|
||||||
*
|
*
|
||||||
* @param int $x The x-coordinate given in user-unit
|
* @param int $x The x-coordinate given in user-unit
|
||||||
* @param int $y The y-coordinate given in user-unit
|
* @param int $y The y-coordinate given in user-unit
|
||||||
* @param int $w The width given in user-unit
|
* @param int $w The width given in user-unit
|
||||||
* @param int $h The height given in user-unit
|
* @param int $h The height given in user-unit
|
||||||
* @return int The ID of new created Template
|
* @return int The ID of new created Template
|
||||||
*/
|
*/
|
||||||
function beginTemplate($x=null,$y=null,$w=null,$h=null) {
|
function beginTemplate($x=null,$y=null,$w=null,$h=null) {
|
||||||
if ($this->page <= 0)
|
if ($this->page <= 0)
|
||||||
$this->error("You have to add a page to fpdf first!");
|
$this->error("You have to add a page to fpdf first!");
|
||||||
|
|
||||||
// Save settings
|
// Save settings
|
||||||
$this->tpl++;
|
$this->tpl++;
|
||||||
$this->tpls[$this->tpl]['o_x'] = $this->x;
|
$this->tpls[$this->tpl]['o_x'] = $this->x;
|
||||||
$this->tpls[$this->tpl]['o_y'] = $this->y;
|
$this->tpls[$this->tpl]['o_y'] = $this->y;
|
||||||
$this->tpls[$this->tpl]['o_AutoPageBreak'] = $this->AutoPageBreak;
|
$this->tpls[$this->tpl]['o_AutoPageBreak'] = $this->AutoPageBreak;
|
||||||
$this->tpls[$this->tpl]['o_bMargin'] = $this->bMargin;
|
$this->tpls[$this->tpl]['o_bMargin'] = $this->bMargin;
|
||||||
$this->tpls[$this->tpl]['o_tMargin'] = $this->tMargin;
|
$this->tpls[$this->tpl]['o_tMargin'] = $this->tMargin;
|
||||||
$this->tpls[$this->tpl]['o_lMargin'] = $this->lMargin;
|
$this->tpls[$this->tpl]['o_lMargin'] = $this->lMargin;
|
||||||
$this->tpls[$this->tpl]['o_rMargin'] = $this->rMargin;
|
$this->tpls[$this->tpl]['o_rMargin'] = $this->rMargin;
|
||||||
$this->tpls[$this->tpl]['o_h'] = $this->h;
|
$this->tpls[$this->tpl]['o_h'] = $this->h;
|
||||||
$this->tpls[$this->tpl]['o_w'] = $this->w;
|
$this->tpls[$this->tpl]['o_w'] = $this->w;
|
||||||
|
|
||||||
$this->SetAutoPageBreak(false);
|
$this->SetAutoPageBreak(false);
|
||||||
|
|
||||||
if ($x == null)
|
if ($x == null)
|
||||||
$x = 0;
|
$x = 0;
|
||||||
if ($y == null)
|
if ($y == null)
|
||||||
$y = 0;
|
$y = 0;
|
||||||
if ($w == null)
|
if ($w == null)
|
||||||
$w = $this->w;
|
$w = $this->w;
|
||||||
if ($h == null)
|
if ($h == null)
|
||||||
$h = $this->h;
|
$h = $this->h;
|
||||||
|
|
||||||
// Define own high and width to calculate possitions correct
|
// Define own high and width to calculate possitions correct
|
||||||
$this->h = $h;
|
$this->h = $h;
|
||||||
$this->w = $w;
|
$this->w = $w;
|
||||||
|
|
||||||
$this->tpls[$this->tpl]['buffer'] = "";
|
$this->tpls[$this->tpl]['buffer'] = "";
|
||||||
$this->tpls[$this->tpl]['x'] = $x;
|
$this->tpls[$this->tpl]['x'] = $x;
|
||||||
$this->tpls[$this->tpl]['y'] = $y;
|
$this->tpls[$this->tpl]['y'] = $y;
|
||||||
$this->tpls[$this->tpl]['w'] = $w;
|
$this->tpls[$this->tpl]['w'] = $w;
|
||||||
$this->tpls[$this->tpl]['h'] = $h;
|
$this->tpls[$this->tpl]['h'] = $h;
|
||||||
|
|
||||||
$this->intpl = true;
|
$this->intpl = true;
|
||||||
$this->SetXY($x+$this->lMargin,$y+$this->tMargin);
|
$this->SetXY($x+$this->lMargin,$y+$this->tMargin);
|
||||||
$this->SetRightMargin($this->w-$w+$this->rMargin);
|
$this->SetRightMargin($this->w-$w+$this->rMargin);
|
||||||
|
|
||||||
return $this->tpl;
|
return $this->tpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* End Template
|
* End Template
|
||||||
*
|
*
|
||||||
* This method ends a template and reset initiated variables on beginTemplate.
|
* This method ends a template and reset initiated variables on beginTemplate.
|
||||||
*
|
*
|
||||||
* @return mixed If a template is opened, the ID is returned. If not a false is returned.
|
* @return mixed If a template is opened, the ID is returned. If not a false is returned.
|
||||||
*/
|
*/
|
||||||
function endTemplate() {
|
function endTemplate() {
|
||||||
if ($this->intpl) {
|
if ($this->intpl) {
|
||||||
$this->intpl = false;
|
$this->intpl = false;
|
||||||
$this->SetAutoPageBreak($this->tpls[$this->tpl]['o_AutoPageBreak'],$this->tpls[$this->tpl]['o_bMargin']);
|
$this->SetAutoPageBreak($this->tpls[$this->tpl]['o_AutoPageBreak'],$this->tpls[$this->tpl]['o_bMargin']);
|
||||||
$this->SetXY($this->tpls[$this->tpl]['o_x'],$this->tpls[$this->tpl]['o_y']);
|
$this->SetXY($this->tpls[$this->tpl]['o_x'],$this->tpls[$this->tpl]['o_y']);
|
||||||
$this->tMargin = $this->tpls[$this->tpl]['o_tMargin'];
|
$this->tMargin = $this->tpls[$this->tpl]['o_tMargin'];
|
||||||
$this->lMargin = $this->tpls[$this->tpl]['o_lMargin'];
|
$this->lMargin = $this->tpls[$this->tpl]['o_lMargin'];
|
||||||
$this->rMargin = $this->tpls[$this->tpl]['o_rMargin'];
|
$this->rMargin = $this->tpls[$this->tpl]['o_rMargin'];
|
||||||
$this->h = $this->tpls[$this->tpl]['o_h'];
|
$this->h = $this->tpls[$this->tpl]['o_h'];
|
||||||
$this->w = $this->tpls[$this->tpl]['o_w'];
|
$this->w = $this->tpls[$this->tpl]['o_w'];
|
||||||
return $this->tpl;
|
return $this->tpl;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use a Template in current Page or other Template
|
* Use a Template in current Page or other Template
|
||||||
*
|
*
|
||||||
* You can use a template in a page or in another template.
|
* You can use a template in a page or in another template.
|
||||||
* You can give the used template a new size like you use the Image()-method.
|
* You can give the used template a new size like you use the Image()-method.
|
||||||
* All parameters are optional. The width or height is calculated automaticaly
|
* All parameters are optional. The width or height is calculated automaticaly
|
||||||
* if one is given. If no parameter is given the origin size as defined in
|
* if one is given. If no parameter is given the origin size as defined in
|
||||||
* beginTemplate() is used.
|
* beginTemplate() is used.
|
||||||
* The calculated or used width and height are returned as an array.
|
* The calculated or used width and height are returned as an array.
|
||||||
*
|
*
|
||||||
* @param int $tplidx A valid template-Id
|
* @param int $tplidx A valid template-Id
|
||||||
* @param int $_x The x-position
|
* @param int $_x The x-position
|
||||||
* @param int $_y The y-position
|
* @param int $_y The y-position
|
||||||
* @param int $_w The new width of the template
|
* @param int $_w The new width of the template
|
||||||
* @param int $_h The new height of the template
|
* @param int $_h The new height of the template
|
||||||
* @retrun array The height and width of the template
|
* @retrun array The height and width of the template
|
||||||
*/
|
*/
|
||||||
function useTemplate($tplidx, $_x=null, $_y=null, $_w=0, $_h=0) {
|
function useTemplate($tplidx, $_x=null, $_y=null, $_w=0, $_h=0) {
|
||||||
if ($this->page <= 0)
|
if ($this->page <= 0)
|
||||||
$this->error("You have to add a page to fpdf first!");
|
$this->error("You have to add a page to fpdf first!");
|
||||||
|
|
||||||
if (!$this->tpls[$tplidx])
|
if (!$this->tpls[$tplidx])
|
||||||
$this->error("Template does not exist!");
|
$this->error("Template does not exist!");
|
||||||
|
|
||||||
if ($this->intpl) {
|
if ($this->intpl) {
|
||||||
$this->res['tpl'][$this->tpl]['tpls'][$tplidx] =& $this->tpls[$tplidx];
|
$this->res['tpl'][$this->tpl]['tpls'][$tplidx] =& $this->tpls[$tplidx];
|
||||||
}
|
}
|
||||||
extract($this->tpls[$tplidx]);
|
extract($this->tpls[$tplidx]);
|
||||||
|
|
||||||
if ($_x == null)
|
if ($_x == null)
|
||||||
$_x = $x;
|
$_x = $x;
|
||||||
if ($_y == null)
|
if ($_y == null)
|
||||||
$_y = $y;
|
$_y = $y;
|
||||||
$wh = $this->getTemplateSize($tplidx,$_w,$_h);
|
$wh = $this->getTemplateSize($tplidx,$_w,$_h);
|
||||||
$_w = $wh['w'];
|
$_w = $wh['w'];
|
||||||
$_h = $wh['h'];
|
$_h = $wh['h'];
|
||||||
|
|
||||||
$this->_out(sprintf("q %.4f 0 0 %.4f %.2f %.2f cm", ($_w/$w), ($_h/$h), $_x*$this->k, ($this->h-($_y+$_h))*$this->k)); // Translate
|
$this->_out(sprintf("q %.4f 0 0 %.4f %.2f %.2f cm", ($_w/$w), ($_h/$h), $_x*$this->k, ($this->h-($_y+$_h))*$this->k)); // Translate
|
||||||
$this->_out($this->tplprefix.$tplidx." Do Q");
|
$this->_out($this->tplprefix.$tplidx." Do Q");
|
||||||
|
|
||||||
return array("w" => $_w, "h" => $_h);
|
return array("w" => $_w, "h" => $_h);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get The calculated Size of a Template
|
* Get The calculated Size of a Template
|
||||||
*
|
*
|
||||||
* If one size is given, this method calculates the other one.
|
* If one size is given, this method calculates the other one.
|
||||||
*
|
*
|
||||||
* @param int $tplidx A valid template-Id
|
* @param int $tplidx A valid template-Id
|
||||||
* @param int $_w The width of the template
|
* @param int $_w The width of the template
|
||||||
* @param int $_h The height of the template
|
* @param int $_h The height of the template
|
||||||
* @return array The height and width of the template
|
* @return array The height and width of the template
|
||||||
*/
|
*/
|
||||||
function getTemplateSize($tplidx, $_w=0, $_h=0) {
|
function getTemplateSize($tplidx, $_w=0, $_h=0) {
|
||||||
if (!$this->tpls[$tplidx])
|
if (!$this->tpls[$tplidx])
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
extract($this->tpls[$tplidx]);
|
extract($this->tpls[$tplidx]);
|
||||||
if ($_w == 0 and $_h == 0) {
|
if ($_w == 0 and $_h == 0) {
|
||||||
$_w = $w;
|
$_w = $w;
|
||||||
$_h = $h;
|
$_h = $h;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_w==0)
|
if($_w==0)
|
||||||
$_w=$_h*$w/$h;
|
$_w=$_h*$w/$h;
|
||||||
if($_h==0)
|
if($_h==0)
|
||||||
$_h=$_w*$h/$w;
|
$_h=$_w*$h/$w;
|
||||||
|
|
||||||
return array("w" => $_w, "h" => $_h);
|
return array("w" => $_w, "h" => $_h);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See FPDF-Documentation ;-)
|
* See FPDF-Documentation ;-)
|
||||||
*/
|
*/
|
||||||
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;
|
global $fpdf_charwidths;
|
||||||
|
|
||||||
$family=strtolower($family);
|
$family=strtolower($family);
|
||||||
if($family=='')
|
if($family=='')
|
||||||
$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' or $family=='zapfdingbats')
|
||||||
$style='';
|
$style='';
|
||||||
$style=strtoupper($style);
|
$style=strtoupper($style);
|
||||||
if(is_int(strpos($style,'U')))
|
if(is_int(strpos($style,'U')))
|
||||||
{
|
{
|
||||||
$this->underline=true;
|
$this->underline=true;
|
||||||
$style=str_replace('U','',$style);
|
$style=str_replace('U','',$style);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$this->underline=false;
|
$this->underline=false;
|
||||||
if($style=='IB')
|
if($style=='IB')
|
||||||
$style='BI';
|
$style='BI';
|
||||||
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 and !$this->intpl)
|
if($this->FontFamily==$family and $this->FontStyle==$style and $this->FontSizePt==$size and !$this->intpl)
|
||||||
return;
|
return;
|
||||||
//Test if used for the first time
|
//Test if used for the first time
|
||||||
$fontkey=$family.$style;
|
$fontkey=$family.$style;
|
||||||
if(!isset($this->fonts[$fontkey]))
|
if(!isset($this->fonts[$fontkey]))
|
||||||
{
|
{
|
||||||
//Check if one of the standard fonts
|
//Check if one of the standard fonts
|
||||||
if(isset($this->CoreFonts[$fontkey]))
|
if(isset($this->CoreFonts[$fontkey]))
|
||||||
{
|
{
|
||||||
if(!isset($fpdf_charwidths[$fontkey]))
|
if(!isset($fpdf_charwidths[$fontkey]))
|
||||||
{
|
{
|
||||||
//Load metric file
|
//Load metric file
|
||||||
$file=$family;
|
$file=$family;
|
||||||
if($family=='times' or $family=='helvetica')
|
if($family=='times' or $family=='helvetica')
|
||||||
$file.=strtolower($style);
|
$file.=strtolower($style);
|
||||||
$file.='.php';
|
$file.='.php';
|
||||||
if(defined('FPDF_FONTPATH'))
|
if(defined('FPDF_FONTPATH'))
|
||||||
$file=FPDF_FONTPATH.$file;
|
$file=FPDF_FONTPATH.$file;
|
||||||
include($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');
|
||||||
}
|
}
|
||||||
$i = $this->findNextAvailFont();
|
$i = $this->findNextAvailFont();
|
||||||
$this->fonts[$fontkey]=array('i'=>$i,'type'=>'core','name'=>$this->CoreFonts[$fontkey],'up'=>-100,'ut'=>50,'cw'=>$fpdf_charwidths[$fontkey]);
|
$this->fonts[$fontkey]=array('i'=>$i,'type'=>'core','name'=>$this->CoreFonts[$fontkey],'up'=>-100,'ut'=>50,'cw'=>$fpdf_charwidths[$fontkey]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$this->Error('Undefined font: '.$family.' '.$style);
|
$this->Error('Undefined font: '.$family.' '.$style);
|
||||||
}
|
}
|
||||||
//Select it
|
//Select it
|
||||||
$this->FontFamily=$family;
|
$this->FontFamily=$family;
|
||||||
$this->FontStyle=$style;
|
$this->FontStyle=$style;
|
||||||
$this->FontSizePt=$size;
|
$this->FontSizePt=$size;
|
||||||
$this->FontSize=$size/$this->k;
|
$this->FontSize=$size/$this->k;
|
||||||
$this->CurrentFont=&$this->fonts[$fontkey];
|
$this->CurrentFont=&$this->fonts[$fontkey];
|
||||||
if($this->page>0)
|
if($this->page>0)
|
||||||
$this->_out(sprintf('BT '.$this->fontprefix.'%d %.2f Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
|
$this->_out(sprintf('BT '.$this->fontprefix.'%d %.2f Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
|
||||||
|
|
||||||
|
|
||||||
if ($this->intpl) {
|
if ($this->intpl) {
|
||||||
$this->res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey];
|
$this->res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey];
|
||||||
} else {
|
} else {
|
||||||
$this->res['page'][$this->page]['fonts'][$fontkey] =& $this->fonts[$fontkey];
|
$this->res['page'][$this->page]['fonts'][$fontkey] =& $this->fonts[$fontkey];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find the next available Font-No.
|
* Find the next available Font-No.
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
function findNextAvailFont() {
|
function findNextAvailFont() {
|
||||||
return count($this->fonts)+1;
|
return count($this->fonts)+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See FPDF-Documentation ;-)
|
* See FPDF-Documentation ;-)
|
||||||
*/
|
*/
|
||||||
function Image($file,$x,$y,$w=0,$h=0,$type='',$link='') {
|
function Image($file,$x,$y,$w=0,$h=0,$type='',$link='') {
|
||||||
parent::Image($file,$x,$y,$w,$h,$type,$link);
|
parent::Image($file,$x,$y,$w,$h,$type,$link);
|
||||||
if ($this->intpl) {
|
if ($this->intpl) {
|
||||||
$this->res['tpl'][$this->tpl]['images'][$file] =& $this->images[$file];
|
$this->res['tpl'][$this->tpl]['images'][$file] =& $this->images[$file];
|
||||||
} else {
|
} else {
|
||||||
$this->res['page'][$this->page]['images'][$file] =& $this->images[$file];
|
$this->res['page'][$this->page]['images'][$file] =& $this->images[$file];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See FPDF-Documentation ;-)
|
* See FPDF-Documentation ;-)
|
||||||
*
|
*
|
||||||
* AddPage is not available when you're "in" a template.
|
* AddPage is not available when you're "in" a template.
|
||||||
*/
|
*/
|
||||||
function AddPage($orientation='') {
|
function AddPage($orientation='') {
|
||||||
if ($this->intpl)
|
if ($this->intpl)
|
||||||
$this->Error('Adding pages in templates isn\'t possible!');
|
$this->Error('Adding pages in templates isn\'t possible!');
|
||||||
parent::AddPage($orientation);
|
parent::AddPage($orientation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Preserve adding Links in Templates ...won't work
|
* Preserve adding Links in Templates ...won't work
|
||||||
*/
|
*/
|
||||||
function Link($x,$y,$w,$h,$link) {
|
function Link($x,$y,$w,$h,$link) {
|
||||||
if ($this->intpl)
|
if ($this->intpl)
|
||||||
$this->Error('Using links in templates aren\'t possible!');
|
$this->Error('Using links in templates aren\'t possible!');
|
||||||
parent::Link($x,$y,$w,$h,$link);
|
parent::Link($x,$y,$w,$h,$link);
|
||||||
}
|
}
|
||||||
|
|
||||||
function AddLink() {
|
function AddLink() {
|
||||||
if ($this->intpl)
|
if ($this->intpl)
|
||||||
$this->Error('Adding links in templates aren\'t possible!');
|
$this->Error('Adding links in templates aren\'t possible!');
|
||||||
return parent::AddLink();
|
return parent::AddLink();
|
||||||
}
|
}
|
||||||
|
|
||||||
function SetLink($link,$y=0,$page=-1) {
|
function SetLink($link,$y=0,$page=-1) {
|
||||||
if ($this->intpl)
|
if ($this->intpl)
|
||||||
$this->Error('Setting links in templates aren\'t possible!');
|
$this->Error('Setting links in templates aren\'t possible!');
|
||||||
parent::SetLink($link,$y,$page);
|
parent::SetLink($link,$y,$page);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private Method that writes the Resources-Objects
|
* Private Method that writes the Resources-Objects
|
||||||
*/
|
*/
|
||||||
function _puttemplates() {
|
function _puttemplates() {
|
||||||
$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
|
$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
|
||||||
reset($this->tpls);
|
reset($this->tpls);
|
||||||
foreach($this->tpls AS $tplidx => $tpl) {
|
foreach($this->tpls AS $tplidx => $tpl) {
|
||||||
|
|
||||||
$p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer'];
|
$p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer'];
|
||||||
$this->_newobj();
|
$this->_newobj();
|
||||||
$this->tpls[$tplidx]['n'] = $this->n;
|
$this->tpls[$tplidx]['n'] = $this->n;
|
||||||
$this->_out('<<'.$filter.'/Type /XObject');
|
$this->_out('<<'.$filter.'/Type /XObject');
|
||||||
$this->_out('/Subtype /Form');
|
$this->_out('/Subtype /Form');
|
||||||
$this->_out('/FormType 1');
|
$this->_out('/FormType 1');
|
||||||
$this->_out(sprintf('/BBox [%.2f %.2f %.2f %.2f]',$tpl['x']*$this->k, ($tpl['h']-$tpl['y'])*$this->k, $tpl['w']*$this->k, ($tpl['h']-$tpl['y']-$tpl['h'])*$this->k)); // ($this->h-$tpl['y'])*$this->k
|
$this->_out(sprintf('/BBox [%.2f %.2f %.2f %.2f]',$tpl['x']*$this->k, ($tpl['h']-$tpl['y'])*$this->k, $tpl['w']*$this->k, ($tpl['h']-$tpl['y']-$tpl['h'])*$this->k)); // ($this->h-$tpl['y'])*$this->k
|
||||||
$this->_out('/Resources ');
|
$this->_out('/Resources ');
|
||||||
|
|
||||||
$this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
|
$this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
|
||||||
if (count($this->res['tpl'][$tplidx]['fonts'])) {
|
if (count($this->res['tpl'][$tplidx]['fonts'])) {
|
||||||
$this->_out('/Font <<');
|
$this->_out('/Font <<');
|
||||||
foreach($this->res['tpl'][$tplidx]['fonts'] as $font)
|
foreach($this->res['tpl'][$tplidx]['fonts'] as $font)
|
||||||
$this->_out($this->fontprefix.$font['i'].' '.$font['n'].' 0 R');
|
$this->_out($this->fontprefix.$font['i'].' '.$font['n'].' 0 R');
|
||||||
$this->_out('>>');
|
$this->_out('>>');
|
||||||
}
|
}
|
||||||
if(count($this->res['tpl'][$tplidx]['images']) || count($this->res['tpl'][$tplidx]['tpls']))
|
if(count($this->res['tpl'][$tplidx]['images']) || count($this->res['tpl'][$tplidx]['tpls']))
|
||||||
{
|
{
|
||||||
$this->_out('/XObject <<');
|
$this->_out('/XObject <<');
|
||||||
if (count($this->res['tpl'][$tplidx]['images'])) {
|
if (count($this->res['tpl'][$tplidx]['images'])) {
|
||||||
foreach($this->res['tpl'][$tplidx]['images'] as $image)
|
foreach($this->res['tpl'][$tplidx]['images'] as $image)
|
||||||
$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
|
$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
|
||||||
}
|
}
|
||||||
if (count($this->res['tpl'][$tplidx]['tpls'])) {
|
if (count($this->res['tpl'][$tplidx]['tpls'])) {
|
||||||
foreach($this->res['tpl'][$tplidx]['tpls'] as $i => $tpl)
|
foreach($this->res['tpl'][$tplidx]['tpls'] as $i => $tpl)
|
||||||
$this->_out($this->tplprefix.$i.' '.$tpl['n'].' 0 R');
|
$this->_out($this->tplprefix.$i.' '.$tpl['n'].' 0 R');
|
||||||
}
|
}
|
||||||
$this->_out('>>');
|
$this->_out('>>');
|
||||||
}
|
}
|
||||||
$this->_out('>>');
|
$this->_out('>>');
|
||||||
|
|
||||||
$this->_out('/Length '.strlen($p).' >>');
|
$this->_out('/Length '.strlen($p).' >>');
|
||||||
$this->_putstream($p);
|
$this->_putstream($p);
|
||||||
$this->_out('endobj');
|
$this->_out('endobj');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private Method
|
* Private Method
|
||||||
*/
|
*/
|
||||||
function _putresources() {
|
function _putresources() {
|
||||||
$this->_putfonts();
|
$this->_putfonts();
|
||||||
$this->_putimages();
|
$this->_putimages();
|
||||||
$this->_puttemplates();
|
$this->_puttemplates();
|
||||||
//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('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
|
||||||
$this->_out('/Font <<');
|
$this->_out('/Font <<');
|
||||||
foreach($this->fonts as $font)
|
foreach($this->fonts as $font)
|
||||||
$this->_out($this->fontprefix.$font['i'].' '.$font['n'].' 0 R');
|
$this->_out($this->fontprefix.$font['i'].' '.$font['n'].' 0 R');
|
||||||
$this->_out('>>');
|
$this->_out('>>');
|
||||||
if(count($this->images) || count($this->tpls))
|
if(count($this->images) || count($this->tpls))
|
||||||
{
|
{
|
||||||
$this->_out('/XObject <<');
|
$this->_out('/XObject <<');
|
||||||
if (count($this->images)) {
|
if (count($this->images)) {
|
||||||
foreach($this->images as $image)
|
foreach($this->images as $image)
|
||||||
$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
|
$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
|
||||||
}
|
}
|
||||||
if (count($this->tpls)) {
|
if (count($this->tpls)) {
|
||||||
foreach($this->tpls as $tplidx => $tpl)
|
foreach($this->tpls as $tplidx => $tpl)
|
||||||
$this->_out($this->tplprefix.$tplidx.' '.$tpl['n'].' 0 R');
|
$this->_out($this->tplprefix.$tplidx.' '.$tpl['n'].' 0 R');
|
||||||
}
|
}
|
||||||
$this->_out('>>');
|
$this->_out('>>');
|
||||||
}
|
}
|
||||||
$this->_out('>>');
|
$this->_out('>>');
|
||||||
$this->_out('endobj');
|
$this->_out('endobj');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private Method
|
* Private Method
|
||||||
*/
|
*/
|
||||||
function _out($s) {
|
function _out($s) {
|
||||||
//Add a line to the document
|
//Add a line to the document
|
||||||
if ($this->state==2) {
|
if ($this->state==2) {
|
||||||
if (!$this->intpl)
|
if (!$this->intpl)
|
||||||
$this->pages[$this->page].=$s."\n";
|
$this->pages[$this->page].=$s."\n";
|
||||||
else
|
else
|
||||||
$this->tpls[$this->tpl]['buffer'] .= $s."\n";
|
$this->tpls[$this->tpl]['buffer'] .= $s."\n";
|
||||||
} else {
|
} else {
|
||||||
$this->buffer.=$s."\n";
|
$this->buffer.=$s."\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@ -1,413 +1,413 @@
|
|||||||
<?php
|
<?php
|
||||||
//
|
//
|
||||||
// FPDI - Version 1.1
|
// FPDI - Version 1.1
|
||||||
//
|
//
|
||||||
// Copyright 2004,2005 Setasign - Jan Slabon
|
// Copyright 2004,2005 Setasign - Jan Slabon
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
//
|
//
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
//
|
//
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
|
||||||
define ('PDF_TYPE_NULL', 0);
|
define ('PDF_TYPE_NULL', 0);
|
||||||
define ('PDF_TYPE_NUMERIC', 1);
|
define ('PDF_TYPE_NUMERIC', 1);
|
||||||
define ('PDF_TYPE_TOKEN', 2);
|
define ('PDF_TYPE_TOKEN', 2);
|
||||||
define ('PDF_TYPE_HEX', 3);
|
define ('PDF_TYPE_HEX', 3);
|
||||||
define ('PDF_TYPE_STRING', 4);
|
define ('PDF_TYPE_STRING', 4);
|
||||||
define ('PDF_TYPE_DICTIONARY', 5);
|
define ('PDF_TYPE_DICTIONARY', 5);
|
||||||
define ('PDF_TYPE_ARRAY', 6);
|
define ('PDF_TYPE_ARRAY', 6);
|
||||||
define ('PDF_TYPE_OBJDEC', 7);
|
define ('PDF_TYPE_OBJDEC', 7);
|
||||||
define ('PDF_TYPE_OBJREF', 8);
|
define ('PDF_TYPE_OBJREF', 8);
|
||||||
define ('PDF_TYPE_OBJECT', 9);
|
define ('PDF_TYPE_OBJECT', 9);
|
||||||
define ('PDF_TYPE_STREAM', 10);
|
define ('PDF_TYPE_STREAM', 10);
|
||||||
|
|
||||||
ini_set('auto_detect_line_endings',1); // Strongly required!
|
ini_set('auto_detect_line_endings',1); // Strongly required!
|
||||||
|
|
||||||
require_once("fpdf_tpl.php");
|
require_once(FPDF_PATH.'fpdf_tpl.php');
|
||||||
require_once("fpdi_pdf_parser.php");
|
require_once(FPDF_PATH.'fpdi_pdf_parser.php');
|
||||||
|
|
||||||
|
|
||||||
class fpdi extends fpdf_tpl {
|
class fpdi extends fpdf_tpl {
|
||||||
/**
|
/**
|
||||||
* Actual filename
|
* Actual filename
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $current_filename;
|
var $current_filename;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parser-Objects
|
* Parser-Objects
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $parsers;
|
var $parsers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Current parser
|
* Current parser
|
||||||
* @var object
|
* @var object
|
||||||
*/
|
*/
|
||||||
var $current_parser;
|
var $current_parser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FPDF/FPDI - PDF-Version
|
* FPDF/FPDI - PDF-Version
|
||||||
* @var double
|
* @var double
|
||||||
*/
|
*/
|
||||||
var $PDFVersion = 1.3;
|
var $PDFVersion = 1.3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Highest version of imported PDF
|
* Highest version of imported PDF
|
||||||
* @var double
|
* @var double
|
||||||
*/
|
*/
|
||||||
var $importVersion = 1.3;
|
var $importVersion = 1.3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* object stack
|
* object stack
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $obj_stack;
|
var $obj_stack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* done object stack
|
* done object stack
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $don_obj_stack;
|
var $don_obj_stack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Current Object Id.
|
* Current Object Id.
|
||||||
* @var integer
|
* @var integer
|
||||||
*/
|
*/
|
||||||
var $current_obj_id;
|
var $current_obj_id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* See FPDF-Manual
|
* See FPDF-Manual
|
||||||
*/
|
*/
|
||||||
function fpdi($orientation='P',$unit='mm',$format='A4') {
|
function fpdi($orientation='P',$unit='mm',$format='A4') {
|
||||||
parent::fpdf_tpl($orientation,$unit,$format);
|
parent::fpdf_tpl($orientation,$unit,$format);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a source-file
|
* Set a source-file
|
||||||
*
|
*
|
||||||
* @param string $filename a valid filename
|
* @param string $filename a valid filename
|
||||||
* @return int number of available pages
|
* @return int number of available pages
|
||||||
*/
|
*/
|
||||||
function setSourceFile($filename) {
|
function setSourceFile($filename) {
|
||||||
$this->current_filename = $filename;
|
$this->current_filename = $filename;
|
||||||
$fn =& $this->current_filename;
|
$fn =& $this->current_filename;
|
||||||
|
|
||||||
$this->parsers[$fn] = new fpdi_pdf_parser($fn,$this);
|
$this->parsers[$fn] = new fpdi_pdf_parser($fn,$this);
|
||||||
$this->current_parser =& $this->parsers[$fn];
|
$this->current_parser =& $this->parsers[$fn];
|
||||||
|
|
||||||
return $this->parsers[$fn]->getPageCount();
|
return $this->parsers[$fn]->getPageCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import a page
|
* Import a page
|
||||||
*
|
*
|
||||||
* @param int $pageno pagenumber
|
* @param int $pageno pagenumber
|
||||||
* @return int Index of imported page - to use with fpdf_tpl::useTemplate()
|
* @return int Index of imported page - to use with fpdf_tpl::useTemplate()
|
||||||
*/
|
*/
|
||||||
function ImportPage($pageno) {
|
function ImportPage($pageno) {
|
||||||
$fn =& $this->current_filename;
|
$fn =& $this->current_filename;
|
||||||
|
|
||||||
$this->parsers[$fn]->setPageno($pageno);
|
$this->parsers[$fn]->setPageno($pageno);
|
||||||
|
|
||||||
$this->tpl++;
|
$this->tpl++;
|
||||||
$this->tpls[$this->tpl] = array();
|
$this->tpls[$this->tpl] = array();
|
||||||
$this->tpls[$this->tpl]['parser'] =& $this->parsers[$fn];
|
$this->tpls[$this->tpl]['parser'] =& $this->parsers[$fn];
|
||||||
$this->tpls[$this->tpl]['resources'] = $this->parsers[$fn]->getPageResources();
|
$this->tpls[$this->tpl]['resources'] = $this->parsers[$fn]->getPageResources();
|
||||||
$this->tpls[$this->tpl]['buffer'] = $this->parsers[$fn]->getContent();
|
$this->tpls[$this->tpl]['buffer'] = $this->parsers[$fn]->getContent();
|
||||||
// $mediabox holds the dimensions of the source page
|
// $mediabox holds the dimensions of the source page
|
||||||
$mediabox = $this->parsers[$fn]->getPageMediaBox($pageno);
|
$mediabox = $this->parsers[$fn]->getPageMediaBox($pageno);
|
||||||
|
|
||||||
// To build array that can used by pdf_tpl::useTemplate()
|
// To build array that can used by pdf_tpl::useTemplate()
|
||||||
$this->tpls[$this->tpl] = array_merge($this->tpls[$this->tpl],$mediabox);
|
$this->tpls[$this->tpl] = array_merge($this->tpls[$this->tpl],$mediabox);
|
||||||
|
|
||||||
return $this->tpl;
|
return $this->tpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private method, that rebuilds all needed objects of source files
|
* Private method, that rebuilds all needed objects of source files
|
||||||
*/
|
*/
|
||||||
function _putOobjects() {
|
function _putOobjects() {
|
||||||
if (is_array($this->parsers) && count($this->parsers) > 0) {
|
if (is_array($this->parsers) && count($this->parsers) > 0) {
|
||||||
foreach($this->parsers AS $filename => $p) {
|
foreach($this->parsers AS $filename => $p) {
|
||||||
$this->current_parser =& $this->parsers[$filename];
|
$this->current_parser =& $this->parsers[$filename];
|
||||||
if (is_array($this->obj_stack[$filename])) {
|
if (is_array($this->obj_stack[$filename])) {
|
||||||
while($n = key($this->obj_stack[$filename])) {
|
while($n = key($this->obj_stack[$filename])) {
|
||||||
$nObj = $this->current_parser->pdf_resolve_object($this->current_parser->c,$this->obj_stack[$filename][$n][1]);
|
$nObj = $this->current_parser->pdf_resolve_object($this->current_parser->c,$this->obj_stack[$filename][$n][1]);
|
||||||
|
|
||||||
$this->_newobj($this->obj_stack[$filename][$n][0]);
|
$this->_newobj($this->obj_stack[$filename][$n][0]);
|
||||||
|
|
||||||
if ($nObj[0] == PDF_TYPE_STREAM) {
|
if ($nObj[0] == PDF_TYPE_STREAM) {
|
||||||
$this->pdf_write_value ($nObj);
|
$this->pdf_write_value ($nObj);
|
||||||
} else {
|
} else {
|
||||||
$this->pdf_write_value ($nObj[1]);
|
$this->pdf_write_value ($nObj[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_out('endobj');
|
$this->_out('endobj');
|
||||||
$this->obj_stack[$filename][$n] = null; // free memory
|
$this->obj_stack[$filename][$n] = null; // free memory
|
||||||
unset($this->obj_stack[$filename][$n]);
|
unset($this->obj_stack[$filename][$n]);
|
||||||
reset($this->obj_stack[$filename]);
|
reset($this->obj_stack[$filename]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rewritten for handling own defined PDF-Versions
|
* Rewritten for handling own defined PDF-Versions
|
||||||
* only needed by FPDF 1.52
|
* only needed by FPDF 1.52
|
||||||
*/
|
*/
|
||||||
function _begindoc() {
|
function _begindoc() {
|
||||||
//Start document
|
//Start document
|
||||||
$this->state=1;
|
$this->state=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the PDF Version to the highest of imported documents
|
* Sets the PDF Version to the highest of imported documents
|
||||||
*/
|
*/
|
||||||
function setVersion() {
|
function setVersion() {
|
||||||
if ($this->importVersion > $this->PDFVersion)
|
if ($this->importVersion > $this->PDFVersion)
|
||||||
$this->PDFVersion = $this->importVersion;
|
$this->PDFVersion = $this->importVersion;
|
||||||
|
|
||||||
if (!method_exists($this, '_putheader')) {
|
if (!method_exists($this, '_putheader')) {
|
||||||
$this->buffer = '%PDF-'.$this->PDFVersion."\n".$this->buffer;
|
$this->buffer = '%PDF-'.$this->PDFVersion."\n".$this->buffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* rewritten for handling higher PDF Versions
|
* rewritten for handling higher PDF Versions
|
||||||
*/
|
*/
|
||||||
function _enddoc() {
|
function _enddoc() {
|
||||||
$this->setVersion();
|
$this->setVersion();
|
||||||
parent::_enddoc();
|
parent::_enddoc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Put resources
|
* Put resources
|
||||||
*/
|
*/
|
||||||
function _putresources() {
|
function _putresources() {
|
||||||
$this->_putfonts();
|
$this->_putfonts();
|
||||||
$this->_putimages();
|
$this->_putimages();
|
||||||
$this->_puttemplates();
|
$this->_puttemplates();
|
||||||
$this->_putOobjects();
|
$this->_putOobjects();
|
||||||
|
|
||||||
//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('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
|
||||||
$this->_out('/Font <<');
|
$this->_out('/Font <<');
|
||||||
foreach($this->fonts as $font)
|
foreach($this->fonts as $font)
|
||||||
$this->_out($this->fontprefix.$font['i'].' '.$font['n'].' 0 R');
|
$this->_out($this->fontprefix.$font['i'].' '.$font['n'].' 0 R');
|
||||||
$this->_out('>>');
|
$this->_out('>>');
|
||||||
if(count($this->images) || count($this->tpls))
|
if(count($this->images) || count($this->tpls))
|
||||||
{
|
{
|
||||||
$this->_out('/XObject <<');
|
$this->_out('/XObject <<');
|
||||||
if (count($this->images)) {
|
if (count($this->images)) {
|
||||||
foreach($this->images as $image)
|
foreach($this->images as $image)
|
||||||
$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
|
$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
|
||||||
}
|
}
|
||||||
if (count($this->tpls)) {
|
if (count($this->tpls)) {
|
||||||
foreach($this->tpls as $tplidx => $tpl)
|
foreach($this->tpls as $tplidx => $tpl)
|
||||||
$this->_out($this->tplprefix.$tplidx.' '.$tpl['n'].' 0 R');
|
$this->_out($this->tplprefix.$tplidx.' '.$tpl['n'].' 0 R');
|
||||||
}
|
}
|
||||||
$this->_out('>>');
|
$this->_out('>>');
|
||||||
}
|
}
|
||||||
$this->_out('>>');
|
$this->_out('>>');
|
||||||
$this->_out('endobj');
|
$this->_out('endobj');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private Method that writes /XObjects - "Templates"
|
* Private Method that writes /XObjects - "Templates"
|
||||||
*/
|
*/
|
||||||
function _puttemplates() {
|
function _puttemplates() {
|
||||||
$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
|
$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
|
||||||
reset($this->tpls);
|
reset($this->tpls);
|
||||||
foreach($this->tpls AS $tplidx => $tpl) {
|
foreach($this->tpls AS $tplidx => $tpl) {
|
||||||
|
|
||||||
$p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer'];
|
$p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer'];
|
||||||
$this->_newobj();
|
$this->_newobj();
|
||||||
$this->tpls[$tplidx]['n'] = $this->n;
|
$this->tpls[$tplidx]['n'] = $this->n;
|
||||||
$this->_out('<<'.$filter.'/Type /XObject');
|
$this->_out('<<'.$filter.'/Type /XObject');
|
||||||
$this->_out('/Subtype /Form');
|
$this->_out('/Subtype /Form');
|
||||||
$this->_out('/FormType 1');
|
$this->_out('/FormType 1');
|
||||||
$this->_out(sprintf('/BBox [%.2f %.2f %.2f %.2f]',$tpl['x']*$this->k, ($tpl['h']-$tpl['y'])*$this->k, $tpl['w']*$this->k, ($tpl['h']-$tpl['y']-$tpl['h'])*$this->k));
|
$this->_out(sprintf('/BBox [%.2f %.2f %.2f %.2f]',$tpl['x']*$this->k, ($tpl['h']-$tpl['y'])*$this->k, $tpl['w']*$this->k, ($tpl['h']-$tpl['y']-$tpl['h'])*$this->k));
|
||||||
$this->_out('/Resources ');
|
$this->_out('/Resources ');
|
||||||
|
|
||||||
if ($tpl['resources']) {
|
if ($tpl['resources']) {
|
||||||
$this->current_parser =& $tpl['parser'];
|
$this->current_parser =& $tpl['parser'];
|
||||||
$this->pdf_write_value($tpl['resources']);
|
$this->pdf_write_value($tpl['resources']);
|
||||||
} else {
|
} else {
|
||||||
$this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
|
$this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
|
||||||
if (count($this->res['tpl'][$tplidx]['fonts'])) {
|
if (count($this->res['tpl'][$tplidx]['fonts'])) {
|
||||||
$this->_out('/Font <<');
|
$this->_out('/Font <<');
|
||||||
foreach($this->res['tpl'][$tplidx]['fonts'] as $font)
|
foreach($this->res['tpl'][$tplidx]['fonts'] as $font)
|
||||||
$this->_out($this->fontprefix.$font['i'].' '.$font['n'].' 0 R');
|
$this->_out($this->fontprefix.$font['i'].' '.$font['n'].' 0 R');
|
||||||
$this->_out('>>');
|
$this->_out('>>');
|
||||||
}
|
}
|
||||||
if(count($this->res['tpl'][$tplidx]['images']) || count($this->res['tpl'][$tplidx]['tpls']))
|
if(count($this->res['tpl'][$tplidx]['images']) || count($this->res['tpl'][$tplidx]['tpls']))
|
||||||
{
|
{
|
||||||
$this->_out('/XObject <<');
|
$this->_out('/XObject <<');
|
||||||
if (count($this->res['tpl'][$tplidx]['images'])) {
|
if (count($this->res['tpl'][$tplidx]['images'])) {
|
||||||
foreach($this->res['tpl'][$tplidx]['images'] as $image)
|
foreach($this->res['tpl'][$tplidx]['images'] as $image)
|
||||||
$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
|
$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
|
||||||
}
|
}
|
||||||
if (count($this->res['tpl'][$tplidx]['tpls'])) {
|
if (count($this->res['tpl'][$tplidx]['tpls'])) {
|
||||||
foreach($this->res['tpl'][$tplidx]['tpls'] as $i => $tpl)
|
foreach($this->res['tpl'][$tplidx]['tpls'] as $i => $tpl)
|
||||||
$this->_out($this->tplprefix.$i.' '.$tpl['n'].' 0 R');
|
$this->_out($this->tplprefix.$i.' '.$tpl['n'].' 0 R');
|
||||||
}
|
}
|
||||||
$this->_out('>>');
|
$this->_out('>>');
|
||||||
}
|
}
|
||||||
$this->_out('>>');
|
$this->_out('>>');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_out('/Length '.strlen($p).' >>');
|
$this->_out('/Length '.strlen($p).' >>');
|
||||||
$this->_putstream($p);
|
$this->_putstream($p);
|
||||||
$this->_out('endobj');
|
$this->_out('endobj');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rewritten to handle existing own defined objects
|
* Rewritten to handle existing own defined objects
|
||||||
*/
|
*/
|
||||||
function _newobj($obj_id=false,$onlynewobj=false) {
|
function _newobj($obj_id=false,$onlynewobj=false) {
|
||||||
if (!$obj_id) {
|
if (!$obj_id) {
|
||||||
$obj_id = ++$this->n;
|
$obj_id = ++$this->n;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Begin a new object
|
//Begin a new object
|
||||||
if (!$onlynewobj) {
|
if (!$onlynewobj) {
|
||||||
$this->offsets[$obj_id]=strlen($this->buffer);
|
$this->offsets[$obj_id]=strlen($this->buffer);
|
||||||
$this->_out($obj_id.' 0 obj');
|
$this->_out($obj_id.' 0 obj');
|
||||||
$this->current_obj_id = $obj_id; // for later use with encryption
|
$this->current_obj_id = $obj_id; // for later use with encryption
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a value
|
* Writes a value
|
||||||
* Needed to rebuild the source document
|
* Needed to rebuild the source document
|
||||||
*
|
*
|
||||||
* @param mixed $value A PDF-Value. Structure of values see cases in this method
|
* @param mixed $value A PDF-Value. Structure of values see cases in this method
|
||||||
*/
|
*/
|
||||||
function pdf_write_value(&$value)
|
function pdf_write_value(&$value)
|
||||||
{
|
{
|
||||||
|
|
||||||
switch ($value[0]) {
|
switch ($value[0]) {
|
||||||
|
|
||||||
case PDF_TYPE_NUMERIC :
|
case PDF_TYPE_NUMERIC :
|
||||||
case PDF_TYPE_TOKEN :
|
case PDF_TYPE_TOKEN :
|
||||||
// A numeric value or a token.
|
// A numeric value or a token.
|
||||||
// Simply output them
|
// Simply output them
|
||||||
$this->_out($value[1]." ");
|
$this->_out($value[1]." ");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PDF_TYPE_ARRAY :
|
case PDF_TYPE_ARRAY :
|
||||||
|
|
||||||
// An array. Output the proper
|
// An array. Output the proper
|
||||||
// structure and move on.
|
// structure and move on.
|
||||||
|
|
||||||
$this->_out("[",false);
|
$this->_out("[",false);
|
||||||
for ($i = 0; $i < count($value[1]); $i++) {
|
for ($i = 0; $i < count($value[1]); $i++) {
|
||||||
$this->pdf_write_value($value[1][$i]);
|
$this->pdf_write_value($value[1][$i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_out("]");
|
$this->_out("]");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PDF_TYPE_DICTIONARY :
|
case PDF_TYPE_DICTIONARY :
|
||||||
|
|
||||||
// A dictionary.
|
// A dictionary.
|
||||||
$this->_out("<<",false);
|
$this->_out("<<",false);
|
||||||
|
|
||||||
reset ($value[1]);
|
reset ($value[1]);
|
||||||
|
|
||||||
while (list($k, $v) = each($value[1])) {
|
while (list($k, $v) = each($value[1])) {
|
||||||
$this->_out($k . " ",false);
|
$this->_out($k . " ",false);
|
||||||
$this->pdf_write_value($v);
|
$this->pdf_write_value($v);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_out(">>");
|
$this->_out(">>");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PDF_TYPE_OBJREF :
|
case PDF_TYPE_OBJREF :
|
||||||
|
|
||||||
// An indirect object reference
|
// An indirect object reference
|
||||||
// Fill the object stack if needed
|
// Fill the object stack if needed
|
||||||
if (!isset($this->don_obj_stack[$this->current_parser->filename][$value[1]])) {
|
if (!isset($this->don_obj_stack[$this->current_parser->filename][$value[1]])) {
|
||||||
$this->_newobj(false,true);
|
$this->_newobj(false,true);
|
||||||
$this->obj_stack[$this->current_parser->filename][$value[1]] = array($this->n,$value);
|
$this->obj_stack[$this->current_parser->filename][$value[1]] = array($this->n,$value);
|
||||||
$this->don_obj_stack[$this->current_parser->filename][$value[1]] = array($this->n,$value);
|
$this->don_obj_stack[$this->current_parser->filename][$value[1]] = array($this->n,$value);
|
||||||
}
|
}
|
||||||
$objid = $this->don_obj_stack[$this->current_parser->filename][$value[1]][0];
|
$objid = $this->don_obj_stack[$this->current_parser->filename][$value[1]][0];
|
||||||
|
|
||||||
$this->_out("{$objid} 0 R"); //{$value[2]}
|
$this->_out("{$objid} 0 R"); //{$value[2]}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PDF_TYPE_STRING :
|
case PDF_TYPE_STRING :
|
||||||
|
|
||||||
// A string.
|
// A string.
|
||||||
$this->_out('(' . $value[1] . ')');
|
$this->_out('(' . $value[1] . ')');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PDF_TYPE_STREAM :
|
case PDF_TYPE_STREAM :
|
||||||
|
|
||||||
// A stream. First, output the
|
// A stream. First, output the
|
||||||
// stream dictionary, then the
|
// stream dictionary, then the
|
||||||
// stream data itself.
|
// stream data itself.
|
||||||
$this->pdf_write_value($value[1]);
|
$this->pdf_write_value($value[1]);
|
||||||
$this->_out("stream");
|
$this->_out("stream");
|
||||||
$this->_out($value[2][1]);
|
$this->_out($value[2][1]);
|
||||||
$this->_out("endstream");
|
$this->_out("endstream");
|
||||||
break;
|
break;
|
||||||
case PDF_TYPE_HEX :
|
case PDF_TYPE_HEX :
|
||||||
|
|
||||||
$this->_out("<" . $value[1] . ">");
|
$this->_out("<" . $value[1] . ">");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PDF_TYPE_NULL :
|
case PDF_TYPE_NULL :
|
||||||
// The null object.
|
// The null object.
|
||||||
|
|
||||||
$this->_out("null");
|
$this->_out("null");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private Method
|
* Private Method
|
||||||
*/
|
*/
|
||||||
function _out($s,$ln=true) {
|
function _out($s,$ln=true) {
|
||||||
//Add a line to the document
|
//Add a line to the document
|
||||||
if ($this->state==2) {
|
if ($this->state==2) {
|
||||||
if (!$this->intpl)
|
if (!$this->intpl)
|
||||||
$this->pages[$this->page].=$s.($ln == true ? "\n" : '');
|
$this->pages[$this->page].=$s.($ln == true ? "\n" : '');
|
||||||
else
|
else
|
||||||
$this->tpls[$this->tpl]['buffer'] .= $s.($ln == true ? "\n" : '');
|
$this->tpls[$this->tpl]['buffer'] .= $s.($ln == true ? "\n" : '');
|
||||||
} else {
|
} else {
|
||||||
$this->buffer.=$s.($ln == true ? "\n" : '');
|
$this->buffer.=$s.($ln == true ? "\n" : '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* close all files opened by parsers
|
* close all files opened by parsers
|
||||||
*/
|
*/
|
||||||
function closeParsers() {
|
function closeParsers() {
|
||||||
foreach ($this->parsers as $parser){
|
foreach ($this->parsers as $parser){
|
||||||
$parser->closeFile();
|
$parser->closeFile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@ -1,482 +1,482 @@
|
|||||||
<?php
|
<?php
|
||||||
//
|
//
|
||||||
// FPDI - Version 1.1
|
// FPDI - Version 1.1
|
||||||
//
|
//
|
||||||
// Copyright 2004,2005 Setasign - Jan Slabon
|
// Copyright 2004,2005 Setasign - Jan Slabon
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
//
|
//
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
//
|
//
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
|
||||||
if (!defined ('PDF_TYPE_NULL'))
|
if (!defined ('PDF_TYPE_NULL'))
|
||||||
define ('PDF_TYPE_NULL', 0);
|
define ('PDF_TYPE_NULL', 0);
|
||||||
if (!defined ('PDF_TYPE_NUMERIC'))
|
if (!defined ('PDF_TYPE_NUMERIC'))
|
||||||
define ('PDF_TYPE_NUMERIC', 1);
|
define ('PDF_TYPE_NUMERIC', 1);
|
||||||
if (!defined ('PDF_TYPE_TOKEN'))
|
if (!defined ('PDF_TYPE_TOKEN'))
|
||||||
define ('PDF_TYPE_TOKEN', 2);
|
define ('PDF_TYPE_TOKEN', 2);
|
||||||
if (!defined ('PDF_TYPE_HEX'))
|
if (!defined ('PDF_TYPE_HEX'))
|
||||||
define ('PDF_TYPE_HEX', 3);
|
define ('PDF_TYPE_HEX', 3);
|
||||||
if (!defined ('PDF_TYPE_STRING'))
|
if (!defined ('PDF_TYPE_STRING'))
|
||||||
define ('PDF_TYPE_STRING', 4);
|
define ('PDF_TYPE_STRING', 4);
|
||||||
if (!defined ('PDF_TYPE_DICTIONARY'))
|
if (!defined ('PDF_TYPE_DICTIONARY'))
|
||||||
define ('PDF_TYPE_DICTIONARY', 5);
|
define ('PDF_TYPE_DICTIONARY', 5);
|
||||||
if (!defined ('PDF_TYPE_ARRAY'))
|
if (!defined ('PDF_TYPE_ARRAY'))
|
||||||
define ('PDF_TYPE_ARRAY', 6);
|
define ('PDF_TYPE_ARRAY', 6);
|
||||||
if (!defined ('PDF_TYPE_OBJDEC'))
|
if (!defined ('PDF_TYPE_OBJDEC'))
|
||||||
define ('PDF_TYPE_OBJDEC', 7);
|
define ('PDF_TYPE_OBJDEC', 7);
|
||||||
if (!defined ('PDF_TYPE_OBJREF'))
|
if (!defined ('PDF_TYPE_OBJREF'))
|
||||||
define ('PDF_TYPE_OBJREF', 8);
|
define ('PDF_TYPE_OBJREF', 8);
|
||||||
if (!defined ('PDF_TYPE_OBJECT'))
|
if (!defined ('PDF_TYPE_OBJECT'))
|
||||||
define ('PDF_TYPE_OBJECT', 9);
|
define ('PDF_TYPE_OBJECT', 9);
|
||||||
if (!defined ('PDF_TYPE_STREAM'))
|
if (!defined ('PDF_TYPE_STREAM'))
|
||||||
define ('PDF_TYPE_STREAM', 10);
|
define ('PDF_TYPE_STREAM', 10);
|
||||||
|
|
||||||
|
|
||||||
require_once("wrapper_functions.php");
|
require_once(FPDF_PATH.'wrapper_functions.php');
|
||||||
require_once("pdf_parser.php");
|
require_once(FPDF_PATH.'pdf_parser.php');
|
||||||
|
|
||||||
class fpdi_pdf_parser extends pdf_parser {
|
class fpdi_pdf_parser extends pdf_parser {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pages
|
* Pages
|
||||||
* Index beginns at 0
|
* Index beginns at 0
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $pages;
|
var $pages;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page count
|
* Page count
|
||||||
* @var integer
|
* @var integer
|
||||||
*/
|
*/
|
||||||
var $page_count;
|
var $page_count;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* actual page number
|
* actual page number
|
||||||
* @var integer
|
* @var integer
|
||||||
*/
|
*/
|
||||||
var $pageno;
|
var $pageno;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PDF Version of imported Document
|
* PDF Version of imported Document
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $pdfVersion;
|
var $pdfVersion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FPDI Reference
|
* FPDI Reference
|
||||||
* @var object
|
* @var object
|
||||||
*/
|
*/
|
||||||
var $fpdi;
|
var $fpdi;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param string $filename Source-Filename
|
* @param string $filename Source-Filename
|
||||||
* @param object $fpdi Object of type fpdi
|
* @param object $fpdi Object of type fpdi
|
||||||
*/
|
*/
|
||||||
function fpdi_pdf_parser($filename,&$fpdi) {
|
function fpdi_pdf_parser($filename,&$fpdi) {
|
||||||
$this->fpdi =& $fpdi;
|
$this->fpdi =& $fpdi;
|
||||||
$this->filename = $filename;
|
$this->filename = $filename;
|
||||||
|
|
||||||
parent::pdf_parser($filename);
|
parent::pdf_parser($filename);
|
||||||
|
|
||||||
// Get Info
|
// Get Info
|
||||||
$this->getInfo();
|
$this->getInfo();
|
||||||
|
|
||||||
// resolve Pages-Dictonary
|
// resolve Pages-Dictonary
|
||||||
$pages = $this->pdf_resolve_object($this->c, $this->root[1][1]['/Pages']);
|
$pages = $this->pdf_resolve_object($this->c, $this->root[1][1]['/Pages']);
|
||||||
|
|
||||||
// Read pages
|
// Read pages
|
||||||
$this->read_pages($this->c, $pages, $this->pages);
|
$this->read_pages($this->c, $pages, $this->pages);
|
||||||
|
|
||||||
// count pages;
|
// count pages;
|
||||||
$this->page_count = count($this->pages);
|
$this->page_count = count($this->pages);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overwrite parent::error()
|
* Overwrite parent::error()
|
||||||
*
|
*
|
||||||
* @param string $msg Error-Message
|
* @param string $msg Error-Message
|
||||||
*/
|
*/
|
||||||
function error($msg) {
|
function error($msg) {
|
||||||
$this->fpdi->error($msg);
|
$this->fpdi->error($msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get pagecount from sourcefile
|
* Get pagecount from sourcefile
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
function getPageCount() {
|
function getPageCount() {
|
||||||
return $this->page_count;
|
return $this->page_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set pageno
|
* Set pageno
|
||||||
*
|
*
|
||||||
* @param int $pageno Pagenumber to use
|
* @param int $pageno Pagenumber to use
|
||||||
*/
|
*/
|
||||||
function setPageno($pageno) {
|
function setPageno($pageno) {
|
||||||
$pageno-=1;
|
$pageno-=1;
|
||||||
|
|
||||||
if ($pageno < 0 || $pageno >= $this->getPageCount()) {
|
if ($pageno < 0 || $pageno >= $this->getPageCount()) {
|
||||||
$this->fpdi->error("Pagenumber is wrong!");
|
$this->fpdi->error("Pagenumber is wrong!");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->pageno = $pageno;
|
$this->pageno = $pageno;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get page-resources from current page
|
* Get page-resources from current page
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getPageResources() {
|
function getPageResources() {
|
||||||
return $this->_getPageResources($this->pages[$this->pageno]);
|
return $this->_getPageResources($this->pages[$this->pageno]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get page-resources from /Page
|
* Get page-resources from /Page
|
||||||
*
|
*
|
||||||
* @param array $obj Array of pdf-data
|
* @param array $obj Array of pdf-data
|
||||||
*/
|
*/
|
||||||
function _getPageResources ($obj) { // $obj = /Page
|
function _getPageResources ($obj) { // $obj = /Page
|
||||||
$obj = $this->pdf_resolve_object($this->c, $obj);
|
$obj = $this->pdf_resolve_object($this->c, $obj);
|
||||||
|
|
||||||
// If the current object has a resources
|
// If the current object has a resources
|
||||||
// dictionary associated with it, we use
|
// dictionary associated with it, we use
|
||||||
// it. Otherwise, we move back to its
|
// it. Otherwise, we move back to its
|
||||||
// parent object.
|
// parent object.
|
||||||
if (isset ($obj[1][1]['/Resources'])) {
|
if (isset ($obj[1][1]['/Resources'])) {
|
||||||
$res = $this->pdf_resolve_object($this->c, $obj[1][1]['/Resources']);
|
$res = $this->pdf_resolve_object($this->c, $obj[1][1]['/Resources']);
|
||||||
if ($res[0] == PDF_TYPE_OBJECT)
|
if ($res[0] == PDF_TYPE_OBJECT)
|
||||||
return $res[1];
|
return $res[1];
|
||||||
return $res;
|
return $res;
|
||||||
} else {
|
} else {
|
||||||
if (!isset ($obj[1][1]['/Parent'])) {
|
if (!isset ($obj[1][1]['/Parent'])) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
$res = $this->_getPageResources($obj[1][1]['/Parent']);
|
$res = $this->_getPageResources($obj[1][1]['/Parent']);
|
||||||
if ($res[0] == PDF_TYPE_OBJECT)
|
if ($res[0] == PDF_TYPE_OBJECT)
|
||||||
return $res[1];
|
return $res[1];
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getInfo() {
|
function getInfo() {
|
||||||
$avail_infos = array("Title", "Author", "Subject", "Keywords", "Creator", "Producer", "CreationDate", "ModDate", "Trapped");
|
$avail_infos = array("Title", "Author", "Subject", "Keywords", "Creator", "Producer", "CreationDate", "ModDate", "Trapped");
|
||||||
|
|
||||||
$_infos = $this->pdf_resolve_object($this->c,$this->xref['trailer'][1]['/Info']);
|
$_infos = $this->pdf_resolve_object($this->c,$this->xref['trailer'][1]['/Info']);
|
||||||
$infos = array();
|
$infos = array();
|
||||||
|
|
||||||
foreach ($avail_infos AS $info) {
|
foreach ($avail_infos AS $info) {
|
||||||
if (isset($_infos[1][1]["/".$info])) {
|
if (isset($_infos[1][1]["/".$info])) {
|
||||||
if ($_infos[1][1]["/".$info][0] == PDF_TYPE_STRING) {
|
if ($_infos[1][1]["/".$info][0] == PDF_TYPE_STRING) {
|
||||||
$infos[$info] = $this->deescapeString($_infos[1][1]["/".$info][1]);
|
$infos[$info] = $this->deescapeString($_infos[1][1]["/".$info][1]);
|
||||||
} else if ($_infos[1][1]["/".$info][0] == PDF_TYPE_HEX) {
|
} else if ($_infos[1][1]["/".$info][0] == PDF_TYPE_HEX) {
|
||||||
$infos[$info] = $this->hex2String($_infos[1][1]["/".$info][1]);
|
$infos[$info] = $this->hex2String($_infos[1][1]["/".$info][1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->infos = $infos;
|
$this->infos = $infos;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rebuilds a hexstring to string
|
* Rebuilds a hexstring to string
|
||||||
*
|
*
|
||||||
* @param string $hex hexstring
|
* @param string $hex hexstring
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function hex2String($hex) {
|
function hex2String($hex) {
|
||||||
$endian = false;
|
$endian = false;
|
||||||
|
|
||||||
if (preg_match("/^FEFF/",$hex)) { // is utf-16 aka big endian
|
if (preg_match("/^FEFF/",$hex)) { // is utf-16 aka big endian
|
||||||
$i = 4;
|
$i = 4;
|
||||||
$endian = "big";
|
$endian = "big";
|
||||||
} else if (preg_match("/^FFFE/",$hex)) { // is utf-16 aka little endian
|
} else if (preg_match("/^FFFE/",$hex)) { // is utf-16 aka little endian
|
||||||
$i = 4;
|
$i = 4;
|
||||||
$endian = "little";
|
$endian = "little";
|
||||||
} else {
|
} else {
|
||||||
$i = 0;
|
$i = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$s = "";
|
$s = "";
|
||||||
$l = strlen($hex);
|
$l = strlen($hex);
|
||||||
for (; $i < $l; $i+=2) {
|
for (; $i < $l; $i+=2) {
|
||||||
if (!$endian) {
|
if (!$endian) {
|
||||||
$s .= chr(hexdec($hex[$i].(isset($hex[$i+1]) ? $hex[$i+1] : '0')));
|
$s .= chr(hexdec($hex[$i].(isset($hex[$i+1]) ? $hex[$i+1] : '0')));
|
||||||
} else {
|
} else {
|
||||||
if ($endian == "big") {
|
if ($endian == "big") {
|
||||||
$_c = $hex[$i].$hex[$i+1];
|
$_c = $hex[$i].$hex[$i+1];
|
||||||
$i+=2;
|
$i+=2;
|
||||||
$c = $hex[$i].$hex[$i+1];
|
$c = $hex[$i].$hex[$i+1];
|
||||||
|
|
||||||
if ($_c != "00") {
|
if ($_c != "00") {
|
||||||
$s .= "?";
|
$s .= "?";
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
$s .= chr(hexdec($c));
|
$s .= chr(hexdec($c));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else if ($endian == "little") {
|
} else if ($endian == "little") {
|
||||||
$c = $hex[$i].$hex[$i+1];
|
$c = $hex[$i].$hex[$i+1];
|
||||||
$i+=2;
|
$i+=2;
|
||||||
$_c = $hex[$i].$hex[$i+1];
|
$_c = $hex[$i].$hex[$i+1];
|
||||||
|
|
||||||
if ($_c != "00") {
|
if ($_c != "00") {
|
||||||
$s .= "?";
|
$s .= "?";
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
$s .= chr(hexdec($c));
|
$s .= chr(hexdec($c));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $s;
|
return $s;
|
||||||
}
|
}
|
||||||
|
|
||||||
function deescapeString($s) {
|
function deescapeString($s) {
|
||||||
$torepl = array("/\\\(\d{1,3})/e" => "chr(octdec(\\1))",
|
$torepl = array("/\\\(\d{1,3})/e" => "chr(octdec(\\1))",
|
||||||
"/\\\\\(/" => "(",
|
"/\\\\\(/" => "(",
|
||||||
"/\\\\\)/" => ")");
|
"/\\\\\)/" => ")");
|
||||||
return preg_replace(array_keys($torepl),$torepl,$s);
|
return preg_replace(array_keys($torepl),$torepl,$s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get content of current page
|
* Get content of current page
|
||||||
*
|
*
|
||||||
* If more /Contents is an array, the streams are concated
|
* If more /Contents is an array, the streams are concated
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getContent() {
|
function getContent() {
|
||||||
$buffer = "";
|
$buffer = "";
|
||||||
|
|
||||||
$contents = $this->getPageContent($this->pages[$this->pageno][1][1]['/Contents']);
|
$contents = $this->getPageContent($this->pages[$this->pageno][1][1]['/Contents']);
|
||||||
foreach($contents AS $tmp_content) {
|
foreach($contents AS $tmp_content) {
|
||||||
$buffer .= $this->rebuildContentStream($tmp_content);
|
$buffer .= $this->rebuildContentStream($tmp_content);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $buffer;
|
return $buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolve all content-objects
|
* Resolve all content-objects
|
||||||
*
|
*
|
||||||
* @param array $content_ref
|
* @param array $content_ref
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getPageContent($content_ref) {
|
function getPageContent($content_ref) {
|
||||||
$contents = array();
|
$contents = array();
|
||||||
|
|
||||||
if ($content_ref[0] == PDF_TYPE_OBJREF) {
|
if ($content_ref[0] == PDF_TYPE_OBJREF) {
|
||||||
$content = $this->pdf_resolve_object($this->c, $content_ref);
|
$content = $this->pdf_resolve_object($this->c, $content_ref);
|
||||||
if ($content[1][0] == PDF_TYPE_ARRAY) {
|
if ($content[1][0] == PDF_TYPE_ARRAY) {
|
||||||
$contents = $this->getPageContent($content[1]);
|
$contents = $this->getPageContent($content[1]);
|
||||||
} else {
|
} else {
|
||||||
$contents[] = $content;
|
$contents[] = $content;
|
||||||
}
|
}
|
||||||
} else if ($content_ref[0] == PDF_TYPE_ARRAY) {
|
} else if ($content_ref[0] == PDF_TYPE_ARRAY) {
|
||||||
foreach ($content_ref[1] AS $tmp_content_ref) {
|
foreach ($content_ref[1] AS $tmp_content_ref) {
|
||||||
$contents = array_merge($contents,$this->getPageContent($tmp_content_ref));
|
$contents = array_merge($contents,$this->getPageContent($tmp_content_ref));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $contents;
|
return $contents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rebuild content-streams
|
* Rebuild content-streams
|
||||||
* only non-compressed streams and /FlateDecode are ready!
|
* only non-compressed streams and /FlateDecode are ready!
|
||||||
*
|
*
|
||||||
* @param array $obj
|
* @param array $obj
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function rebuildContentStream($obj) {
|
function rebuildContentStream($obj) {
|
||||||
$filters = array();
|
$filters = array();
|
||||||
|
|
||||||
if (isset($obj[1][1]['/Filter'])) {
|
if (isset($obj[1][1]['/Filter'])) {
|
||||||
$_filter = $obj[1][1]['/Filter'];
|
$_filter = $obj[1][1]['/Filter'];
|
||||||
|
|
||||||
if ($_filter[0] == PDF_TYPE_TOKEN) {
|
if ($_filter[0] == PDF_TYPE_TOKEN) {
|
||||||
$filters[] = $_filter;
|
$filters[] = $_filter;
|
||||||
} else if ($_filter[0] == PDF_TYPE_ARRAY) {
|
} else if ($_filter[0] == PDF_TYPE_ARRAY) {
|
||||||
$filters = $_filter[1];
|
$filters = $_filter[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$stream = $obj[2][1];
|
$stream = $obj[2][1];
|
||||||
|
|
||||||
foreach ($filters AS $_filter) {
|
foreach ($filters AS $_filter) {
|
||||||
switch ($_filter[1]) {
|
switch ($_filter[1]) {
|
||||||
case "/FlateDecode":
|
case "/FlateDecode":
|
||||||
if (function_exists('gzuncompress')) {
|
if (function_exists('gzuncompress')) {
|
||||||
$stream = @gzuncompress($stream);
|
$stream = @gzuncompress($stream);
|
||||||
} else {
|
} else {
|
||||||
$this->fpdi->error(sprintf("To handle %s filter, please compile php with zlib support.",$_filter[1]));
|
$this->fpdi->error(sprintf("To handle %s filter, please compile php with zlib support.",$_filter[1]));
|
||||||
}
|
}
|
||||||
if ($stream === false) {
|
if ($stream === false) {
|
||||||
$this->fpdi->error("Error while decompressing string.");
|
$this->fpdi->error("Error while decompressing string.");
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "/LZWDecode":
|
case "/LZWDecode":
|
||||||
@include_once("decoders/lzw.php");
|
@include_once("decoders/lzw.php");
|
||||||
if (class_exists("LZWDecode")) {
|
if (class_exists("LZWDecode")) {
|
||||||
$lzwdec = new LZWDecode($this->fpdi);
|
$lzwdec = new LZWDecode($this->fpdi);
|
||||||
$stream = $lzwdec->decode($stream);
|
$stream = $lzwdec->decode($stream);
|
||||||
} else {
|
} else {
|
||||||
$this->fpdi->error(sprintf("Unsupported Filter: %s",$_filter[1]));
|
$this->fpdi->error(sprintf("Unsupported Filter: %s",$_filter[1]));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "/ASCII85Decode":
|
case "/ASCII85Decode":
|
||||||
@include_once("decoders/ascii85.php");
|
@include_once("decoders/ascii85.php");
|
||||||
if (class_exists("ASCII85Decode")) {
|
if (class_exists("ASCII85Decode")) {
|
||||||
$ascii85 = new ASCII85Decode($this->fpdi);
|
$ascii85 = new ASCII85Decode($this->fpdi);
|
||||||
$stream = $ascii85->decode(trim($stream));
|
$stream = $ascii85->decode(trim($stream));
|
||||||
} else {
|
} else {
|
||||||
$this->fpdi->error(sprintf("Unsupported Filter: %s",$_filter[1]));
|
$this->fpdi->error(sprintf("Unsupported Filter: %s",$_filter[1]));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case null:
|
case null:
|
||||||
$stream = $stream;
|
$stream = $stream;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->fpdi->error(sprintf("Unsupported Filter: %s",$_filter[1]));
|
$this->fpdi->error(sprintf("Unsupported Filter: %s",$_filter[1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $stream;
|
return $stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get MediaBox
|
* Get MediaBox
|
||||||
*
|
*
|
||||||
* gets an array that describes the size of a page.
|
* gets an array that describes the size of a page.
|
||||||
*
|
*
|
||||||
* @param integer $pageno
|
* @param integer $pageno
|
||||||
* @return array @see getPageBox()
|
* @return array @see getPageBox()
|
||||||
*/
|
*/
|
||||||
function getPageMediaBox($pageno) {
|
function getPageMediaBox($pageno) {
|
||||||
return $this->getPageBox($this->pages[$pageno-1],"/MediaBox");
|
return $this->getPageBox($this->pages[$pageno-1],"/MediaBox");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a Box from a page
|
* Get a Box from a page
|
||||||
* Arrayformat is same as used by fpdf_tpl
|
* Arrayformat is same as used by fpdf_tpl
|
||||||
*
|
*
|
||||||
* @param array $page a /Page
|
* @param array $page a /Page
|
||||||
* @param string $box_index Type of Box @see getPageBoxes()
|
* @param string $box_index Type of Box @see getPageBoxes()
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getPageBox($page, $box_index) {
|
function getPageBox($page, $box_index) {
|
||||||
$page = $this->pdf_resolve_object($this->c,$page);
|
$page = $this->pdf_resolve_object($this->c,$page);
|
||||||
|
|
||||||
$box = null;
|
$box = null;
|
||||||
if (isset($page[1][1][$box_index]))
|
if (isset($page[1][1][$box_index]))
|
||||||
$box =& $page[1][1][$box_index];
|
$box =& $page[1][1][$box_index];
|
||||||
|
|
||||||
if (!is_null($box) && $box[0] == PDF_TYPE_OBJREF) {
|
if (!is_null($box) && $box[0] == PDF_TYPE_OBJREF) {
|
||||||
$tmp_box = $this->pdf_resolve_object($this->c,$box);
|
$tmp_box = $this->pdf_resolve_object($this->c,$box);
|
||||||
$box = $tmp_box[1];
|
$box = $tmp_box[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_null($box) && $box[0] == PDF_TYPE_ARRAY) {
|
if (!is_null($box) && $box[0] == PDF_TYPE_ARRAY) {
|
||||||
$b =& $box[1];
|
$b =& $box[1];
|
||||||
return array("x" => $b[0][1]/$this->fpdi->k,
|
return array("x" => $b[0][1]/$this->fpdi->k,
|
||||||
"y" => $b[1][1]/$this->fpdi->k,
|
"y" => $b[1][1]/$this->fpdi->k,
|
||||||
"w" => $b[2][1]/$this->fpdi->k,
|
"w" => $b[2][1]/$this->fpdi->k,
|
||||||
"h" => $b[3][1]/$this->fpdi->k);
|
"h" => $b[3][1]/$this->fpdi->k);
|
||||||
} else if (!isset ($page[1][1]['/Parent'])) {
|
} else if (!isset ($page[1][1]['/Parent'])) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return $this->getPageBox($this->pdf_resolve_object($this->c, $page[1][1]['/Parent']), $box_index);
|
return $this->getPageBox($this->pdf_resolve_object($this->c, $page[1][1]['/Parent']), $box_index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all Boxes from /Page
|
* Get all Boxes from /Page
|
||||||
*
|
*
|
||||||
* @param array a /Page
|
* @param array a /Page
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getPageBoxes($page) {
|
function getPageBoxes($page) {
|
||||||
$_boxes = array("/MediaBox","/CropBox","/BleedBox","/TrimBox","/ArtBox");
|
$_boxes = array("/MediaBox","/CropBox","/BleedBox","/TrimBox","/ArtBox");
|
||||||
$boxes = array();
|
$boxes = array();
|
||||||
|
|
||||||
foreach($_boxes AS $box) {
|
foreach($_boxes AS $box) {
|
||||||
if ($_box = $this->getPageBox($page,$box)) {
|
if ($_box = $this->getPageBox($page,$box)) {
|
||||||
$boxes[$box] = $_box;
|
$boxes[$box] = $_box;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $boxes;
|
return $boxes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read all /Page(es)
|
* Read all /Page(es)
|
||||||
*
|
*
|
||||||
* @param object pdf_context
|
* @param object pdf_context
|
||||||
* @param array /Pages
|
* @param array /Pages
|
||||||
* @param array the result-array
|
* @param array the result-array
|
||||||
*/
|
*/
|
||||||
function read_pages (&$c, &$pages, &$result) {
|
function read_pages (&$c, &$pages, &$result) {
|
||||||
|
|
||||||
// Get the kids dictionary
|
// Get the kids dictionary
|
||||||
$kids = $this->pdf_resolve_object ($c, $pages[1][1]['/Kids']);
|
$kids = $this->pdf_resolve_object ($c, $pages[1][1]['/Kids']);
|
||||||
|
|
||||||
if (!is_array($kids))
|
if (!is_array($kids))
|
||||||
$this->fpdi->Error("Cannot find /Kids in current /Page-Dictionary");
|
$this->fpdi->Error("Cannot find /Kids in current /Page-Dictionary");
|
||||||
foreach ($kids[1] as $v) {
|
foreach ($kids[1] as $v) {
|
||||||
$pg = $this->pdf_resolve_object ($c, $v);
|
$pg = $this->pdf_resolve_object ($c, $v);
|
||||||
#print_r($pg);
|
#print_r($pg);
|
||||||
|
|
||||||
if ($pg[1][1]['/Type'][1] === '/Pages') {
|
if ($pg[1][1]['/Type'][1] === '/Pages') {
|
||||||
// If one of the kids is an embedded
|
// If one of the kids is an embedded
|
||||||
// /Pages array, resolve it as well.
|
// /Pages array, resolve it as well.
|
||||||
$this->read_pages ($c, $pg, $result);
|
$this->read_pages ($c, $pg, $result);
|
||||||
} else {
|
} else {
|
||||||
$result[] = $pg;
|
$result[] = $pg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get PDF-Version
|
* Get PDF-Version
|
||||||
*
|
*
|
||||||
* And reset the PDF Version used in FPDI if needed
|
* And reset the PDF Version used in FPDI if needed
|
||||||
*/
|
*/
|
||||||
function getPDFVersion() {
|
function getPDFVersion() {
|
||||||
parent::getPDFVersion();
|
parent::getPDFVersion();
|
||||||
|
|
||||||
if (isset($this->fpdi->importVersion) && $this->pdfVersion > $this->fpdi->importVersion) {
|
if (isset($this->fpdi->importVersion) && $this->pdfVersion > $this->fpdi->importVersion) {
|
||||||
$this->fpdi->importVersion = $this->pdfVersion;
|
$this->fpdi->importVersion = $this->pdfVersion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@ -20,7 +20,7 @@
|
|||||||
* *
|
* *
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
require_once("fpdi.php");
|
require_once(FPDF_PATH.'fpdi.php');
|
||||||
|
|
||||||
class FPDI_Protection extends fpdi {
|
class FPDI_Protection extends fpdi {
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user