Upgrade FPDI libraries

This commit is contained in:
Laurent Destailleur 2010-09-16 17:54:00 +00:00
parent 5929f14ea2
commit 30ed46efd0
13 changed files with 1396 additions and 1430 deletions

View File

@ -14,8 +14,8 @@ ArtiChow 1.07 Public Domain Yes Graphics
EFC/XFSS 1.0.1 LGPL 3.0 Yes Enhanced File Crypt/Extended File Stealth System
FCKEditor 2.6.4 LGPL 2.1 or Mozilla PL 1.0 Yes Editor WYSIWYG
FPDF 1.6 Public domain Yes PDF generation (original code is modified)
FPDF_TPL 1.1.4 Apache Software License 2.0 No GPL3 only PDF templates management
FPDI 1.3.2 Apache Software License 2.0 No GPL3 only PDF templates management
FPDF_TPL 1.1.5 Apache Software License 2.0 No GPL3 only PDF templates management
FPDI 1.3.4 Apache Software License 2.0 No GPL3 only PDF templates management
FPDI_Protection 1.0.3 Apache Software License 2.0 No GPL3 only PDF encryption (8 files)
GeoIP x.x Yes GeoIP Maxmind conversion
iWebkit 5.0.4 LGPL 3.0 Yes Iphone templates framework

View File

@ -1,6 +1,6 @@
<?php
//
// FPDI - Version 1.3.2
// FPDI - Version 1.3.4
//
// Copyright 2004-2010 Setasign - Jan Slabon
//

View File

@ -1,6 +1,6 @@
<?php
//
// FPDI - Version 1.3.2
// FPDI - Version 1.3.4
//
// Copyright 2004-2010 Setasign - Jan Slabon
//
@ -23,7 +23,7 @@ class FilterASCII85_FPDI extends FilterASCII85 {
var $fpdi;
function FPDI_FilterASCII85(&$fpdi) {
function FilterASCII85_FPDI(&$fpdi) {
$this->fpdi =& $fpdi;
}

View File

@ -1,6 +1,6 @@
<?php
//
// FPDI - Version 1.3.2
// FPDI - Version 1.3.4
//
// Copyright 2004-2010 Setasign - Jan Slabon
//

View File

@ -1,6 +1,6 @@
<?php
//
// FPDI - Version 1.3.2
// FPDI - Version 1.3.4
//
// Copyright 2004-2010 Setasign - Jan Slabon
//

View File

@ -1,6 +1,6 @@
<?php
//
// FPDF_TPL - Version 1.1.4
// FPDF_TPL - Version 1.1.5
//
// Copyright 2004-2010 Setasign - Jan Slabon
//
@ -266,17 +266,19 @@ class FPDF_TPL extends FPDF {
/**
* See FPDF/TCPDF-Documentation ;-)
*/
function Image($file, $x, $y, $w=0, $h=0, $type='', $link='', $align='', $resize=false, $dpi=300, $palign='', $ismask=false, $imgmask=false, $border=0, $fitbox = false, $hidden = false) {
function Image($file, $x='', $y='', $w=0, $h=0, $type='', $link='', $align='', $resize=false, $dpi=300, $palign='', $ismask=false, $imgmask=false, $border=0, $fitbox=false, $hidden=false, $fitonpage=false) {
if (!is_subclass_of($this, 'TCPDF') && func_num_args() > 7) {
$this->Error('More than 7 arguments for the Image method are only available in TCPDF.');
}
parent::Image($file, $x, $y, $w, $h, $type, $link, $align, $resize, $dpi, $palign, $ismask, $imgmask, $border, $fitbox, $hidden);
$ret = parent::Image($file, $x, $y, $w, $h, $type, $link, $align, $resize, $dpi, $palign, $ismask, $imgmask, $border, $fitbox, $hidden, $fitonpage);
if ($this->_intpl) {
$this->_res['tpl'][$this->tpl]['images'][$file] =& $this->images[$file];
} else {
$this->_res['page'][$this->page]['images'][$file] =& $this->images[$file];
}
return $ret;
}
/**
@ -284,10 +286,14 @@ class FPDF_TPL extends FPDF {
*
* AddPage is not available when you're "in" a template.
*/
function AddPage($orientation='', $format='') {
function AddPage($orientation='', $format='', $keepmargins=false) {
if (!is_subclass_of($this, 'TCPDF') && func_num_args() > 2) {
$this->Error('More than 2 arguments for the AddPage method are only available in TCPDF.');
}
if ($this->_intpl)
$this->Error('Adding pages in templates isn\'t possible!');
parent::AddPage($orientation, $format);
parent::AddPage($orientation, $format, $keepmargins);
}
/**

View File

@ -1,6 +1,6 @@
<?php
//
// FPDI - Version 1.3.2
// FPDI - Version 1.3.4
//
// Copyright 2004-2010 Setasign - Jan Slabon
//
@ -17,8 +17,7 @@
// limitations under the License.
//
define('FPDI_VERSION','1.3.2');
define('FPDI_VERSION','1.3.4');
/* Begin DOLCHANGE Added by Regis */
// height of cell repect font height
@ -88,9 +87,12 @@ class FPDI extends FPDF_TPL {
*/
var $lastUsedPageBox;
/**
* Cache for imported pages/template ids
* @var array
*/
var $_importedPages = array();
/**
* Set a source-file
*
@ -99,7 +101,7 @@ class FPDI extends FPDF_TPL {
*/
function setSourceFile($filename) {
$this->current_filename = $filename;
$fn =& $this->current_filename;
$fn = $this->current_filename;
if (!isset($this->parsers[$fn]))
$this->parsers[$fn] = new fpdi_pdf_parser($fn, $this);
@ -119,7 +121,7 @@ class FPDI extends FPDF_TPL {
return $this->error('Please import the desired pages before creating a new template.');
}
$fn =& $this->current_filename;
$fn = $this->current_filename;
// check if page already imported
$pageKey = $fn.((int)$pageno).$boxName;
@ -193,6 +195,7 @@ class FPDI extends FPDF_TPL {
if ($adjustPageSize == true && is_null($_x) && is_null($_y)) {
$size = $this->getTemplateSize($tplidx, $_w, $_h);
$format = array($size['w'], $size['h']);
if (!is_subclass_of($this, 'TCPDF')) {
if ($format[0] != $this->CurPageFormat[0] || $format[1] != $this->CurPageFormat[1]) {
$this->w = $format[0];
$this->h = $format[1];
@ -202,6 +205,10 @@ class FPDI extends FPDF_TPL {
$this->CurPageFormat = $format;
$this->PageSizes[$this->page] = array($this->wPt, $this->hPt);
}
} else {
$this->setPageFormat($format, $format[0] > $format[1] ? 'L' : 'P');
}
}
$this->_out('q 0 J 1 w 0 j 0 G 0 g'); // reset standard values

View File

@ -1,6 +1,6 @@
<?php
//
// FPDI - Version 1.3.2
// FPDI - Version 1.3.4
//
// Copyright 2004-2010 Setasign - Jan Slabon
//
@ -51,6 +51,22 @@ class FPDF extends TCPDF {
}
}
function _putstream($s) {
$this->_out($this->_getstream($s));
}
function _getxobjectdict() {
$out = parent::_getxobjectdict();
if (count($this->tpls)) {
foreach($this->tpls as $tplidx => $tpl) {
$out .= sprintf('%s%d %d 0 R', $this->tplprefix, $tplidx, $tpl['n']);
}
}
return $out;
}
/**
* Encryption of imported data by FPDI
*

View File

@ -1,6 +1,6 @@
<?php
//
// FPDI - Version 1.3.2
// FPDI - Version 1.3.4
//
// Copyright 2004-2010 Setasign - Jan Slabon
//
@ -213,6 +213,11 @@ class fpdi_pdf_parser extends pdf_parser {
if (isset($obj[1][1]['/Filter'])) {
$_filter = $obj[1][1]['/Filter'];
if ($_filter[0] == PDF_TYPE_OBJREF) {
$tmpFilter = $this->pdf_resolve_object($this->c, $_filter);
$_filter = $tmpFilter[1];
}
if ($_filter[0] == PDF_TYPE_TOKEN) {
$filters[] = $_filter;
} else if ($_filter[0] == PDF_TYPE_ARRAY) {
@ -225,11 +230,13 @@ class fpdi_pdf_parser extends pdf_parser {
foreach ($filters AS $_filter) {
switch ($_filter[1]) {
case '/FlateDecode':
// $stream .= "\x0F\x0D"; // in an errorious stream this suffix could work
if (function_exists('gzuncompress')) {
$stream = (strlen($stream) > 0) ? @gzuncompress($stream) : '';
} else {
$this->error(sprintf('To handle %s filter, please compile php with zlib support.',$_filter[1]));
}
if ($stream === false) {
$this->error('Error while decompressing stream.');
}

View File

@ -30,20 +30,6 @@ class FPDI_Protection extends FPDI {
var $last_rc4_key_c; //last RC4 computed key
var $padding = "\x28\xBF\x4E\x5E\x4E\x75\x8A\x41\x64\x00\x4E\x56\xFF\xFA\x01\x08\x2E\x2E\x00\xB6\xD0\x68\x3E\x80\x2F\x0C\xA9\xFE\x64\x53\x69\x7A";
// DOL_CHANGE
/*
function FPDI_Protection($orientation='P',$unit='mm',$format='A4')
{
parent::FPDI($orientation,$unit,$format);
$this->_current_obj_id =& $this->current_obj_id; // for FPDI 1.1 compatibility
$this->encrypted=false;
$this->last_rc4_key = '';
$this->padding = "\x28\xBF\x4E\x5E\x4E\x75\x8A\x41\x64\x00\x4E\x56\xFF\xFA\x01\x08".
"\x2E\x2E\x00\xB6\xD0\x68\x3E\x80\x2F\x0C\xA9\xFE\x64\x53\x69\x7A";
}
*/
/**
* Function to set permissions as well as user and owner passwords
*

View File

@ -1,6 +1,6 @@
<?php
//
// FPDI - Version 1.3.2
// FPDI - Version 1.3.4
//
// Copyright 2004-2010 Setasign - Jan Slabon
//

View File

@ -1,6 +1,6 @@
<?php
//
// FPDI - Version 1.3.2
// FPDI - Version 1.3.4
//
// Copyright 2004-2010 Setasign - Jan Slabon
//
@ -87,6 +87,13 @@ if (!call_user_func_array('class_exists', $__tmp)) {
*/
var $pdfVersion;
/**
* For reading encrypted documents and xref/objectstreams are in use
*
* @var boolean
*/
var $readPlain = true;
/**
* Constructor
*
@ -206,8 +213,8 @@ if (!call_user_func_array('class_exists', $__tmp)) {
* @param integer $offset of xref-table
*/
function pdf_read_xref(&$result, $offset) {
fseek($this->f, $o_pos = $offset-20); // set some bytes backwards to fetch errorious docs
$o_pos = $offset-min(20, $offset);
fseek($this->f, $o_pos); // set some bytes backwards to fetch errorious docs
$data = fread($this->f, 100);
@ -542,8 +549,15 @@ if (!call_user_func_array('class_exists', $__tmp)) {
$header = $this->pdf_read_value($c);
if ($header[0] != PDF_TYPE_OBJDEC || $header[1] != $obj_spec[1] || $header[2] != $obj_spec[2]) {
$toSearchFor = $obj_spec[1].' '.$obj_spec[2].' obj';
if (preg_match('/'.$toSearchFor.'/', $c->buffer)) {
$c->offset = strpos($c->buffer, $toSearchFor) + strlen($toSearchFor);
// reset stack
$c->stack = array();
} else {
$this->error("Unable to find object ({$obj_spec[1]}, {$obj_spec[2]}) at expected location");
}
}
// If we're being asked to store all the information
// about the object, we add the object ID and generation

View File

@ -1,70 +0,0 @@
<?php
//
// FPDI - Version 1.2.1
//
// Copyright 2004-2008 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
if (!defined("PHP_VER_LOWER43"))
define("PHP_VER_LOWER43", version_compare(PHP_VERSION, "4.3", "<"));
/**
* ensure that strspn works correct if php-version < 4.3
*/
function _strspn($str1, $str2, $start=null, $length=null) {
$numargs = func_num_args();
if (PHP_VER_LOWER43 == 1) {
if (isset($length)) {
$str1 = substr($str1, $start, $length);
} else {
$str1 = substr($str1, $start);
}
}
if ($numargs == 2 || PHP_VER_LOWER43 == 1) {
return strspn($str1, $str2);
} else if ($numargs == 3) {
return strspn($str1, $str2, $start);
} else {
return strspn($str1, $str2, $start, $length);
}
}
/**
* ensure that strcspn works correct if php-version < 4.3
*/
function _strcspn($str1, $str2, $start=null, $length=null) {
$numargs = func_num_args();
if (PHP_VER_LOWER43 == 1) {
if (isset($length)) {
$str1 = substr($str1, $start, $length);
} else {
$str1 = substr($str1, $start);
}
}
if ($numargs == 2 || PHP_VER_LOWER43 == 1) {
return strcspn($str1, $str2);
} else if ($numargs == 3) {
return strcspn($str1, $str2, $start);
} else {
return strcspn($str1, $str2, $start, $length);
}
}