forked from Wavyzz/dolibarr
Qual: Removed no more used external libraries (fpdi_protection)
Qual: Centralize include of external libray fpdi Qual: Now use fpdi with no changes
This commit is contained in:
@@ -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 $');
|
||||
?>
|
||||
|
||||
@@ -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);
|
||||
// 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);
|
||||
}
|
||||
|
||||
if (class_exists('TCPDF'))
|
||||
{
|
||||
$pdf->setPrintHeader(false);
|
||||
$pdf->setPrintFooter(false);
|
||||
}
|
||||
//$pdf->SetFont(pdf_getPDFFont($outputlangs));
|
||||
// Create empty PDF
|
||||
$pdf=pdf_getInstance();
|
||||
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');
|
||||
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 $');
|
||||
?>
|
||||
|
||||
@@ -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/
|
||||
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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]);
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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");
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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<EFBFBD>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<EFBFBD>ros d<EFBFBD>j<EFBFBD> en vigueur dans la base ne provoquent pas d
|
||||
* de conflits qui empechera cette num<EFBFBD>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<EFBFBD>e
|
||||
/** \brief Renvoi prochaine valeur attribuee
|
||||
* \return string Valeur
|
||||
*/
|
||||
function getNextValue()
|
||||
@@ -129,13 +128,13 @@ class ModeleNumRefDons
|
||||
|
||||
|
||||
/**
|
||||
\brief Cr<EFBFBD>e un don sur disque en fonction du mod<EFBFBD>le de DON_ADDON_PDF
|
||||
\param db objet base de donn<EFBFBD>e
|
||||
\param id id du don <EFBFBD> cr<EFBFBD>er
|
||||
\param message message
|
||||
\param modele force le modele <EFBFBD> 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<EFBFBD>s de la cr<63>ation de la facture. On g<>n<EFBFBD>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<EFBFBD><EFBFBD> un meta fichier <EFBFBD> c<EFBFBD>t<EFBFBD> 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<61>e ou compliqu<71>e <20> g<>rer ... avec un rgrep c'est vite fait bien fait [eric seigne
|
||||
\param db Objet base de donn<EFBFBD>e
|
||||
\param donid Id du don <EFBFBD> cr<EFBFBD>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<61>e ou compliqu<71>e <20> 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<EFBFBD>visualitation, pour le cas de r<>g<EFBFBD>n<EFBFBD>ration de facture
|
||||
\param db Objet base de donn<EFBFBD>e
|
||||
\param donid Id du don
|
||||
* \brief Supprime l'image de previsualitation, pour le cas de r<>g<EFBFBD>n<EFBFBD>ration de facture
|
||||
* \param db Objet base de donnee
|
||||
* \param donid Id du don
|
||||
*/
|
||||
function don_delete_preview($db, $donid)
|
||||
{
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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/'); }
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user