diff --git a/htdocs/admin/fournisseur.php b/htdocs/admin/fournisseur.php index 3b6047e5330c4522ddc00554038e0cae48b8fda0..a7a431d6cda4311224f19875aaf7e7cd9080252b 100644 --- a/htdocs/admin/fournisseur.php +++ b/htdocs/admin/fournisseur.php @@ -25,7 +25,7 @@ * \file htdocs/admin/fournisseur.php * \ingroup fournisseur * \brief Page d'administration-configuration du module Fournisseur - * \version $Id: fournisseur.php,v 1.63 2011/07/31 22:23:21 eldy Exp $ + * \version $Id: fournisseur.php,v 1.64 2011/08/11 12:14:02 eldy Exp $ */ require("../main.inc.php"); @@ -109,10 +109,11 @@ if ($action == 'specimenfacture') // For invoices // Charge le modele $dir = "/includes/modules/supplier_invoice/pdf/"; $file = "pdf_".$modele.".modules.php"; - if (file_exists($dir.$file)) + $file = dol_buildpath($dir.$file); + if (file_exists($file)) { $classname = "pdf_".$modele; - require_once($dir.$file); + require_once($file); $obj = new $classname($db,$facture); @@ -499,6 +500,7 @@ else dol_print_error($db); } + print '<table class="noborder" width="100%">'."\n"; print '<tr class="liste_titre">'."\n"; print '<td width="100">'.$langs->trans("Name").'</td>'."\n"; @@ -617,5 +619,5 @@ print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">' print "</td></tr>\n"; print '</form>'; -llxFooter('$Date: 2011/07/31 22:23:21 $ - $Revision: 1.63 $'); +llxFooter('$Date: 2011/08/11 12:14:02 $ - $Revision: 1.64 $'); ?> diff --git a/htdocs/compta/facture/impayees.php b/htdocs/compta/facture/impayees.php index 26257a0549227c227cce5cdf6b45098d0a550af1..45f161fe22b5458eb1dc4b54b33eedf4014d6b75 100644 --- a/htdocs/compta/facture/impayees.php +++ b/htdocs/compta/facture/impayees.php @@ -22,7 +22,7 @@ * \file htdocs/compta/facture/impayees.php * \ingroup facture * \brief Page to list and build liste of unpaid invoices - * \version $Revision: 1.85 $ + * \version $Revision: 1.86 $ */ require("../../main.inc.php"); @@ -30,6 +30,7 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"); require_once(DOL_DOCUMENT_ROOT."/compta/paiement/class/paiement.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); +require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php'); $langs->load("bills"); @@ -52,9 +53,6 @@ if ($_POST["action"] == "builddoc" && $user->rights->facture->lire) { if (is_array($_POST['toGenerate'])) { - require_once(FPDFI_PATH.'fpdi.php'); - require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php'); - $factures = dol_dir_list($conf->facture->dir_output,'all',1,implode('\.pdf|',$_POST['toGenerate']).'\.pdf','\.meta$|\.png','date',SORT_DESC) ; // liste les fichiers @@ -68,22 +66,27 @@ if ($_POST["action"] == "builddoc" && $user->rights->facture->lire) } } - // Create empty PDF - $pdf=new FPDI('P','mm','A4'); - if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); - - if (class_exists('TCPDF')) - { - $pdf->setPrintHeader(false); - $pdf->setPrintFooter(false); - } - //$pdf->SetFont(pdf_getPDFFont($outputlangs)); - - //$pdf->Open(); - //$pdf->AddPage(); - //$title=$langs->trans("BillsCustomersUnpaid"); - //if ($option=='late') $title=$langs->trans("BillsCustomersUnpaid"); - //$pdf->MultiCell(100, 3, $title, 0, 'J'); + // Define output language (Here it is not used because we do only merging existing PDF) + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + + // Create empty PDF + $pdf=pdf_getInstance(); + if (class_exists('TCPDF')) + { + $pdf->setPrintHeader(false); + $pdf->setPrintFooter(false); + } + $pdf->SetFont(pdf_getPDFFont($outputlangs)); + + if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); // Add all others foreach($files as $file) @@ -424,5 +427,5 @@ if ($result) $db->close(); -llxFooter('$Date: 2011/08/10 23:21:13 $ - $Revision: 1.85 $'); +llxFooter('$Date: 2011/08/11 12:14:03 $ - $Revision: 1.86 $'); ?> diff --git a/htdocs/includes/fpdf/fpdfi/README.txt b/htdocs/includes/fpdf/fpdfi/README.txt index b1c69409786717270bbf1b8b3bb833128a4426c3..dc09ef070ca20df6d3a8c405e880ee9e736f4a17 100644 --- a/htdocs/includes/fpdf/fpdfi/README.txt +++ b/htdocs/includes/fpdf/fpdfi/README.txt @@ -1,5 +1,4 @@ This directory contains all FPDFI librairies: - FPDI - FPDI_TPL -- FPDI_Protection Found on http://www.setasign.de/products/pdf-php-solutions/fpdi/ diff --git a/htdocs/includes/fpdf/fpdfi/filters/FilterASCII85.php b/htdocs/includes/fpdf/fpdfi/filters/FilterASCII85.php index 116edd3b1f410737bd204096c30f2c1b181b84ac..092f3299b6425f0464fcc3c037245e597e5fe752 100644 --- a/htdocs/includes/fpdf/fpdfi/filters/FilterASCII85.php +++ b/htdocs/includes/fpdf/fpdfi/filters/FilterASCII85.php @@ -1,8 +1,8 @@ <?php // -// FPDI - Version 1.3.4 +// FPDI - Version 1.4.1 // -// Copyright 2004-2010 Setasign - Jan Slabon +// Copyright 2004-2011 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. @@ -26,8 +26,7 @@ if (!defined('ORD_u')) if (!defined('ORD_tilde')) define('ORD_tilde', ord('~')); -$__tmp = version_compare(phpversion(), "5") == -1 ? array('FilterASCII85') : array('FilterASCII85', false); -if (!call_user_func_array('class_exists', $__tmp)) { +if (!class_exists('FilterASCII85', false)) { class FilterASCII85 { @@ -100,5 +99,3 @@ if (!call_user_func_array('class_exists', $__tmp)) { } } } - -unset($__tmp); \ No newline at end of file diff --git a/htdocs/includes/fpdf/fpdfi/filters/FilterASCII85_FPDI.php b/htdocs/includes/fpdf/fpdfi/filters/FilterASCII85_FPDI.php index 2b5ccfe26329d6937173d8b66a436b6767b4beb3..706e032f66a2334ba5e883f1d05c10376a421278 100644 --- a/htdocs/includes/fpdf/fpdfi/filters/FilterASCII85_FPDI.php +++ b/htdocs/includes/fpdf/fpdfi/filters/FilterASCII85_FPDI.php @@ -1,33 +1,33 @@ -<?php -// -// FPDI - Version 1.3.4 -// -// Copyright 2004-2010 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. -// - -require_once('FilterASCII85.php'); - -class FilterASCII85_FPDI extends FilterASCII85 { - - var $fpdi; - - function FilterASCII85_FPDI(&$fpdi) { - $this->fpdi =& $fpdi; - } - - function error($msg) { - $this->fpdi->error($msg); - } +<?php +// +// FPDI - Version 1.4.1 +// +// Copyright 2004-2011 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. +// + +require_once('FilterASCII85.php'); + +class FilterASCII85_FPDI extends FilterASCII85 { + + var $fpdi; + + function FilterASCII85_FPDI(&$fpdi) { + $this->fpdi =& $fpdi; + } + + function error($msg) { + $this->fpdi->error($msg); + } } \ No newline at end of file diff --git a/htdocs/includes/fpdf/fpdfi/filters/FilterLZW.php b/htdocs/includes/fpdf/fpdfi/filters/FilterLZW.php index 4b8dd8edec958a4d87682c531aedbd7d75bb7c60..76d303d3803ec856aedb410b2ca9d25fbc1023a3 100644 --- a/htdocs/includes/fpdf/fpdfi/filters/FilterLZW.php +++ b/htdocs/includes/fpdf/fpdfi/filters/FilterLZW.php @@ -1,8 +1,8 @@ <?php // -// FPDI - Version 1.3.4 +// FPDI - Version 1.4.1 // -// Copyright 2004-2010 Setasign - Jan Slabon +// Copyright 2004-2011 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. @@ -17,8 +17,7 @@ // limitations under the License. // -$__tmp = version_compare(phpversion(), "5") == -1 ? array('FilterLZW') : array('FilterLZW', false); -if (!call_user_func_array('class_exists', $__tmp)) { +if (!class_exists('FilterLZW', false)) { class FilterLZW { @@ -156,5 +155,3 @@ if (!call_user_func_array('class_exists', $__tmp)) { } } } - -unset($__tmp); \ No newline at end of file diff --git a/htdocs/includes/fpdf/fpdfi/filters/FilterLZW_FPDI.php b/htdocs/includes/fpdf/fpdfi/filters/FilterLZW_FPDI.php index 90e9cdd0d4994a382f8d030a0e99414d0e87d79d..d9bae438c8a69335e123e56d019c71bacf367cfa 100644 --- a/htdocs/includes/fpdf/fpdfi/filters/FilterLZW_FPDI.php +++ b/htdocs/includes/fpdf/fpdfi/filters/FilterLZW_FPDI.php @@ -1,33 +1,33 @@ -<?php -// -// FPDI - Version 1.3.4 -// -// Copyright 2004-2010 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. -// - -require_once('FilterLZW.php'); - -class FilterLZW_FPDI extends FilterLZW { - - var $fpdi; - - function FilterLZW_FPDI(&$fpdi) { - $this->fpdi =& $fpdi; - } - - function error($msg) { - $this->fpdi->error($msg); - } +<?php +// +// FPDI - Version 1.4.1 +// +// Copyright 2004-2011 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. +// + +require_once('FilterLZW.php'); + +class FilterLZW_FPDI extends FilterLZW { + + var $fpdi; + + function FilterLZW_FPDI(&$fpdi) { + $this->fpdi =& $fpdi; + } + + function error($msg) { + $this->fpdi->error($msg); + } } \ No newline at end of file diff --git a/htdocs/includes/fpdf/fpdfi/fpdf_tpl.php b/htdocs/includes/fpdf/fpdfi/fpdf_tpl.php index af5f704b14d93323d68b92335d99b549e9df95e8..d21743e63742c7f834ec722378d0edb2afb09508 100644 --- a/htdocs/includes/fpdf/fpdfi/fpdf_tpl.php +++ b/htdocs/includes/fpdf/fpdfi/fpdf_tpl.php @@ -1,415 +1,449 @@ -<?php -// -// FPDF_TPL - Version 1.1.5 -// -// Copyright 2004-2010 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. -// - -class FPDF_TPL extends FPDF { - /** - * Array of Tpl-Data - * @var array - */ - var $tpls = array(); - - /** - * Current Template-ID - * @var int - */ - var $tpl = 0; - - /** - * "In Template"-Flag - * @var boolean - */ - var $_intpl = false; - - /** - * 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 $tplprefix = "/TPL"; - - /** - * Resources used By Templates and Pages - * @var array - */ - var $_res = array(); - - /** - * Last used Template data - * - * @var array - */ - var $lastUsedTemplateData = array(); - - /** - * Start a Template - * - * 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. - * 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. - * - * 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. - * 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 $y The y-coordinate given in user-unit - * @param int $w The width given in user-unit - * @param int $h The height given in user-unit - * @return int The ID of new created Template - */ - function beginTemplate($x=null, $y=null, $w=null, $h=null) { - if ($this->page <= 0) - $this->error("You have to add a page to fpdf first!"); - - if ($x == null) - $x = 0; - if ($y == null) - $y = 0; - if ($w == null) - $w = $this->w; - if ($h == null) - $h = $this->h; - - // Save settings - $this->tpl++; - $tpl =& $this->tpls[$this->tpl]; - $tpl = array( - 'o_x' => $this->x, - 'o_y' => $this->y, - 'o_AutoPageBreak' => $this->AutoPageBreak, - 'o_bMargin' => $this->bMargin, - 'o_tMargin' => $this->tMargin, - 'o_lMargin' => $this->lMargin, - 'o_rMargin' => $this->rMargin, - 'o_h' => $this->h, - 'o_w' => $this->w, - 'buffer' => '', - 'x' => $x, - 'y' => $y, - 'w' => $w, - 'h' => $h - ); - - $this->SetAutoPageBreak(false); - - // Define own high and width to calculate possitions correct - $this->h = $h; - $this->w = $w; - - $this->_intpl = true; - $this->SetXY($x+$this->lMargin, $y+$this->tMargin); - $this->SetRightMargin($this->w-$w+$this->rMargin); - - return $this->tpl; - } - - /** - * End Template - * - * 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. - */ - function endTemplate() { - if ($this->_intpl) { - $this->_intpl = false; - $tpl =& $this->tpls[$this->tpl]; - $this->SetXY($tpl['o_x'], $tpl['o_y']); - $this->tMargin = $tpl['o_tMargin']; - $this->lMargin = $tpl['o_lMargin']; - $this->rMargin = $tpl['o_rMargin']; - $this->h = $tpl['o_h']; - $this->w = $tpl['o_w']; - $this->SetAutoPageBreak($tpl['o_AutoPageBreak'], $tpl['o_bMargin']); - - return $this->tpl; - } else { - return false; - } - } - - /** - * Use a Template in current Page or other 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. - * 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 - * beginTemplate() is used. - * The calculated or used width and height are returned as an array. - * - * @param int $tplidx A valid template-Id - * @param int $_x The x-position - * @param int $_y The y-position - * @param int $_w The new width of the template - * @param int $_h The new height of the template - * @retrun array The height and width of the template - */ - function useTemplate($tplidx, $_x=null, $_y=null, $_w=0, $_h=0) { - if ($this->page <= 0) - $this->error("You have to add a page to fpdf first!"); - - if (!isset($this->tpls[$tplidx])) - $this->error("Template does not exist!"); - - if ($this->_intpl) { - $this->_res['tpl'][$this->tpl]['tpls'][$tplidx] =& $this->tpls[$tplidx]; - } - - $tpl =& $this->tpls[$tplidx]; - $w = $tpl['w']; - $h = $tpl['h']; - - if ($_x == null) - $_x = 0; - if ($_y == null) - $_y = 0; - - $_x += $tpl['x']; - $_y += $tpl['y']; - - $wh = $this->getTemplateSize($tplidx, $_w, $_h); - $_w = $wh['w']; - $_h = $wh['h']; - - $tData = array( - 'x' => $this->x, - 'y' => $this->y, - 'w' => $_w, - 'h' => $_h, - 'scaleX' => ($_w/$w), - 'scaleY' => ($_h/$h), - 'tx' => $_x, - 'ty' => ($this->h-$_y-$_h), - 'lty' => ($this->h-$_y-$_h) - ($this->h-$h) * ($_h/$h) - ); - - $this->_out(sprintf("q %.4F 0 0 %.4F %.4F %.4F cm", $tData['scaleX'], $tData['scaleY'], $tData['tx']*$this->k, $tData['ty']*$this->k)); // Translate - $this->_out(sprintf('%s%d Do Q', $this->tplprefix, $tplidx)); - - $this->lastUsedTemplateData = $tData; - - return array("w" => $_w, "h" => $_h); - } - - /** - * Get The calculated Size of a Template - * - * If one size is given, this method calculates the other one. - * - * @param int $tplidx A valid template-Id - * @param int $_w The width of the template - * @param int $_h The height of the template - * @return array The height and width of the template - */ - function getTemplateSize($tplidx, $_w=0, $_h=0) { - if (!$this->tpls[$tplidx]) - return false; - - $tpl =& $this->tpls[$tplidx]; - $w = $tpl['w']; - $h = $tpl['h']; - - if ($_w == 0 and $_h == 0) { - $_w = $w; - $_h = $h; - } - - if($_w==0) - $_w = $_h*$w/$h; - if($_h==0) - $_h = $_w*$h/$w; - - return array("w" => $_w, "h" => $_h); - } - - /** - * See FPDF/TCPDF-Documentation ;-) - */ - function SetFont($family, $style='', $size=0, $fontfile='') { - if (!is_subclass_of($this, 'TCPDF') && func_num_args() > 3) { - $this->Error('More than 3 arguments for the SetFont method are only available in TCPDF.'); - } - /** - * force the resetting of font changes in a template - */ - if ($this->_intpl) - $this->FontFamily = ''; - - parent::SetFont($family, $style, $size, $fontfile); - - $fontkey = $this->FontFamily.$this->FontStyle; - - if ($this->_intpl) { - $this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey]; - } else { - $this->_res['page'][$this->page]['fonts'][$fontkey] =& $this->fonts[$fontkey]; - } - } - - /** - * 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, $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.'); - } - - $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; - } - - /** - * See FPDF-Documentation ;-) - * - * AddPage is not available when you're "in" a template. - */ - 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, $keepmargins); - } - - /** - * Preserve adding Links in Templates ...won't work - */ - function Link($x, $y, $w, $h, $link, $spaces=0) { - if (!is_subclass_of($this, 'TCPDF') && func_num_args() > 5) { - $this->Error('More than 5 arguments for the Image method are only available in TCPDF.'); - } - - if ($this->_intpl) - $this->Error('Using links in templates aren\'t possible!'); - parent::Link($x, $y, $w, $h, $link, $spaces); - } - - function AddLink() { - if ($this->_intpl) - $this->Error('Adding links in templates aren\'t possible!'); - return parent::AddLink(); - } - - function SetLink($link, $y=0, $page=-1) { - if ($this->_intpl) - $this->Error('Setting links in templates aren\'t possible!'); - parent::SetLink($link, $y, $page); - } - - /** - * Private Method that writes the form xobjects - */ - function _putformxobjects() { - $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; - reset($this->tpls); - foreach($this->tpls AS $tplidx => $tpl) { - - $p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer']; - $this->_newobj(); - $this->tpls[$tplidx]['n'] = $this->n; - $this->_out('<<'.$filter.'/Type /XObject'); - $this->_out('/Subtype /Form'); - $this->_out('/FormType 1'); - $this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]', - // llx - $tpl['x']*$this->k, - // lly - -$tpl['y']*$this->k, - // urx - ($tpl['w']+$tpl['x'])*$this->k, - // ury - ($tpl['h']-$tpl['y'])*$this->k - )); - - if ($tpl['x'] != 0 || $tpl['y'] != 0) { - $this->_out(sprintf('/Matrix [1 0 0 1 %.5F %.5F]', - -$tpl['x']*$this->k*2, $tpl['y']*$this->k*2 - )); - } - - $this->_out('/Resources '); - - $this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]'); - if (isset($this->_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) { - $this->_out('/Font <<'); - foreach($this->_res['tpl'][$tplidx]['fonts'] as $font) - $this->_out('/F'.$font['i'].' '.$font['n'].' 0 R'); - $this->_out('>>'); - } - if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) || - isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) - { - $this->_out('/XObject <<'); - if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) { - foreach($this->_res['tpl'][$tplidx]['images'] as $image) - $this->_out('/I'.$image['i'].' '.$image['n'].' 0 R'); - } - if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) { - foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl) - $this->_out($this->tplprefix.$i.' '.$tpl['n'].' 0 R'); - } - $this->_out('>>'); - } - $this->_out('>>'); - - $this->_out('/Length '.strlen($p).' >>'); - $this->_putstream($p); - $this->_out('endobj'); - } - } - - /** - * Overwritten to add _putformxobjects() after _putimages() - * - */ - function _putimages() { - parent::_putimages(); - $this->_putformxobjects(); - } - - function _putxobjectdict() { - parent::_putxobjectdict(); - - if (count($this->tpls)) { - foreach($this->tpls as $tplidx => $tpl) { - $this->_out(sprintf('%s%d %d 0 R', $this->tplprefix, $tplidx, $tpl['n'])); - } - } - } - - /** - * Private Method - */ - function _out($s) { - if ($this->state==2 && $this->_intpl) { - $this->tpls[$this->tpl]['buffer'] .= $s."\n"; - } else { - parent::_out($s); - } - } -} +<?php +// +// FPDF_TPL - Version 1.2 +// +// Copyright 2004-2010 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. +// + +class FPDF_TPL extends FPDF { + /** + * Array of Tpl-Data + * @var array + */ + var $tpls = array(); + + /** + * Current Template-ID + * @var int + */ + var $tpl = 0; + + /** + * "In Template"-Flag + * @var boolean + */ + var $_intpl = false; + + /** + * 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 $tplprefix = "/TPL"; + + /** + * Resources used By Templates and Pages + * @var array + */ + var $_res = array(); + + /** + * Last used Template data + * + * @var array + */ + var $lastUsedTemplateData = array(); + + /** + * Start a Template + * + * 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. + * 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. + * + * 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. + * 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 $y The y-coordinate given in user-unit + * @param int $w The width given in user-unit + * @param int $h The height given in user-unit + * @return int The ID of new created Template + */ + function beginTemplate($x = null, $y = null, $w = null, $h = null) { + if (is_subclass_of($this, 'TCPDF')) { + $this->Error('This method is only usable with FPDF. Use TCPDF methods startTemplate() instead.'); + return; + } + + if ($this->page <= 0) + $this->error("You have to add a page to fpdf first!"); + + if ($x == null) + $x = 0; + if ($y == null) + $y = 0; + if ($w == null) + $w = $this->w; + if ($h == null) + $h = $this->h; + + // Save settings + $this->tpl++; + $tpl =& $this->tpls[$this->tpl]; + $tpl = array( + 'o_x' => $this->x, + 'o_y' => $this->y, + 'o_AutoPageBreak' => $this->AutoPageBreak, + 'o_bMargin' => $this->bMargin, + 'o_tMargin' => $this->tMargin, + 'o_lMargin' => $this->lMargin, + 'o_rMargin' => $this->rMargin, + 'o_h' => $this->h, + 'o_w' => $this->w, + 'buffer' => '', + 'x' => $x, + 'y' => $y, + 'w' => $w, + 'h' => $h + ); + + $this->SetAutoPageBreak(false); + + // Define own high and width to calculate possitions correct + $this->h = $h; + $this->w = $w; + + $this->_intpl = true; + $this->SetXY($x + $this->lMargin, $y + $this->tMargin); + $this->SetRightMargin($this->w - $w + $this->rMargin); + + return $this->tpl; + } + + /** + * End Template + * + * 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. + */ + function endTemplate() { + if (is_subclass_of($this, 'TCPDF')) { + $args = func_get_args(); + return call_user_func_array(array($this, 'TCPDF::endTemplate'), $args); + } + + if ($this->_intpl) { + $this->_intpl = false; + $tpl =& $this->tpls[$this->tpl]; + $this->SetXY($tpl['o_x'], $tpl['o_y']); + $this->tMargin = $tpl['o_tMargin']; + $this->lMargin = $tpl['o_lMargin']; + $this->rMargin = $tpl['o_rMargin']; + $this->h = $tpl['o_h']; + $this->w = $tpl['o_w']; + $this->SetAutoPageBreak($tpl['o_AutoPageBreak'], $tpl['o_bMargin']); + + return $this->tpl; + } else { + return false; + } + } + + /** + * Use a Template in current Page or other 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. + * 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 + * beginTemplate() is used. + * The calculated or used width and height are returned as an array. + * + * @param int $tplidx A valid template-Id + * @param int $_x The x-position + * @param int $_y The y-position + * @param int $_w The new width of the template + * @param int $_h The new height of the template + * @retrun array The height and width of the template + */ + function useTemplate($tplidx, $_x = null, $_y = null, $_w = 0, $_h = 0) { + if ($this->page <= 0) + $this->error('You have to add a page first!'); + + if (!isset($this->tpls[$tplidx])) + $this->error('Template does not exist!'); + + if ($this->_intpl) { + $this->_res['tpl'][$this->tpl]['tpls'][$tplidx] =& $this->tpls[$tplidx]; + } + + $tpl =& $this->tpls[$tplidx]; + $w = $tpl['w']; + $h = $tpl['h']; + + if ($_x == null) + $_x = 0; + if ($_y == null) + $_y = 0; + + $_x += $tpl['x']; + $_y += $tpl['y']; + + $wh = $this->getTemplateSize($tplidx, $_w, $_h); + $_w = $wh['w']; + $_h = $wh['h']; + + $tData = array( + 'x' => $this->x, + 'y' => $this->y, + 'w' => $_w, + 'h' => $_h, + 'scaleX' => ($_w / $w), + 'scaleY' => ($_h / $h), + 'tx' => $_x, + 'ty' => ($this->h - $_y - $_h), + 'lty' => ($this->h - $_y - $_h) - ($this->h - $h) * ($_h / $h) + ); + + $this->_out(sprintf('q %.4F 0 0 %.4F %.4F %.4F cm', $tData['scaleX'], $tData['scaleY'], $tData['tx'] * $this->k, $tData['ty'] * $this->k)); // Translate + $this->_out(sprintf('%s%d Do Q', $this->tplprefix, $tplidx)); + + // reset font in the outer graphic state + if ($this->FontFamily) { + $family = $this->FontFamily; + $this->FontFamily = ''; + $this->SetFont($family); + } + + $this->lastUsedTemplateData = $tData; + + return array('w' => $_w, 'h' => $_h); + } + + /** + * Get The calculated Size of a Template + * + * If one size is given, this method calculates the other one. + * + * @param int $tplidx A valid template-Id + * @param int $_w The width of the template + * @param int $_h The height of the template + * @return array The height and width of the template + */ + function getTemplateSize($tplidx, $_w = 0, $_h = 0) { + if (!$this->tpls[$tplidx]) + return false; + + $tpl =& $this->tpls[$tplidx]; + $w = $tpl['w']; + $h = $tpl['h']; + + if ($_w == 0 and $_h == 0) { + $_w = $w; + $_h = $h; + } + + if($_w == 0) + $_w = $_h * $w / $h; + if($_h == 0) + $_h = $_w * $h / $w; + + return array("w" => $_w, "h" => $_h); + } + + /** + * See FPDF/TCPDF-Documentation ;-) + */ + public function SetFont($family, $style = '', $size = 0) { + if (is_subclass_of($this, 'TCPDF')) { + $args = func_get_args(); + return call_user_func_array(array($this, 'TCPDF::SetFont'), $args); + } + + /** + * force the resetting of font changes in a template + */ + if ($this->_intpl) + $this->FontFamily = ''; + + parent::SetFont($family, $style, $size); + + $fontkey = $this->FontFamily . $this->FontStyle; + + if ($this->_intpl) { + $this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey]; + } else { + $this->_res['page'][$this->page]['fonts'][$fontkey] =& $this->fonts[$fontkey]; + } + } + + /** + * See FPDF/TCPDF-Documentation ;-) + */ + function Image($file, $x = null, $y = null, $w = 0, $h = 0, $type = '', $link = '') { + if (is_subclass_of($this, 'TCPDF')) { + $args = func_get_args(); + return call_user_func_array(array($this, 'TCPDF::Image'), $args); + } + + $ret = parent::Image($file, $x, $y, $w, $h, $type, $link); + 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; + } + + /** + * See FPDF-Documentation ;-) + * + * AddPage is not available when you're "in" a template. + */ + function AddPage($orientation = '', $format = '') { + if (is_subclass_of($this, 'TCPDF')) { + $args = func_get_args(); + return call_user_func_array(array($this, 'TCPDF::AddPage'), $args); + } + + if ($this->_intpl) + $this->Error('Adding pages in templates isn\'t possible!'); + + parent::AddPage($orientation, $format); + } + + /** + * Preserve adding Links in Templates ...won't work + */ + function Link($x, $y, $w, $h, $link) { + if (is_subclass_of($this, 'TCPDF')) { + $args = func_get_args(); + return call_user_func_array(array($this, 'TCPDF::Link'), $args); + } + + if ($this->_intpl) + $this->Error('Using links in templates aren\'t possible!'); + + parent::Link($x, $y, $w, $h, $link); + } + + function AddLink() { + if (is_subclass_of($this, 'TCPDF')) { + $args = func_get_args(); + return call_user_func_array(array($this, 'TCPDF::AddLink'), $args); + } + + if ($this->_intpl) + $this->Error('Adding links in templates aren\'t possible!'); + return parent::AddLink(); + } + + function SetLink($link, $y = 0, $page = -1) { + if (is_subclass_of($this, 'TCPDF')) { + $args = func_get_args(); + return call_user_func_array(array($this, 'TCPDF::SetLink'), $args); + } + + if ($this->_intpl) + $this->Error('Setting links in templates aren\'t possible!'); + parent::SetLink($link, $y, $page); + } + + /** + * Private Method that writes the form xobjects + */ + function _putformxobjects() { + $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; + reset($this->tpls); + foreach($this->tpls AS $tplidx => $tpl) { + + $p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer']; + $this->_newobj(); + $this->tpls[$tplidx]['n'] = $this->n; + $this->_out('<<'.$filter.'/Type /XObject'); + $this->_out('/Subtype /Form'); + $this->_out('/FormType 1'); + $this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]', + // llx + $tpl['x'] * $this->k, + // lly + -$tpl['y'] * $this->k, + // urx + ($tpl['w'] + $tpl['x']) * $this->k, + // ury + ($tpl['h'] - $tpl['y']) * $this->k + )); + + if ($tpl['x'] != 0 || $tpl['y'] != 0) { + $this->_out(sprintf('/Matrix [1 0 0 1 %.5F %.5F]', + -$tpl['x'] * $this->k * 2, $tpl['y'] * $this->k * 2 + )); + } + + $this->_out('/Resources '); + + $this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]'); + if (isset($this->_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) { + $this->_out('/Font <<'); + foreach($this->_res['tpl'][$tplidx]['fonts'] as $font) + $this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R'); + $this->_out('>>'); + } + if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) || + isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) + { + $this->_out('/XObject <<'); + if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) { + foreach($this->_res['tpl'][$tplidx]['images'] as $image) + $this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R'); + } + if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) { + foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl) + $this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R'); + } + $this->_out('>>'); + } + $this->_out('>>'); + + $this->_out('/Length ' . strlen($p) . ' >>'); + $this->_putstream($p); + $this->_out('endobj'); + } + } + + /** + * Overwritten to add _putformxobjects() after _putimages() + * + */ + function _putimages() { + parent::_putimages(); + $this->_putformxobjects(); + } + + function _putxobjectdict() { + parent::_putxobjectdict(); + + if (count($this->tpls)) { + foreach($this->tpls as $tplidx => $tpl) { + $this->_out(sprintf('%s%d %d 0 R', $this->tplprefix, $tplidx, $tpl['n'])); + } + } + } + + /** + * Private Method + */ + function _out($s) { + if ($this->state == 2 && $this->_intpl) { + $this->tpls[$this->tpl]['buffer'] .= $s . "\n"; + } else { + parent::_out($s); + } + } +} diff --git a/htdocs/includes/fpdf/fpdfi/fpdi.php b/htdocs/includes/fpdf/fpdfi/fpdi.php index 4d732b9f27462fe609ecc08b24ccc04c829bd2e7..e4ebb0c3241d74b19326e0f593575fe5f96b46ee 100644 --- a/htdocs/includes/fpdf/fpdfi/fpdi.php +++ b/htdocs/includes/fpdf/fpdfi/fpdi.php @@ -1,527 +1,542 @@ -<?php -// -// FPDI - Version 1.3.4 -// -// Copyright 2004-2010 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. -// - -define('FPDI_VERSION','1.3.4'); - -/* Begin DOLCHANGE Added by Regis */ -// height of cell repect font height -define("K_CELL_HEIGHT_RATIO", 1.25); -// Repertoire des documents de fckeditor -if (! empty($conf->fckeditor->dir_output)) define ("K_PATH_CACHE", $conf->fckeditor->dir_output); -// url qui sera substituer par le K_PATH_CACHE lorsqu'une image sera integree au pdf -if (defined('DOL_URL_ROOT')) define ("K_PATH_URL_CACHE", DOL_URL_ROOT."/document.php?modulepart=editor&file="); -/* End DOLCHANGE Added by Regis */ - -// DOLCHANGE LDR -if (! empty($conf->global->MAIN_USE_FPDF)) require_once(DOL_DOCUMENT_ROOT.'/includes/fpdf/fpdf/fpdf.php'); -else require_once(DOL_DOCUMENT_ROOT.'/includes/tcpdf/tcpdf.php'); -//require_once(DOL_DOCUMENT_ROOT.'/includes/tcpdf/tcpdf.php'); - - -// Check for TCPDF and remap TCPDF to FPDF -$__tmp = version_compare(phpversion(), "5") == -1 ? array('TCPDF') : array('TCPDF', false); -if (call_user_func_array('class_exists', $__tmp)) { - require_once('fpdi2tcpdf_bridge.php'); -} -unset($__tmp); - -require_once('fpdf_tpl.php'); -require_once('fpdi_pdf_parser.php'); - - -class FPDI extends FPDF_TPL { - /** - * Actual filename - * @var string - */ - var $current_filename; - - /** - * Parser-Objects - * @var array - */ - var $parsers; - - /** - * Current parser - * @var object - */ - var $current_parser; - - /** - * object stack - * @var array - */ - var $_obj_stack; - - /** - * done object stack - * @var array - */ - var $_don_obj_stack; - - /** - * Current Object Id. - * @var integer - */ - var $_current_obj_id; - - /** - * The name of the last imported page box - * @var string - */ - var $lastUsedPageBox; - - /** - * Cache for imported pages/template ids - * @var array - */ - var $_importedPages = array(); - - /** - * Set a source-file - * - * @param string $filename a valid filename - * @return int number of available pages - */ - function setSourceFile($filename) { - $this->current_filename = $filename; - $fn = $this->current_filename; - - if (!isset($this->parsers[$fn])) - $this->parsers[$fn] = new fpdi_pdf_parser($fn, $this); - $this->current_parser =& $this->parsers[$fn]; - - return $this->parsers[$fn]->getPageCount(); - } - - /** - * Import a page - * - * @param int $pageno pagenumber - * @return int Index of imported page - to use with fpdf_tpl::useTemplate() - */ - function importPage($pageno, $boxName='/CropBox') { - if ($this->_intpl) { - return $this->error('Please import the desired pages before creating a new template.'); - } - - $fn = $this->current_filename; - - // check if page already imported - $pageKey = $fn.((int)$pageno).$boxName; - if (isset($this->_importedPages[$pageKey])) - return $this->_importedPages[$pageKey]; - - $parser =& $this->parsers[$fn]; - $parser->setPageno($pageno); - - if (!in_array($boxName, $parser->availableBoxes)) - return $this->Error(sprintf('Unknown box: %s', $boxName)); - $pageboxes = $parser->getPageBoxes($pageno); - - /** - * MediaBox - * CropBox: Default -> MediaBox - * BleedBox: Default -> CropBox - * TrimBox: Default -> CropBox - * ArtBox: Default -> CropBox - */ - if (!isset($pageboxes[$boxName]) && ($boxName == '/BleedBox' || $boxName == '/TrimBox' || $boxName == '/ArtBox')) - $boxName = '/CropBox'; - if (!isset($pageboxes[$boxName]) && $boxName == '/CropBox') - $boxName = '/MediaBox'; - - if (!isset($pageboxes[$boxName])) - return false; - $this->lastUsedPageBox = $boxName; - - $box = $pageboxes[$boxName]; - - $this->tpl++; - $this->tpls[$this->tpl] = array(); - $tpl =& $this->tpls[$this->tpl]; - $tpl['parser'] =& $parser; - $tpl['resources'] = $parser->getPageResources(); - $tpl['buffer'] = $parser->getContent(); - $tpl['box'] = $box; - - // To build an array that can be used by PDF_TPL::useTemplate() - $this->tpls[$this->tpl] = array_merge($this->tpls[$this->tpl], $box); - - // An imported page will start at 0,0 everytime. Translation will be set in _putformxobjects() - $tpl['x'] = 0; - $tpl['y'] = 0; - - // handle rotated pages - $rotation = $parser->getPageRotation($pageno); - $tpl['_rotationAngle'] = 0; - if (isset($rotation[1]) && ($angle = $rotation[1] % 360) != 0) { - $steps = $angle / 90; - - $_w = $tpl['w']; - $_h = $tpl['h']; - $tpl['w'] = $steps % 2 == 0 ? $_w : $_h; - $tpl['h'] = $steps % 2 == 0 ? $_h : $_w; - - $tpl['_rotationAngle'] = $angle*-1; - } - - $this->_importedPages[$pageKey] = $this->tpl; - - return $this->tpl; - } - - function getLastUsedPageBox() { - return $this->lastUsedPageBox; - } - - function useTemplate($tplidx, $_x=null, $_y=null, $_w=0, $_h=0, $adjustPageSize=false) { - 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]; - $this->wPt = $this->w*$this->k; - $this->hPt = $this->h*$this->k; - $this->PageBreakTrigger = $this->h-$this->bMargin; - $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 - $s = parent::useTemplate($tplidx, $_x, $_y, $_w, $_h); - $this->_out('Q'); - return $s; - } - - /** - * Private method, that rebuilds all needed objects of source files - */ - function _putimportedobjects() { - if (is_array($this->parsers) && count($this->parsers) > 0) { - foreach($this->parsers AS $filename => $p) { - $this->current_parser =& $this->parsers[$filename]; - if (isset($this->_obj_stack[$filename]) && is_array($this->_obj_stack[$filename])) { - while(($n = key($this->_obj_stack[$filename])) !== null) { - $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]); - - if ($nObj[0] == PDF_TYPE_STREAM) { - $this->pdf_write_value ($nObj); - } else { - $this->pdf_write_value ($nObj[1]); - } - - $this->_out('endobj'); - $this->_obj_stack[$filename][$n] = null; // free memory - unset($this->_obj_stack[$filename][$n]); - reset($this->_obj_stack[$filename]); - } - } - } - } - } - - - /** - * Private Method that writes the form xobjects - */ - function _putformxobjects() { - $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; - reset($this->tpls); - foreach($this->tpls AS $tplidx => $tpl) { - $p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer']; - $this->_newobj(); - $cN = $this->n; // TCPDF/Protection: rem current "n" - - $this->tpls[$tplidx]['n'] = $this->n; - $this->_out('<<'.$filter.'/Type /XObject'); - $this->_out('/Subtype /Form'); - $this->_out('/FormType 1'); - - $this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]', - (isset($tpl['box']['llx']) ? $tpl['box']['llx'] : $tpl['x'])*$this->k, - (isset($tpl['box']['lly']) ? $tpl['box']['lly'] : -$tpl['y'])*$this->k, - (isset($tpl['box']['urx']) ? $tpl['box']['urx'] : $tpl['w'] + $tpl['x'])*$this->k, - (isset($tpl['box']['ury']) ? $tpl['box']['ury'] : $tpl['h']-$tpl['y'])*$this->k - )); - - $c = 1; - $s = 0; - $tx = 0; - $ty = 0; - - if (isset($tpl['box'])) { - $tx = -$tpl['box']['llx']; - $ty = -$tpl['box']['lly']; - - if ($tpl['_rotationAngle'] <> 0) { - $angle = $tpl['_rotationAngle'] * M_PI/180; - $c=cos($angle); - $s=sin($angle); - - switch($tpl['_rotationAngle']) { - case -90: - $tx = -$tpl['box']['lly']; - $ty = $tpl['box']['urx']; - break; - case -180: - $tx = $tpl['box']['urx']; - $ty = $tpl['box']['ury']; - break; - case -270: - $tx = $tpl['box']['ury']; - $ty = -$tpl['box']['llx']; - break; - } - } - } else if ($tpl['x'] != 0 || $tpl['y'] != 0) { - $tx = -$tpl['x']*2; - $ty = $tpl['y']*2; - } - - $tx *= $this->k; - $ty *= $this->k; - - if ($c != 1 || $s != 0 || $tx != 0 || $ty != 0) { - $this->_out(sprintf('/Matrix [%.5F %.5F %.5F %.5F %.5F %.5F]', - $c, $s, -$s, $c, $tx, $ty - )); - } - - $this->_out('/Resources '); - - if (isset($tpl['resources'])) { - $this->current_parser =& $tpl['parser']; - $this->pdf_write_value($tpl['resources']); // "n" will be changed - } else { - $this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]'); - if (isset($this->_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) { - $this->_out('/Font <<'); - foreach($this->_res['tpl'][$tplidx]['fonts'] as $font) - $this->_out('/F'.$font['i'].' '.$font['n'].' 0 R'); - $this->_out('>>'); - } - if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) || - isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) - { - $this->_out('/XObject <<'); - if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) { - foreach($this->_res['tpl'][$tplidx]['images'] as $image) - $this->_out('/I'.$image['i'].' '.$image['n'].' 0 R'); - } - if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) { - foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl) - $this->_out($this->tplprefix.$i.' '.$tpl['n'].' 0 R'); - } - $this->_out('>>'); - } - $this->_out('>>'); - } - - $nN = $this->n; // TCPDF: rem new "n" - $this->n = $cN; // TCPDF: reset to current "n" - $this->_out('/Length '.strlen($p).' >>'); - $this->_putstream($p); - $this->_out('endobj'); - $this->n = $nN; // TCPDF: reset to new "n" - } - - $this->_putimportedobjects(); - } - - /** - * Rewritten to handle existing own defined objects - */ - function _newobj($obj_id=false,$onlynewobj=false) { - if (!$obj_id) { - $obj_id = ++$this->n; - } - - //Begin a new object - if (!$onlynewobj) { - $this->offsets[$obj_id] = is_subclass_of($this, 'TCPDF') ? $this->bufferlen : strlen($this->buffer); - $this->_out($obj_id.' 0 obj'); - $this->_current_obj_id = $obj_id; // for later use with encryption - } - return $obj_id; - } - - /** - * Writes a value - * Needed to rebuild the source document - * - * @param mixed $value A PDF-Value. Structure of values see cases in this method - */ - function pdf_write_value(&$value) - { - if (is_subclass_of($this, 'TCPDF')) { - parent::pdf_write_value($value); - } - - switch ($value[0]) { - - case PDF_TYPE_TOKEN : - $this->_straightOut($value[1] . ' '); - break; - case PDF_TYPE_NUMERIC : - case PDF_TYPE_REAL : - if (is_float($value[1]) && $value[1] != 0) { - $this->_straightOut(rtrim(rtrim(sprintf('%F', $value[1]), '0'), '.') .' '); - } else { - $this->_straightOut($value[1] . ' '); - } - break; - - case PDF_TYPE_ARRAY : - - // An array. Output the proper - // structure and move on. - - $this->_straightOut('['); - for ($i = 0; $i < count($value[1]); $i++) { - $this->pdf_write_value($value[1][$i]); - } - - $this->_out(']'); - break; - - case PDF_TYPE_DICTIONARY : - - // A dictionary. - $this->_straightOut('<<'); - - reset ($value[1]); - - while (list($k, $v) = each($value[1])) { - $this->_straightOut($k . ' '); - $this->pdf_write_value($v); - } - - $this->_straightOut('>>'); - break; - - case PDF_TYPE_OBJREF : - - // An indirect object reference - // Fill the object stack if needed - $cpfn =& $this->current_parser->filename; - - if (!isset($this->_don_obj_stack[$cpfn][$value[1]])) { - $this->_newobj(false,true); - $this->_obj_stack[$cpfn][$value[1]] = array($this->n, $value); - $this->_don_obj_stack[$cpfn][$value[1]] = array($this->n, $value); // Value is maybee obsolete!!! - } - $objid = $this->_don_obj_stack[$cpfn][$value[1]][0]; - - $this->_out($objid.' 0 R'); - break; - - case PDF_TYPE_STRING : - - // A string. - $this->_straightOut('('.$value[1].')'); - - break; - - case PDF_TYPE_STREAM : - - // A stream. First, output the - // stream dictionary, then the - // stream data itself. - $this->pdf_write_value($value[1]); - $this->_out('stream'); - $this->_out($value[2][1]); - $this->_out('endstream'); - break; - case PDF_TYPE_HEX : - $this->_straightOut('<'.$value[1].'>'); - break; - - case PDF_TYPE_BOOLEAN : - $this->_straightOut($value[1] ? 'true ' : 'false '); - break; - - case PDF_TYPE_NULL : - // The null object. - - $this->_straightOut('null '); - break; - } - } - - - /** - * Modified so not each call will add a newline to the output. - */ - function _straightOut($s) { - if (!is_subclass_of($this, 'TCPDF')) { - if($this->state==2) - $this->pages[$this->page] .= $s; - else - $this->buffer .= $s; - } else { - if ($this->state == 2) { - if (isset($this->footerlen[$this->page]) AND ($this->footerlen[$this->page] > 0)) { - // puts data before page footer - $page = substr($this->getPageBuffer($this->page), 0, -$this->footerlen[$this->page]); - $footer = substr($this->getPageBuffer($this->page), -$this->footerlen[$this->page]); - $this->setPageBuffer($this->page, $page.' '.$s."\n".$footer); - } else { - $this->setPageBuffer($this->page, $s, true); - } - } else { - $this->setBuffer($s); - } - } - } - - /** - * rewritten to close opened parsers - * - */ - function _enddoc() { - parent::_enddoc(); - $this->_closeParsers(); - } - - /** - * close all files opened by parsers - */ - function _closeParsers() { - if ($this->state > 2 && count($this->parsers) > 0) { - foreach ($this->parsers as $k => $_){ - $this->parsers[$k]->closeFile(); - $this->parsers[$k] = null; - unset($this->parsers[$k]); - } - return true; - } - return false; - } +<?php +// +// FPDI - Version 1.4.1 +// +// Copyright 2004-2011 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. +// + +define('FPDI_VERSION', '1.4.1'); + +// Check for TCPDF and remap TCPDF to FPDF +if (class_exists('TCPDF', false)) { + require_once('fpdi2tcpdf_bridge.php'); +} + +require_once('fpdf_tpl.php'); +require_once('fpdi_pdf_parser.php'); + + +class FPDI extends FPDF_TPL { + /** + * Actual filename + * @var string + */ + var $current_filename; + + /** + * Parser-Objects + * @var array + */ + var $parsers; + + /** + * Current parser + * @var object + */ + var $current_parser; + + /** + * object stack + * @var array + */ + var $_obj_stack; + + /** + * done object stack + * @var array + */ + var $_don_obj_stack; + + /** + * Current Object Id. + * @var integer + */ + var $_current_obj_id; + + /** + * The name of the last imported page box + * @var string + */ + var $lastUsedPageBox; + + /** + * Cache for imported pages/template ids + * @var array + */ + var $_importedPages = array(); + + /** + * Set a source-file + * + * @param string $filename a valid filename + * @return int number of available pages + */ + function setSourceFile($filename) { + $this->current_filename = $filename; + + if (!isset($this->parsers[$filename])) + $this->parsers[$filename] = $this->_getPdfParser($filename); + $this->current_parser =& $this->parsers[$filename]; + + return $this->parsers[$filename]->getPageCount(); + } + + /** + * Returns a PDF parser object + * + * @param string $filename + * @return fpdi_pdf_parser + */ + function _getPdfParser($filename) { + return new fpdi_pdf_parser($filename, $this); + } + + /** + * Get the current PDF version + * + * @return string + */ + function getPDFVersion() { + return $this->PDFVersion; + } + + /** + * Set the PDF version + * + * @return string + */ + function setPDFVersion($version = '1.3') { + $this->PDFVersion = $version; + } + + /** + * Import a page + * + * @param int $pageno pagenumber + * @return int Index of imported page - to use with fpdf_tpl::useTemplate() + */ + function importPage($pageno, $boxName = '/CropBox') { + if ($this->_intpl) { + return $this->error('Please import the desired pages before creating a new template.'); + } + + $fn = $this->current_filename; + + // check if page already imported + $pageKey = $fn . '-' . ((int)$pageno) . $boxName; + if (isset($this->_importedPages[$pageKey])) + return $this->_importedPages[$pageKey]; + + $parser =& $this->parsers[$fn]; + $parser->setPageno($pageno); + + if (!in_array($boxName, $parser->availableBoxes)) + return $this->Error(sprintf('Unknown box: %s', $boxName)); + $pageboxes = $parser->getPageBoxes($pageno, $this->k); + + /** + * MediaBox + * CropBox: Default -> MediaBox + * BleedBox: Default -> CropBox + * TrimBox: Default -> CropBox + * ArtBox: Default -> CropBox + */ + if (!isset($pageboxes[$boxName]) && ($boxName == '/BleedBox' || $boxName == '/TrimBox' || $boxName == '/ArtBox')) + $boxName = '/CropBox'; + if (!isset($pageboxes[$boxName]) && $boxName == '/CropBox') + $boxName = '/MediaBox'; + + if (!isset($pageboxes[$boxName])) + return false; + $this->lastUsedPageBox = $boxName; + + $box = $pageboxes[$boxName]; + + $this->tpl++; + $this->tpls[$this->tpl] = array(); + $tpl =& $this->tpls[$this->tpl]; + $tpl['parser'] =& $parser; + $tpl['resources'] = $parser->getPageResources(); + $tpl['buffer'] = $parser->getContent(); + $tpl['box'] = $box; + + // To build an array that can be used by PDF_TPL::useTemplate() + $this->tpls[$this->tpl] = array_merge($this->tpls[$this->tpl], $box); + + // An imported page will start at 0,0 everytime. Translation will be set in _putformxobjects() + $tpl['x'] = 0; + $tpl['y'] = 0; + + // handle rotated pages + $rotation = $parser->getPageRotation($pageno); + $tpl['_rotationAngle'] = 0; + if (isset($rotation[1]) && ($angle = $rotation[1] % 360) != 0) { + $steps = $angle / 90; + + $_w = $tpl['w']; + $_h = $tpl['h']; + $tpl['w'] = $steps % 2 == 0 ? $_w : $_h; + $tpl['h'] = $steps % 2 == 0 ? $_h : $_w; + + if ($angle < 0) + $angle += 360; + + $tpl['_rotationAngle'] = $angle * -1; + } + + $this->_importedPages[$pageKey] = $this->tpl; + + return $this->tpl; + } + + function getLastUsedPageBox() { + return $this->lastUsedPageBox; + } + + function useTemplate($tplidx, $_x = null, $_y = null, $_w = 0, $_h = 0, $adjustPageSize = false) { + 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')) { + $this->setPageFormat($format, $format[0] > $format[1] ? 'L' : 'P'); + } else { + if ($format[0] != $this->CurPageFormat[0] || $format[1] != $this->CurPageFormat[1]) { + $this->w = $format[0]; + $this->h = $format[1]; + $this->wPt = $this->w * $this->k; + $this->hPt = $this->h * $this->k; + $this->PageBreakTrigger = $this->h - $this->bMargin; + $this->CurPageFormat = $format; + $this->PageSizes[$this->page] = array($this->wPt, $this->hPt); + } + } + } + + $this->_out('q 0 J 1 w 0 j 0 G 0 g'); // reset standard values + $s = parent::useTemplate($tplidx, $_x, $_y, $_w, $_h); + $this->_out('Q'); + + return $s; + } + + /** + * Private method, that rebuilds all needed objects of source files + */ + function _putimportedobjects() { + if (is_array($this->parsers) && count($this->parsers) > 0) { + foreach($this->parsers AS $filename => $p) { + $this->current_parser =& $this->parsers[$filename]; + if (isset($this->_obj_stack[$filename]) && is_array($this->_obj_stack[$filename])) { + while(($n = key($this->_obj_stack[$filename])) !== null) { + $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]); + + if ($nObj[0] == PDF_TYPE_STREAM) { + $this->pdf_write_value($nObj); + } else { + $this->pdf_write_value($nObj[1]); + } + + $this->_out('endobj'); + $this->_obj_stack[$filename][$n] = null; // free memory + unset($this->_obj_stack[$filename][$n]); + reset($this->_obj_stack[$filename]); + } + } + } + } + } + + + /** + * Private Method that writes the form xobjects + */ + function _putformxobjects() { + $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; + reset($this->tpls); + foreach($this->tpls AS $tplidx => $tpl) { + $p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer']; + $this->_newobj(); + $cN = $this->n; // TCPDF/Protection: rem current "n" + + $this->tpls[$tplidx]['n'] = $this->n; + $this->_out('<<' . $filter . '/Type /XObject'); + $this->_out('/Subtype /Form'); + $this->_out('/FormType 1'); + + $this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]', + (isset($tpl['box']['llx']) ? $tpl['box']['llx'] : $tpl['x']) * $this->k, + (isset($tpl['box']['lly']) ? $tpl['box']['lly'] : -$tpl['y']) * $this->k, + (isset($tpl['box']['urx']) ? $tpl['box']['urx'] : $tpl['w'] + $tpl['x']) * $this->k, + (isset($tpl['box']['ury']) ? $tpl['box']['ury'] : $tpl['h'] - $tpl['y']) * $this->k + )); + + $c = 1; + $s = 0; + $tx = 0; + $ty = 0; + + if (isset($tpl['box'])) { + $tx = -$tpl['box']['llx']; + $ty = -$tpl['box']['lly']; + + if ($tpl['_rotationAngle'] <> 0) { + $angle = $tpl['_rotationAngle'] * M_PI/180; + $c=cos($angle); + $s=sin($angle); + + switch($tpl['_rotationAngle']) { + case -90: + $tx = -$tpl['box']['lly']; + $ty = $tpl['box']['urx']; + break; + case -180: + $tx = $tpl['box']['urx']; + $ty = $tpl['box']['ury']; + break; + case -270: + $tx = $tpl['box']['ury']; + $ty = -$tpl['box']['llx']; + break; + } + } + } else if ($tpl['x'] != 0 || $tpl['y'] != 0) { + $tx = -$tpl['x']*2; + $ty = $tpl['y']*2; + } + + $tx *= $this->k; + $ty *= $this->k; + + if ($c != 1 || $s != 0 || $tx != 0 || $ty != 0) { + $this->_out(sprintf('/Matrix [%.5F %.5F %.5F %.5F %.5F %.5F]', + $c, $s, -$s, $c, $tx, $ty + )); + } + + $this->_out('/Resources '); + + if (isset($tpl['resources'])) { + $this->current_parser =& $tpl['parser']; + $this->pdf_write_value($tpl['resources']); // "n" will be changed + } else { + $this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]'); + if (isset($this->_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) { + $this->_out('/Font <<'); + foreach($this->_res['tpl'][$tplidx]['fonts'] as $font) + $this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R'); + $this->_out('>>'); + } + if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) || + isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) + { + $this->_out('/XObject <<'); + if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) { + foreach($this->_res['tpl'][$tplidx]['images'] as $image) + $this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R'); + } + if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) { + foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl) + $this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R'); + } + $this->_out('>>'); + } + $this->_out('>>'); + } + + $nN = $this->n; // TCPDF: rem new "n" + $this->n = $cN; // TCPDF: reset to current "n" + $this->_out('/Length ' . strlen($p) . ' >>'); + $this->_putstream($p); + $this->_out('endobj'); + $this->n = $nN; // TCPDF: reset to new "n" + } + + $this->_putimportedobjects(); + } + + /** + * Rewritten to handle existing own defined objects + */ + function _newobj($obj_id = false, $onlynewobj = false) { + if (!$obj_id) { + $obj_id = ++$this->n; + } + + //Begin a new object + if (!$onlynewobj) { + $this->offsets[$obj_id] = is_subclass_of($this, 'TCPDF') ? $this->bufferlen : strlen($this->buffer); + $this->_out($obj_id . ' 0 obj'); + $this->_current_obj_id = $obj_id; // for later use with encryption + } + + return $obj_id; + } + + /** + * Writes a value + * Needed to rebuild the source document + * + * @param mixed $value A PDF-Value. Structure of values see cases in this method + */ + function pdf_write_value(&$value) + { + if (is_subclass_of($this, 'TCPDF')) { + parent::pdf_write_value($value); + } + + switch ($value[0]) { + + case PDF_TYPE_TOKEN: + $this->_straightOut($value[1] . ' '); + break; + case PDF_TYPE_NUMERIC: + case PDF_TYPE_REAL: + if (is_float($value[1]) && $value[1] != 0) { + $this->_straightOut(rtrim(rtrim(sprintf('%F', $value[1]), '0'), '.') . ' '); + } else { + $this->_straightOut($value[1] . ' '); + } + break; + + case PDF_TYPE_ARRAY: + + // An array. Output the proper + // structure and move on. + + $this->_straightOut('['); + for ($i = 0; $i < count($value[1]); $i++) { + $this->pdf_write_value($value[1][$i]); + } + + $this->_out(']'); + break; + + case PDF_TYPE_DICTIONARY: + + // A dictionary. + $this->_straightOut('<<'); + + reset ($value[1]); + + while (list($k, $v) = each($value[1])) { + $this->_straightOut($k . ' '); + $this->pdf_write_value($v); + } + + $this->_straightOut('>>'); + break; + + case PDF_TYPE_OBJREF: + + // An indirect object reference + // Fill the object stack if needed + $cpfn =& $this->current_parser->filename; + + if (!isset($this->_don_obj_stack[$cpfn][$value[1]])) { + $this->_newobj(false, true); + $this->_obj_stack[$cpfn][$value[1]] = array($this->n, $value); + $this->_don_obj_stack[$cpfn][$value[1]] = array($this->n, $value); // Value is maybee obsolete!!! + } + $objid = $this->_don_obj_stack[$cpfn][$value[1]][0]; + + $this->_out($objid . ' 0 R'); + break; + + case PDF_TYPE_STRING: + + // A string. + $this->_straightOut('(' . $value[1] . ')'); + + break; + + case PDF_TYPE_STREAM: + + // A stream. First, output the + // stream dictionary, then the + // stream data itself. + $this->pdf_write_value($value[1]); + $this->_out('stream'); + $this->_out($value[2][1]); + $this->_out('endstream'); + break; + + case PDF_TYPE_HEX: + $this->_straightOut('<' . $value[1] . '>'); + break; + + case PDF_TYPE_BOOLEAN: + $this->_straightOut($value[1] ? 'true ' : 'false '); + break; + + case PDF_TYPE_NULL: + // The null object. + + $this->_straightOut('null '); + break; + } + } + + + /** + * Modified so not each call will add a newline to the output. + */ + function _straightOut($s) { + if (!is_subclass_of($this, 'TCPDF')) { + if($this->state==2) + $this->pages[$this->page] .= $s; + else + $this->buffer .= $s; + } else { + if ($this->state == 2) { + if (isset($this->footerlen[$this->page]) AND ($this->footerlen[$this->page] > 0)) { + // puts data before page footer + $page = substr($this->getPageBuffer($this->page), 0, -$this->footerlen[$this->page]); + $footer = substr($this->getPageBuffer($this->page), -$this->footerlen[$this->page]); + $this->setPageBuffer($this->page, $page . ' ' . $s . "\n" . $footer); + } else { + $this->setPageBuffer($this->page, $s, true); + } + } else { + $this->setBuffer($s); + } + } + } + + /** + * rewritten to close opened parsers + * + */ + function _enddoc() { + parent::_enddoc(); + $this->_closeParsers(); + } + + /** + * close all files opened by parsers + */ + function _closeParsers() { + if ($this->state > 2 && count($this->parsers) > 0) { + foreach ($this->parsers as $k => $_){ + $this->parsers[$k]->closeFile(); + $this->parsers[$k] = null; + unset($this->parsers[$k]); + } + return true; + } + return false; + } } \ No newline at end of file diff --git a/htdocs/includes/fpdf/fpdfi/fpdi2tcpdf_bridge.php b/htdocs/includes/fpdf/fpdfi/fpdi2tcpdf_bridge.php index 11a3cff2254102d84dae94639bb7fd5a4987c82d..640700a8322aee09ddcde9038c9e8801874eaedf 100644 --- a/htdocs/includes/fpdf/fpdfi/fpdi2tcpdf_bridge.php +++ b/htdocs/includes/fpdf/fpdfi/fpdi2tcpdf_bridge.php @@ -1,8 +1,8 @@ <?php // -// FPDI - Version 1.3.4 +// FPDI - Version 1.4.1 // -// Copyright 2004-2010 Setasign - Jan Slabon +// Copyright 2004-2011 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. @@ -28,35 +28,11 @@ */ class FPDF extends TCPDF { - function __get($name) { - switch ($name) { - case 'PDFVersion': - return $this->PDFVersion; - case 'k': - return $this->k; - default: - // Error handling - $this->Error('Cannot access protected property '.get_class($this).':$'.$name.' / Undefined property: '.get_class($this).'::$'.$name); - } - } - - function __set($name, $value) { - switch ($name) { - case 'PDFVersion': - $this->PDFVersion = $value; - break; - default: - // Error handling - $this->Error('Cannot access protected property '.get_class($this).':$'.$name.' / Undefined property: '.get_class($this).'::$'.$name); - } - } - - function _putstream($s) { + function _putstream($s) { $this->_out($this->_getstream($s)); } function _getxobjectdict() { - $out = parent::_getxobjectdict(); if (count($this->tpls)) { foreach($this->tpls as $tplidx => $tpl) { @@ -74,7 +50,7 @@ class FPDF extends TCPDF { */ function pdf_write_value(&$value) { switch ($value[0]) { - case PDF_TYPE_STRING : + case PDF_TYPE_STRING: if ($this->encrypted) { $value[1] = $this->_unescape($value[1]); $value[1] = $this->_RC4($this->_objectkey($this->_current_obj_id), $value[1]); @@ -82,13 +58,13 @@ class FPDF extends TCPDF { } break; - case PDF_TYPE_STREAM : + case PDF_TYPE_STREAM: if ($this->encrypted) { $value[2][1] = $this->_RC4($this->_objectkey($this->_current_obj_id), $value[2][1]); } break; - case PDF_TYPE_HEX : + case PDF_TYPE_HEX: if ($this->encrypted) { $value[1] = $this->hex2str($value[1]); $value[1] = $this->_RC4($this->_objectkey($this->_current_obj_id), $value[1]); diff --git a/htdocs/includes/fpdf/fpdfi/fpdi_pdf_parser.php b/htdocs/includes/fpdf/fpdfi/fpdi_pdf_parser.php index 6d564af03cba47e04735fc8ad4de76f086943376..57b8e88fd67e3c0dad9950547c794127efb9800c 100644 --- a/htdocs/includes/fpdf/fpdfi/fpdi_pdf_parser.php +++ b/htdocs/includes/fpdf/fpdfi/fpdi_pdf_parser.php @@ -1,398 +1,409 @@ -<?php -// -// FPDI - Version 1.3.4 -// -// Copyright 2004-2010 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. -// - -require_once('pdf_parser.php'); - -class fpdi_pdf_parser extends pdf_parser { - - /** - * Pages - * Index beginns at 0 - * - * @var array - */ - var $pages; - - /** - * Page count - * @var integer - */ - var $page_count; - - /** - * actual page number - * @var integer - */ - var $pageno; - - /** - * PDF Version of imported Document - * @var string - */ - var $pdfVersion; - - /** - * FPDI Reference - * @var object - */ - var $fpdi; - - /** - * Available BoxTypes - * - * @var array - */ - var $availableBoxes = array('/MediaBox', '/CropBox', '/BleedBox', '/TrimBox', '/ArtBox'); - - /** - * Constructor - * - * @param string $filename Source-Filename - * @param object $fpdi Object of type fpdi - */ - function fpdi_pdf_parser($filename, &$fpdi) { - $this->fpdi =& $fpdi; - - parent::pdf_parser($filename); - - // resolve Pages-Dictonary - $pages = $this->pdf_resolve_object($this->c, $this->root[1][1]['/Pages']); - - // Read pages - $this->read_pages($this->c, $pages, $this->pages); - - // count pages; - $this->page_count = count($this->pages); - } - - /** - * Overwrite parent::error() - * - * @param string $msg Error-Message - */ - function error($msg) { - $this->fpdi->error($msg); - } - - /** - * Get pagecount from sourcefile - * - * @return int - */ - function getPageCount() { - return $this->page_count; - } - - - /** - * Set pageno - * - * @param int $pageno Pagenumber to use - */ - function setPageno($pageno) { - $pageno = ((int) $pageno) - 1; - - if ($pageno < 0 || $pageno >= $this->getPageCount()) { - $this->fpdi->error('Pagenumber is wrong!'); - } - - $this->pageno = $pageno; - } - - /** - * Get page-resources from current page - * - * @return array - */ - function getPageResources() { - return $this->_getPageResources($this->pages[$this->pageno]); - } - - /** - * Get page-resources from /Page - * - * @param array $obj Array of pdf-data - */ - function _getPageResources ($obj) { // $obj = /Page - $obj = $this->pdf_resolve_object($this->c, $obj); - - // If the current object has a resources - // dictionary associated with it, we use - // it. Otherwise, we move back to its - // parent object. - if (isset ($obj[1][1]['/Resources'])) { - $res = $this->pdf_resolve_object($this->c, $obj[1][1]['/Resources']); - if ($res[0] == PDF_TYPE_OBJECT) - return $res[1]; - return $res; - } else { - if (!isset ($obj[1][1]['/Parent'])) { - return false; - } else { - $res = $this->_getPageResources($obj[1][1]['/Parent']); - if ($res[0] == PDF_TYPE_OBJECT) - return $res[1]; - return $res; - } - } - } - - - /** - * Get content of current page - * - * If more /Contents is an array, the streams are concated - * - * @return string - */ - function getContent() { - $buffer = ''; - - if (isset($this->pages[$this->pageno][1][1]['/Contents'])) { - $contents = $this->_getPageContent($this->pages[$this->pageno][1][1]['/Contents']); - foreach($contents AS $tmp_content) { - $buffer .= $this->_rebuildContentStream($tmp_content).' '; - } - } - - return $buffer; - } - - - /** - * Resolve all content-objects - * - * @param array $content_ref - * @return array - */ - function _getPageContent($content_ref) { - $contents = array(); - - if ($content_ref[0] == PDF_TYPE_OBJREF) { - $content = $this->pdf_resolve_object($this->c, $content_ref); - if ($content[1][0] == PDF_TYPE_ARRAY) { - $contents = $this->_getPageContent($content[1]); - } else { - $contents[] = $content; - } - } else if ($content_ref[0] == PDF_TYPE_ARRAY) { - foreach ($content_ref[1] AS $tmp_content_ref) { - $contents = array_merge($contents,$this->_getPageContent($tmp_content_ref)); - } - } - - return $contents; - } - - - /** - * Rebuild content-streams - * - * @param array $obj - * @return string - */ - function _rebuildContentStream($obj) { - $filters = array(); - - 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) { - $filters = $_filter[1]; - } - } - - $stream = $obj[2][1]; - - 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.'); - } - break; - case '/LZWDecode': - include_once('filters/FilterLZW_FPDI.php'); - $decoder = new FilterLZW_FPDI($this->fpdi); - $stream = $decoder->decode($stream); - break; - case '/ASCII85Decode': - include_once('filters/FilterASCII85_FPDI.php'); - $decoder = new FilterASCII85_FPDI($this->fpdi); - $stream = $decoder->decode($stream); - break; - case null: - $stream = $stream; - break; - default: - $this->error(sprintf('Unsupported Filter: %s',$_filter[1])); - } - } - - return $stream; - } - - - /** - * Get a Box from a page - * Arrayformat is same as used by fpdf_tpl - * - * @param array $page a /Page - * @param string $box_index Type of Box @see $availableBoxes - * @return array - */ - function getPageBox($page, $box_index) { - $page = $this->pdf_resolve_object($this->c,$page); - $box = null; - if (isset($page[1][1][$box_index])) - $box =& $page[1][1][$box_index]; - - if (!is_null($box) && $box[0] == PDF_TYPE_OBJREF) { - $tmp_box = $this->pdf_resolve_object($this->c,$box); - $box = $tmp_box[1]; - } - - if (!is_null($box) && $box[0] == PDF_TYPE_ARRAY) { - $b =& $box[1]; - return array('x' => $b[0][1]/$this->fpdi->k, - 'y' => $b[1][1]/$this->fpdi->k, - 'w' => abs($b[0][1]-$b[2][1])/$this->fpdi->k, - 'h' => abs($b[1][1]-$b[3][1])/$this->fpdi->k, - 'llx' => min($b[0][1], $b[2][1])/$this->fpdi->k, - 'lly' => min($b[1][1], $b[3][1])/$this->fpdi->k, - 'urx' => max($b[0][1], $b[2][1])/$this->fpdi->k, - 'ury' => max($b[1][1], $b[3][1])/$this->fpdi->k, - ); - } else if (!isset ($page[1][1]['/Parent'])) { - return false; - } else { - return $this->getPageBox($this->pdf_resolve_object($this->c, $page[1][1]['/Parent']), $box_index); - } - } - - function getPageBoxes($pageno) { - return $this->_getPageBoxes($this->pages[$pageno-1]); - } - - /** - * Get all Boxes from /Page - * - * @param array a /Page - * @return array - */ - function _getPageBoxes($page) { - $boxes = array(); - - foreach($this->availableBoxes AS $box) { - if ($_box = $this->getPageBox($page,$box)) { - $boxes[$box] = $_box; - } - } - - return $boxes; - } - - /** - * Get the page rotation by pageno - * - * @param integer $pageno - * @return array - */ - function getPageRotation($pageno) { - return $this->_getPageRotation($this->pages[$pageno-1]); - } - - function _getPageRotation ($obj) { // $obj = /Page - $obj = $this->pdf_resolve_object($this->c, $obj); - if (isset ($obj[1][1]['/Rotate'])) { - $res = $this->pdf_resolve_object($this->c, $obj[1][1]['/Rotate']); - if ($res[0] == PDF_TYPE_OBJECT) - return $res[1]; - return $res; - } else { - if (!isset ($obj[1][1]['/Parent'])) { - return false; - } else { - $res = $this->_getPageRotation($obj[1][1]['/Parent']); - if ($res[0] == PDF_TYPE_OBJECT) - return $res[1]; - return $res; - } - } - } - - /** - * Read all /Page(es) - * - * @param object pdf_context - * @param array /Pages - * @param array the result-array - */ - function read_pages (&$c, &$pages, &$result) { - // Get the kids dictionary - $_kids = $this->pdf_resolve_object ($c, $pages[1][1]['/Kids']); - - if (!is_array($_kids)) - $this->error('Cannot find /Kids in current /Page-Dictionary'); - - if ($_kids[1][0] == PDF_TYPE_ARRAY) { - $kids = $_kids[1][1]; - } else { - $kids = $_kids[1]; - } - - foreach ($kids as $v) { - $pg = $this->pdf_resolve_object ($c, $v); - if ($pg[1][1]['/Type'][1] === '/Pages') { - // If one of the kids is an embedded - // /Pages array, resolve it as well. - $this->read_pages ($c, $pg, $result); - } else { - $result[] = $pg; - } - } - } - - - - /** - * Get PDF-Version - * - * And reset the PDF Version used in FPDI if needed - */ - function getPDFVersion() { - parent::getPDFVersion(); - $this->fpdi->PDFVersion = max($this->fpdi->PDFVersion, $this->pdfVersion); - } - +<?php +// +// FPDI - Version 1.4.1 +// +// Copyright 2004-2011 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. +// + +require_once('pdf_parser.php'); + +class fpdi_pdf_parser extends pdf_parser { + + /** + * Pages + * Index beginns at 0 + * + * @var array + */ + var $pages; + + /** + * Page count + * @var integer + */ + var $page_count; + + /** + * actual page number + * @var integer + */ + var $pageno; + + /** + * PDF Version of imported Document + * @var string + */ + var $pdfVersion; + + /** + * FPDI Reference + * @var object + */ + var $fpdi; + + /** + * Available BoxTypes + * + * @var array + */ + var $availableBoxes = array('/MediaBox', '/CropBox', '/BleedBox', '/TrimBox', '/ArtBox'); + + /** + * Constructor + * + * @param string $filename Source-Filename + * @param object $fpdi Object of type fpdi + */ + function fpdi_pdf_parser($filename, &$fpdi) { + $this->fpdi =& $fpdi; + + parent::pdf_parser($filename); + + // resolve Pages-Dictonary + $pages = $this->pdf_resolve_object($this->c, $this->root[1][1]['/Pages']); + + // Read pages + $this->read_pages($this->c, $pages, $this->pages); + + // count pages; + $this->page_count = count($this->pages); + } + + /** + * Overwrite parent::error() + * + * @param string $msg Error-Message + */ + function error($msg) { + $this->fpdi->error($msg); + } + + /** + * Get pagecount from sourcefile + * + * @return int + */ + function getPageCount() { + return $this->page_count; + } + + + /** + * Set pageno + * + * @param int $pageno Pagenumber to use + */ + function setPageno($pageno) { + $pageno = ((int) $pageno) - 1; + + if ($pageno < 0 || $pageno >= $this->getPageCount()) { + $this->fpdi->error('Pagenumber is wrong!'); + } + + $this->pageno = $pageno; + } + + /** + * Get page-resources from current page + * + * @return array + */ + function getPageResources() { + return $this->_getPageResources($this->pages[$this->pageno]); + } + + /** + * Get page-resources from /Page + * + * @param array $obj Array of pdf-data + */ + function _getPageResources ($obj) { // $obj = /Page + $obj = $this->pdf_resolve_object($this->c, $obj); + + // If the current object has a resources + // dictionary associated with it, we use + // it. Otherwise, we move back to its + // parent object. + if (isset ($obj[1][1]['/Resources'])) { + $res = $this->pdf_resolve_object($this->c, $obj[1][1]['/Resources']); + if ($res[0] == PDF_TYPE_OBJECT) + return $res[1]; + return $res; + } else { + if (!isset ($obj[1][1]['/Parent'])) { + return false; + } else { + $res = $this->_getPageResources($obj[1][1]['/Parent']); + if ($res[0] == PDF_TYPE_OBJECT) + return $res[1]; + return $res; + } + } + } + + + /** + * Get content of current page + * + * If more /Contents is an array, the streams are concated + * + * @return string + */ + function getContent() { + $buffer = ''; + + if (isset($this->pages[$this->pageno][1][1]['/Contents'])) { + $contents = $this->_getPageContent($this->pages[$this->pageno][1][1]['/Contents']); + foreach($contents AS $tmp_content) { + $buffer .= $this->_rebuildContentStream($tmp_content) . ' '; + } + } + + return $buffer; + } + + + /** + * Resolve all content-objects + * + * @param array $content_ref + * @return array + */ + function _getPageContent($content_ref) { + $contents = array(); + + if ($content_ref[0] == PDF_TYPE_OBJREF) { + $content = $this->pdf_resolve_object($this->c, $content_ref); + if ($content[1][0] == PDF_TYPE_ARRAY) { + $contents = $this->_getPageContent($content[1]); + } else { + $contents[] = $content; + } + } else if ($content_ref[0] == PDF_TYPE_ARRAY) { + foreach ($content_ref[1] AS $tmp_content_ref) { + $contents = array_merge($contents,$this->_getPageContent($tmp_content_ref)); + } + } + + return $contents; + } + + + /** + * Rebuild content-streams + * + * @param array $obj + * @return string + */ + function _rebuildContentStream($obj) { + $filters = array(); + + 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) { + $filters = $_filter[1]; + } + } + + $stream = $obj[2][1]; + + foreach ($filters AS $_filter) { + switch ($_filter[1]) { + case '/FlateDecode': + case '/Fl': + // $stream .= "\x0F\x0D"; // in an errorious stream this suffix could work + // $stream .= "\x0A"; + // $stream .= "\x0D"; + 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.'); + } + break; + case '/LZWDecode': + include_once('filters/FilterLZW_FPDI.php'); + $decoder = new FilterLZW_FPDI($this->fpdi); + $stream = $decoder->decode($stream); + break; + case '/ASCII85Decode': + include_once('filters/FilterASCII85_FPDI.php'); + $decoder = new FilterASCII85_FPDI($this->fpdi); + $stream = $decoder->decode($stream); + break; + case null: + $stream = $stream; + break; + default: + $this->error(sprintf('Unsupported Filter: %s',$_filter[1])); + } + } + + return $stream; + } + + + /** + * Get a Box from a page + * Arrayformat is same as used by fpdf_tpl + * + * @param array $page a /Page + * @param string $box_index Type of Box @see $availableBoxes + * @param float Scale factor from user space units to points + * @return array + */ + function getPageBox($page, $box_index, $k) { + $page = $this->pdf_resolve_object($this->c, $page); + $box = null; + if (isset($page[1][1][$box_index])) + $box =& $page[1][1][$box_index]; + + if (!is_null($box) && $box[0] == PDF_TYPE_OBJREF) { + $tmp_box = $this->pdf_resolve_object($this->c, $box); + $box = $tmp_box[1]; + } + + if (!is_null($box) && $box[0] == PDF_TYPE_ARRAY) { + $b =& $box[1]; + return array('x' => $b[0][1]/$k, + 'y' => $b[1][1]/$k, + 'w' => abs($b[0][1]-$b[2][1])/$k, + 'h' => abs($b[1][1]-$b[3][1])/$k, + 'llx' => min($b[0][1], $b[2][1])/$k, + 'lly' => min($b[1][1], $b[3][1])/$k, + 'urx' => max($b[0][1], $b[2][1])/$k, + 'ury' => max($b[1][1], $b[3][1])/$k, + ); + } else if (!isset ($page[1][1]['/Parent'])) { + return false; + } else { + return $this->getPageBox($this->pdf_resolve_object($this->c, $page[1][1]['/Parent']), $box_index, $k); + } + } + + /** + * Get all page boxes by page no + * + * @param int The page number + * @param float Scale factor from user space units to points + * @return array + */ + function getPageBoxes($pageno, $k) { + return $this->_getPageBoxes($this->pages[$pageno-1], $k); + } + + /** + * Get all boxes from /Page + * + * @param array a /Page + * @return array + */ + function _getPageBoxes($page, $k) { + $boxes = array(); + + foreach($this->availableBoxes AS $box) { + if ($_box = $this->getPageBox($page, $box, $k)) { + $boxes[$box] = $_box; + } + } + + return $boxes; + } + + /** + * Get the page rotation by pageno + * + * @param integer $pageno + * @return array + */ + function getPageRotation($pageno) { + return $this->_getPageRotation($this->pages[$pageno-1]); + } + + function _getPageRotation($obj) { // $obj = /Page + $obj = $this->pdf_resolve_object($this->c, $obj); + if (isset ($obj[1][1]['/Rotate'])) { + $res = $this->pdf_resolve_object($this->c, $obj[1][1]['/Rotate']); + if ($res[0] == PDF_TYPE_OBJECT) + return $res[1]; + return $res; + } else { + if (!isset ($obj[1][1]['/Parent'])) { + return false; + } else { + $res = $this->_getPageRotation($obj[1][1]['/Parent']); + if ($res[0] == PDF_TYPE_OBJECT) + return $res[1]; + return $res; + } + } + } + + /** + * Read all /Page(es) + * + * @param object pdf_context + * @param array /Pages + * @param array the result-array + */ + function read_pages(&$c, &$pages, &$result) { + // Get the kids dictionary + $_kids = $this->pdf_resolve_object ($c, $pages[1][1]['/Kids']); + + if (!is_array($_kids)) + $this->error('Cannot find /Kids in current /Page-Dictionary'); + + if ($_kids[1][0] == PDF_TYPE_ARRAY) { + $kids = $_kids[1][1]; + } else { + $kids = $_kids[1]; + } + + foreach ($kids as $v) { + $pg = $this->pdf_resolve_object ($c, $v); + if ($pg[1][1]['/Type'][1] === '/Pages') { + // If one of the kids is an embedded + // /Pages array, resolve it as well. + $this->read_pages($c, $pg, $result); + } else { + $result[] = $pg; + } + } + } + + + + /** + * Get PDF-Version + * + * And reset the PDF Version used in FPDI if needed + */ + function getPDFVersion() { + parent::getPDFVersion(); + $this->fpdi->setPDFVersion(max($this->fpdi->getPDFVersion(), $this->pdfVersion)); + } + } \ No newline at end of file diff --git a/htdocs/includes/fpdf/fpdfi/fpdi_protection.php b/htdocs/includes/fpdf/fpdfi/fpdi_protection.php deleted file mode 100644 index bdd56eba6b49560e8f5c1c2704192e620a3eb664..0000000000000000000000000000000000000000 --- a/htdocs/includes/fpdf/fpdfi/fpdi_protection.php +++ /dev/null @@ -1,305 +0,0 @@ -<?php -/**************************************************************************** -* Software: FPDI_Protection * -* Version: 1.0.3 * -* Date: 2009/03/06 * -* Author: Klemen VODOPIVEC, Jan Slabon * -* License: Freeware * -* * -* You may use and modify this software as you wish as stated in original * -* FPDF package. * -* * -* Infos (by Jan Slabon): * -* This class extends the FPDI-class available at http://www.setasign.de * -* so that you can import pages and create new protected pdf files. * -* * -* This release is dedicated to my son Fin Frederik (*2005/06/04) * -* * -****************************************************************************/ - -require_once('fpdi.php'); - -class FPDI_Protection extends FPDI { - - var $encrypted = false; //whether document is protected - var $Uvalue; //U entry in pdf document - var $Ovalue; //O entry in pdf document - var $Pvalue; //P entry in pdf document - var $enc_obj_id; //encryption object id - var $last_rc4_key = ''; //last RC4 key encrypted (cached for optimisation) - 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"; - - /** - * Function to set permissions as well as user and owner passwords - * - * - permissions is an array with values taken from the following list: - * 40bit: copy, print, modify, annot-forms - * 128bit: fill-in, screenreaders, assemble, degraded-print - * If a value is present it means that the permission is granted - * - If a user password is set, user will be prompted before document is opened - * - If an owner password is set, document can be opened in privilege mode with no - * restriction if that password is entered - */ - function SetProtection($permissions=array(), $user_pass='', $owner_pass=null) { - $options = array('print' => 4, 'modify' => 8, 'copy' => 16, 'annot-forms' => 32 ); - $protection = 192; - foreach($permissions as $permission){ - if (!isset($options[$permission])) - $this->Error('Incorrect permission: '.$permission); - $protection += $options[$permission]; - } - if ($owner_pass === null) - $owner_pass = uniqid(rand()); - $this->encrypted = true; - $this->_generateencryptionkey($user_pass, $owner_pass, $protection); - } - - - function _putstream($s) { - if ($this->encrypted) { - $s = $this->_RC4($this->_objectkey($this->_current_obj_id), $s); - } - parent::_putstream($s); - } - - - function _textstring($s) { - if ($this->encrypted) { - $s = $this->_RC4($this->_objectkey($this->_current_obj_id), $s); - } - return parent::_textstring($s); - } - - - /** - * Compute key depending on object number where the encrypted data is stored - */ - function _objectkey($n) { - return substr($this->_md5_16($this->encryption_key.pack('VXxx', $n)), 0, 10); - } - - - /** - * Escape special characters - */ - function _escape($s) { - return str_replace( - array('\\',')','(',"\r", "\n", "\t"), - array('\\\\','\\)','\\(','\\r', '\\n', '\\t'),$s); - } - - function _putresources() { - parent::_putresources(); - if ($this->encrypted) { - $this->_newobj(); - $this->enc_obj_id = $this->_current_obj_id; - $this->_out('<<'); - $this->_putencryption(); - $this->_out('>>'); - } - } - - function _putencryption() { - $this->_out('/Filter /Standard'); - $this->_out('/V 1'); - $this->_out('/R 2'); - $this->_out('/O ('.$this->_escape($this->Ovalue).')'); - $this->_out('/U ('.$this->_escape($this->Uvalue).')'); - $this->_out('/P '.$this->Pvalue); - } - - - function _puttrailer() { - parent::_puttrailer(); - if ($this->encrypted) { - $this->_out('/Encrypt '.$this->enc_obj_id.' 0 R'); - $this->_out('/ID [()()]'); - } - } - - - /** - * RC4 is the standard encryption algorithm used in PDF format - */ - function _RC4($key, $text) { - if ($this->last_rc4_key != $key) { - $k = str_repeat($key, 256/strlen($key)+1); - $rc4 = range(0,255); - $j = 0; - for ($i=0; $i<256; $i++){ - $t = $rc4[$i]; - $j = ($j + $t + ord($k{$i})) % 256; - $rc4[$i] = $rc4[$j]; - $rc4[$j] = $t; - } - $this->last_rc4_key = $key; - $this->last_rc4_key_c = $rc4; - } else { - $rc4 = $this->last_rc4_key_c; - } - - $len = strlen($text); - $a = 0; - $b = 0; - $out = ''; - for ($i=0; $i<$len; $i++){ - $a = ($a+1)%256; - $t= $rc4[$a]; - $b = ($b+$t)%256; - $rc4[$a] = $rc4[$b]; - $rc4[$b] = $t; - $k = $rc4[($rc4[$a]+$rc4[$b])%256]; - $out.=chr(ord($text{$i}) ^ $k); - } - - return $out; - } - - - /** - * Get MD5 as binary string - */ - function _md5_16($string) { - return pack('H*',md5($string)); - } - - /** - * Compute O value - */ - function _Ovalue($user_pass, $owner_pass) { - $tmp = $this->_md5_16($owner_pass); - $owner_RC4_key = substr($tmp,0,5); - return $this->_RC4($owner_RC4_key, $user_pass); - } - - - /** - * Compute U value - */ - function _Uvalue() { - return $this->_RC4($this->encryption_key, $this->padding); - } - - - /** - * Compute encryption key - */ - function _generateencryptionkey($user_pass, $owner_pass, $protection) { - // Pad passwords - $user_pass = substr($user_pass.$this->padding,0,32); - $owner_pass = substr($owner_pass.$this->padding,0,32); - // Compute O value - $this->Ovalue = $this->_Ovalue($user_pass,$owner_pass); - // Compute encyption key - $tmp = $this->_md5_16($user_pass.$this->Ovalue.chr($protection)."\xFF\xFF\xFF"); - $this->encryption_key = substr($tmp,0,5); - // Compute U value - $this->Uvalue = $this->_Uvalue(); - // Compute P value - $this->Pvalue = -(($protection^255)+1); - } - - - function pdf_write_value(&$value) { - switch ($value[0]) { - case PDF_TYPE_STRING : - if ($this->encrypted) { - $value[1] = $this->_unescape($value[1]); - $value[1] = $this->_RC4($this->_objectkey($this->_current_obj_id), $value[1]); - $value[1] = $this->_escape($value[1]); - } - break; - - case PDF_TYPE_STREAM : - if ($this->encrypted) { - $value[2][1] = $this->_RC4($this->_objectkey($this->_current_obj_id), $value[2][1]); - } - break; - - case PDF_TYPE_HEX : - - if ($this->encrypted) { - $value[1] = $this->hex2str($value[1]); - $value[1] = $this->_RC4($this->_objectkey($this->_current_obj_id), $value[1]); - - // remake hexstring of encrypted string - $value[1] = $this->str2hex($value[1]); - } - break; - } - - parent::pdf_write_value($value); - } - - - function hex2str($hex) { - return pack('H*', str_replace(array("\r","\n",' '),'', $hex)); - } - - function str2hex($str) { - return current(unpack('H*',$str)); - } - - /** - * Deescape special characters - */ - function _unescape($s) { - $out = ''; - for ($count = 0, $n = strlen($s); $count < $n; $count++) { - if ($s[$count] != '\\' || $count == $n-1) { - $out .= $s[$count]; - } else { - switch ($s[++$count]) { - case ')': - case '(': - case '\\': - $out .= $s[$count]; - break; - case 'f': - $out .= chr(0x0C); - break; - case 'b': - $out .= chr(0x08); - break; - case 't': - $out .= chr(0x09); - break; - case 'r': - $out .= chr(0x0D); - break; - case 'n': - $out .= chr(0x0A); - break; - case "\r": - if ($count != $n-1 && $s[$count+1] == "\n") - $count++; - break; - case "\n": - break; - default: - // Octal-Values - if (ord($s[$count]) >= ord('0') && - ord($s[$count]) <= ord('9')) { - $oct = ''. $s[$count]; - - if (ord($s[$count+1]) >= ord('0') && - ord($s[$count+1]) <= ord('9')) { - $oct .= $s[++$count]; - - if (ord($s[$count+1]) >= ord('0') && - ord($s[$count+1]) <= ord('9')) { - $oct .= $s[++$count]; - } - } - - $out .= chr(octdec($oct)); - } else { - $out .= $s[$count]; - } - } - } - } - return $out; - } -} \ No newline at end of file diff --git a/htdocs/includes/fpdf/fpdfi/pdf_context.php b/htdocs/includes/fpdf/fpdfi/pdf_context.php index c47e980c49ad8f76722dd23042bba148e87c6214..0cece449ed237c1b4e43bcc6f9de96a875d0b6a5 100644 --- a/htdocs/includes/fpdf/fpdfi/pdf_context.php +++ b/htdocs/includes/fpdf/fpdfi/pdf_context.php @@ -1,103 +1,104 @@ -<?php -// -// FPDI - Version 1.3.4 -// -// Copyright 2004-2010 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. -// - -$__tmp = version_compare(phpversion(), "5") == -1 ? array('pdf_context') : array('pdf_context', false); -if (!call_user_func_array('class_exists', $__tmp)) { - - class pdf_context { - - /** - * Modi - * - * @var integer 0 = file | 1 = string - */ - var $_mode = 0; - - var $file; - var $buffer; - var $offset; - var $length; - - var $stack; - - // Constructor - - function pdf_context(&$f) { - $this->file =& $f; - if (is_string($this->file)) - $this->_mode = 1; - $this->reset(); - } - - // Optionally move the file - // pointer to a new location - // and reset the buffered data - - function reset($pos = null, $l = 100) { - if ($this->_mode == 0) { - if (!is_null ($pos)) { - fseek ($this->file, $pos); - } - - $this->buffer = $l > 0 ? fread($this->file, $l) : ''; - $this->length = strlen($this->buffer); - if ($this->length < $l) - $this->increase_length($l - $this->length); - } else { - $this->buffer = $this->file; - $this->length = strlen($this->buffer); - } - $this->offset = 0; - $this->stack = array(); - } - - // Make sure that there is at least one - // character beyond the current offset in - // the buffer to prevent the tokenizer - // from attempting to access data that does - // not exist - - function ensure_content() { - if ($this->offset >= $this->length - 1) { - return $this->increase_length(); - } else { - return true; - } - } - - // Forcefully read more data into the buffer - - function increase_length($l=100) { - if ($this->_mode == 0 && feof($this->file)) { - return false; - } else if ($this->_mode == 0) { - $totalLength = $this->length + $l; - do { - $this->buffer .= fread($this->file, $totalLength-$this->length); - } while ((($this->length = strlen($this->buffer)) != $totalLength) && !feof($this->file)); - - return true; - } else { - return false; - } - } - } -} - -unset($__tmp); \ No newline at end of file +<?php +// +// FPDI - Version 1.4.1 +// +// Copyright 2004-2011 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 (!class_exists('pdf_context', false)) { + + class pdf_context { + + /** + * Modi + * + * @var integer 0 = file | 1 = string + */ + var $_mode = 0; + + var $file; + var $buffer; + var $offset; + var $length; + + var $stack; + + // Constructor + + function pdf_context(&$f) { + $this->file =& $f; + if (is_string($this->file)) + $this->_mode = 1; + $this->reset(); + } + + // Optionally move the file + // pointer to a new location + // and reset the buffered data + + function reset($pos = null, $l = 100) { + if ($this->_mode == 0) { + if (!is_null ($pos)) { + fseek ($this->file, $pos); + } + + $this->buffer = $l > 0 ? fread($this->file, $l) : ''; + $this->length = strlen($this->buffer); + if ($this->length < $l) + $this->increase_length($l - $this->length); + } else { + $this->buffer = $this->file; + $this->length = strlen($this->buffer); + } + $this->offset = 0; + $this->stack = array(); + } + + // Make sure that there is at least one + // character beyond the current offset in + // the buffer to prevent the tokenizer + // from attempting to access data that does + // not exist + + function ensure_content() { + if ($this->offset >= $this->length - 1) { + return $this->increase_length(); + } else { + return true; + } + } + + // Forcefully read more data into the buffer + + function increase_length($l = 100) { + if ($this->_mode == 0 && feof($this->file)) { + return false; + } else if ($this->_mode == 0) { + $totalLength = $this->length + $l; + do { + $toRead = $totalLength - $this->length; + if ($toRead < 1) + break; + + $this->buffer .= fread($this->file, $toRead); + } while ((($this->length = strlen($this->buffer)) != $totalLength) && !feof($this->file)); + + return true; + } else { + return false; + } + } + } +} \ No newline at end of file diff --git a/htdocs/includes/fpdf/fpdfi/pdf_parser.php b/htdocs/includes/fpdf/fpdfi/pdf_parser.php index 352f59fa74765b87081b8b9b29e019e338336b23..0724152e982c31da0f88c497583ce89db696ed91 100644 --- a/htdocs/includes/fpdf/fpdfi/pdf_parser.php +++ b/htdocs/includes/fpdf/fpdfi/pdf_parser.php @@ -1,722 +1,719 @@ -<?php -// -// FPDI - Version 1.3.4 -// -// Copyright 2004-2010 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 ('PDF_TYPE_NULL')) - define ('PDF_TYPE_NULL', 0); -if (!defined ('PDF_TYPE_NUMERIC')) - define ('PDF_TYPE_NUMERIC', 1); -if (!defined ('PDF_TYPE_TOKEN')) - define ('PDF_TYPE_TOKEN', 2); -if (!defined ('PDF_TYPE_HEX')) - define ('PDF_TYPE_HEX', 3); -if (!defined ('PDF_TYPE_STRING')) - define ('PDF_TYPE_STRING', 4); -if (!defined ('PDF_TYPE_DICTIONARY')) - define ('PDF_TYPE_DICTIONARY', 5); -if (!defined ('PDF_TYPE_ARRAY')) - define ('PDF_TYPE_ARRAY', 6); -if (!defined ('PDF_TYPE_OBJDEC')) - define ('PDF_TYPE_OBJDEC', 7); -if (!defined ('PDF_TYPE_OBJREF')) - define ('PDF_TYPE_OBJREF', 8); -if (!defined ('PDF_TYPE_OBJECT')) - define ('PDF_TYPE_OBJECT', 9); -if (!defined ('PDF_TYPE_STREAM')) - define ('PDF_TYPE_STREAM', 10); -if (!defined ('PDF_TYPE_BOOLEAN')) - define ('PDF_TYPE_BOOLEAN', 11); -if (!defined ('PDF_TYPE_REAL')) - define ('PDF_TYPE_REAL', 12); - -require_once('pdf_context.php'); - -$__tmp = version_compare(phpversion(), "5") == -1 ? array('pdf_parser') : array('pdf_parser', false); -if (!call_user_func_array('class_exists', $__tmp)) { - - class pdf_parser { - - /** - * Filename - * @var string - */ - var $filename; - - /** - * File resource - * @var resource - */ - var $f; - - /** - * PDF Context - * @var object pdf_context-Instance - */ - var $c; - - /** - * xref-Data - * @var array - */ - var $xref; - - /** - * root-Object - * @var array - */ - var $root; - - /** - * PDF version of the loaded document - * @var string - */ - var $pdfVersion; - - /** - * For reading encrypted documents and xref/objectstreams are in use - * - * @var boolean - */ - var $readPlain = true; - - /** - * Constructor - * - * @param string $filename Source-Filename - */ - function pdf_parser($filename) { - $this->filename = $filename; - - $this->f = @fopen($this->filename, 'rb'); - - if (!$this->f) - $this->error(sprintf('Cannot open %s !', $filename)); - - $this->getPDFVersion(); - - $this->c = new pdf_context($this->f); - - // Read xref-Data - $this->xref = array(); - $this->pdf_read_xref($this->xref, $this->pdf_find_xref()); - - // Check for Encryption - $this->getEncryption(); - - // Read root - $this->pdf_read_root(); - } - - /** - * Close the opened file - */ - function closeFile() { - if (isset($this->f) && is_resource($this->f)) { - fclose($this->f); - unset($this->f); - } - } - - /** - * Print Error and die - * - * @param string $msg Error-Message - */ - function error($msg) { - die('<b>PDF-Parser Error:</b> '.$msg); - } - - /** - * Check Trailer for Encryption - */ - function getEncryption() { - if (isset($this->xref['trailer'][1]['/Encrypt'])) { - $this->error('File is encrypted!'); - } - } - - /** - * Find/Return /Root - * - * @return array - */ - function pdf_find_root() { - if ($this->xref['trailer'][1]['/Root'][0] != PDF_TYPE_OBJREF) { - $this->error('Wrong Type of Root-Element! Must be an indirect reference'); - } - - return $this->xref['trailer'][1]['/Root']; - } - - /** - * Read the /Root - */ - function pdf_read_root() { - // read root - $this->root = $this->pdf_resolve_object($this->c, $this->pdf_find_root()); - } - - /** - * Get PDF-Version - * - * And reset the PDF Version used in FPDI if needed - */ - function getPDFVersion() { - fseek($this->f, 0); - preg_match('/\d\.\d/',fread($this->f,16),$m); - if (isset($m[0])) - $this->pdfVersion = $m[0]; - return $this->pdfVersion; - } - - /** - * Find the xref-Table - */ - function pdf_find_xref() { - $toRead = 1500; - - $stat = fseek ($this->f, -$toRead, SEEK_END); - if ($stat === -1) { - fseek ($this->f, 0); - } - $data = fread($this->f, $toRead); - - $pos = strlen($data) - strpos(strrev($data), strrev('startxref')); - $data = substr($data, $pos); - - if (!preg_match('/\s*(\d+).*$/s', $data, $matches)) { - $this->error('Unable to find pointer to xref table'); - } - - return (int) $matches[1]; - } - - /** - * Read xref-table - * - * @param array $result Array of xref-table - * @param integer $offset of xref-table - */ - function pdf_read_xref(&$result, $offset) { - $o_pos = $offset-min(20, $offset); - fseek($this->f, $o_pos); // set some bytes backwards to fetch errorious docs - - $data = fread($this->f, 100); - - $xrefPos = strrpos($data, 'xref'); - - if ($xrefPos === false) { - fseek($this->f, $offset); - $c = new pdf_context($this->f); - $xrefStreamObjDec = $this->pdf_read_value($c); - - if (is_array($xrefStreamObjDec) && isset($xrefStreamObjDec[0]) && $xrefStreamObjDec[0] == PDF_TYPE_OBJDEC) { - $this->error(sprintf('This document (%s) probably uses a compression technique which is not supported by the free parser shipped with FPDI.', $this->filename)); - } else { - $this->error('Unable to find xref table.'); - } - } - - if (!isset($result['xref_location'])) { - $result['xref_location'] = $o_pos+$xrefPos; - $result['max_object'] = 0; - } - - $cylces = -1; - $bytesPerCycle = 100; - - fseek($this->f, $o_pos = $o_pos+$xrefPos+4); // set the handle directly after the "xref"-keyword - $data = fread($this->f, $bytesPerCycle); - - while (($trailerPos = strpos($data, 'trailer', max($bytesPerCycle*$cylces++, 0))) === false && !feof($this->f)) { - $data .= fread($this->f, $bytesPerCycle); - } - - if ($trailerPos === false) { - $this->error('Trailer keyword not found after xref table'); - } - - $data = substr($data, 0, $trailerPos); - - // get Line-Ending - preg_match_all("/(\r\n|\n|\r)/", substr($data, 0, 100), $m); // check the first 100 bytes for linebreaks - - $differentLineEndings = count(array_unique($m[0])); - if ($differentLineEndings > 1) { - $lines = preg_split("/(\r\n|\n|\r)/", $data, -1, PREG_SPLIT_NO_EMPTY); - } else { - $lines = explode($m[0][1], $data); - } - - $data = $differentLineEndings = $m = null; - unset($data, $differentLineEndings, $m); - - $linesCount = count($lines); - - $start = 1; - - for ($i = 0; $i < $linesCount; $i++) { - $line = trim($lines[$i]); - if ($line) { - $pieces = explode(' ', $line); - $c = count($pieces); - switch($c) { - case 2: - $start = (int)$pieces[0]; - $end = $start+(int)$pieces[1]; - if ($end > $result['max_object']) - $result['max_object'] = $end; - break; - case 3: - if (!isset($result['xref'][$start])) - $result['xref'][$start] = array(); - - if (!array_key_exists($gen = (int) $pieces[1], $result['xref'][$start])) { - $result['xref'][$start][$gen] = $pieces[2] == 'n' ? (int) $pieces[0] : null; - } - $start++; - break; - default: - $this->error('Unexpected data in xref table'); - } - } - } - - $lines = $pieces = $line = $start = $end = $gen = null; - unset($lines, $pieces, $line, $start, $end, $gen); - - fseek($this->f, $o_pos+$trailerPos+7); - - $c = new pdf_context($this->f); - $trailer = $this->pdf_read_value($c); - - $c = null; - unset($c); - - if (!isset($result['trailer'])) { - $result['trailer'] = $trailer; - } - - if (isset($trailer[1]['/Prev'])) { - $this->pdf_read_xref($result, $trailer[1]['/Prev'][1]); - } - - $trailer = null; - unset($trailer); - - return true; - } - - /** - * Reads an Value - * - * @param object $c pdf_context - * @param string $token a Token - * @return mixed - */ - function pdf_read_value(&$c, $token = null) { - if (is_null($token)) { - $token = $this->pdf_read_token($c); - } - - if ($token === false) { - return false; - } - - switch ($token) { - case '<': - // This is a hex string. - // Read the value, then the terminator - - $pos = $c->offset; - - while(1) { - - $match = strpos ($c->buffer, '>', $pos); - - // If you can't find it, try - // reading more data from the stream - - if ($match === false) { - if (!$c->increase_length()) { - return false; - } else { - continue; - } - } - - $result = substr ($c->buffer, $c->offset, $match - $c->offset); - $c->offset = $match + 1; - - return array (PDF_TYPE_HEX, $result); - } - - break; - case '<<': - // This is a dictionary. - - $result = array(); - - // Recurse into this function until we reach - // the end of the dictionary. - while (($key = $this->pdf_read_token($c)) !== '>>') { - if ($key === false) { - return false; - } - - if (($value = $this->pdf_read_value($c)) === false) { - return false; - } - - // Catch missing value - if ($value[0] == PDF_TYPE_TOKEN && $value[1] == '>>') { - $result[$key] = array(PDF_TYPE_NULL); - break; - } - - $result[$key] = $value; - } - - return array (PDF_TYPE_DICTIONARY, $result); - - case '[': - // This is an array. - - $result = array(); - - // Recurse into this function until we reach - // the end of the array. - while (($token = $this->pdf_read_token($c)) !== ']') { - if ($token === false) { - return false; - } - - if (($value = $this->pdf_read_value($c, $token)) === false) { - return false; - } - - $result[] = $value; - } - - return array (PDF_TYPE_ARRAY, $result); - - case '(' : - // This is a string - $pos = $c->offset; - - $openBrackets = 1; - do { - for (; $openBrackets != 0 && $pos < $c->length; $pos++) { - switch (ord($c->buffer[$pos])) { - case 0x28: // '(' - $openBrackets++; - break; - case 0x29: // ')' - $openBrackets--; - break; - case 0x5C: // backslash - $pos++; - } - } - } while($openBrackets != 0 && $c->increase_length()); - - $result = substr($c->buffer, $c->offset, $pos - $c->offset - 1); - $c->offset = $pos; - - return array (PDF_TYPE_STRING, $result); - - case 'stream': - $o_pos = ftell($c->file)-strlen($c->buffer); - $o_offset = $c->offset; - - $c->reset($startpos = $o_pos + $o_offset); - - $e = 0; // ensure line breaks in front of the stream - if ($c->buffer[0] == chr(10) || $c->buffer[0] == chr(13)) - $e++; - if ($c->buffer[1] == chr(10) && $c->buffer[0] != chr(10)) - $e++; - - if ($this->actual_obj[1][1]['/Length'][0] == PDF_TYPE_OBJREF) { - $tmp_c = new pdf_context($this->f); - $tmp_length = $this->pdf_resolve_object($tmp_c, $this->actual_obj[1][1]['/Length']); - $length = $tmp_length[1][1]; - } else { - $length = $this->actual_obj[1][1]['/Length'][1]; - } - - if ($length > 0) { - $c->reset($startpos+$e,$length); - $v = $c->buffer; - } else { - $v = ''; - } - $c->reset($startpos+$e+$length+9); // 9 = strlen("endstream") - - return array(PDF_TYPE_STREAM, $v); - - default : - if (is_numeric ($token)) { - // A numeric token. Make sure that - // it is not part of something else. - if (($tok2 = $this->pdf_read_token ($c)) !== false) { - if (is_numeric ($tok2)) { - - // Two numeric tokens in a row. - // In this case, we're probably in - // front of either an object reference - // or an object specification. - // Determine the case and return the data - if (($tok3 = $this->pdf_read_token ($c)) !== false) { - switch ($tok3) { - case 'obj' : - return array (PDF_TYPE_OBJDEC, (int) $token, (int) $tok2); - case 'R' : - return array (PDF_TYPE_OBJREF, (int) $token, (int) $tok2); - } - // If we get to this point, that numeric value up - // there was just a numeric value. Push the extra - // tokens back into the stack and return the value. - array_push ($c->stack, $tok3); - } - } - - array_push ($c->stack, $tok2); - } - - if ($token === (string)((int)$token)) - return array (PDF_TYPE_NUMERIC, (int)$token); - else - return array (PDF_TYPE_REAL, (float)$token); - } else if ($token == 'true' || $token == 'false') { - return array (PDF_TYPE_BOOLEAN, $token == 'true'); - } else if ($token == 'null') { - return array (PDF_TYPE_NULL); - } else { - // Just a token. Return it. - return array (PDF_TYPE_TOKEN, $token); - } - } - } - - /** - * Resolve an object - * - * @param object $c pdf_context - * @param array $obj_spec The object-data - * @param boolean $encapsulate Must set to true, cause the parsing and fpdi use this method only without this para - */ - function pdf_resolve_object(&$c, $obj_spec, $encapsulate = true) { - // Exit if we get invalid data - if (!is_array($obj_spec)) { - $ret = false; - return $ret; - } - - if ($obj_spec[0] == PDF_TYPE_OBJREF) { - - // This is a reference, resolve it - if (isset($this->xref['xref'][$obj_spec[1]][$obj_spec[2]])) { - - // Save current file position - // This is needed if you want to resolve - // references while you're reading another object - // (e.g.: if you need to determine the length - // of a stream) - - $old_pos = ftell($c->file); - - // Reposition the file pointer and - // load the object header. - - $c->reset($this->xref['xref'][$obj_spec[1]][$obj_spec[2]]); - - $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 - // number for later use - $result = array(); - $this->actual_obj =& $result; - if ($encapsulate) { - $result = array ( - PDF_TYPE_OBJECT, - 'obj' => $obj_spec[1], - 'gen' => $obj_spec[2] - ); - } - - // Now simply read the object data until - // we encounter an end-of-object marker - while(1) { - $value = $this->pdf_read_value($c); - if ($value === false || count($result) > 4) { - // in this case the parser coudn't find an endobj so we break here - break; - } - - if ($value[0] == PDF_TYPE_TOKEN && $value[1] === 'endobj') { - break; - } - - $result[] = $value; - } - - $c->reset($old_pos); - - if (isset($result[2][0]) && $result[2][0] == PDF_TYPE_STREAM) { - $result[0] = PDF_TYPE_STREAM; - } - - return $result; - } - } else { - return $obj_spec; - } - } - - - - /** - * Reads a token from the file - * - * @param object $c pdf_context - * @return mixed - */ - function pdf_read_token(&$c) - { - // If there is a token available - // on the stack, pop it out and - // return it. - - if (count($c->stack)) { - return array_pop($c->stack); - } - - // Strip away any whitespace - - do { - if (!$c->ensure_content()) { - return false; - } - $c->offset += strspn($c->buffer, " \n\r\t", $c->offset); - } while ($c->offset >= $c->length - 1); - - // Get the first character in the stream - - $char = $c->buffer[$c->offset++]; - - switch ($char) { - - case '[': - case ']': - case '(': - case ')': - - // This is either an array or literal string - // delimiter, Return it - - return $char; - - case '<': - case '>': - - // This could either be a hex string or - // dictionary delimiter. Determine the - // appropriate case and return the token - - if ($c->buffer[$c->offset] == $char) { - if (!$c->ensure_content()) { - return false; - } - $c->offset++; - return $char . $char; - } else { - return $char; - } - - case '%': - - // This is a comment - jump over it! - - $pos = $c->offset; - while(1) { - $match = preg_match("/(\r\n|\r|\n)/", $c->buffer, $m, PREG_OFFSET_CAPTURE, $pos); - if ($match === 0) { - if (!$c->increase_length()) { - return false; - } else { - continue; - } - } - - $c->offset = $m[0][1]+strlen($m[0][0]); - - return $this->pdf_read_token($c); - } - - default: - - // This is "another" type of token (probably - // a dictionary entry or a numeric value) - // Find the end and return it. - - if (!$c->ensure_content()) { - return false; - } - - while(1) { - - // Determine the length of the token - - $pos = strcspn($c->buffer, " %[]<>()\r\n\t/", $c->offset); - - if ($c->offset + $pos <= $c->length - 1) { - break; - } else { - // If the script reaches this point, - // the token may span beyond the end - // of the current buffer. Therefore, - // we increase the size of the buffer - // and try again--just to be safe. - - $c->increase_length(); - } - } - - $result = substr($c->buffer, $c->offset - 1, $pos + 1); - - $c->offset += $pos; - return $result; - } - } - } -} - -unset($__tmp); \ No newline at end of file +<?php +// +// FPDI - Version 1.4.1 +// +// Copyright 2004-2011 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 ('PDF_TYPE_NULL')) + define ('PDF_TYPE_NULL', 0); +if (!defined ('PDF_TYPE_NUMERIC')) + define ('PDF_TYPE_NUMERIC', 1); +if (!defined ('PDF_TYPE_TOKEN')) + define ('PDF_TYPE_TOKEN', 2); +if (!defined ('PDF_TYPE_HEX')) + define ('PDF_TYPE_HEX', 3); +if (!defined ('PDF_TYPE_STRING')) + define ('PDF_TYPE_STRING', 4); +if (!defined ('PDF_TYPE_DICTIONARY')) + define ('PDF_TYPE_DICTIONARY', 5); +if (!defined ('PDF_TYPE_ARRAY')) + define ('PDF_TYPE_ARRAY', 6); +if (!defined ('PDF_TYPE_OBJDEC')) + define ('PDF_TYPE_OBJDEC', 7); +if (!defined ('PDF_TYPE_OBJREF')) + define ('PDF_TYPE_OBJREF', 8); +if (!defined ('PDF_TYPE_OBJECT')) + define ('PDF_TYPE_OBJECT', 9); +if (!defined ('PDF_TYPE_STREAM')) + define ('PDF_TYPE_STREAM', 10); +if (!defined ('PDF_TYPE_BOOLEAN')) + define ('PDF_TYPE_BOOLEAN', 11); +if (!defined ('PDF_TYPE_REAL')) + define ('PDF_TYPE_REAL', 12); + +require_once('pdf_context.php'); + +if (!class_exists('pdf_parser', false)) { + + class pdf_parser { + + /** + * Filename + * @var string + */ + var $filename; + + /** + * File resource + * @var resource + */ + var $f; + + /** + * PDF Context + * @var object pdf_context-Instance + */ + var $c; + + /** + * xref-Data + * @var array + */ + var $xref; + + /** + * root-Object + * @var array + */ + var $root; + + /** + * PDF version of the loaded document + * @var string + */ + var $pdfVersion; + + /** + * For reading encrypted documents and xref/objectstreams are in use + * + * @var boolean + */ + var $readPlain = true; + + /** + * Constructor + * + * @param string $filename Source-Filename + */ + function pdf_parser($filename) { + $this->filename = $filename; + + $this->f = @fopen($this->filename, 'rb'); + + if (!$this->f) + $this->error(sprintf('Cannot open %s !', $filename)); + + $this->getPDFVersion(); + + $this->c = new pdf_context($this->f); + + // Read xref-Data + $this->xref = array(); + $this->pdf_read_xref($this->xref, $this->pdf_find_xref()); + + // Check for Encryption + $this->getEncryption(); + + // Read root + $this->pdf_read_root(); + } + + /** + * Close the opened file + */ + function closeFile() { + if (isset($this->f) && is_resource($this->f)) { + fclose($this->f); + unset($this->f); + } + } + + /** + * Print Error and die + * + * @param string $msg Error-Message + */ + function error($msg) { + die('<b>PDF-Parser Error:</b> '.$msg); + } + + /** + * Check Trailer for Encryption + */ + function getEncryption() { + if (isset($this->xref['trailer'][1]['/Encrypt'])) { + $this->error('File is encrypted!'); + } + } + + /** + * Find/Return /Root + * + * @return array + */ + function pdf_find_root() { + if ($this->xref['trailer'][1]['/Root'][0] != PDF_TYPE_OBJREF) { + $this->error('Wrong Type of Root-Element! Must be an indirect reference'); + } + + return $this->xref['trailer'][1]['/Root']; + } + + /** + * Read the /Root + */ + function pdf_read_root() { + // read root + $this->root = $this->pdf_resolve_object($this->c, $this->pdf_find_root()); + } + + /** + * Get PDF-Version + * + * And reset the PDF Version used in FPDI if needed + */ + function getPDFVersion() { + fseek($this->f, 0); + preg_match('/\d\.\d/',fread($this->f,16),$m); + if (isset($m[0])) + $this->pdfVersion = $m[0]; + return $this->pdfVersion; + } + + /** + * Find the xref-Table + */ + function pdf_find_xref() { + $toRead = 1500; + + $stat = fseek ($this->f, -$toRead, SEEK_END); + if ($stat === -1) { + fseek ($this->f, 0); + } + $data = fread($this->f, $toRead); + + $pos = strlen($data) - strpos(strrev($data), strrev('startxref')); + $data = substr($data, $pos); + + if (!preg_match('/\s*(\d+).*$/s', $data, $matches)) { + $this->error('Unable to find pointer to xref table'); + } + + return (int) $matches[1]; + } + + /** + * Read xref-table + * + * @param array $result Array of xref-table + * @param integer $offset of xref-table + */ + function pdf_read_xref(&$result, $offset) { + $o_pos = $offset-min(20, $offset); + fseek($this->f, $o_pos); // set some bytes backwards to fetch errorious docs + + $data = fread($this->f, 100); + + $xrefPos = strrpos($data, 'xref'); + + if ($xrefPos === false) { + fseek($this->f, $offset); + $c = new pdf_context($this->f); + $xrefStreamObjDec = $this->pdf_read_value($c); + + if (is_array($xrefStreamObjDec) && isset($xrefStreamObjDec[0]) && $xrefStreamObjDec[0] == PDF_TYPE_OBJDEC) { + $this->error(sprintf('This document (%s) probably uses a compression technique which is not supported by the free parser shipped with FPDI.', $this->filename)); + } else { + $this->error('Unable to find xref table.'); + } + } + + if (!isset($result['xref_location'])) { + $result['xref_location'] = $o_pos+$xrefPos; + $result['max_object'] = 0; + } + + $cylces = -1; + $bytesPerCycle = 100; + + fseek($this->f, $o_pos = $o_pos+$xrefPos+4); // set the handle directly after the "xref"-keyword + $data = fread($this->f, $bytesPerCycle); + + while (($trailerPos = strpos($data, 'trailer', max($bytesPerCycle*$cylces++, 0))) === false && !feof($this->f)) { + $data .= fread($this->f, $bytesPerCycle); + } + + if ($trailerPos === false) { + $this->error('Trailer keyword not found after xref table'); + } + + $data = substr($data, 0, $trailerPos); + + // get Line-Ending + preg_match_all("/(\r\n|\n|\r)/", substr($data, 0, 100), $m); // check the first 100 bytes for linebreaks + + $differentLineEndings = count(array_unique($m[0])); + if ($differentLineEndings > 1) { + $lines = preg_split("/(\r\n|\n|\r)/", $data, -1, PREG_SPLIT_NO_EMPTY); + } else { + $lines = explode($m[0][1], $data); + } + + $data = $differentLineEndings = $m = null; + unset($data, $differentLineEndings, $m); + + $linesCount = count($lines); + + $start = 1; + + for ($i = 0; $i < $linesCount; $i++) { + $line = trim($lines[$i]); + if ($line) { + $pieces = explode(' ', $line); + $c = count($pieces); + switch($c) { + case 2: + $start = (int)$pieces[0]; + $end = $start+(int)$pieces[1]; + if ($end > $result['max_object']) + $result['max_object'] = $end; + break; + case 3: + if (!isset($result['xref'][$start])) + $result['xref'][$start] = array(); + + if (!array_key_exists($gen = (int) $pieces[1], $result['xref'][$start])) { + $result['xref'][$start][$gen] = $pieces[2] == 'n' ? (int) $pieces[0] : null; + } + $start++; + break; + default: + $this->error('Unexpected data in xref table'); + } + } + } + + $lines = $pieces = $line = $start = $end = $gen = null; + unset($lines, $pieces, $line, $start, $end, $gen); + + fseek($this->f, $o_pos+$trailerPos+7); + + $c = new pdf_context($this->f); + $trailer = $this->pdf_read_value($c); + + $c = null; + unset($c); + + if (!isset($result['trailer'])) { + $result['trailer'] = $trailer; + } + + if (isset($trailer[1]['/Prev'])) { + $this->pdf_read_xref($result, $trailer[1]['/Prev'][1]); + } + + $trailer = null; + unset($trailer); + + return true; + } + + /** + * Reads an Value + * + * @param object $c pdf_context + * @param string $token a Token + * @return mixed + */ + function pdf_read_value(&$c, $token = null) { + if (is_null($token)) { + $token = $this->pdf_read_token($c); + } + + if ($token === false) { + return false; + } + + switch ($token) { + case '<': + // This is a hex string. + // Read the value, then the terminator + + $pos = $c->offset; + + while(1) { + + $match = strpos ($c->buffer, '>', $pos); + + // If you can't find it, try + // reading more data from the stream + + if ($match === false) { + if (!$c->increase_length()) { + return false; + } else { + continue; + } + } + + $result = substr ($c->buffer, $c->offset, $match - $c->offset); + $c->offset = $match + 1; + + return array (PDF_TYPE_HEX, $result); + } + + break; + case '<<': + // This is a dictionary. + + $result = array(); + + // Recurse into this function until we reach + // the end of the dictionary. + while (($key = $this->pdf_read_token($c)) !== '>>') { + if ($key === false) { + return false; + } + + if (($value = $this->pdf_read_value($c)) === false) { + return false; + } + + // Catch missing value + if ($value[0] == PDF_TYPE_TOKEN && $value[1] == '>>') { + $result[$key] = array(PDF_TYPE_NULL); + break; + } + + $result[$key] = $value; + } + + return array (PDF_TYPE_DICTIONARY, $result); + + case '[': + // This is an array. + + $result = array(); + + // Recurse into this function until we reach + // the end of the array. + while (($token = $this->pdf_read_token($c)) !== ']') { + if ($token === false) { + return false; + } + + if (($value = $this->pdf_read_value($c, $token)) === false) { + return false; + } + + $result[] = $value; + } + + return array (PDF_TYPE_ARRAY, $result); + + case '(' : + // This is a string + $pos = $c->offset; + + $openBrackets = 1; + do { + for (; $openBrackets != 0 && $pos < $c->length; $pos++) { + switch (ord($c->buffer[$pos])) { + case 0x28: // '(' + $openBrackets++; + break; + case 0x29: // ')' + $openBrackets--; + break; + case 0x5C: // backslash + $pos++; + } + } + } while($openBrackets != 0 && $c->increase_length()); + + $result = substr($c->buffer, $c->offset, $pos - $c->offset - 1); + $c->offset = $pos; + + return array (PDF_TYPE_STRING, $result); + + case 'stream': + $o_pos = ftell($c->file)-strlen($c->buffer); + $o_offset = $c->offset; + + $c->reset($startpos = $o_pos + $o_offset); + + $e = 0; // ensure line breaks in front of the stream + if ($c->buffer[0] == chr(10) || $c->buffer[0] == chr(13)) + $e++; + if ($c->buffer[1] == chr(10) && $c->buffer[0] != chr(10)) + $e++; + + if ($this->actual_obj[1][1]['/Length'][0] == PDF_TYPE_OBJREF) { + $tmp_c = new pdf_context($this->f); + $tmp_length = $this->pdf_resolve_object($tmp_c, $this->actual_obj[1][1]['/Length']); + $length = $tmp_length[1][1]; + } else { + $length = $this->actual_obj[1][1]['/Length'][1]; + } + + if ($length > 0) { + $c->reset($startpos+$e,$length); + $v = $c->buffer; + } else { + $v = ''; + } + $c->reset($startpos+$e+$length+9); // 9 = strlen("endstream") + + return array(PDF_TYPE_STREAM, $v); + + default : + if (is_numeric ($token)) { + // A numeric token. Make sure that + // it is not part of something else. + if (($tok2 = $this->pdf_read_token ($c)) !== false) { + if (is_numeric ($tok2)) { + + // Two numeric tokens in a row. + // In this case, we're probably in + // front of either an object reference + // or an object specification. + // Determine the case and return the data + if (($tok3 = $this->pdf_read_token ($c)) !== false) { + switch ($tok3) { + case 'obj' : + return array (PDF_TYPE_OBJDEC, (int) $token, (int) $tok2); + case 'R' : + return array (PDF_TYPE_OBJREF, (int) $token, (int) $tok2); + } + // If we get to this point, that numeric value up + // there was just a numeric value. Push the extra + // tokens back into the stack and return the value. + array_push ($c->stack, $tok3); + } + } + + array_push ($c->stack, $tok2); + } + + if ($token === (string)((int)$token)) + return array (PDF_TYPE_NUMERIC, (int)$token); + else + return array (PDF_TYPE_REAL, (float)$token); + } else if ($token == 'true' || $token == 'false') { + return array (PDF_TYPE_BOOLEAN, $token == 'true'); + } else if ($token == 'null') { + return array (PDF_TYPE_NULL); + } else { + // Just a token. Return it. + return array (PDF_TYPE_TOKEN, $token); + } + } + } + + /** + * Resolve an object + * + * @param object $c pdf_context + * @param array $obj_spec The object-data + * @param boolean $encapsulate Must set to true, cause the parsing and fpdi use this method only without this para + */ + function pdf_resolve_object(&$c, $obj_spec, $encapsulate = true) { + // Exit if we get invalid data + if (!is_array($obj_spec)) { + $ret = false; + return $ret; + } + + if ($obj_spec[0] == PDF_TYPE_OBJREF) { + + // This is a reference, resolve it + if (isset($this->xref['xref'][$obj_spec[1]][$obj_spec[2]])) { + + // Save current file position + // This is needed if you want to resolve + // references while you're reading another object + // (e.g.: if you need to determine the length + // of a stream) + + $old_pos = ftell($c->file); + + // Reposition the file pointer and + // load the object header. + + $c->reset($this->xref['xref'][$obj_spec[1]][$obj_spec[2]]); + + $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 + // number for later use + $result = array(); + $this->actual_obj =& $result; + if ($encapsulate) { + $result = array ( + PDF_TYPE_OBJECT, + 'obj' => $obj_spec[1], + 'gen' => $obj_spec[2] + ); + } + + // Now simply read the object data until + // we encounter an end-of-object marker + while(1) { + $value = $this->pdf_read_value($c); + if ($value === false || count($result) > 4) { + // in this case the parser coudn't find an endobj so we break here + break; + } + + if ($value[0] == PDF_TYPE_TOKEN && $value[1] === 'endobj') { + break; + } + + $result[] = $value; + } + + $c->reset($old_pos); + + if (isset($result[2][0]) && $result[2][0] == PDF_TYPE_STREAM) { + $result[0] = PDF_TYPE_STREAM; + } + + return $result; + } + } else { + return $obj_spec; + } + } + + + + /** + * Reads a token from the file + * + * @param object $c pdf_context + * @return mixed + */ + function pdf_read_token(&$c) + { + // If there is a token available + // on the stack, pop it out and + // return it. + + if (count($c->stack)) { + return array_pop($c->stack); + } + + // Strip away any whitespace + + do { + if (!$c->ensure_content()) { + return false; + } + $c->offset += strspn($c->buffer, " \n\r\t", $c->offset); + } while ($c->offset >= $c->length - 1); + + // Get the first character in the stream + + $char = $c->buffer[$c->offset++]; + + switch ($char) { + + case '[': + case ']': + case '(': + case ')': + + // This is either an array or literal string + // delimiter, Return it + + return $char; + + case '<': + case '>': + + // This could either be a hex string or + // dictionary delimiter. Determine the + // appropriate case and return the token + + if ($c->buffer[$c->offset] == $char) { + if (!$c->ensure_content()) { + return false; + } + $c->offset++; + return $char . $char; + } else { + return $char; + } + + case '%': + + // This is a comment - jump over it! + + $pos = $c->offset; + while(1) { + $match = preg_match("/(\r\n|\r|\n)/", $c->buffer, $m, PREG_OFFSET_CAPTURE, $pos); + if ($match === 0) { + if (!$c->increase_length()) { + return false; + } else { + continue; + } + } + + $c->offset = $m[0][1]+strlen($m[0][0]); + + return $this->pdf_read_token($c); + } + + default: + + // This is "another" type of token (probably + // a dictionary entry or a numeric value) + // Find the end and return it. + + if (!$c->ensure_content()) { + return false; + } + + while(1) { + + // Determine the length of the token + + $pos = strcspn($c->buffer, " %[]<>()\r\n\t/", $c->offset); + + if ($c->offset + $pos <= $c->length - 1) { + break; + } else { + // If the script reaches this point, + // the token may span beyond the end + // of the current buffer. Therefore, + // we increase the size of the buffer + // and try again--just to be safe. + + $c->increase_length(); + } + } + + $result = substr($c->buffer, $c->offset - 1, $pos + 1); + + $c->offset += $pos; + return $result; + } + } + } +} diff --git a/htdocs/includes/modules/action/rapport.pdf.php b/htdocs/includes/modules/action/rapport.pdf.php index db7288b06e72329e0c0be7615e48596141c8f5a3..50f028eb232ee38d0044ea5cffe46dc45bc2cc60 100644 --- a/htdocs/includes/modules/action/rapport.pdf.php +++ b/htdocs/includes/modules/action/rapport.pdf.php @@ -22,10 +22,9 @@ * \file htdocs/includes/modules/action/rapport.pdf.php * \ingroup commercial * \brief File to build PDF with events - * \version $Id: rapport.pdf.php,v 1.36 2011/08/10 23:21:13 eldy Exp $ + * \version $Id: rapport.pdf.php,v 1.37 2011/08/11 12:14:04 eldy Exp $ */ -require_once(FPDFI_PATH.'fpdi_protection.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/date.lib.php'); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); @@ -83,7 +82,7 @@ class CommActionRapport if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); diff --git a/htdocs/includes/modules/cheque/pdf/modules_chequereceipts.php b/htdocs/includes/modules/cheque/pdf/modules_chequereceipts.php index ac0b637c4d77902047ce29705be6a38b8348b2dc..99803015c2080060e9f112060f2994123f4a7f44 100644 --- a/htdocs/includes/modules/cheque/pdf/modules_chequereceipts.php +++ b/htdocs/includes/modules/cheque/pdf/modules_chequereceipts.php @@ -23,10 +23,9 @@ * \file htdocs/includes/modules/cheque/pdf/modules_chequereceipts.php * \ingroup facture * \brief File with parent class of check receipt document generators - * \version $Id: modules_chequereceipts.php,v 1.6 2011/08/10 23:21:12 eldy Exp $ + * \version $Id: modules_chequereceipts.php,v 1.7 2011/08/11 12:14:03 eldy Exp $ */ -require_once(FPDFI_PATH.'fpdi_protection.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php'); require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); require_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php"); // Requis car utilise dans les classes qui heritent diff --git a/htdocs/includes/modules/cheque/pdf/pdf_blochet.class.php b/htdocs/includes/modules/cheque/pdf/pdf_blochet.class.php index f40c2af94114d729e9a80fb9d6f230a40f09c34d..4162526b5d01fe6809ed8b91c391c1910b925c93 100644 --- a/htdocs/includes/modules/cheque/pdf/pdf_blochet.class.php +++ b/htdocs/includes/modules/cheque/pdf/pdf_blochet.class.php @@ -21,10 +21,9 @@ * \file htdocs/includes/modules/cheque/pdf/pdf_blochet.class.php * \ingroup banque * \brief File to build cheque deposit receipts - * \version $Id: pdf_blochet.class.php,v 1.42 2011/08/10 23:21:12 eldy Exp $ + * \version $Id: pdf_blochet.class.php,v 1.43 2011/08/11 12:14:03 eldy Exp $ */ -require_once(FPDFI_PATH.'fpdi_protection.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php'); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/includes/modules/cheque/pdf/modules_chequereceipts.php"); @@ -89,7 +88,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO $sav_charset_output=$outputlangs->charset_output; - if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("companies"); diff --git a/htdocs/includes/modules/commande/modules_commande.php b/htdocs/includes/modules/commande/modules_commande.php index a61543b7a33075a245281b0d5616460a46ec7085..92047b54c3e15fb91e7a422ed5ebeabd108a1795 100644 --- a/htdocs/includes/modules/commande/modules_commande.php +++ b/htdocs/includes/modules/commande/modules_commande.php @@ -25,10 +25,9 @@ * \ingroup commande * \brief Fichier contenant la classe mere de generation des commandes en PDF * et la classe mere de numerotation des commandes - * \version $Id: modules_commande.php,v 1.50 2011/08/10 23:21:09 eldy Exp $ + * \version $Id: modules_commande.php,v 1.51 2011/08/11 12:14:00 eldy Exp $ */ -require_once(FPDFI_PATH.'fpdi_protection.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php'); require_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php"); // requis car utilise par les classes qui heritent require_once(DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'); diff --git a/htdocs/includes/modules/commande/pdf_edison.modules.php b/htdocs/includes/modules/commande/pdf_edison.modules.php index 4d9d364e85d2cf8b92e4eecd86b1db36b99c9a95..16d7cbc14ef1b024e57733aea81480f3a980da1c 100644 --- a/htdocs/includes/modules/commande/pdf_edison.modules.php +++ b/htdocs/includes/modules/commande/pdf_edison.modules.php @@ -23,7 +23,7 @@ * \file htdocs/includes/modules/commande/pdf_edison.modules.php * \ingroup commande * \brief Fichier de la classe permettant de generer les commandes au modele Edison - * \version $Id: pdf_edison.modules.php,v 1.90 2011/08/10 17:40:45 hregis Exp $ + * \version $Id: pdf_edison.modules.php,v 1.91 2011/08/11 12:14:00 eldy Exp $ */ require_once(DOL_DOCUMENT_ROOT ."/includes/modules/commande/modules_commande.php"); @@ -101,7 +101,7 @@ class pdf_edison extends ModelePDFCommandes if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); diff --git a/htdocs/includes/modules/commande/pdf_einstein.modules.php b/htdocs/includes/modules/commande/pdf_einstein.modules.php index 49ca9f87f6f38903c2c8d866edf5e883dd9c3574..38f142d8d49695070d31ca970b19b7020f053135 100644 --- a/htdocs/includes/modules/commande/pdf_einstein.modules.php +++ b/htdocs/includes/modules/commande/pdf_einstein.modules.php @@ -24,7 +24,7 @@ * \ingroup commande * \brief Fichier de la classe permettant de generer les commandes au modele Einstein * \author Laurent Destailleur - * \version $Id: pdf_einstein.modules.php,v 1.164 2011/08/10 17:40:45 hregis Exp $ + * \version $Id: pdf_einstein.modules.php,v 1.165 2011/08/11 12:14:00 eldy Exp $ */ require_once(DOL_DOCUMENT_ROOT ."/includes/modules/commande/modules_commande.php"); @@ -117,7 +117,7 @@ class pdf_einstein extends ModelePDFCommandes if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); @@ -588,10 +588,10 @@ class pdf_einstein extends ModelePDFCommandes if ($tvakey > 0) // On affiche pas taux 0 { $this->atleastoneratenotnull++; - + $index++; $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); - + $tvacompl=''; if (preg_match('/\*/',$tvakey)) { @@ -601,7 +601,7 @@ class pdf_einstein extends ModelePDFCommandes $totalvat =$outputlangs->transnoentities("TotalVAT").' '; $totalvat.=vatrate($tvakey,1).$tvacompl; $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - + $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); } @@ -611,10 +611,10 @@ class pdf_einstein extends ModelePDFCommandes $index++; $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1); - + $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1); - + // Total LocalTax1 if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0) { @@ -624,7 +624,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1); } - + // Total LocalTax2 if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0) { @@ -645,10 +645,10 @@ class pdf_einstein extends ModelePDFCommandes if ($tvakey>0) // On affiche pas taux 0 { //$this->atleastoneratenotnull++; - + $index++; $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); - + $tvacompl=''; if (preg_match('/\*/',$tvakey)) { @@ -658,13 +658,13 @@ class pdf_einstein extends ModelePDFCommandes $totalvat =$outputlangs->transnoentities("TotalLT1".$mysoc->pays_code).' '; $totalvat.=vatrate($tvakey,1).$tvacompl; $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - + $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); } } } - + //Local tax 2 if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') { @@ -673,10 +673,10 @@ class pdf_einstein extends ModelePDFCommandes if ($tvakey>0) // On affiche pas taux 0 { //$this->atleastoneratenotnull++; - + $index++; $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); - + $tvacompl=''; if (preg_match('/\*/',$tvakey)) { @@ -686,7 +686,7 @@ class pdf_einstein extends ModelePDFCommandes $totalvat =$outputlangs->transnoentities("TotalLT2".$mysoc->pays_code).' '; $totalvat.=vatrate($tvakey,1).$tvacompl; $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - + $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); } @@ -703,7 +703,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetTextColor(0,0,60); $pdf->SetFillColor(224,224,224); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); - + $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc), $useborder, 'R', 1); } diff --git a/htdocs/includes/modules/dons/modules_don.php b/htdocs/includes/modules/dons/modules_don.php index e4529ad467ec05ca7654e9c9fc2c2a8aebd7ece3..c87ea245fea42335ce5bf5ea465fa9175d78c66a 100644 --- a/htdocs/includes/modules/dons/modules_don.php +++ b/htdocs/includes/modules/dons/modules_don.php @@ -23,9 +23,8 @@ * \file htdocs/includes/modules/dons/modules_don.php * \ingroup don * \brief File of class to manage donation document generation - * \version $Id: modules_don.php,v 1.22 2011/08/10 23:21:12 eldy Exp $ + * \version $Id: modules_don.php,v 1.23 2011/08/11 12:14:02 eldy Exp $ */ -require_once(FPDFI_PATH.'fpdi_protection.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php'); require_once(DOL_DOCUMENT_ROOT."/compta/dons/class/don.class.php"); @@ -84,7 +83,7 @@ class ModeleNumRefDons return $langs->trans("NoDescription"); } - /** \brief Renvoi un exemple de num�rotation + /** \brief Renvoi un exemple de numerotation * \return string Example */ function getExample() @@ -94,8 +93,8 @@ class ModeleNumRefDons return $langs->trans("NoExample"); } - /** \brief Test si les num�ros d�j� en vigueur dans la base ne provoquent pas d - * de conflits qui empechera cette num�rotation de fonctionner. + /** \brief Test si les numeros deja en vigueur dans la base ne provoquent pas d + * de conflits qui empechera cette numerotation de fonctionner. * \return boolean false si conflit, true si ok */ function canBeActivated() @@ -103,7 +102,7 @@ class ModeleNumRefDons return true; } - /** \brief Renvoi prochaine valeur attribu�e + /** \brief Renvoi prochaine valeur attribuee * \return string Valeur */ function getNextValue() @@ -129,13 +128,13 @@ class ModeleNumRefDons /** - \brief Cr�e un don sur disque en fonction du mod�le de DON_ADDON_PDF - \param db objet base de donn�e - \param id id du don � cr�er - \param message message - \param modele force le modele � utiliser ('' par defaut) - \param outputlangs objet lang a utiliser pour traduction - \return int 0 si KO, 1 si OK + * \brief Cree un don sur disque en fonction du modele de DON_ADDON_PDF + * \param db objet base de donnee + * \param id id du don e creer + * \param message message + * \param modele force le modele a utiliser ('' par defaut) + * \param outputlangs objet lang a utiliser pour traduction + * \return int 0 si KO, 1 si OK */ function don_create($db, $id, $message, $modele, $outputlangs) { @@ -175,7 +174,7 @@ function don_create($db, $id, $message, $modele, $outputlangs) $sav_charset_output=$outputlangs->charset_output; if ($obj->write_file($id,$outputlangs) > 0) { - // Succ�s de la cr�ation de la facture. On g�n�re le fichier meta + // Success. We build meta file don_meta_create($db, $id); // et on supprime l'image correspondant au preview don_delete_preview($db, $id); @@ -199,10 +198,10 @@ function don_create($db, $id, $message, $modele, $outputlangs) } /** - \brief Cr�� un meta fichier � c�t� de la facture sur le disque pour faciliter les recherches en texte plein. Pourquoi ? tout simplement parcequ'en fin d'exercice quand je suis avec mon comptable je n'ai pas de connexion internet "rapide" pour retrouver en 2 secondes une facture non pay�e ou compliqu�e � g�rer ... avec un rgrep c'est vite fait bien fait [eric seigne - \param db Objet base de donn�e - \param donid Id du don � cr�er - \param message Message + * \brief Cree un meta fichier a cote de la facture sur le disque pour faciliter les recherches en texte plein. Pourquoi ? tout simplement parcequ'en fin d'exercice quand je suis avec mon comptable je n'ai pas de connexion internet "rapide" pour retrouver en 2 secondes une facture non pay�e ou compliqu�e � g�rer ... avec un rgrep c'est vite fait bien fait [eric seigne + * \param db Objet base de donnee + * \param donid Id du don a creer + * \param message Message */ function don_meta_create($db, $donid, $message="") { @@ -215,9 +214,9 @@ function don_meta_create($db, $donid, $message="") /** - \brief Supprime l'image de pr�visualitation, pour le cas de r�g�n�ration de facture - \param db Objet base de donn�e - \param donid Id du don + * \brief Supprime l'image de previsualitation, pour le cas de r�g�n�ration de facture + * \param db Objet base de donnee + * \param donid Id du don */ function don_delete_preview($db, $donid) { diff --git a/htdocs/includes/modules/expedition/methode_expedition.modules.php b/htdocs/includes/modules/expedition/methode_expedition.modules.php index ed86d225f8f8ac331205397cb57dd9a922b47056..b0eb668e889e5a6f8ec54147880540e865829d59 100644 --- a/htdocs/includes/modules/expedition/methode_expedition.modules.php +++ b/htdocs/includes/modules/expedition/methode_expedition.modules.php @@ -22,9 +22,8 @@ * \ingroup expedition * \brief Fichier contenant la classe mere de generation de bon de livraison en PDF * et la classe mere de numerotation des bons de livraisons - * \version $Id: methode_expedition.modules.php,v 1.11 2011/08/10 23:21:12 eldy Exp $ + * \version $Id: methode_expedition.modules.php,v 1.12 2011/08/11 12:14:02 eldy Exp $ */ -require_once(FPDFI_PATH.'fpdi_protection.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php'); diff --git a/htdocs/includes/modules/expedition/pdf/ModelePdfExpedition.class.php b/htdocs/includes/modules/expedition/pdf/ModelePdfExpedition.class.php index 48e0b7a4b479d3ca89bf05473bc2db52393cee96..3a13c10ea8dbd338df3d4d90a24f9fcb00374bcb 100644 --- a/htdocs/includes/modules/expedition/pdf/ModelePdfExpedition.class.php +++ b/htdocs/includes/modules/expedition/pdf/ModelePdfExpedition.class.php @@ -22,10 +22,9 @@ * \file htdocs/includes/modules/expedition/pdf/ModelePdfExpedition.class.php * \ingroup shipping * \brief Fichier contenant la classe mere de generation des expeditions - * \version $Id: ModelePdfExpedition.class.php,v 1.17 2011/08/10 23:20:55 eldy Exp $ + * \version $Id: ModelePdfExpedition.class.php,v 1.18 2011/08/11 12:14:00 eldy Exp $ */ -require_once(FPDFI_PATH.'fpdi_protection.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php'); diff --git a/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php b/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php index 6b97bf3d4d53ebacddb9fd05ae7ea6f8f248fd48..75c938956ada0b6afe56bed584890bc9b95be663 100644 --- a/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php +++ b/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php @@ -22,7 +22,7 @@ * \file htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php * \ingroup expedition * \brief Fichier de la classe permettant de generer les bordereaux envoi au modele Merou - * \version $Id: pdf_expedition_merou.modules.php,v 1.85 2011/07/31 23:28:13 eldy Exp $ + * \version $Id: pdf_expedition_merou.modules.php,v 1.86 2011/08/11 12:14:00 eldy Exp $ */ require_once DOL_DOCUMENT_ROOT."/includes/modules/expedition/pdf/ModelePdfExpedition.class.php"; @@ -81,7 +81,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); @@ -325,7 +325,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition function _pagehead(&$pdf, $object, $outputlangs) { global $conf, $langs; - + $default_font_size = pdf_getPDFFontSize($outputlangs); pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); @@ -384,9 +384,9 @@ Class pdf_expedition_merou extends ModelePdfExpedition //$this->Code39($Xoff+43, $Yoff+1, $object->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true); // Add list of linked elements - // TODO possibility to use with other elements (business module,...) + // TODO possibility to use with other elements (business module,...) //$object->load_object_linked(); - + $origin = $object->origin; $origin_id = $object->origin_id; @@ -394,7 +394,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition if ($conf->$origin->enabled) { $outputlangs->load('orders'); - + $classname = ucfirst($origin); $linkedobject = new $classname($this->db); $result=$linkedobject->fetch($origin_id); @@ -451,7 +451,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition $pdf->SetXY($blSocX-80,$blSocY+23); $pdf->SetFont('','', $default_font_size - 2); $pdf->SetTextColor(0,0,0); - + if (! empty($object->tracking_number)) { $object->GetUrlTrackingStatus($object->tracking_number); diff --git a/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php b/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php index 349bb32b719bdb1961abb4a5ad61751757b09eea..424aa96c07bd10c794d7cef84833dd8a5c60eea7 100644 --- a/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php +++ b/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php @@ -22,7 +22,7 @@ * \file htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php * \ingroup expedition * \brief Fichier de la classe permettant de generer les bordereaux envoi au modele Rouget - * \version $Id: pdf_expedition_rouget.modules.php,v 1.60 2011/07/31 23:28:13 eldy Exp $ + * \version $Id: pdf_expedition_rouget.modules.php,v 1.61 2011/08/11 12:14:00 eldy Exp $ */ require_once DOL_DOCUMENT_ROOT."/includes/modules/expedition/pdf/ModelePdfExpedition.class.php"; @@ -65,7 +65,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition // Recupere emmetteur $this->emetteur=$mysoc; if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // By default if not defined - + // Defini position des colonnes $this->posxdesc=$this->marge_gauche+1; $this->posxqtyordered=120; @@ -87,7 +87,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); @@ -159,11 +159,11 @@ Class pdf_expedition_rouget extends ModelePdfExpedition $tab_top = 90; $tab_height = 170; - + if (! empty($object->note_public) || ! empty($object->tracking_number)) { $tab_top = 88; - + // Tracking number if (! empty($object->tracking_number)) { @@ -189,14 +189,14 @@ Class pdf_expedition_rouget extends ModelePdfExpedition $pdf->SetXY ($this->posxdesc-1, $tab_top); $pdf->MultiCell(190, 3, $outputlangs->convToOutputCharset($object->note_public), 0, 'L'); } - + $nexY = $pdf->GetY(); $height_note=$nexY-$tab_top; // Rect prend une longueur en 3eme param $pdf->SetDrawColor(192,192,192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); - + $tab_height = $tab_height - $height_note; $tab_top = $nexY+6; } @@ -204,7 +204,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition { $height_note=0; } - + $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); $nexY = $tab_top + 7; @@ -257,7 +257,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition $this->error=$langs->transnoentities("ErrorUnknown"); return 0; // Erreur par defaut } - + /** * Build table * @param pdf objet PDF @@ -265,7 +265,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs) { global $conf; - + $default_font_size = pdf_getPDFFontSize($outputlangs); $pdf->SetTextColor(0,0,0); @@ -280,11 +280,11 @@ Class pdf_expedition_rouget extends ModelePdfExpedition $pdf->SetXY ($this->posxdesc-1, $tab_top+1); $pdf->MultiCell(108, 2, $outputlangs->trans("Description"), '', 'L'); - + $pdf->line($this->posxqtyordered-1, $tab_top, $this->posxqtyordered-1, $tab_top + $tab_height); $pdf->SetXY ($this->posxqtyordered-1, $tab_top+1); $pdf->MultiCell(40,2, $outputlangs->transnoentities("QtyOrdered"),'','C'); - + $pdf->line($this->posxqtytoship-1, $tab_top, $this->posxqtytoship-1, $tab_top + $tab_height); $pdf->SetXY ($this->posxqtytoship-1, $tab_top+1); $pdf->MultiCell(40,2, $outputlangs->transnoentities("QtyToShip"),'','C'); @@ -405,7 +405,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition // Add list of linked orders // TODO possibility to use with other document (business module,...) //$object->load_object_linked(); - + $origin = $object->origin; $origin_id = $object->origin_id; @@ -413,7 +413,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition if ($conf->$origin->enabled) { $outputlangs->load('orders'); - + $classname = ucfirst($origin); $linkedobject = new $classname($this->db); $result=$linkedobject->fetch($origin_id); @@ -430,7 +430,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition $pdf->MultiCell(60, 2, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->commande->date,"%d %b %Y",false,$outputlangs,true), 0, 'R'); } } - + if ($showaddress) { // Sender properties diff --git a/htdocs/includes/modules/facture/doc/pdf_crabe.modules.php b/htdocs/includes/modules/facture/doc/pdf_crabe.modules.php index 5eed344e67d7a70ea0e854c0714ff0fa07346299..8ad01066f793f2db907accf89d5d02fdfe584d16 100755 --- a/htdocs/includes/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/includes/modules/facture/doc/pdf_crabe.modules.php @@ -24,7 +24,7 @@ * \ingroup facture * \brief File of class to generate invoices from crab model * \author Laurent Destailleur - * \version $Id: pdf_crabe.modules.php,v 1.13 2011/08/10 17:56:11 hregis Exp $ + * \version $Id: pdf_crabe.modules.php,v 1.14 2011/08/11 12:14:02 eldy Exp $ */ require_once(DOL_DOCUMENT_ROOT."/includes/modules/facture/modules_facture.php"); @@ -121,7 +121,7 @@ class pdf_crabe extends ModelePDFFactures if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); diff --git a/htdocs/includes/modules/facture/doc/pdf_oursin.modules.php b/htdocs/includes/modules/facture/doc/pdf_oursin.modules.php index b702ddae8059b935dd5efe19e52f9ae3dc7d6c5f..b8ffecd6a9154c3112077286fd3981ea7f725c88 100755 --- a/htdocs/includes/modules/facture/doc/pdf_oursin.modules.php +++ b/htdocs/includes/modules/facture/doc/pdf_oursin.modules.php @@ -25,7 +25,7 @@ * \ingroup facture * \brief Fichier de la classe permettant de generer les factures au modele oursin * \author Sylvain SCATTOLINI base sur un modele de Laurent Destailleur - * \version $Id: pdf_oursin.modules.php,v 1.12 2011/08/10 17:56:10 hregis Exp $ + * \version $Id: pdf_oursin.modules.php,v 1.13 2011/08/11 12:14:02 eldy Exp $ */ require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); @@ -120,7 +120,7 @@ class pdf_oursin extends ModelePDFFactures if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; $default_font_size = pdf_getPDFFontSize($outputlangs); diff --git a/htdocs/includes/modules/facture/modules_facture.php b/htdocs/includes/modules/facture/modules_facture.php index 122fa59f20ed7c146a3d379a8de92ae72162d5d9..89e29ee24b524f8c5df4bc2ccf2be23452bfbc52 100644 --- a/htdocs/includes/modules/facture/modules_facture.php +++ b/htdocs/includes/modules/facture/modules_facture.php @@ -24,11 +24,9 @@ * \ingroup facture * \brief Fichier contenant la classe mere de generation des factures en PDF * et la classe mere de numerotation des factures - * \version $Id: modules_facture.php,v 1.95 2011/08/10 23:21:13 eldy Exp $ + * \version $Id: modules_facture.php,v 1.96 2011/08/11 12:14:04 eldy Exp $ */ -require_once(FPDFI_PATH.'fpdi_protection.php'); -require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php'); require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); require_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php"); // Requis car utilise dans les classes qui heritent require_once(DOL_DOCUMENT_ROOT."/core/class/commondocgenerator.class.php"); diff --git a/htdocs/includes/modules/fichinter/modules_fichinter.php b/htdocs/includes/modules/fichinter/modules_fichinter.php index b37befb9c50e0926846f9dd0f05e35664f7e16fb..ea9a33733521d7c4e1be47b5f56d3818452595ac 100644 --- a/htdocs/includes/modules/fichinter/modules_fichinter.php +++ b/htdocs/includes/modules/fichinter/modules_fichinter.php @@ -23,10 +23,9 @@ * \ingroup ficheinter * \brief Fichier contenant la classe mere de generation des fiches interventions en PDF * et la classe mere de numerotation des fiches interventions - * \version $Id: modules_fichinter.php,v 1.43 2011/08/10 23:21:13 eldy Exp $ + * \version $Id: modules_fichinter.php,v 1.44 2011/08/11 12:14:03 eldy Exp $ */ -require_once(FPDFI_PATH.'fpdi_protection.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php'); diff --git a/htdocs/includes/modules/fichinter/pdf_soleil.modules.php b/htdocs/includes/modules/fichinter/pdf_soleil.modules.php index 73dbde338ed21046c998f60d675f264f1a8a2ba9..f1a6ad0debc68099f05369a1b71a856933820cdb 100644 --- a/htdocs/includes/modules/fichinter/pdf_soleil.modules.php +++ b/htdocs/includes/modules/fichinter/pdf_soleil.modules.php @@ -22,7 +22,7 @@ * \file htdocs/includes/modules/fichinter/pdf_soleil.modules.php * \ingroup ficheinter * \brief Fichier de la classe permettant de generer les fiches d'intervention au modele Soleil - * \version $Id: pdf_soleil.modules.php,v 1.102 2011/07/31 23:28:15 eldy Exp $ + * \version $Id: pdf_soleil.modules.php,v 1.103 2011/08/11 12:14:03 eldy Exp $ */ require_once(DOL_DOCUMENT_ROOT."/includes/modules/fichinter/modules_fichinter.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); @@ -87,7 +87,7 @@ class pdf_soleil extends ModelePDFFicheinter if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); diff --git a/htdocs/includes/modules/livraison/modules_livraison.php b/htdocs/includes/modules/livraison/modules_livraison.php index ea0f0ea0da1f8d4d3e9af654dbbfdb615b7b5824..8777355e4165054c4fb50e7b5998c76f55cd1ac9 100644 --- a/htdocs/includes/modules/livraison/modules_livraison.php +++ b/htdocs/includes/modules/livraison/modules_livraison.php @@ -24,10 +24,9 @@ * \ingroup expedition * \brief Fichier contenant la classe mere de generation de bon de livraison en PDF * et la classe mere de numerotation des bons de livraisons - * \version $Id: modules_livraison.php,v 1.19 2011/08/10 23:21:12 eldy Exp $ + * \version $Id: modules_livraison.php,v 1.20 2011/08/11 12:14:02 eldy Exp $ */ -require_once(FPDFI_PATH.'fpdi_protection.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php'); diff --git a/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php b/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php index c8198051b204a4e34ded5871e6d09cabd75d183d..5ea5d69e294ed2dc81c4dc660ccc252fad4afc3e 100644 --- a/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php +++ b/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php @@ -23,7 +23,7 @@ * \file htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php * \ingroup livraison * \brief File of class to manage receving receipts with template Sirocco - * \version $Id: pdf_sirocco.modules.php,v 1.78 2011/08/08 16:07:48 eldy Exp $ + * \version $Id: pdf_sirocco.modules.php,v 1.79 2011/08/11 12:14:02 eldy Exp $ */ require_once(DOL_DOCUMENT_ROOT."/includes/modules/livraison/modules_livraison.php"); @@ -85,7 +85,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); diff --git a/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php b/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php index dd79a49a8279e5760491b83a87d3fb5a21490b68..0bc24d16dde9235ffffb50336582d208a4ab12c2 100644 --- a/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php +++ b/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php @@ -24,7 +24,7 @@ * \ingroup livraison * \brief File of class to manage receving receipts with template Typhon * \author Laurent Destailleur - * \version $Id: pdf_typhon.modules.php,v 1.87 2011/08/08 16:07:48 eldy Exp $ + * \version $Id: pdf_typhon.modules.php,v 1.88 2011/08/11 12:14:02 eldy Exp $ */ require_once(DOL_DOCUMENT_ROOT."/includes/modules/livraison/modules_livraison.php"); @@ -107,7 +107,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); diff --git a/htdocs/includes/modules/member/cards/modules_cards.php b/htdocs/includes/modules/member/cards/modules_cards.php index 40d367b7d05262ca515ef9997a655259c3a9cd34..ff7a89715a5a99f1e480910a8dbed9d77b39bcf9 100644 --- a/htdocs/includes/modules/member/cards/modules_cards.php +++ b/htdocs/includes/modules/member/cards/modules_cards.php @@ -23,10 +23,9 @@ * \file htdocs/includes/modules/member/cards/modules_cards.php * \ingroup member * \brief File of parent class of document generator for members cards. - * \version $Id: modules_cards.php,v 1.12 2011/08/10 23:20:55 eldy Exp $ + * \version $Id: modules_cards.php,v 1.13 2011/08/11 12:13:59 eldy Exp $ */ -require_once(FPDFI_PATH.'fpdi_protection.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php'); require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); diff --git a/htdocs/includes/modules/member/cards/pdf_standard.class.php b/htdocs/includes/modules/member/cards/pdf_standard.class.php index f2463194be2415d31bf6a9e9b08d07a02082494b..f049ef0f99b3c0b47dceb674ad7a714c0c8c69f4 100644 --- a/htdocs/includes/modules/member/cards/pdf_standard.class.php +++ b/htdocs/includes/modules/member/cards/pdf_standard.class.php @@ -60,10 +60,9 @@ * \author Laurent Passebecq * \author Rodolphe Quiedville * \author Jean Louis Bergamo. - * \version $Id: pdf_standard.class.php,v 1.23 2011/08/10 23:20:55 eldy Exp $ + * \version $Id: pdf_standard.class.php,v 1.24 2011/08/11 12:14:00 eldy Exp $ */ -require_once(FPDFI_PATH.'fpdi_protection.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/format_cards.lib.php'); @@ -375,7 +374,7 @@ class pdf_standard { if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); diff --git a/htdocs/includes/modules/member/labels/modules_labels.php b/htdocs/includes/modules/member/labels/modules_labels.php index fb5856b7070233cd7ae963a927fc7e7910b31731..ae78fd03eb708c764adffeee5188881fae0b6bf8 100644 --- a/htdocs/includes/modules/member/labels/modules_labels.php +++ b/htdocs/includes/modules/member/labels/modules_labels.php @@ -23,10 +23,9 @@ * \file htdocs/includes/modules/member/labels/modules_labels.php * \ingroup member * \brief File of parent class of document generator for members labels sheets. - * \version $Id: modules_labels.php,v 1.3 2011/08/10 23:21:11 eldy Exp $ + * \version $Id: modules_labels.php,v 1.4 2011/08/11 12:14:01 eldy Exp $ */ -require_once(FPDFI_PATH.'fpdi_protection.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php'); require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); diff --git a/htdocs/includes/modules/member/labels/pdf_standardlabel.class.php b/htdocs/includes/modules/member/labels/pdf_standardlabel.class.php index 8774f9d7bf30321036c201a264e472cdffdec45f..5f3c60eeacebf98ef4da9fc3a7f5f3bb2ee3369c 100644 --- a/htdocs/includes/modules/member/labels/pdf_standardlabel.class.php +++ b/htdocs/includes/modules/member/labels/pdf_standardlabel.class.php @@ -60,10 +60,9 @@ * \author Laurent Passebecq * \author Rodolphe Quiedville * \author Jean Louis Bergamo. - * \version $Id: pdf_standardlabel.class.php,v 1.14 2011/08/10 23:21:11 eldy Exp $ + * \version $Id: pdf_standardlabel.class.php,v 1.15 2011/08/11 12:14:01 eldy Exp $ */ -require_once(FPDFI_PATH.'fpdi_protection.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/format_cards.lib.php'); @@ -354,7 +353,7 @@ class pdf_standardlabel { if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); diff --git a/htdocs/includes/modules/project/modules_project.php b/htdocs/includes/modules/project/modules_project.php index 908d755325c87b95ea8c0a7fbe1d53d5899cfcc7..9d574ebe143aac132ebc34b839bb0adb8a77a6f6 100644 --- a/htdocs/includes/modules/project/modules_project.php +++ b/htdocs/includes/modules/project/modules_project.php @@ -21,9 +21,8 @@ * \ingroup project * \brief File that contain parent class for projects models * and parent class for projects numbering models - * \version $Id: modules_project.php,v 1.13 2011/08/10 23:21:09 eldy Exp $ + * \version $Id: modules_project.php,v 1.14 2011/08/11 12:14:01 eldy Exp $ */ -require_once(FPDFI_PATH.'fpdi_protection.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php'); diff --git a/htdocs/includes/modules/project/pdf/pdf_baleine.modules.php b/htdocs/includes/modules/project/pdf/pdf_baleine.modules.php index fb253da1e8ff814291d6562e1f37c928fd837aac..d989738c73671db6e8b1906b82697c9a7923f0e9 100644 --- a/htdocs/includes/modules/project/pdf/pdf_baleine.modules.php +++ b/htdocs/includes/modules/project/pdf/pdf_baleine.modules.php @@ -21,7 +21,7 @@ * \ingroup project * \brief Fichier de la classe permettant de generer les projets au modele Baleine * \author Regis Houssin - * \version $Id: pdf_baleine.modules.php,v 1.39 2011/07/31 23:28:18 eldy Exp $ + * \version $Id: pdf_baleine.modules.php,v 1.40 2011/08/11 12:14:04 eldy Exp $ */ require_once(DOL_DOCUMENT_ROOT."/includes/modules/project/modules_project.php"); @@ -95,7 +95,7 @@ class pdf_baleine extends ModelePDFProjects if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); diff --git a/htdocs/includes/modules/propale/modules_propale.php b/htdocs/includes/modules/propale/modules_propale.php index c6bcec1244145f032527e1cd2624df9e26f79706..5c57ca2f476550744e9d52f7848253f2dbbc459e 100644 --- a/htdocs/includes/modules/propale/modules_propale.php +++ b/htdocs/includes/modules/propale/modules_propale.php @@ -23,10 +23,9 @@ * \ingroup propale * \brief Fichier contenant la classe mere de generation des propales en PDF * et la classe mere de numerotation des propales - * \version $Id: modules_propale.php,v 1.65 2011/08/10 23:21:13 eldy Exp $ + * \version $Id: modules_propale.php,v 1.66 2011/08/11 12:14:03 eldy Exp $ */ -require_once(FPDFI_PATH.'fpdi_protection.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php'); require_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php"); // Requis car utilise dans les classes qui heritent diff --git a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php index afc8e881366dbd9be2359449d956fc8129dfc8bc..849e8d4a8ccf7c193e6e509cfb3887ce85ab44ae 100644 --- a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php +++ b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php @@ -24,7 +24,7 @@ * \ingroup propale * \brief Fichier de la classe permettant de generer les propales au modele Azur * \author Laurent Destailleur - * \version $Id: pdf_propale_azur.modules.php,v 1.244 2011/08/10 17:40:42 hregis Exp $ + * \version $Id: pdf_propale_azur.modules.php,v 1.245 2011/08/11 12:14:03 eldy Exp $ */ require_once(DOL_DOCUMENT_ROOT."/includes/modules/propale/modules_propale.php"); require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); @@ -117,7 +117,7 @@ class pdf_propale_azur extends ModelePDFPropales if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO $sav_charset_output=$outputlangs->charset_output; - if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); diff --git a/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php b/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php index 5e68c469b95ff08ec0861e7b4f04a30dd56e7310..b4e826c71c325712da5154e7e3e70d7bbb3880e0 100644 --- a/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php +++ b/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php @@ -23,7 +23,7 @@ * \file htdocs/includes/modules/propale/pdf_propale_jaune.modules.php * \ingroup propale * \brief Fichier de la classe permettant de generer les propales au modele Jaune - * \version $Id: pdf_propale_jaune.modules.php,v 1.118 2011/08/10 17:40:44 hregis Exp $ + * \version $Id: pdf_propale_jaune.modules.php,v 1.119 2011/08/11 12:14:03 eldy Exp $ */ require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/modules_propale.php"); @@ -93,7 +93,7 @@ class pdf_propale_jaune extends ModelePDFPropales if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO $sav_charset_output=$outputlangs->charset_output; - if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); diff --git a/htdocs/includes/modules/rapport/pdf_paiement.class.php b/htdocs/includes/modules/rapport/pdf_paiement.class.php index 92b1196385bbde12eae10583c2a403b26796f2ae..4a08de7634cf5f87de3d7743c5aa8133bf84ba9d 100644 --- a/htdocs/includes/modules/rapport/pdf_paiement.class.php +++ b/htdocs/includes/modules/rapport/pdf_paiement.class.php @@ -21,9 +21,8 @@ * \file htdocs/includes/modules/rapport/pdf_paiement.class.php * \ingroup banque * \brief File to build payment reports - * \version $Id: pdf_paiement.class.php,v 1.65 2011/08/10 23:21:09 eldy Exp $ + * \version $Id: pdf_paiement.class.php,v 1.66 2011/08/11 12:14:01 eldy Exp $ */ -require_once(FPDFI_PATH.'fpdi_protection.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php'); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); @@ -81,7 +80,7 @@ class pdf_paiement if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; $this->month=$month; $this->year=$year; diff --git a/htdocs/includes/modules/supplier_invoice/modules_facturefournisseur.php b/htdocs/includes/modules/supplier_invoice/modules_facturefournisseur.php index e93a9ac0b2879652114a952072099bd3b2bfa9d4..78e13367d445f6d39a0c7d7d496ef967edf38d43 100755 --- a/htdocs/includes/modules/supplier_invoice/modules_facturefournisseur.php +++ b/htdocs/includes/modules/supplier_invoice/modules_facturefournisseur.php @@ -20,9 +20,8 @@ * \file htdocs/includes/modules/supplier_invoice/modules_facturefournisseur.php * \ingroup facture fourniseur * \brief File that contain parent class for supplier invoices models - * \version $Id: modules_facturefournisseur.php,v 1.10 2011/08/10 23:21:14 eldy Exp $ + * \version $Id: modules_facturefournisseur.php,v 1.11 2011/08/11 12:14:04 eldy Exp $ */ -require_once(FPDFI_PATH.'fpdi_protection.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php'); diff --git a/htdocs/includes/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/includes/modules/supplier_invoice/pdf/pdf_canelle.modules.php index 91e94490f7cf225dd275fe0b8fb7040104fb7b98..41af644c10ac6dc8ef2088ffbe4e313a8da95b42 100755 --- a/htdocs/includes/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/includes/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -21,7 +21,7 @@ * \file htdocs/includes/modules/supplier_invoice/pdf/pdf_canelle.modules.php * \ingroup fournisseur * \brief Class file to generate the supplier invoices with the canelle model - * \version $Id: pdf_canelle.modules.php,v 1.35 2011/07/31 23:28:18 eldy Exp $ + * \version $Id: pdf_canelle.modules.php,v 1.36 2011/08/11 12:14:01 eldy Exp $ */ require_once(DOL_DOCUMENT_ROOT."/includes/modules/supplier_invoice/modules_facturefournisseur.php"); @@ -105,7 +105,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); diff --git a/htdocs/includes/modules/supplier_order/modules_commandefournisseur.php b/htdocs/includes/modules/supplier_order/modules_commandefournisseur.php index 5da2f11a92a3bf7a629526ea131fbc4f4cde0f57..2e4f206a5a6f06d64963fdc050560579a7926543 100644 --- a/htdocs/includes/modules/supplier_order/modules_commandefournisseur.php +++ b/htdocs/includes/modules/supplier_order/modules_commandefournisseur.php @@ -26,9 +26,8 @@ * \ingroup commande * \brief File that contain parent class for supplier orders models * and parent class for supplier orders numbering models - * \version $Id: modules_commandefournisseur.php,v 1.23 2011/08/10 23:21:14 eldy Exp $ + * \version $Id: modules_commandefournisseur.php,v 1.24 2011/08/11 12:14:04 eldy Exp $ */ -require_once(FPDFI_PATH.'fpdi_protection.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php'); require_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php"); // requis car utilise par les classes qui heritent diff --git a/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php index d856f6eb4d80628da031d93d1935714dd5532247..3f09393927dc206ecea3e63de4e65189795b10f5 100644 --- a/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -23,7 +23,7 @@ * \file htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php * \ingroup fournisseur * \brief Fichier de la classe permettant de generer les commandes fournisseurs au modele Muscadet - * \version $Id: pdf_muscadet.modules.php,v 1.87 2011/07/31 23:28:13 eldy Exp $ + * \version $Id: pdf_muscadet.modules.php,v 1.88 2011/08/11 12:14:00 eldy Exp $ */ require_once(DOL_DOCUMENT_ROOT."/includes/modules/supplier_order/modules_commandefournisseur.php"); @@ -106,7 +106,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); @@ -667,7 +667,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $text=$this->emetteur->name; $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } - + $pdf->SetFont('','B',$default_font_size + 3); $pdf->SetXY(100,$posy); $pdf->SetTextColor(0,0,60); diff --git a/htdocs/lib/pdf.lib.php b/htdocs/lib/pdf.lib.php index 6a45a7c5ea36101d7d9e3648d59adc9a310103e0..0bfe0b22340b6188549dfe8d4b0014f142120e2d 100644 --- a/htdocs/lib/pdf.lib.php +++ b/htdocs/lib/pdf.lib.php @@ -24,21 +24,67 @@ * \file htdocs/lib/pdf.lib.php * \brief Set of functions used for PDF generation * \ingroup core - * \version $Id: pdf.lib.php,v 1.102 2011/08/10 22:47:35 eldy Exp $ + * \version $Id: pdf.lib.php,v 1.103 2011/08/11 12:14:04 eldy Exp $ */ /** - * Return a PDF instance object. We create a FPDI instance that instanciate TCPDF (or FPDF if MAIN_USE_FPDF is on) - * @param format Array(width,height) + * Return array with format properties of default PDF format + * @return array Array('width'=>w,'height'=>h,'unit'=>u); + */ +function pdf_getFormat() +{ + global $conf,$db; + + // Default value if setup was not done and/or entry into c_paper_format not defined + $width=210; $height=297; $unit='mm'; + + $pdfformat=$conf->global->MAIN_PDF_FORMAT; + if (empty($pdfformat)) + { + include_once(DOL_DOCUMENT_ROOT.'/lib/functions2.lib.php'); + $pdfformat=dol_getDefaultFormat(); + } + + $sql="SELECT code, label, width, height, unit FROM ".MAIN_DB_PREFIX."c_paper_format"; + $sql.=" WHERE code = '".$pdfformat."'"; + $resql=$db->query($sql); + if ($resql) + { + $obj=$db->fetch_object($resql); + if ($obj) + { + $width=$obj->width; + $height=$obj->height; + $unit=$obj->unit; + } + } + + //print "pdfformat=".$pdfformat." width=".$width." height=".$height." unit=".$unit; + return array('width'=>$width,'height'=>$height,'unit'=>$unit); +} + +/** + * Return a PDF instance object. We create a FPDI instance that instanciate TCPDF. + * @param format Array(width,height). Keep empty to use default setup. * @param metric Unit of format ('mm') * @param pagetype 'P' or 'l' * @return PDF object */ -function pdf_getInstance($format,$metric='mm',$pagetype='P') +function pdf_getInstance($format='',$metric='mm',$pagetype='P') { global $conf; + require_once(TCPDF_PATH.'tcpdf.php'); + require_once(FPDFI_PATH.'fpdi.php'); + + //if (! is_array($format) || empty($format) || empty($metric)) + //{ + $arrayformat=pdf_getFormat(); + $format=array($arrayformat['width'],$arrayformat['height']); + $metric=$arrayformat['unit']; + //} + // Protection et encryption du pdf if ($conf->global->PDF_SECURITY_ENCRYPTION) { diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index eedd6a8841cfb198f325bdc0d7b25af55221fd18..b3f203a8c32d37a7a596d686413fc3aa0c4c572b 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -29,7 +29,7 @@ * \ingroup core * \brief File that defines environment for all Dolibarr process (pages or scripts) * This script reads the conf file, init $lang, $db and and empty $user - * \version $Id: master.inc.php,v 1.352 2011/08/01 12:25:14 hregis Exp $ + * \version $Id: master.inc.php,v 1.353 2011/08/11 12:14:03 eldy Exp $ */ @@ -302,9 +302,9 @@ if (! defined('NOREQUIRETRAN')) */ // Les path racines if (! defined('FPDF_PATH')) { define('FPDF_PATH', DOL_DOCUMENT_ROOT .'/includes/fpdf/fpdf/'); } +if (! defined('TCPDF_PATH')) { define('TCPDF_PATH', DOL_DOCUMENT_ROOT .'/includes/tcpdf/'); } if (! defined('FPDFI_PATH')) { define('FPDFI_PATH', DOL_DOCUMENT_ROOT .'/includes/fpdf/fpdfi/'); } if (! defined('MAGPIERSS_PATH')) { define('MAGPIERSS_PATH', DOL_DOCUMENT_ROOT .'/includes/magpierss/'); } -if (! defined('JPGRAPH_PATH')) { define('JPGRAPH_PATH', DOL_DOCUMENT_ROOT .'/includes/jpgraph/'); } if (! defined('NUSOAP_PATH')) { define('NUSOAP_PATH', DOL_DOCUMENT_ROOT .'/includes/nusoap/lib/'); } if (! defined('PHP_WRITEEXCEL_PATH')) { define('PHP_WRITEEXCEL_PATH',DOL_DOCUMENT_ROOT .'/includes/php_writeexcel/'); } if (! defined('PHPEXCELREADER')) { define('PHPEXCELREADER', DOL_DOCUMENT_ROOT .'/includes/phpexcelreader/'); } diff --git a/scripts/invoices/rebuild_merge_pdf.php b/scripts/invoices/rebuild_merge_pdf.php index de043e7f08effc3fae04d8bf8c4703be47274fa1..c23225eb4fa2b2fae50a8f388f4e1ce508e32067 100644 --- a/scripts/invoices/rebuild_merge_pdf.php +++ b/scripts/invoices/rebuild_merge_pdf.php @@ -21,7 +21,7 @@ * \file scripts/invoices/rebuild_merge_pdf.php * \ingroup facture * \brief Script to rebuild PDF and merge PDF files into one - * \version $Id: rebuild_merge_pdf.php,v 1.22 2011/08/10 23:31:05 eldy Exp $ + * \version $Id: rebuild_merge_pdf.php,v 1.23 2011/08/11 12:14:22 eldy Exp $ */ $sapi_type = php_sapi_name(); @@ -37,7 +37,6 @@ if (substr($sapi_type, 0, 3) == 'cgi') { // Include Dolibarr environment require_once($path."../../htdocs/master.inc.php"); // After this $db is an opened handler to database. We close it at end of file. -require_once(FPDFI_PATH.'fpdi_protection.php'); require_once(DOL_DOCUMENT_ROOT."/cron/functions_cron.lib.php"); require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"); require_once(DOL_DOCUMENT_ROOT."/includes/modules/facture/modules_facture.php"); @@ -48,7 +47,7 @@ require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php'); $langs->load("main"); // Global variables -$version='$Revision: 1.22 $'; +$version='$Revision: 1.23 $'; $error=0; @@ -290,10 +289,7 @@ if ( $resql=$db->query($sql) ) //--------------------------------------------------------- // Create empty PDF - $pdf=new FPDI('P','mm','A4'); - if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); - //$pdf->SetCompression(false); - + $pdf=pdf_getInstance(); if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); @@ -301,6 +297,10 @@ if ( $resql=$db->query($sql) ) } $pdf->SetFont(pdf_getPDFFont($outputlangs)); + if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); + //$pdf->SetCompression(false); + + //$pdf->Open(); //$pdf->AddPage(); //$title=$langs->trans("BillsCustomersUnpaid");