diff --git a/htdocs/admin/fournisseur.php b/htdocs/admin/fournisseur.php
index 3b6047e5330..a7a431d6cda 100644
--- a/htdocs/admin/fournisseur.php
+++ b/htdocs/admin/fournisseur.php
@@ -25,7 +25,7 @@
* \file htdocs/admin/fournisseur.php
* \ingroup fournisseur
* \brief Page d'administration-configuration du module Fournisseur
- * \version $Id: fournisseur.php,v 1.63 2011/07/31 22:23:21 eldy Exp $
+ * \version $Id: fournisseur.php,v 1.64 2011/08/11 12:14:02 eldy Exp $
*/
require("../main.inc.php");
@@ -109,10 +109,11 @@ if ($action == 'specimenfacture') // For invoices
// Charge le modele
$dir = "/includes/modules/supplier_invoice/pdf/";
$file = "pdf_".$modele.".modules.php";
- if (file_exists($dir.$file))
+ $file = dol_buildpath($dir.$file);
+ if (file_exists($file))
{
$classname = "pdf_".$modele;
- require_once($dir.$file);
+ require_once($file);
$obj = new $classname($db,$facture);
@@ -499,6 +500,7 @@ else
dol_print_error($db);
}
+
print '
'."\n";
print ''."\n";
print '| '.$langs->trans("Name").' | '."\n";
@@ -617,5 +619,5 @@ print ''
print "
\n";
print '';
-llxFooter('$Date: 2011/07/31 22:23:21 $ - $Revision: 1.63 $');
+llxFooter('$Date: 2011/08/11 12:14:02 $ - $Revision: 1.64 $');
?>
diff --git a/htdocs/compta/facture/impayees.php b/htdocs/compta/facture/impayees.php
index 26257a05492..45f161fe22b 100644
--- a/htdocs/compta/facture/impayees.php
+++ b/htdocs/compta/facture/impayees.php
@@ -22,7 +22,7 @@
* \file htdocs/compta/facture/impayees.php
* \ingroup facture
* \brief Page to list and build liste of unpaid invoices
- * \version $Revision: 1.85 $
+ * \version $Revision: 1.86 $
*/
require("../../main.inc.php");
@@ -30,6 +30,7 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
require_once(DOL_DOCUMENT_ROOT."/compta/paiement/class/paiement.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
+require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php');
$langs->load("bills");
@@ -52,9 +53,6 @@ if ($_POST["action"] == "builddoc" && $user->rights->facture->lire)
{
if (is_array($_POST['toGenerate']))
{
- require_once(FPDFI_PATH.'fpdi.php');
- require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php');
-
$factures = dol_dir_list($conf->facture->dir_output,'all',1,implode('\.pdf|',$_POST['toGenerate']).'\.pdf','\.meta$|\.png','date',SORT_DESC) ;
// liste les fichiers
@@ -68,22 +66,27 @@ if ($_POST["action"] == "builddoc" && $user->rights->facture->lire)
}
}
- // Create empty PDF
- $pdf=new FPDI('P','mm','A4');
- if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
+ // 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 $');
?>
diff --git a/htdocs/includes/fpdf/fpdfi/README.txt b/htdocs/includes/fpdf/fpdfi/README.txt
index b1c69409786..dc09ef070ca 100644
--- a/htdocs/includes/fpdf/fpdfi/README.txt
+++ b/htdocs/includes/fpdf/fpdfi/README.txt
@@ -1,5 +1,4 @@
This directory contains all FPDFI librairies:
- FPDI
- FPDI_TPL
-- FPDI_Protection
Found on http://www.setasign.de/products/pdf-php-solutions/fpdi/
diff --git a/htdocs/includes/fpdf/fpdfi/filters/FilterASCII85.php b/htdocs/includes/fpdf/fpdfi/filters/FilterASCII85.php
index 116edd3b1f4..092f3299b64 100644
--- a/htdocs/includes/fpdf/fpdfi/filters/FilterASCII85.php
+++ b/htdocs/includes/fpdf/fpdfi/filters/FilterASCII85.php
@@ -1,8 +1,8 @@
fpdi =& $fpdi;
- }
-
- function error($msg) {
- $this->fpdi->error($msg);
- }
+fpdi =& $fpdi;
+ }
+
+ function error($msg) {
+ $this->fpdi->error($msg);
+ }
}
\ No newline at end of file
diff --git a/htdocs/includes/fpdf/fpdfi/filters/FilterLZW.php b/htdocs/includes/fpdf/fpdfi/filters/FilterLZW.php
index 4b8dd8edec9..76d303d3803 100644
--- a/htdocs/includes/fpdf/fpdfi/filters/FilterLZW.php
+++ b/htdocs/includes/fpdf/fpdfi/filters/FilterLZW.php
@@ -1,8 +1,8 @@
fpdi =& $fpdi;
- }
-
- function error($msg) {
- $this->fpdi->error($msg);
- }
+fpdi =& $fpdi;
+ }
+
+ function error($msg) {
+ $this->fpdi->error($msg);
+ }
}
\ No newline at end of file
diff --git a/htdocs/includes/fpdf/fpdfi/fpdf_tpl.php b/htdocs/includes/fpdf/fpdfi/fpdf_tpl.php
index af5f704b14d..d21743e6374 100644
--- a/htdocs/includes/fpdf/fpdfi/fpdf_tpl.php
+++ b/htdocs/includes/fpdf/fpdfi/fpdf_tpl.php
@@ -1,415 +1,449 @@
-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('<_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);
- }
- }
-}
+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('<_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) {
+ $this->_out('/Font <<');
+ foreach($this->_res['tpl'][$tplidx]['fonts'] as $font)
+ $this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R');
+ $this->_out('>>');
+ }
+ if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) ||
+ isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls']))
+ {
+ $this->_out('/XObject <<');
+ if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) {
+ foreach($this->_res['tpl'][$tplidx]['images'] as $image)
+ $this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R');
+ }
+ if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) {
+ foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl)
+ $this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R');
+ }
+ $this->_out('>>');
+ }
+ $this->_out('>>');
+
+ $this->_out('/Length ' . strlen($p) . ' >>');
+ $this->_putstream($p);
+ $this->_out('endobj');
+ }
+ }
+
+ /**
+ * Overwritten to add _putformxobjects() after _putimages()
+ *
+ */
+ function _putimages() {
+ parent::_putimages();
+ $this->_putformxobjects();
+ }
+
+ function _putxobjectdict() {
+ parent::_putxobjectdict();
+
+ if (count($this->tpls)) {
+ foreach($this->tpls as $tplidx => $tpl) {
+ $this->_out(sprintf('%s%d %d 0 R', $this->tplprefix, $tplidx, $tpl['n']));
+ }
+ }
+ }
+
+ /**
+ * Private Method
+ */
+ function _out($s) {
+ if ($this->state == 2 && $this->_intpl) {
+ $this->tpls[$this->tpl]['buffer'] .= $s . "\n";
+ } else {
+ parent::_out($s);
+ }
+ }
+}
diff --git a/htdocs/includes/fpdf/fpdfi/fpdi.php b/htdocs/includes/fpdf/fpdfi/fpdi.php
index 4d732b9f274..e4ebb0c3241 100644
--- a/htdocs/includes/fpdf/fpdfi/fpdi.php
+++ b/htdocs/includes/fpdf/fpdfi/fpdi.php
@@ -1,527 +1,542 @@
-fckeditor->dir_output)) define ("K_PATH_CACHE", $conf->fckeditor->dir_output);
-// url qui sera substituer par le K_PATH_CACHE lorsqu'une image sera integree au pdf
-if (defined('DOL_URL_ROOT')) define ("K_PATH_URL_CACHE", DOL_URL_ROOT."/document.php?modulepart=editor&file=");
-/* End DOLCHANGE Added by Regis */
-
-// DOLCHANGE LDR
-if (! empty($conf->global->MAIN_USE_FPDF)) require_once(DOL_DOCUMENT_ROOT.'/includes/fpdf/fpdf/fpdf.php');
-else require_once(DOL_DOCUMENT_ROOT.'/includes/tcpdf/tcpdf.php');
-//require_once(DOL_DOCUMENT_ROOT.'/includes/tcpdf/tcpdf.php');
-
-
-// Check for TCPDF and remap TCPDF to FPDF
-$__tmp = version_compare(phpversion(), "5") == -1 ? array('TCPDF') : array('TCPDF', false);
-if (call_user_func_array('class_exists', $__tmp)) {
- require_once('fpdi2tcpdf_bridge.php');
-}
-unset($__tmp);
-
-require_once('fpdf_tpl.php');
-require_once('fpdi_pdf_parser.php');
-
-
-class FPDI extends FPDF_TPL {
- /**
- * Actual filename
- * @var string
- */
- var $current_filename;
-
- /**
- * Parser-Objects
- * @var array
- */
- var $parsers;
-
- /**
- * Current parser
- * @var object
- */
- var $current_parser;
-
- /**
- * object stack
- * @var array
- */
- var $_obj_stack;
-
- /**
- * done object stack
- * @var array
- */
- var $_don_obj_stack;
-
- /**
- * Current Object Id.
- * @var integer
- */
- var $_current_obj_id;
-
- /**
- * The name of the last imported page box
- * @var string
- */
- var $lastUsedPageBox;
-
- /**
- * Cache for imported pages/template ids
- * @var array
- */
- var $_importedPages = array();
-
- /**
- * Set a source-file
- *
- * @param string $filename a valid filename
- * @return int number of available pages
- */
- function setSourceFile($filename) {
- $this->current_filename = $filename;
- $fn = $this->current_filename;
-
- if (!isset($this->parsers[$fn]))
- $this->parsers[$fn] = new fpdi_pdf_parser($fn, $this);
- $this->current_parser =& $this->parsers[$fn];
-
- return $this->parsers[$fn]->getPageCount();
- }
-
- /**
- * Import a page
- *
- * @param int $pageno pagenumber
- * @return int Index of imported page - to use with fpdf_tpl::useTemplate()
- */
- function importPage($pageno, $boxName='/CropBox') {
- if ($this->_intpl) {
- return $this->error('Please import the desired pages before creating a new template.');
- }
-
- $fn = $this->current_filename;
-
- // check if page already imported
- $pageKey = $fn.((int)$pageno).$boxName;
- if (isset($this->_importedPages[$pageKey]))
- return $this->_importedPages[$pageKey];
-
- $parser =& $this->parsers[$fn];
- $parser->setPageno($pageno);
-
- if (!in_array($boxName, $parser->availableBoxes))
- return $this->Error(sprintf('Unknown box: %s', $boxName));
- $pageboxes = $parser->getPageBoxes($pageno);
-
- /**
- * MediaBox
- * CropBox: Default -> MediaBox
- * BleedBox: Default -> CropBox
- * TrimBox: Default -> CropBox
- * ArtBox: Default -> CropBox
- */
- if (!isset($pageboxes[$boxName]) && ($boxName == '/BleedBox' || $boxName == '/TrimBox' || $boxName == '/ArtBox'))
- $boxName = '/CropBox';
- if (!isset($pageboxes[$boxName]) && $boxName == '/CropBox')
- $boxName = '/MediaBox';
-
- if (!isset($pageboxes[$boxName]))
- return false;
- $this->lastUsedPageBox = $boxName;
-
- $box = $pageboxes[$boxName];
-
- $this->tpl++;
- $this->tpls[$this->tpl] = array();
- $tpl =& $this->tpls[$this->tpl];
- $tpl['parser'] =& $parser;
- $tpl['resources'] = $parser->getPageResources();
- $tpl['buffer'] = $parser->getContent();
- $tpl['box'] = $box;
-
- // To build an array that can be used by PDF_TPL::useTemplate()
- $this->tpls[$this->tpl] = array_merge($this->tpls[$this->tpl], $box);
-
- // An imported page will start at 0,0 everytime. Translation will be set in _putformxobjects()
- $tpl['x'] = 0;
- $tpl['y'] = 0;
-
- // handle rotated pages
- $rotation = $parser->getPageRotation($pageno);
- $tpl['_rotationAngle'] = 0;
- if (isset($rotation[1]) && ($angle = $rotation[1] % 360) != 0) {
- $steps = $angle / 90;
-
- $_w = $tpl['w'];
- $_h = $tpl['h'];
- $tpl['w'] = $steps % 2 == 0 ? $_w : $_h;
- $tpl['h'] = $steps % 2 == 0 ? $_h : $_w;
-
- $tpl['_rotationAngle'] = $angle*-1;
- }
-
- $this->_importedPages[$pageKey] = $this->tpl;
-
- return $this->tpl;
- }
-
- function getLastUsedPageBox() {
- return $this->lastUsedPageBox;
- }
-
- function useTemplate($tplidx, $_x=null, $_y=null, $_w=0, $_h=0, $adjustPageSize=false) {
- if ($adjustPageSize == true && is_null($_x) && is_null($_y)) {
- $size = $this->getTemplateSize($tplidx, $_w, $_h);
- $format = array($size['w'], $size['h']);
- if (!is_subclass_of($this, 'TCPDF')) {
- if ($format[0] != $this->CurPageFormat[0] || $format[1] != $this->CurPageFormat[1]) {
- $this->w = $format[0];
- $this->h = $format[1];
- $this->wPt = $this->w*$this->k;
- $this->hPt = $this->h*$this->k;
- $this->PageBreakTrigger = $this->h-$this->bMargin;
- $this->CurPageFormat = $format;
- $this->PageSizes[$this->page] = array($this->wPt, $this->hPt);
- }
-
- } else {
- $this->setPageFormat($format, $format[0] > $format[1] ? 'L' : 'P');
- }
- }
-
- $this->_out('q 0 J 1 w 0 j 0 G 0 g'); // reset standard values
- $s = parent::useTemplate($tplidx, $_x, $_y, $_w, $_h);
- $this->_out('Q');
- return $s;
- }
-
- /**
- * Private method, that rebuilds all needed objects of source files
- */
- function _putimportedobjects() {
- if (is_array($this->parsers) && count($this->parsers) > 0) {
- foreach($this->parsers AS $filename => $p) {
- $this->current_parser =& $this->parsers[$filename];
- if (isset($this->_obj_stack[$filename]) && is_array($this->_obj_stack[$filename])) {
- while(($n = key($this->_obj_stack[$filename])) !== null) {
- $nObj = $this->current_parser->pdf_resolve_object($this->current_parser->c,$this->_obj_stack[$filename][$n][1]);
-
- $this->_newobj($this->_obj_stack[$filename][$n][0]);
-
- if ($nObj[0] == PDF_TYPE_STREAM) {
- $this->pdf_write_value ($nObj);
- } else {
- $this->pdf_write_value ($nObj[1]);
- }
-
- $this->_out('endobj');
- $this->_obj_stack[$filename][$n] = null; // free memory
- unset($this->_obj_stack[$filename][$n]);
- reset($this->_obj_stack[$filename]);
- }
- }
- }
- }
- }
-
-
- /**
- * Private Method that writes the form xobjects
- */
- function _putformxobjects() {
- $filter=($this->compress) ? '/Filter /FlateDecode ' : '';
- reset($this->tpls);
- foreach($this->tpls AS $tplidx => $tpl) {
- $p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer'];
- $this->_newobj();
- $cN = $this->n; // TCPDF/Protection: rem current "n"
-
- $this->tpls[$tplidx]['n'] = $this->n;
- $this->_out('<<'.$filter.'/Type /XObject');
- $this->_out('/Subtype /Form');
- $this->_out('/FormType 1');
-
- $this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]',
- (isset($tpl['box']['llx']) ? $tpl['box']['llx'] : $tpl['x'])*$this->k,
- (isset($tpl['box']['lly']) ? $tpl['box']['lly'] : -$tpl['y'])*$this->k,
- (isset($tpl['box']['urx']) ? $tpl['box']['urx'] : $tpl['w'] + $tpl['x'])*$this->k,
- (isset($tpl['box']['ury']) ? $tpl['box']['ury'] : $tpl['h']-$tpl['y'])*$this->k
- ));
-
- $c = 1;
- $s = 0;
- $tx = 0;
- $ty = 0;
-
- if (isset($tpl['box'])) {
- $tx = -$tpl['box']['llx'];
- $ty = -$tpl['box']['lly'];
-
- if ($tpl['_rotationAngle'] <> 0) {
- $angle = $tpl['_rotationAngle'] * M_PI/180;
- $c=cos($angle);
- $s=sin($angle);
-
- switch($tpl['_rotationAngle']) {
- case -90:
- $tx = -$tpl['box']['lly'];
- $ty = $tpl['box']['urx'];
- break;
- case -180:
- $tx = $tpl['box']['urx'];
- $ty = $tpl['box']['ury'];
- break;
- case -270:
- $tx = $tpl['box']['ury'];
- $ty = -$tpl['box']['llx'];
- break;
- }
- }
- } else if ($tpl['x'] != 0 || $tpl['y'] != 0) {
- $tx = -$tpl['x']*2;
- $ty = $tpl['y']*2;
- }
-
- $tx *= $this->k;
- $ty *= $this->k;
-
- if ($c != 1 || $s != 0 || $tx != 0 || $ty != 0) {
- $this->_out(sprintf('/Matrix [%.5F %.5F %.5F %.5F %.5F %.5F]',
- $c, $s, -$s, $c, $tx, $ty
- ));
- }
-
- $this->_out('/Resources ');
-
- if (isset($tpl['resources'])) {
- $this->current_parser =& $tpl['parser'];
- $this->pdf_write_value($tpl['resources']); // "n" will be changed
- } else {
- $this->_out('<_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) {
- $this->_out('/Font <<');
- foreach($this->_res['tpl'][$tplidx]['fonts'] as $font)
- $this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
- $this->_out('>>');
- }
- if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) ||
- isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls']))
- {
- $this->_out('/XObject <<');
- if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) {
- foreach($this->_res['tpl'][$tplidx]['images'] as $image)
- $this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
- }
- if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) {
- foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl)
- $this->_out($this->tplprefix.$i.' '.$tpl['n'].' 0 R');
- }
- $this->_out('>>');
- }
- $this->_out('>>');
- }
-
- $nN = $this->n; // TCPDF: rem new "n"
- $this->n = $cN; // TCPDF: reset to current "n"
- $this->_out('/Length '.strlen($p).' >>');
- $this->_putstream($p);
- $this->_out('endobj');
- $this->n = $nN; // TCPDF: reset to new "n"
- }
-
- $this->_putimportedobjects();
- }
-
- /**
- * Rewritten to handle existing own defined objects
- */
- function _newobj($obj_id=false,$onlynewobj=false) {
- if (!$obj_id) {
- $obj_id = ++$this->n;
- }
-
- //Begin a new object
- if (!$onlynewobj) {
- $this->offsets[$obj_id] = is_subclass_of($this, 'TCPDF') ? $this->bufferlen : strlen($this->buffer);
- $this->_out($obj_id.' 0 obj');
- $this->_current_obj_id = $obj_id; // for later use with encryption
- }
- return $obj_id;
- }
-
- /**
- * Writes a value
- * Needed to rebuild the source document
- *
- * @param mixed $value A PDF-Value. Structure of values see cases in this method
- */
- function pdf_write_value(&$value)
- {
- if (is_subclass_of($this, 'TCPDF')) {
- parent::pdf_write_value($value);
- }
-
- switch ($value[0]) {
-
- case PDF_TYPE_TOKEN :
- $this->_straightOut($value[1] . ' ');
- break;
- case PDF_TYPE_NUMERIC :
- case PDF_TYPE_REAL :
- if (is_float($value[1]) && $value[1] != 0) {
- $this->_straightOut(rtrim(rtrim(sprintf('%F', $value[1]), '0'), '.') .' ');
- } else {
- $this->_straightOut($value[1] . ' ');
- }
- break;
-
- case PDF_TYPE_ARRAY :
-
- // An array. Output the proper
- // structure and move on.
-
- $this->_straightOut('[');
- for ($i = 0; $i < count($value[1]); $i++) {
- $this->pdf_write_value($value[1][$i]);
- }
-
- $this->_out(']');
- break;
-
- case PDF_TYPE_DICTIONARY :
-
- // A dictionary.
- $this->_straightOut('<<');
-
- reset ($value[1]);
-
- while (list($k, $v) = each($value[1])) {
- $this->_straightOut($k . ' ');
- $this->pdf_write_value($v);
- }
-
- $this->_straightOut('>>');
- break;
-
- case PDF_TYPE_OBJREF :
-
- // An indirect object reference
- // Fill the object stack if needed
- $cpfn =& $this->current_parser->filename;
-
- if (!isset($this->_don_obj_stack[$cpfn][$value[1]])) {
- $this->_newobj(false,true);
- $this->_obj_stack[$cpfn][$value[1]] = array($this->n, $value);
- $this->_don_obj_stack[$cpfn][$value[1]] = array($this->n, $value); // Value is maybee obsolete!!!
- }
- $objid = $this->_don_obj_stack[$cpfn][$value[1]][0];
-
- $this->_out($objid.' 0 R');
- break;
-
- case PDF_TYPE_STRING :
-
- // A string.
- $this->_straightOut('('.$value[1].')');
-
- break;
-
- case PDF_TYPE_STREAM :
-
- // A stream. First, output the
- // stream dictionary, then the
- // stream data itself.
- $this->pdf_write_value($value[1]);
- $this->_out('stream');
- $this->_out($value[2][1]);
- $this->_out('endstream');
- break;
- case PDF_TYPE_HEX :
- $this->_straightOut('<'.$value[1].'>');
- break;
-
- case PDF_TYPE_BOOLEAN :
- $this->_straightOut($value[1] ? 'true ' : 'false ');
- break;
-
- case PDF_TYPE_NULL :
- // The null object.
-
- $this->_straightOut('null ');
- break;
- }
- }
-
-
- /**
- * Modified so not each call will add a newline to the output.
- */
- function _straightOut($s) {
- if (!is_subclass_of($this, 'TCPDF')) {
- if($this->state==2)
- $this->pages[$this->page] .= $s;
- else
- $this->buffer .= $s;
- } else {
- if ($this->state == 2) {
- if (isset($this->footerlen[$this->page]) AND ($this->footerlen[$this->page] > 0)) {
- // puts data before page footer
- $page = substr($this->getPageBuffer($this->page), 0, -$this->footerlen[$this->page]);
- $footer = substr($this->getPageBuffer($this->page), -$this->footerlen[$this->page]);
- $this->setPageBuffer($this->page, $page.' '.$s."\n".$footer);
- } else {
- $this->setPageBuffer($this->page, $s, true);
- }
- } else {
- $this->setBuffer($s);
- }
- }
- }
-
- /**
- * rewritten to close opened parsers
- *
- */
- function _enddoc() {
- parent::_enddoc();
- $this->_closeParsers();
- }
-
- /**
- * close all files opened by parsers
- */
- function _closeParsers() {
- if ($this->state > 2 && count($this->parsers) > 0) {
- foreach ($this->parsers as $k => $_){
- $this->parsers[$k]->closeFile();
- $this->parsers[$k] = null;
- unset($this->parsers[$k]);
- }
- return true;
- }
- return false;
- }
+current_filename = $filename;
+
+ if (!isset($this->parsers[$filename]))
+ $this->parsers[$filename] = $this->_getPdfParser($filename);
+ $this->current_parser =& $this->parsers[$filename];
+
+ return $this->parsers[$filename]->getPageCount();
+ }
+
+ /**
+ * Returns a PDF parser object
+ *
+ * @param string $filename
+ * @return fpdi_pdf_parser
+ */
+ function _getPdfParser($filename) {
+ return new fpdi_pdf_parser($filename, $this);
+ }
+
+ /**
+ * Get the current PDF version
+ *
+ * @return string
+ */
+ function getPDFVersion() {
+ return $this->PDFVersion;
+ }
+
+ /**
+ * Set the PDF version
+ *
+ * @return string
+ */
+ function setPDFVersion($version = '1.3') {
+ $this->PDFVersion = $version;
+ }
+
+ /**
+ * Import a page
+ *
+ * @param int $pageno pagenumber
+ * @return int Index of imported page - to use with fpdf_tpl::useTemplate()
+ */
+ function importPage($pageno, $boxName = '/CropBox') {
+ if ($this->_intpl) {
+ return $this->error('Please import the desired pages before creating a new template.');
+ }
+
+ $fn = $this->current_filename;
+
+ // check if page already imported
+ $pageKey = $fn . '-' . ((int)$pageno) . $boxName;
+ if (isset($this->_importedPages[$pageKey]))
+ return $this->_importedPages[$pageKey];
+
+ $parser =& $this->parsers[$fn];
+ $parser->setPageno($pageno);
+
+ if (!in_array($boxName, $parser->availableBoxes))
+ return $this->Error(sprintf('Unknown box: %s', $boxName));
+ $pageboxes = $parser->getPageBoxes($pageno, $this->k);
+
+ /**
+ * MediaBox
+ * CropBox: Default -> MediaBox
+ * BleedBox: Default -> CropBox
+ * TrimBox: Default -> CropBox
+ * ArtBox: Default -> CropBox
+ */
+ if (!isset($pageboxes[$boxName]) && ($boxName == '/BleedBox' || $boxName == '/TrimBox' || $boxName == '/ArtBox'))
+ $boxName = '/CropBox';
+ if (!isset($pageboxes[$boxName]) && $boxName == '/CropBox')
+ $boxName = '/MediaBox';
+
+ if (!isset($pageboxes[$boxName]))
+ return false;
+ $this->lastUsedPageBox = $boxName;
+
+ $box = $pageboxes[$boxName];
+
+ $this->tpl++;
+ $this->tpls[$this->tpl] = array();
+ $tpl =& $this->tpls[$this->tpl];
+ $tpl['parser'] =& $parser;
+ $tpl['resources'] = $parser->getPageResources();
+ $tpl['buffer'] = $parser->getContent();
+ $tpl['box'] = $box;
+
+ // To build an array that can be used by PDF_TPL::useTemplate()
+ $this->tpls[$this->tpl] = array_merge($this->tpls[$this->tpl], $box);
+
+ // An imported page will start at 0,0 everytime. Translation will be set in _putformxobjects()
+ $tpl['x'] = 0;
+ $tpl['y'] = 0;
+
+ // handle rotated pages
+ $rotation = $parser->getPageRotation($pageno);
+ $tpl['_rotationAngle'] = 0;
+ if (isset($rotation[1]) && ($angle = $rotation[1] % 360) != 0) {
+ $steps = $angle / 90;
+
+ $_w = $tpl['w'];
+ $_h = $tpl['h'];
+ $tpl['w'] = $steps % 2 == 0 ? $_w : $_h;
+ $tpl['h'] = $steps % 2 == 0 ? $_h : $_w;
+
+ if ($angle < 0)
+ $angle += 360;
+
+ $tpl['_rotationAngle'] = $angle * -1;
+ }
+
+ $this->_importedPages[$pageKey] = $this->tpl;
+
+ return $this->tpl;
+ }
+
+ function getLastUsedPageBox() {
+ return $this->lastUsedPageBox;
+ }
+
+ function useTemplate($tplidx, $_x = null, $_y = null, $_w = 0, $_h = 0, $adjustPageSize = false) {
+ if ($adjustPageSize == true && is_null($_x) && is_null($_y)) {
+ $size = $this->getTemplateSize($tplidx, $_w, $_h);
+ $format = array($size['w'], $size['h']);
+ if (is_subclass_of($this, 'TCPDF')) {
+ $this->setPageFormat($format, $format[0] > $format[1] ? 'L' : 'P');
+ } else {
+ if ($format[0] != $this->CurPageFormat[0] || $format[1] != $this->CurPageFormat[1]) {
+ $this->w = $format[0];
+ $this->h = $format[1];
+ $this->wPt = $this->w * $this->k;
+ $this->hPt = $this->h * $this->k;
+ $this->PageBreakTrigger = $this->h - $this->bMargin;
+ $this->CurPageFormat = $format;
+ $this->PageSizes[$this->page] = array($this->wPt, $this->hPt);
+ }
+ }
+ }
+
+ $this->_out('q 0 J 1 w 0 j 0 G 0 g'); // reset standard values
+ $s = parent::useTemplate($tplidx, $_x, $_y, $_w, $_h);
+ $this->_out('Q');
+
+ return $s;
+ }
+
+ /**
+ * Private method, that rebuilds all needed objects of source files
+ */
+ function _putimportedobjects() {
+ if (is_array($this->parsers) && count($this->parsers) > 0) {
+ foreach($this->parsers AS $filename => $p) {
+ $this->current_parser =& $this->parsers[$filename];
+ if (isset($this->_obj_stack[$filename]) && is_array($this->_obj_stack[$filename])) {
+ while(($n = key($this->_obj_stack[$filename])) !== null) {
+ $nObj = $this->current_parser->pdf_resolve_object($this->current_parser->c, $this->_obj_stack[$filename][$n][1]);
+
+ $this->_newobj($this->_obj_stack[$filename][$n][0]);
+
+ if ($nObj[0] == PDF_TYPE_STREAM) {
+ $this->pdf_write_value($nObj);
+ } else {
+ $this->pdf_write_value($nObj[1]);
+ }
+
+ $this->_out('endobj');
+ $this->_obj_stack[$filename][$n] = null; // free memory
+ unset($this->_obj_stack[$filename][$n]);
+ reset($this->_obj_stack[$filename]);
+ }
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Private Method that writes the form xobjects
+ */
+ function _putformxobjects() {
+ $filter=($this->compress) ? '/Filter /FlateDecode ' : '';
+ reset($this->tpls);
+ foreach($this->tpls AS $tplidx => $tpl) {
+ $p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer'];
+ $this->_newobj();
+ $cN = $this->n; // TCPDF/Protection: rem current "n"
+
+ $this->tpls[$tplidx]['n'] = $this->n;
+ $this->_out('<<' . $filter . '/Type /XObject');
+ $this->_out('/Subtype /Form');
+ $this->_out('/FormType 1');
+
+ $this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]',
+ (isset($tpl['box']['llx']) ? $tpl['box']['llx'] : $tpl['x']) * $this->k,
+ (isset($tpl['box']['lly']) ? $tpl['box']['lly'] : -$tpl['y']) * $this->k,
+ (isset($tpl['box']['urx']) ? $tpl['box']['urx'] : $tpl['w'] + $tpl['x']) * $this->k,
+ (isset($tpl['box']['ury']) ? $tpl['box']['ury'] : $tpl['h'] - $tpl['y']) * $this->k
+ ));
+
+ $c = 1;
+ $s = 0;
+ $tx = 0;
+ $ty = 0;
+
+ if (isset($tpl['box'])) {
+ $tx = -$tpl['box']['llx'];
+ $ty = -$tpl['box']['lly'];
+
+ if ($tpl['_rotationAngle'] <> 0) {
+ $angle = $tpl['_rotationAngle'] * M_PI/180;
+ $c=cos($angle);
+ $s=sin($angle);
+
+ switch($tpl['_rotationAngle']) {
+ case -90:
+ $tx = -$tpl['box']['lly'];
+ $ty = $tpl['box']['urx'];
+ break;
+ case -180:
+ $tx = $tpl['box']['urx'];
+ $ty = $tpl['box']['ury'];
+ break;
+ case -270:
+ $tx = $tpl['box']['ury'];
+ $ty = -$tpl['box']['llx'];
+ break;
+ }
+ }
+ } else if ($tpl['x'] != 0 || $tpl['y'] != 0) {
+ $tx = -$tpl['x']*2;
+ $ty = $tpl['y']*2;
+ }
+
+ $tx *= $this->k;
+ $ty *= $this->k;
+
+ if ($c != 1 || $s != 0 || $tx != 0 || $ty != 0) {
+ $this->_out(sprintf('/Matrix [%.5F %.5F %.5F %.5F %.5F %.5F]',
+ $c, $s, -$s, $c, $tx, $ty
+ ));
+ }
+
+ $this->_out('/Resources ');
+
+ if (isset($tpl['resources'])) {
+ $this->current_parser =& $tpl['parser'];
+ $this->pdf_write_value($tpl['resources']); // "n" will be changed
+ } else {
+ $this->_out('<_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) {
+ $this->_out('/Font <<');
+ foreach($this->_res['tpl'][$tplidx]['fonts'] as $font)
+ $this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R');
+ $this->_out('>>');
+ }
+ if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) ||
+ isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls']))
+ {
+ $this->_out('/XObject <<');
+ if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) {
+ foreach($this->_res['tpl'][$tplidx]['images'] as $image)
+ $this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R');
+ }
+ if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) {
+ foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl)
+ $this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R');
+ }
+ $this->_out('>>');
+ }
+ $this->_out('>>');
+ }
+
+ $nN = $this->n; // TCPDF: rem new "n"
+ $this->n = $cN; // TCPDF: reset to current "n"
+ $this->_out('/Length ' . strlen($p) . ' >>');
+ $this->_putstream($p);
+ $this->_out('endobj');
+ $this->n = $nN; // TCPDF: reset to new "n"
+ }
+
+ $this->_putimportedobjects();
+ }
+
+ /**
+ * Rewritten to handle existing own defined objects
+ */
+ function _newobj($obj_id = false, $onlynewobj = false) {
+ if (!$obj_id) {
+ $obj_id = ++$this->n;
+ }
+
+ //Begin a new object
+ if (!$onlynewobj) {
+ $this->offsets[$obj_id] = is_subclass_of($this, 'TCPDF') ? $this->bufferlen : strlen($this->buffer);
+ $this->_out($obj_id . ' 0 obj');
+ $this->_current_obj_id = $obj_id; // for later use with encryption
+ }
+
+ return $obj_id;
+ }
+
+ /**
+ * Writes a value
+ * Needed to rebuild the source document
+ *
+ * @param mixed $value A PDF-Value. Structure of values see cases in this method
+ */
+ function pdf_write_value(&$value)
+ {
+ if (is_subclass_of($this, 'TCPDF')) {
+ parent::pdf_write_value($value);
+ }
+
+ switch ($value[0]) {
+
+ case PDF_TYPE_TOKEN:
+ $this->_straightOut($value[1] . ' ');
+ break;
+ case PDF_TYPE_NUMERIC:
+ case PDF_TYPE_REAL:
+ if (is_float($value[1]) && $value[1] != 0) {
+ $this->_straightOut(rtrim(rtrim(sprintf('%F', $value[1]), '0'), '.') . ' ');
+ } else {
+ $this->_straightOut($value[1] . ' ');
+ }
+ break;
+
+ case PDF_TYPE_ARRAY:
+
+ // An array. Output the proper
+ // structure and move on.
+
+ $this->_straightOut('[');
+ for ($i = 0; $i < count($value[1]); $i++) {
+ $this->pdf_write_value($value[1][$i]);
+ }
+
+ $this->_out(']');
+ break;
+
+ case PDF_TYPE_DICTIONARY:
+
+ // A dictionary.
+ $this->_straightOut('<<');
+
+ reset ($value[1]);
+
+ while (list($k, $v) = each($value[1])) {
+ $this->_straightOut($k . ' ');
+ $this->pdf_write_value($v);
+ }
+
+ $this->_straightOut('>>');
+ break;
+
+ case PDF_TYPE_OBJREF:
+
+ // An indirect object reference
+ // Fill the object stack if needed
+ $cpfn =& $this->current_parser->filename;
+
+ if (!isset($this->_don_obj_stack[$cpfn][$value[1]])) {
+ $this->_newobj(false, true);
+ $this->_obj_stack[$cpfn][$value[1]] = array($this->n, $value);
+ $this->_don_obj_stack[$cpfn][$value[1]] = array($this->n, $value); // Value is maybee obsolete!!!
+ }
+ $objid = $this->_don_obj_stack[$cpfn][$value[1]][0];
+
+ $this->_out($objid . ' 0 R');
+ break;
+
+ case PDF_TYPE_STRING:
+
+ // A string.
+ $this->_straightOut('(' . $value[1] . ')');
+
+ break;
+
+ case PDF_TYPE_STREAM:
+
+ // A stream. First, output the
+ // stream dictionary, then the
+ // stream data itself.
+ $this->pdf_write_value($value[1]);
+ $this->_out('stream');
+ $this->_out($value[2][1]);
+ $this->_out('endstream');
+ break;
+
+ case PDF_TYPE_HEX:
+ $this->_straightOut('<' . $value[1] . '>');
+ break;
+
+ case PDF_TYPE_BOOLEAN:
+ $this->_straightOut($value[1] ? 'true ' : 'false ');
+ break;
+
+ case PDF_TYPE_NULL:
+ // The null object.
+
+ $this->_straightOut('null ');
+ break;
+ }
+ }
+
+
+ /**
+ * Modified so not each call will add a newline to the output.
+ */
+ function _straightOut($s) {
+ if (!is_subclass_of($this, 'TCPDF')) {
+ if($this->state==2)
+ $this->pages[$this->page] .= $s;
+ else
+ $this->buffer .= $s;
+ } else {
+ if ($this->state == 2) {
+ if (isset($this->footerlen[$this->page]) AND ($this->footerlen[$this->page] > 0)) {
+ // puts data before page footer
+ $page = substr($this->getPageBuffer($this->page), 0, -$this->footerlen[$this->page]);
+ $footer = substr($this->getPageBuffer($this->page), -$this->footerlen[$this->page]);
+ $this->setPageBuffer($this->page, $page . ' ' . $s . "\n" . $footer);
+ } else {
+ $this->setPageBuffer($this->page, $s, true);
+ }
+ } else {
+ $this->setBuffer($s);
+ }
+ }
+ }
+
+ /**
+ * rewritten to close opened parsers
+ *
+ */
+ function _enddoc() {
+ parent::_enddoc();
+ $this->_closeParsers();
+ }
+
+ /**
+ * close all files opened by parsers
+ */
+ function _closeParsers() {
+ if ($this->state > 2 && count($this->parsers) > 0) {
+ foreach ($this->parsers as $k => $_){
+ $this->parsers[$k]->closeFile();
+ $this->parsers[$k] = null;
+ unset($this->parsers[$k]);
+ }
+ return true;
+ }
+ return false;
+ }
}
\ No newline at end of file
diff --git a/htdocs/includes/fpdf/fpdfi/fpdi2tcpdf_bridge.php b/htdocs/includes/fpdf/fpdfi/fpdi2tcpdf_bridge.php
index 11a3cff2254..640700a8322 100644
--- a/htdocs/includes/fpdf/fpdfi/fpdi2tcpdf_bridge.php
+++ b/htdocs/includes/fpdf/fpdfi/fpdi2tcpdf_bridge.php
@@ -1,8 +1,8 @@
PDFVersion;
- case 'k':
- return $this->k;
- default:
- // Error handling
- $this->Error('Cannot access protected property '.get_class($this).':$'.$name.' / Undefined property: '.get_class($this).'::$'.$name);
- }
- }
-
- function __set($name, $value) {
- switch ($name) {
- case 'PDFVersion':
- $this->PDFVersion = $value;
- break;
- default:
- // Error handling
- $this->Error('Cannot access protected property '.get_class($this).':$'.$name.' / Undefined property: '.get_class($this).'::$'.$name);
- }
- }
-
- function _putstream($s) {
+ function _putstream($s) {
$this->_out($this->_getstream($s));
}
function _getxobjectdict() {
-
$out = parent::_getxobjectdict();
if (count($this->tpls)) {
foreach($this->tpls as $tplidx => $tpl) {
@@ -74,7 +50,7 @@ class FPDF extends TCPDF {
*/
function pdf_write_value(&$value) {
switch ($value[0]) {
- case PDF_TYPE_STRING :
+ case PDF_TYPE_STRING:
if ($this->encrypted) {
$value[1] = $this->_unescape($value[1]);
$value[1] = $this->_RC4($this->_objectkey($this->_current_obj_id), $value[1]);
@@ -82,13 +58,13 @@ class FPDF extends TCPDF {
}
break;
- case PDF_TYPE_STREAM :
+ case PDF_TYPE_STREAM:
if ($this->encrypted) {
$value[2][1] = $this->_RC4($this->_objectkey($this->_current_obj_id), $value[2][1]);
}
break;
- case PDF_TYPE_HEX :
+ case PDF_TYPE_HEX:
if ($this->encrypted) {
$value[1] = $this->hex2str($value[1]);
$value[1] = $this->_RC4($this->_objectkey($this->_current_obj_id), $value[1]);
diff --git a/htdocs/includes/fpdf/fpdfi/fpdi_pdf_parser.php b/htdocs/includes/fpdf/fpdfi/fpdi_pdf_parser.php
index 6d564af03cb..57b8e88fd67 100644
--- a/htdocs/includes/fpdf/fpdfi/fpdi_pdf_parser.php
+++ b/htdocs/includes/fpdf/fpdfi/fpdi_pdf_parser.php
@@ -1,398 +1,409 @@
-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);
- }
-
+fpdi =& $fpdi;
+
+ parent::pdf_parser($filename);
+
+ // resolve Pages-Dictonary
+ $pages = $this->pdf_resolve_object($this->c, $this->root[1][1]['/Pages']);
+
+ // Read pages
+ $this->read_pages($this->c, $pages, $this->pages);
+
+ // count pages;
+ $this->page_count = count($this->pages);
+ }
+
+ /**
+ * Overwrite parent::error()
+ *
+ * @param string $msg Error-Message
+ */
+ function error($msg) {
+ $this->fpdi->error($msg);
+ }
+
+ /**
+ * Get pagecount from sourcefile
+ *
+ * @return int
+ */
+ function getPageCount() {
+ return $this->page_count;
+ }
+
+
+ /**
+ * Set pageno
+ *
+ * @param int $pageno Pagenumber to use
+ */
+ function setPageno($pageno) {
+ $pageno = ((int) $pageno) - 1;
+
+ if ($pageno < 0 || $pageno >= $this->getPageCount()) {
+ $this->fpdi->error('Pagenumber is wrong!');
+ }
+
+ $this->pageno = $pageno;
+ }
+
+ /**
+ * Get page-resources from current page
+ *
+ * @return array
+ */
+ function getPageResources() {
+ return $this->_getPageResources($this->pages[$this->pageno]);
+ }
+
+ /**
+ * Get page-resources from /Page
+ *
+ * @param array $obj Array of pdf-data
+ */
+ function _getPageResources ($obj) { // $obj = /Page
+ $obj = $this->pdf_resolve_object($this->c, $obj);
+
+ // If the current object has a resources
+ // dictionary associated with it, we use
+ // it. Otherwise, we move back to its
+ // parent object.
+ if (isset ($obj[1][1]['/Resources'])) {
+ $res = $this->pdf_resolve_object($this->c, $obj[1][1]['/Resources']);
+ if ($res[0] == PDF_TYPE_OBJECT)
+ return $res[1];
+ return $res;
+ } else {
+ if (!isset ($obj[1][1]['/Parent'])) {
+ return false;
+ } else {
+ $res = $this->_getPageResources($obj[1][1]['/Parent']);
+ if ($res[0] == PDF_TYPE_OBJECT)
+ return $res[1];
+ return $res;
+ }
+ }
+ }
+
+
+ /**
+ * Get content of current page
+ *
+ * If more /Contents is an array, the streams are concated
+ *
+ * @return string
+ */
+ function getContent() {
+ $buffer = '';
+
+ if (isset($this->pages[$this->pageno][1][1]['/Contents'])) {
+ $contents = $this->_getPageContent($this->pages[$this->pageno][1][1]['/Contents']);
+ foreach($contents AS $tmp_content) {
+ $buffer .= $this->_rebuildContentStream($tmp_content) . ' ';
+ }
+ }
+
+ return $buffer;
+ }
+
+
+ /**
+ * Resolve all content-objects
+ *
+ * @param array $content_ref
+ * @return array
+ */
+ function _getPageContent($content_ref) {
+ $contents = array();
+
+ if ($content_ref[0] == PDF_TYPE_OBJREF) {
+ $content = $this->pdf_resolve_object($this->c, $content_ref);
+ if ($content[1][0] == PDF_TYPE_ARRAY) {
+ $contents = $this->_getPageContent($content[1]);
+ } else {
+ $contents[] = $content;
+ }
+ } else if ($content_ref[0] == PDF_TYPE_ARRAY) {
+ foreach ($content_ref[1] AS $tmp_content_ref) {
+ $contents = array_merge($contents,$this->_getPageContent($tmp_content_ref));
+ }
+ }
+
+ return $contents;
+ }
+
+
+ /**
+ * Rebuild content-streams
+ *
+ * @param array $obj
+ * @return string
+ */
+ function _rebuildContentStream($obj) {
+ $filters = array();
+
+ if (isset($obj[1][1]['/Filter'])) {
+ $_filter = $obj[1][1]['/Filter'];
+
+ if ($_filter[0] == PDF_TYPE_OBJREF) {
+ $tmpFilter = $this->pdf_resolve_object($this->c, $_filter);
+ $_filter = $tmpFilter[1];
+ }
+
+ if ($_filter[0] == PDF_TYPE_TOKEN) {
+ $filters[] = $_filter;
+ } else if ($_filter[0] == PDF_TYPE_ARRAY) {
+ $filters = $_filter[1];
+ }
+ }
+
+ $stream = $obj[2][1];
+
+ foreach ($filters AS $_filter) {
+ switch ($_filter[1]) {
+ case '/FlateDecode':
+ case '/Fl':
+ // $stream .= "\x0F\x0D"; // in an errorious stream this suffix could work
+ // $stream .= "\x0A";
+ // $stream .= "\x0D";
+ if (function_exists('gzuncompress')) {
+ $stream = (strlen($stream) > 0) ? @gzuncompress($stream) : '';
+ } else {
+ $this->error(sprintf('To handle %s filter, please compile php with zlib support.',$_filter[1]));
+ }
+
+ if ($stream === false) {
+ $this->error('Error while decompressing stream.');
+ }
+ break;
+ case '/LZWDecode':
+ include_once('filters/FilterLZW_FPDI.php');
+ $decoder = new FilterLZW_FPDI($this->fpdi);
+ $stream = $decoder->decode($stream);
+ break;
+ case '/ASCII85Decode':
+ include_once('filters/FilterASCII85_FPDI.php');
+ $decoder = new FilterASCII85_FPDI($this->fpdi);
+ $stream = $decoder->decode($stream);
+ break;
+ case null:
+ $stream = $stream;
+ break;
+ default:
+ $this->error(sprintf('Unsupported Filter: %s',$_filter[1]));
+ }
+ }
+
+ return $stream;
+ }
+
+
+ /**
+ * Get a Box from a page
+ * Arrayformat is same as used by fpdf_tpl
+ *
+ * @param array $page a /Page
+ * @param string $box_index Type of Box @see $availableBoxes
+ * @param float Scale factor from user space units to points
+ * @return array
+ */
+ function getPageBox($page, $box_index, $k) {
+ $page = $this->pdf_resolve_object($this->c, $page);
+ $box = null;
+ if (isset($page[1][1][$box_index]))
+ $box =& $page[1][1][$box_index];
+
+ if (!is_null($box) && $box[0] == PDF_TYPE_OBJREF) {
+ $tmp_box = $this->pdf_resolve_object($this->c, $box);
+ $box = $tmp_box[1];
+ }
+
+ if (!is_null($box) && $box[0] == PDF_TYPE_ARRAY) {
+ $b =& $box[1];
+ return array('x' => $b[0][1]/$k,
+ 'y' => $b[1][1]/$k,
+ 'w' => abs($b[0][1]-$b[2][1])/$k,
+ 'h' => abs($b[1][1]-$b[3][1])/$k,
+ 'llx' => min($b[0][1], $b[2][1])/$k,
+ 'lly' => min($b[1][1], $b[3][1])/$k,
+ 'urx' => max($b[0][1], $b[2][1])/$k,
+ 'ury' => max($b[1][1], $b[3][1])/$k,
+ );
+ } else if (!isset ($page[1][1]['/Parent'])) {
+ return false;
+ } else {
+ return $this->getPageBox($this->pdf_resolve_object($this->c, $page[1][1]['/Parent']), $box_index, $k);
+ }
+ }
+
+ /**
+ * Get all page boxes by page no
+ *
+ * @param int The page number
+ * @param float Scale factor from user space units to points
+ * @return array
+ */
+ function getPageBoxes($pageno, $k) {
+ return $this->_getPageBoxes($this->pages[$pageno-1], $k);
+ }
+
+ /**
+ * Get all boxes from /Page
+ *
+ * @param array a /Page
+ * @return array
+ */
+ function _getPageBoxes($page, $k) {
+ $boxes = array();
+
+ foreach($this->availableBoxes AS $box) {
+ if ($_box = $this->getPageBox($page, $box, $k)) {
+ $boxes[$box] = $_box;
+ }
+ }
+
+ return $boxes;
+ }
+
+ /**
+ * Get the page rotation by pageno
+ *
+ * @param integer $pageno
+ * @return array
+ */
+ function getPageRotation($pageno) {
+ return $this->_getPageRotation($this->pages[$pageno-1]);
+ }
+
+ function _getPageRotation($obj) { // $obj = /Page
+ $obj = $this->pdf_resolve_object($this->c, $obj);
+ if (isset ($obj[1][1]['/Rotate'])) {
+ $res = $this->pdf_resolve_object($this->c, $obj[1][1]['/Rotate']);
+ if ($res[0] == PDF_TYPE_OBJECT)
+ return $res[1];
+ return $res;
+ } else {
+ if (!isset ($obj[1][1]['/Parent'])) {
+ return false;
+ } else {
+ $res = $this->_getPageRotation($obj[1][1]['/Parent']);
+ if ($res[0] == PDF_TYPE_OBJECT)
+ return $res[1];
+ return $res;
+ }
+ }
+ }
+
+ /**
+ * Read all /Page(es)
+ *
+ * @param object pdf_context
+ * @param array /Pages
+ * @param array the result-array
+ */
+ function read_pages(&$c, &$pages, &$result) {
+ // Get the kids dictionary
+ $_kids = $this->pdf_resolve_object ($c, $pages[1][1]['/Kids']);
+
+ if (!is_array($_kids))
+ $this->error('Cannot find /Kids in current /Page-Dictionary');
+
+ if ($_kids[1][0] == PDF_TYPE_ARRAY) {
+ $kids = $_kids[1][1];
+ } else {
+ $kids = $_kids[1];
+ }
+
+ foreach ($kids as $v) {
+ $pg = $this->pdf_resolve_object ($c, $v);
+ if ($pg[1][1]['/Type'][1] === '/Pages') {
+ // If one of the kids is an embedded
+ // /Pages array, resolve it as well.
+ $this->read_pages($c, $pg, $result);
+ } else {
+ $result[] = $pg;
+ }
+ }
+ }
+
+
+
+ /**
+ * Get PDF-Version
+ *
+ * And reset the PDF Version used in FPDI if needed
+ */
+ function getPDFVersion() {
+ parent::getPDFVersion();
+ $this->fpdi->setPDFVersion(max($this->fpdi->getPDFVersion(), $this->pdfVersion));
+ }
+
}
\ No newline at end of file
diff --git a/htdocs/includes/fpdf/fpdfi/fpdi_protection.php b/htdocs/includes/fpdf/fpdfi/fpdi_protection.php
deleted file mode 100644
index bdd56eba6b4..00000000000
--- a/htdocs/includes/fpdf/fpdfi/fpdi_protection.php
+++ /dev/null
@@ -1,305 +0,0 @@
- 4, 'modify' => 8, 'copy' => 16, 'annot-forms' => 32 );
- $protection = 192;
- foreach($permissions as $permission){
- if (!isset($options[$permission]))
- $this->Error('Incorrect permission: '.$permission);
- $protection += $options[$permission];
- }
- if ($owner_pass === null)
- $owner_pass = uniqid(rand());
- $this->encrypted = true;
- $this->_generateencryptionkey($user_pass, $owner_pass, $protection);
- }
-
-
- function _putstream($s) {
- if ($this->encrypted) {
- $s = $this->_RC4($this->_objectkey($this->_current_obj_id), $s);
- }
- parent::_putstream($s);
- }
-
-
- function _textstring($s) {
- if ($this->encrypted) {
- $s = $this->_RC4($this->_objectkey($this->_current_obj_id), $s);
- }
- return parent::_textstring($s);
- }
-
-
- /**
- * Compute key depending on object number where the encrypted data is stored
- */
- function _objectkey($n) {
- return substr($this->_md5_16($this->encryption_key.pack('VXxx', $n)), 0, 10);
- }
-
-
- /**
- * Escape special characters
- */
- function _escape($s) {
- return str_replace(
- array('\\',')','(',"\r", "\n", "\t"),
- array('\\\\','\\)','\\(','\\r', '\\n', '\\t'),$s);
- }
-
- function _putresources() {
- parent::_putresources();
- if ($this->encrypted) {
- $this->_newobj();
- $this->enc_obj_id = $this->_current_obj_id;
- $this->_out('<<');
- $this->_putencryption();
- $this->_out('>>');
- }
- }
-
- function _putencryption() {
- $this->_out('/Filter /Standard');
- $this->_out('/V 1');
- $this->_out('/R 2');
- $this->_out('/O ('.$this->_escape($this->Ovalue).')');
- $this->_out('/U ('.$this->_escape($this->Uvalue).')');
- $this->_out('/P '.$this->Pvalue);
- }
-
-
- function _puttrailer() {
- parent::_puttrailer();
- if ($this->encrypted) {
- $this->_out('/Encrypt '.$this->enc_obj_id.' 0 R');
- $this->_out('/ID [()()]');
- }
- }
-
-
- /**
- * RC4 is the standard encryption algorithm used in PDF format
- */
- function _RC4($key, $text) {
- if ($this->last_rc4_key != $key) {
- $k = str_repeat($key, 256/strlen($key)+1);
- $rc4 = range(0,255);
- $j = 0;
- for ($i=0; $i<256; $i++){
- $t = $rc4[$i];
- $j = ($j + $t + ord($k{$i})) % 256;
- $rc4[$i] = $rc4[$j];
- $rc4[$j] = $t;
- }
- $this->last_rc4_key = $key;
- $this->last_rc4_key_c = $rc4;
- } else {
- $rc4 = $this->last_rc4_key_c;
- }
-
- $len = strlen($text);
- $a = 0;
- $b = 0;
- $out = '';
- for ($i=0; $i<$len; $i++){
- $a = ($a+1)%256;
- $t= $rc4[$a];
- $b = ($b+$t)%256;
- $rc4[$a] = $rc4[$b];
- $rc4[$b] = $t;
- $k = $rc4[($rc4[$a]+$rc4[$b])%256];
- $out.=chr(ord($text{$i}) ^ $k);
- }
-
- return $out;
- }
-
-
- /**
- * Get MD5 as binary string
- */
- function _md5_16($string) {
- return pack('H*',md5($string));
- }
-
- /**
- * Compute O value
- */
- function _Ovalue($user_pass, $owner_pass) {
- $tmp = $this->_md5_16($owner_pass);
- $owner_RC4_key = substr($tmp,0,5);
- return $this->_RC4($owner_RC4_key, $user_pass);
- }
-
-
- /**
- * Compute U value
- */
- function _Uvalue() {
- return $this->_RC4($this->encryption_key, $this->padding);
- }
-
-
- /**
- * Compute encryption key
- */
- function _generateencryptionkey($user_pass, $owner_pass, $protection) {
- // Pad passwords
- $user_pass = substr($user_pass.$this->padding,0,32);
- $owner_pass = substr($owner_pass.$this->padding,0,32);
- // Compute O value
- $this->Ovalue = $this->_Ovalue($user_pass,$owner_pass);
- // Compute encyption key
- $tmp = $this->_md5_16($user_pass.$this->Ovalue.chr($protection)."\xFF\xFF\xFF");
- $this->encryption_key = substr($tmp,0,5);
- // Compute U value
- $this->Uvalue = $this->_Uvalue();
- // Compute P value
- $this->Pvalue = -(($protection^255)+1);
- }
-
-
- function pdf_write_value(&$value) {
- switch ($value[0]) {
- case PDF_TYPE_STRING :
- if ($this->encrypted) {
- $value[1] = $this->_unescape($value[1]);
- $value[1] = $this->_RC4($this->_objectkey($this->_current_obj_id), $value[1]);
- $value[1] = $this->_escape($value[1]);
- }
- break;
-
- case PDF_TYPE_STREAM :
- if ($this->encrypted) {
- $value[2][1] = $this->_RC4($this->_objectkey($this->_current_obj_id), $value[2][1]);
- }
- break;
-
- case PDF_TYPE_HEX :
-
- if ($this->encrypted) {
- $value[1] = $this->hex2str($value[1]);
- $value[1] = $this->_RC4($this->_objectkey($this->_current_obj_id), $value[1]);
-
- // remake hexstring of encrypted string
- $value[1] = $this->str2hex($value[1]);
- }
- break;
- }
-
- parent::pdf_write_value($value);
- }
-
-
- function hex2str($hex) {
- return pack('H*', str_replace(array("\r","\n",' '),'', $hex));
- }
-
- function str2hex($str) {
- return current(unpack('H*',$str));
- }
-
- /**
- * Deescape special characters
- */
- function _unescape($s) {
- $out = '';
- for ($count = 0, $n = strlen($s); $count < $n; $count++) {
- if ($s[$count] != '\\' || $count == $n-1) {
- $out .= $s[$count];
- } else {
- switch ($s[++$count]) {
- case ')':
- case '(':
- case '\\':
- $out .= $s[$count];
- break;
- case 'f':
- $out .= chr(0x0C);
- break;
- case 'b':
- $out .= chr(0x08);
- break;
- case 't':
- $out .= chr(0x09);
- break;
- case 'r':
- $out .= chr(0x0D);
- break;
- case 'n':
- $out .= chr(0x0A);
- break;
- case "\r":
- if ($count != $n-1 && $s[$count+1] == "\n")
- $count++;
- break;
- case "\n":
- break;
- default:
- // Octal-Values
- if (ord($s[$count]) >= ord('0') &&
- ord($s[$count]) <= ord('9')) {
- $oct = ''. $s[$count];
-
- if (ord($s[$count+1]) >= ord('0') &&
- ord($s[$count+1]) <= ord('9')) {
- $oct .= $s[++$count];
-
- if (ord($s[$count+1]) >= ord('0') &&
- ord($s[$count+1]) <= ord('9')) {
- $oct .= $s[++$count];
- }
- }
-
- $out .= chr(octdec($oct));
- } else {
- $out .= $s[$count];
- }
- }
- }
- }
- return $out;
- }
-}
\ No newline at end of file
diff --git a/htdocs/includes/fpdf/fpdfi/pdf_context.php b/htdocs/includes/fpdf/fpdfi/pdf_context.php
index c47e980c49a..0cece449ed2 100644
--- a/htdocs/includes/fpdf/fpdfi/pdf_context.php
+++ b/htdocs/includes/fpdf/fpdfi/pdf_context.php
@@ -1,103 +1,104 @@
-file =& $f;
- if (is_string($this->file))
- $this->_mode = 1;
- $this->reset();
- }
-
- // Optionally move the file
- // pointer to a new location
- // and reset the buffered data
-
- function reset($pos = null, $l = 100) {
- if ($this->_mode == 0) {
- if (!is_null ($pos)) {
- fseek ($this->file, $pos);
- }
-
- $this->buffer = $l > 0 ? fread($this->file, $l) : '';
- $this->length = strlen($this->buffer);
- if ($this->length < $l)
- $this->increase_length($l - $this->length);
- } else {
- $this->buffer = $this->file;
- $this->length = strlen($this->buffer);
- }
- $this->offset = 0;
- $this->stack = array();
- }
-
- // Make sure that there is at least one
- // character beyond the current offset in
- // the buffer to prevent the tokenizer
- // from attempting to access data that does
- // not exist
-
- function ensure_content() {
- if ($this->offset >= $this->length - 1) {
- return $this->increase_length();
- } else {
- return true;
- }
- }
-
- // Forcefully read more data into the buffer
-
- function increase_length($l=100) {
- if ($this->_mode == 0 && feof($this->file)) {
- return false;
- } else if ($this->_mode == 0) {
- $totalLength = $this->length + $l;
- do {
- $this->buffer .= fread($this->file, $totalLength-$this->length);
- } while ((($this->length = strlen($this->buffer)) != $totalLength) && !feof($this->file));
-
- return true;
- } else {
- return false;
- }
- }
- }
-}
-
-unset($__tmp);
\ No newline at end of file
+file =& $f;
+ if (is_string($this->file))
+ $this->_mode = 1;
+ $this->reset();
+ }
+
+ // Optionally move the file
+ // pointer to a new location
+ // and reset the buffered data
+
+ function reset($pos = null, $l = 100) {
+ if ($this->_mode == 0) {
+ if (!is_null ($pos)) {
+ fseek ($this->file, $pos);
+ }
+
+ $this->buffer = $l > 0 ? fread($this->file, $l) : '';
+ $this->length = strlen($this->buffer);
+ if ($this->length < $l)
+ $this->increase_length($l - $this->length);
+ } else {
+ $this->buffer = $this->file;
+ $this->length = strlen($this->buffer);
+ }
+ $this->offset = 0;
+ $this->stack = array();
+ }
+
+ // Make sure that there is at least one
+ // character beyond the current offset in
+ // the buffer to prevent the tokenizer
+ // from attempting to access data that does
+ // not exist
+
+ function ensure_content() {
+ if ($this->offset >= $this->length - 1) {
+ return $this->increase_length();
+ } else {
+ return true;
+ }
+ }
+
+ // Forcefully read more data into the buffer
+
+ function increase_length($l = 100) {
+ if ($this->_mode == 0 && feof($this->file)) {
+ return false;
+ } else if ($this->_mode == 0) {
+ $totalLength = $this->length + $l;
+ do {
+ $toRead = $totalLength - $this->length;
+ if ($toRead < 1)
+ break;
+
+ $this->buffer .= fread($this->file, $toRead);
+ } while ((($this->length = strlen($this->buffer)) != $totalLength) && !feof($this->file));
+
+ return true;
+ } else {
+ return false;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/htdocs/includes/fpdf/fpdfi/pdf_parser.php b/htdocs/includes/fpdf/fpdfi/pdf_parser.php
index 352f59fa747..0724152e982 100644
--- a/htdocs/includes/fpdf/fpdfi/pdf_parser.php
+++ b/htdocs/includes/fpdf/fpdfi/pdf_parser.php
@@ -1,722 +1,719 @@
-filename = $filename;
-
- $this->f = @fopen($this->filename, 'rb');
-
- if (!$this->f)
- $this->error(sprintf('Cannot open %s !', $filename));
-
- $this->getPDFVersion();
-
- $this->c = new pdf_context($this->f);
-
- // Read xref-Data
- $this->xref = array();
- $this->pdf_read_xref($this->xref, $this->pdf_find_xref());
-
- // Check for Encryption
- $this->getEncryption();
-
- // Read root
- $this->pdf_read_root();
- }
-
- /**
- * Close the opened file
- */
- function closeFile() {
- if (isset($this->f) && is_resource($this->f)) {
- fclose($this->f);
- unset($this->f);
- }
- }
-
- /**
- * Print Error and die
- *
- * @param string $msg Error-Message
- */
- function error($msg) {
- die('PDF-Parser Error: '.$msg);
- }
-
- /**
- * Check Trailer for Encryption
- */
- function getEncryption() {
- if (isset($this->xref['trailer'][1]['/Encrypt'])) {
- $this->error('File is encrypted!');
- }
- }
-
- /**
- * Find/Return /Root
- *
- * @return array
- */
- function pdf_find_root() {
- if ($this->xref['trailer'][1]['/Root'][0] != PDF_TYPE_OBJREF) {
- $this->error('Wrong Type of Root-Element! Must be an indirect reference');
- }
-
- return $this->xref['trailer'][1]['/Root'];
- }
-
- /**
- * Read the /Root
- */
- function pdf_read_root() {
- // read root
- $this->root = $this->pdf_resolve_object($this->c, $this->pdf_find_root());
- }
-
- /**
- * Get PDF-Version
- *
- * And reset the PDF Version used in FPDI if needed
- */
- function getPDFVersion() {
- fseek($this->f, 0);
- preg_match('/\d\.\d/',fread($this->f,16),$m);
- if (isset($m[0]))
- $this->pdfVersion = $m[0];
- return $this->pdfVersion;
- }
-
- /**
- * Find the xref-Table
- */
- function pdf_find_xref() {
- $toRead = 1500;
-
- $stat = fseek ($this->f, -$toRead, SEEK_END);
- if ($stat === -1) {
- fseek ($this->f, 0);
- }
- $data = fread($this->f, $toRead);
-
- $pos = strlen($data) - strpos(strrev($data), strrev('startxref'));
- $data = substr($data, $pos);
-
- if (!preg_match('/\s*(\d+).*$/s', $data, $matches)) {
- $this->error('Unable to find pointer to xref table');
- }
-
- return (int) $matches[1];
- }
-
- /**
- * Read xref-table
- *
- * @param array $result Array of xref-table
- * @param integer $offset of xref-table
- */
- function pdf_read_xref(&$result, $offset) {
- $o_pos = $offset-min(20, $offset);
- fseek($this->f, $o_pos); // set some bytes backwards to fetch errorious docs
-
- $data = fread($this->f, 100);
-
- $xrefPos = strrpos($data, 'xref');
-
- if ($xrefPos === false) {
- fseek($this->f, $offset);
- $c = new pdf_context($this->f);
- $xrefStreamObjDec = $this->pdf_read_value($c);
-
- if (is_array($xrefStreamObjDec) && isset($xrefStreamObjDec[0]) && $xrefStreamObjDec[0] == PDF_TYPE_OBJDEC) {
- $this->error(sprintf('This document (%s) probably uses a compression technique which is not supported by the free parser shipped with FPDI.', $this->filename));
- } else {
- $this->error('Unable to find xref table.');
- }
- }
-
- if (!isset($result['xref_location'])) {
- $result['xref_location'] = $o_pos+$xrefPos;
- $result['max_object'] = 0;
- }
-
- $cylces = -1;
- $bytesPerCycle = 100;
-
- fseek($this->f, $o_pos = $o_pos+$xrefPos+4); // set the handle directly after the "xref"-keyword
- $data = fread($this->f, $bytesPerCycle);
-
- while (($trailerPos = strpos($data, 'trailer', max($bytesPerCycle*$cylces++, 0))) === false && !feof($this->f)) {
- $data .= fread($this->f, $bytesPerCycle);
- }
-
- if ($trailerPos === false) {
- $this->error('Trailer keyword not found after xref table');
- }
-
- $data = substr($data, 0, $trailerPos);
-
- // get Line-Ending
- preg_match_all("/(\r\n|\n|\r)/", substr($data, 0, 100), $m); // check the first 100 bytes for linebreaks
-
- $differentLineEndings = count(array_unique($m[0]));
- if ($differentLineEndings > 1) {
- $lines = preg_split("/(\r\n|\n|\r)/", $data, -1, PREG_SPLIT_NO_EMPTY);
- } else {
- $lines = explode($m[0][1], $data);
- }
-
- $data = $differentLineEndings = $m = null;
- unset($data, $differentLineEndings, $m);
-
- $linesCount = count($lines);
-
- $start = 1;
-
- for ($i = 0; $i < $linesCount; $i++) {
- $line = trim($lines[$i]);
- if ($line) {
- $pieces = explode(' ', $line);
- $c = count($pieces);
- switch($c) {
- case 2:
- $start = (int)$pieces[0];
- $end = $start+(int)$pieces[1];
- if ($end > $result['max_object'])
- $result['max_object'] = $end;
- break;
- case 3:
- if (!isset($result['xref'][$start]))
- $result['xref'][$start] = array();
-
- if (!array_key_exists($gen = (int) $pieces[1], $result['xref'][$start])) {
- $result['xref'][$start][$gen] = $pieces[2] == 'n' ? (int) $pieces[0] : null;
- }
- $start++;
- break;
- default:
- $this->error('Unexpected data in xref table');
- }
- }
- }
-
- $lines = $pieces = $line = $start = $end = $gen = null;
- unset($lines, $pieces, $line, $start, $end, $gen);
-
- fseek($this->f, $o_pos+$trailerPos+7);
-
- $c = new pdf_context($this->f);
- $trailer = $this->pdf_read_value($c);
-
- $c = null;
- unset($c);
-
- if (!isset($result['trailer'])) {
- $result['trailer'] = $trailer;
- }
-
- if (isset($trailer[1]['/Prev'])) {
- $this->pdf_read_xref($result, $trailer[1]['/Prev'][1]);
- }
-
- $trailer = null;
- unset($trailer);
-
- return true;
- }
-
- /**
- * Reads an Value
- *
- * @param object $c pdf_context
- * @param string $token a Token
- * @return mixed
- */
- function pdf_read_value(&$c, $token = null) {
- if (is_null($token)) {
- $token = $this->pdf_read_token($c);
- }
-
- if ($token === false) {
- return false;
- }
-
- switch ($token) {
- case '<':
- // This is a hex string.
- // Read the value, then the terminator
-
- $pos = $c->offset;
-
- while(1) {
-
- $match = strpos ($c->buffer, '>', $pos);
-
- // If you can't find it, try
- // reading more data from the stream
-
- if ($match === false) {
- if (!$c->increase_length()) {
- return false;
- } else {
- continue;
- }
- }
-
- $result = substr ($c->buffer, $c->offset, $match - $c->offset);
- $c->offset = $match + 1;
-
- return array (PDF_TYPE_HEX, $result);
- }
-
- break;
- case '<<':
- // This is a dictionary.
-
- $result = array();
-
- // Recurse into this function until we reach
- // the end of the dictionary.
- while (($key = $this->pdf_read_token($c)) !== '>>') {
- if ($key === false) {
- return false;
- }
-
- if (($value = $this->pdf_read_value($c)) === false) {
- return false;
- }
-
- // Catch missing value
- if ($value[0] == PDF_TYPE_TOKEN && $value[1] == '>>') {
- $result[$key] = array(PDF_TYPE_NULL);
- break;
- }
-
- $result[$key] = $value;
- }
-
- return array (PDF_TYPE_DICTIONARY, $result);
-
- case '[':
- // This is an array.
-
- $result = array();
-
- // Recurse into this function until we reach
- // the end of the array.
- while (($token = $this->pdf_read_token($c)) !== ']') {
- if ($token === false) {
- return false;
- }
-
- if (($value = $this->pdf_read_value($c, $token)) === false) {
- return false;
- }
-
- $result[] = $value;
- }
-
- return array (PDF_TYPE_ARRAY, $result);
-
- case '(' :
- // This is a string
- $pos = $c->offset;
-
- $openBrackets = 1;
- do {
- for (; $openBrackets != 0 && $pos < $c->length; $pos++) {
- switch (ord($c->buffer[$pos])) {
- case 0x28: // '('
- $openBrackets++;
- break;
- case 0x29: // ')'
- $openBrackets--;
- break;
- case 0x5C: // backslash
- $pos++;
- }
- }
- } while($openBrackets != 0 && $c->increase_length());
-
- $result = substr($c->buffer, $c->offset, $pos - $c->offset - 1);
- $c->offset = $pos;
-
- return array (PDF_TYPE_STRING, $result);
-
- case 'stream':
- $o_pos = ftell($c->file)-strlen($c->buffer);
- $o_offset = $c->offset;
-
- $c->reset($startpos = $o_pos + $o_offset);
-
- $e = 0; // ensure line breaks in front of the stream
- if ($c->buffer[0] == chr(10) || $c->buffer[0] == chr(13))
- $e++;
- if ($c->buffer[1] == chr(10) && $c->buffer[0] != chr(10))
- $e++;
-
- if ($this->actual_obj[1][1]['/Length'][0] == PDF_TYPE_OBJREF) {
- $tmp_c = new pdf_context($this->f);
- $tmp_length = $this->pdf_resolve_object($tmp_c, $this->actual_obj[1][1]['/Length']);
- $length = $tmp_length[1][1];
- } else {
- $length = $this->actual_obj[1][1]['/Length'][1];
- }
-
- if ($length > 0) {
- $c->reset($startpos+$e,$length);
- $v = $c->buffer;
- } else {
- $v = '';
- }
- $c->reset($startpos+$e+$length+9); // 9 = strlen("endstream")
-
- return array(PDF_TYPE_STREAM, $v);
-
- default :
- if (is_numeric ($token)) {
- // A numeric token. Make sure that
- // it is not part of something else.
- if (($tok2 = $this->pdf_read_token ($c)) !== false) {
- if (is_numeric ($tok2)) {
-
- // Two numeric tokens in a row.
- // In this case, we're probably in
- // front of either an object reference
- // or an object specification.
- // Determine the case and return the data
- if (($tok3 = $this->pdf_read_token ($c)) !== false) {
- switch ($tok3) {
- case 'obj' :
- return array (PDF_TYPE_OBJDEC, (int) $token, (int) $tok2);
- case 'R' :
- return array (PDF_TYPE_OBJREF, (int) $token, (int) $tok2);
- }
- // If we get to this point, that numeric value up
- // there was just a numeric value. Push the extra
- // tokens back into the stack and return the value.
- array_push ($c->stack, $tok3);
- }
- }
-
- array_push ($c->stack, $tok2);
- }
-
- if ($token === (string)((int)$token))
- return array (PDF_TYPE_NUMERIC, (int)$token);
- else
- return array (PDF_TYPE_REAL, (float)$token);
- } else if ($token == 'true' || $token == 'false') {
- return array (PDF_TYPE_BOOLEAN, $token == 'true');
- } else if ($token == 'null') {
- return array (PDF_TYPE_NULL);
- } else {
- // Just a token. Return it.
- return array (PDF_TYPE_TOKEN, $token);
- }
- }
- }
-
- /**
- * Resolve an object
- *
- * @param object $c pdf_context
- * @param array $obj_spec The object-data
- * @param boolean $encapsulate Must set to true, cause the parsing and fpdi use this method only without this para
- */
- function pdf_resolve_object(&$c, $obj_spec, $encapsulate = true) {
- // Exit if we get invalid data
- if (!is_array($obj_spec)) {
- $ret = false;
- return $ret;
- }
-
- if ($obj_spec[0] == PDF_TYPE_OBJREF) {
-
- // This is a reference, resolve it
- if (isset($this->xref['xref'][$obj_spec[1]][$obj_spec[2]])) {
-
- // Save current file position
- // This is needed if you want to resolve
- // references while you're reading another object
- // (e.g.: if you need to determine the length
- // of a stream)
-
- $old_pos = ftell($c->file);
-
- // Reposition the file pointer and
- // load the object header.
-
- $c->reset($this->xref['xref'][$obj_spec[1]][$obj_spec[2]]);
-
- $header = $this->pdf_read_value($c);
-
- if ($header[0] != PDF_TYPE_OBJDEC || $header[1] != $obj_spec[1] || $header[2] != $obj_spec[2]) {
- $toSearchFor = $obj_spec[1].' '.$obj_spec[2].' obj';
- if (preg_match('/'.$toSearchFor.'/', $c->buffer)) {
- $c->offset = strpos($c->buffer, $toSearchFor) + strlen($toSearchFor);
- // reset stack
- $c->stack = array();
- } else {
- $this->error("Unable to find object ({$obj_spec[1]}, {$obj_spec[2]}) at expected location");
- }
- }
-
- // If we're being asked to store all the information
- // about the object, we add the object ID and generation
- // number for later use
- $result = array();
- $this->actual_obj =& $result;
- if ($encapsulate) {
- $result = array (
- PDF_TYPE_OBJECT,
- 'obj' => $obj_spec[1],
- 'gen' => $obj_spec[2]
- );
- }
-
- // Now simply read the object data until
- // we encounter an end-of-object marker
- while(1) {
- $value = $this->pdf_read_value($c);
- if ($value === false || count($result) > 4) {
- // in this case the parser coudn't find an endobj so we break here
- break;
- }
-
- if ($value[0] == PDF_TYPE_TOKEN && $value[1] === 'endobj') {
- break;
- }
-
- $result[] = $value;
- }
-
- $c->reset($old_pos);
-
- if (isset($result[2][0]) && $result[2][0] == PDF_TYPE_STREAM) {
- $result[0] = PDF_TYPE_STREAM;
- }
-
- return $result;
- }
- } else {
- return $obj_spec;
- }
- }
-
-
-
- /**
- * Reads a token from the file
- *
- * @param object $c pdf_context
- * @return mixed
- */
- function pdf_read_token(&$c)
- {
- // If there is a token available
- // on the stack, pop it out and
- // return it.
-
- if (count($c->stack)) {
- return array_pop($c->stack);
- }
-
- // Strip away any whitespace
-
- do {
- if (!$c->ensure_content()) {
- return false;
- }
- $c->offset += strspn($c->buffer, " \n\r\t", $c->offset);
- } while ($c->offset >= $c->length - 1);
-
- // Get the first character in the stream
-
- $char = $c->buffer[$c->offset++];
-
- switch ($char) {
-
- case '[':
- case ']':
- case '(':
- case ')':
-
- // This is either an array or literal string
- // delimiter, Return it
-
- return $char;
-
- case '<':
- case '>':
-
- // This could either be a hex string or
- // dictionary delimiter. Determine the
- // appropriate case and return the token
-
- if ($c->buffer[$c->offset] == $char) {
- if (!$c->ensure_content()) {
- return false;
- }
- $c->offset++;
- return $char . $char;
- } else {
- return $char;
- }
-
- case '%':
-
- // This is a comment - jump over it!
-
- $pos = $c->offset;
- while(1) {
- $match = preg_match("/(\r\n|\r|\n)/", $c->buffer, $m, PREG_OFFSET_CAPTURE, $pos);
- if ($match === 0) {
- if (!$c->increase_length()) {
- return false;
- } else {
- continue;
- }
- }
-
- $c->offset = $m[0][1]+strlen($m[0][0]);
-
- return $this->pdf_read_token($c);
- }
-
- default:
-
- // This is "another" type of token (probably
- // a dictionary entry or a numeric value)
- // Find the end and return it.
-
- if (!$c->ensure_content()) {
- return false;
- }
-
- while(1) {
-
- // Determine the length of the token
-
- $pos = strcspn($c->buffer, " %[]<>()\r\n\t/", $c->offset);
-
- if ($c->offset + $pos <= $c->length - 1) {
- break;
- } else {
- // If the script reaches this point,
- // the token may span beyond the end
- // of the current buffer. Therefore,
- // we increase the size of the buffer
- // and try again--just to be safe.
-
- $c->increase_length();
- }
- }
-
- $result = substr($c->buffer, $c->offset - 1, $pos + 1);
-
- $c->offset += $pos;
- return $result;
- }
- }
- }
-}
-
-unset($__tmp);
\ No newline at end of file
+filename = $filename;
+
+ $this->f = @fopen($this->filename, 'rb');
+
+ if (!$this->f)
+ $this->error(sprintf('Cannot open %s !', $filename));
+
+ $this->getPDFVersion();
+
+ $this->c = new pdf_context($this->f);
+
+ // Read xref-Data
+ $this->xref = array();
+ $this->pdf_read_xref($this->xref, $this->pdf_find_xref());
+
+ // Check for Encryption
+ $this->getEncryption();
+
+ // Read root
+ $this->pdf_read_root();
+ }
+
+ /**
+ * Close the opened file
+ */
+ function closeFile() {
+ if (isset($this->f) && is_resource($this->f)) {
+ fclose($this->f);
+ unset($this->f);
+ }
+ }
+
+ /**
+ * Print Error and die
+ *
+ * @param string $msg Error-Message
+ */
+ function error($msg) {
+ die('PDF-Parser Error: '.$msg);
+ }
+
+ /**
+ * Check Trailer for Encryption
+ */
+ function getEncryption() {
+ if (isset($this->xref['trailer'][1]['/Encrypt'])) {
+ $this->error('File is encrypted!');
+ }
+ }
+
+ /**
+ * Find/Return /Root
+ *
+ * @return array
+ */
+ function pdf_find_root() {
+ if ($this->xref['trailer'][1]['/Root'][0] != PDF_TYPE_OBJREF) {
+ $this->error('Wrong Type of Root-Element! Must be an indirect reference');
+ }
+
+ return $this->xref['trailer'][1]['/Root'];
+ }
+
+ /**
+ * Read the /Root
+ */
+ function pdf_read_root() {
+ // read root
+ $this->root = $this->pdf_resolve_object($this->c, $this->pdf_find_root());
+ }
+
+ /**
+ * Get PDF-Version
+ *
+ * And reset the PDF Version used in FPDI if needed
+ */
+ function getPDFVersion() {
+ fseek($this->f, 0);
+ preg_match('/\d\.\d/',fread($this->f,16),$m);
+ if (isset($m[0]))
+ $this->pdfVersion = $m[0];
+ return $this->pdfVersion;
+ }
+
+ /**
+ * Find the xref-Table
+ */
+ function pdf_find_xref() {
+ $toRead = 1500;
+
+ $stat = fseek ($this->f, -$toRead, SEEK_END);
+ if ($stat === -1) {
+ fseek ($this->f, 0);
+ }
+ $data = fread($this->f, $toRead);
+
+ $pos = strlen($data) - strpos(strrev($data), strrev('startxref'));
+ $data = substr($data, $pos);
+
+ if (!preg_match('/\s*(\d+).*$/s', $data, $matches)) {
+ $this->error('Unable to find pointer to xref table');
+ }
+
+ return (int) $matches[1];
+ }
+
+ /**
+ * Read xref-table
+ *
+ * @param array $result Array of xref-table
+ * @param integer $offset of xref-table
+ */
+ function pdf_read_xref(&$result, $offset) {
+ $o_pos = $offset-min(20, $offset);
+ fseek($this->f, $o_pos); // set some bytes backwards to fetch errorious docs
+
+ $data = fread($this->f, 100);
+
+ $xrefPos = strrpos($data, 'xref');
+
+ if ($xrefPos === false) {
+ fseek($this->f, $offset);
+ $c = new pdf_context($this->f);
+ $xrefStreamObjDec = $this->pdf_read_value($c);
+
+ if (is_array($xrefStreamObjDec) && isset($xrefStreamObjDec[0]) && $xrefStreamObjDec[0] == PDF_TYPE_OBJDEC) {
+ $this->error(sprintf('This document (%s) probably uses a compression technique which is not supported by the free parser shipped with FPDI.', $this->filename));
+ } else {
+ $this->error('Unable to find xref table.');
+ }
+ }
+
+ if (!isset($result['xref_location'])) {
+ $result['xref_location'] = $o_pos+$xrefPos;
+ $result['max_object'] = 0;
+ }
+
+ $cylces = -1;
+ $bytesPerCycle = 100;
+
+ fseek($this->f, $o_pos = $o_pos+$xrefPos+4); // set the handle directly after the "xref"-keyword
+ $data = fread($this->f, $bytesPerCycle);
+
+ while (($trailerPos = strpos($data, 'trailer', max($bytesPerCycle*$cylces++, 0))) === false && !feof($this->f)) {
+ $data .= fread($this->f, $bytesPerCycle);
+ }
+
+ if ($trailerPos === false) {
+ $this->error('Trailer keyword not found after xref table');
+ }
+
+ $data = substr($data, 0, $trailerPos);
+
+ // get Line-Ending
+ preg_match_all("/(\r\n|\n|\r)/", substr($data, 0, 100), $m); // check the first 100 bytes for linebreaks
+
+ $differentLineEndings = count(array_unique($m[0]));
+ if ($differentLineEndings > 1) {
+ $lines = preg_split("/(\r\n|\n|\r)/", $data, -1, PREG_SPLIT_NO_EMPTY);
+ } else {
+ $lines = explode($m[0][1], $data);
+ }
+
+ $data = $differentLineEndings = $m = null;
+ unset($data, $differentLineEndings, $m);
+
+ $linesCount = count($lines);
+
+ $start = 1;
+
+ for ($i = 0; $i < $linesCount; $i++) {
+ $line = trim($lines[$i]);
+ if ($line) {
+ $pieces = explode(' ', $line);
+ $c = count($pieces);
+ switch($c) {
+ case 2:
+ $start = (int)$pieces[0];
+ $end = $start+(int)$pieces[1];
+ if ($end > $result['max_object'])
+ $result['max_object'] = $end;
+ break;
+ case 3:
+ if (!isset($result['xref'][$start]))
+ $result['xref'][$start] = array();
+
+ if (!array_key_exists($gen = (int) $pieces[1], $result['xref'][$start])) {
+ $result['xref'][$start][$gen] = $pieces[2] == 'n' ? (int) $pieces[0] : null;
+ }
+ $start++;
+ break;
+ default:
+ $this->error('Unexpected data in xref table');
+ }
+ }
+ }
+
+ $lines = $pieces = $line = $start = $end = $gen = null;
+ unset($lines, $pieces, $line, $start, $end, $gen);
+
+ fseek($this->f, $o_pos+$trailerPos+7);
+
+ $c = new pdf_context($this->f);
+ $trailer = $this->pdf_read_value($c);
+
+ $c = null;
+ unset($c);
+
+ if (!isset($result['trailer'])) {
+ $result['trailer'] = $trailer;
+ }
+
+ if (isset($trailer[1]['/Prev'])) {
+ $this->pdf_read_xref($result, $trailer[1]['/Prev'][1]);
+ }
+
+ $trailer = null;
+ unset($trailer);
+
+ return true;
+ }
+
+ /**
+ * Reads an Value
+ *
+ * @param object $c pdf_context
+ * @param string $token a Token
+ * @return mixed
+ */
+ function pdf_read_value(&$c, $token = null) {
+ if (is_null($token)) {
+ $token = $this->pdf_read_token($c);
+ }
+
+ if ($token === false) {
+ return false;
+ }
+
+ switch ($token) {
+ case '<':
+ // This is a hex string.
+ // Read the value, then the terminator
+
+ $pos = $c->offset;
+
+ while(1) {
+
+ $match = strpos ($c->buffer, '>', $pos);
+
+ // If you can't find it, try
+ // reading more data from the stream
+
+ if ($match === false) {
+ if (!$c->increase_length()) {
+ return false;
+ } else {
+ continue;
+ }
+ }
+
+ $result = substr ($c->buffer, $c->offset, $match - $c->offset);
+ $c->offset = $match + 1;
+
+ return array (PDF_TYPE_HEX, $result);
+ }
+
+ break;
+ case '<<':
+ // This is a dictionary.
+
+ $result = array();
+
+ // Recurse into this function until we reach
+ // the end of the dictionary.
+ while (($key = $this->pdf_read_token($c)) !== '>>') {
+ if ($key === false) {
+ return false;
+ }
+
+ if (($value = $this->pdf_read_value($c)) === false) {
+ return false;
+ }
+
+ // Catch missing value
+ if ($value[0] == PDF_TYPE_TOKEN && $value[1] == '>>') {
+ $result[$key] = array(PDF_TYPE_NULL);
+ break;
+ }
+
+ $result[$key] = $value;
+ }
+
+ return array (PDF_TYPE_DICTIONARY, $result);
+
+ case '[':
+ // This is an array.
+
+ $result = array();
+
+ // Recurse into this function until we reach
+ // the end of the array.
+ while (($token = $this->pdf_read_token($c)) !== ']') {
+ if ($token === false) {
+ return false;
+ }
+
+ if (($value = $this->pdf_read_value($c, $token)) === false) {
+ return false;
+ }
+
+ $result[] = $value;
+ }
+
+ return array (PDF_TYPE_ARRAY, $result);
+
+ case '(' :
+ // This is a string
+ $pos = $c->offset;
+
+ $openBrackets = 1;
+ do {
+ for (; $openBrackets != 0 && $pos < $c->length; $pos++) {
+ switch (ord($c->buffer[$pos])) {
+ case 0x28: // '('
+ $openBrackets++;
+ break;
+ case 0x29: // ')'
+ $openBrackets--;
+ break;
+ case 0x5C: // backslash
+ $pos++;
+ }
+ }
+ } while($openBrackets != 0 && $c->increase_length());
+
+ $result = substr($c->buffer, $c->offset, $pos - $c->offset - 1);
+ $c->offset = $pos;
+
+ return array (PDF_TYPE_STRING, $result);
+
+ case 'stream':
+ $o_pos = ftell($c->file)-strlen($c->buffer);
+ $o_offset = $c->offset;
+
+ $c->reset($startpos = $o_pos + $o_offset);
+
+ $e = 0; // ensure line breaks in front of the stream
+ if ($c->buffer[0] == chr(10) || $c->buffer[0] == chr(13))
+ $e++;
+ if ($c->buffer[1] == chr(10) && $c->buffer[0] != chr(10))
+ $e++;
+
+ if ($this->actual_obj[1][1]['/Length'][0] == PDF_TYPE_OBJREF) {
+ $tmp_c = new pdf_context($this->f);
+ $tmp_length = $this->pdf_resolve_object($tmp_c, $this->actual_obj[1][1]['/Length']);
+ $length = $tmp_length[1][1];
+ } else {
+ $length = $this->actual_obj[1][1]['/Length'][1];
+ }
+
+ if ($length > 0) {
+ $c->reset($startpos+$e,$length);
+ $v = $c->buffer;
+ } else {
+ $v = '';
+ }
+ $c->reset($startpos+$e+$length+9); // 9 = strlen("endstream")
+
+ return array(PDF_TYPE_STREAM, $v);
+
+ default :
+ if (is_numeric ($token)) {
+ // A numeric token. Make sure that
+ // it is not part of something else.
+ if (($tok2 = $this->pdf_read_token ($c)) !== false) {
+ if (is_numeric ($tok2)) {
+
+ // Two numeric tokens in a row.
+ // In this case, we're probably in
+ // front of either an object reference
+ // or an object specification.
+ // Determine the case and return the data
+ if (($tok3 = $this->pdf_read_token ($c)) !== false) {
+ switch ($tok3) {
+ case 'obj' :
+ return array (PDF_TYPE_OBJDEC, (int) $token, (int) $tok2);
+ case 'R' :
+ return array (PDF_TYPE_OBJREF, (int) $token, (int) $tok2);
+ }
+ // If we get to this point, that numeric value up
+ // there was just a numeric value. Push the extra
+ // tokens back into the stack and return the value.
+ array_push ($c->stack, $tok3);
+ }
+ }
+
+ array_push ($c->stack, $tok2);
+ }
+
+ if ($token === (string)((int)$token))
+ return array (PDF_TYPE_NUMERIC, (int)$token);
+ else
+ return array (PDF_TYPE_REAL, (float)$token);
+ } else if ($token == 'true' || $token == 'false') {
+ return array (PDF_TYPE_BOOLEAN, $token == 'true');
+ } else if ($token == 'null') {
+ return array (PDF_TYPE_NULL);
+ } else {
+ // Just a token. Return it.
+ return array (PDF_TYPE_TOKEN, $token);
+ }
+ }
+ }
+
+ /**
+ * Resolve an object
+ *
+ * @param object $c pdf_context
+ * @param array $obj_spec The object-data
+ * @param boolean $encapsulate Must set to true, cause the parsing and fpdi use this method only without this para
+ */
+ function pdf_resolve_object(&$c, $obj_spec, $encapsulate = true) {
+ // Exit if we get invalid data
+ if (!is_array($obj_spec)) {
+ $ret = false;
+ return $ret;
+ }
+
+ if ($obj_spec[0] == PDF_TYPE_OBJREF) {
+
+ // This is a reference, resolve it
+ if (isset($this->xref['xref'][$obj_spec[1]][$obj_spec[2]])) {
+
+ // Save current file position
+ // This is needed if you want to resolve
+ // references while you're reading another object
+ // (e.g.: if you need to determine the length
+ // of a stream)
+
+ $old_pos = ftell($c->file);
+
+ // Reposition the file pointer and
+ // load the object header.
+
+ $c->reset($this->xref['xref'][$obj_spec[1]][$obj_spec[2]]);
+
+ $header = $this->pdf_read_value($c);
+
+ if ($header[0] != PDF_TYPE_OBJDEC || $header[1] != $obj_spec[1] || $header[2] != $obj_spec[2]) {
+ $toSearchFor = $obj_spec[1].' '.$obj_spec[2].' obj';
+ if (preg_match('/'.$toSearchFor.'/', $c->buffer)) {
+ $c->offset = strpos($c->buffer, $toSearchFor) + strlen($toSearchFor);
+ // reset stack
+ $c->stack = array();
+ } else {
+ $this->error("Unable to find object ({$obj_spec[1]}, {$obj_spec[2]}) at expected location");
+ }
+ }
+
+ // If we're being asked to store all the information
+ // about the object, we add the object ID and generation
+ // number for later use
+ $result = array();
+ $this->actual_obj =& $result;
+ if ($encapsulate) {
+ $result = array (
+ PDF_TYPE_OBJECT,
+ 'obj' => $obj_spec[1],
+ 'gen' => $obj_spec[2]
+ );
+ }
+
+ // Now simply read the object data until
+ // we encounter an end-of-object marker
+ while(1) {
+ $value = $this->pdf_read_value($c);
+ if ($value === false || count($result) > 4) {
+ // in this case the parser coudn't find an endobj so we break here
+ break;
+ }
+
+ if ($value[0] == PDF_TYPE_TOKEN && $value[1] === 'endobj') {
+ break;
+ }
+
+ $result[] = $value;
+ }
+
+ $c->reset($old_pos);
+
+ if (isset($result[2][0]) && $result[2][0] == PDF_TYPE_STREAM) {
+ $result[0] = PDF_TYPE_STREAM;
+ }
+
+ return $result;
+ }
+ } else {
+ return $obj_spec;
+ }
+ }
+
+
+
+ /**
+ * Reads a token from the file
+ *
+ * @param object $c pdf_context
+ * @return mixed
+ */
+ function pdf_read_token(&$c)
+ {
+ // If there is a token available
+ // on the stack, pop it out and
+ // return it.
+
+ if (count($c->stack)) {
+ return array_pop($c->stack);
+ }
+
+ // Strip away any whitespace
+
+ do {
+ if (!$c->ensure_content()) {
+ return false;
+ }
+ $c->offset += strspn($c->buffer, " \n\r\t", $c->offset);
+ } while ($c->offset >= $c->length - 1);
+
+ // Get the first character in the stream
+
+ $char = $c->buffer[$c->offset++];
+
+ switch ($char) {
+
+ case '[':
+ case ']':
+ case '(':
+ case ')':
+
+ // This is either an array or literal string
+ // delimiter, Return it
+
+ return $char;
+
+ case '<':
+ case '>':
+
+ // This could either be a hex string or
+ // dictionary delimiter. Determine the
+ // appropriate case and return the token
+
+ if ($c->buffer[$c->offset] == $char) {
+ if (!$c->ensure_content()) {
+ return false;
+ }
+ $c->offset++;
+ return $char . $char;
+ } else {
+ return $char;
+ }
+
+ case '%':
+
+ // This is a comment - jump over it!
+
+ $pos = $c->offset;
+ while(1) {
+ $match = preg_match("/(\r\n|\r|\n)/", $c->buffer, $m, PREG_OFFSET_CAPTURE, $pos);
+ if ($match === 0) {
+ if (!$c->increase_length()) {
+ return false;
+ } else {
+ continue;
+ }
+ }
+
+ $c->offset = $m[0][1]+strlen($m[0][0]);
+
+ return $this->pdf_read_token($c);
+ }
+
+ default:
+
+ // This is "another" type of token (probably
+ // a dictionary entry or a numeric value)
+ // Find the end and return it.
+
+ if (!$c->ensure_content()) {
+ return false;
+ }
+
+ while(1) {
+
+ // Determine the length of the token
+
+ $pos = strcspn($c->buffer, " %[]<>()\r\n\t/", $c->offset);
+
+ if ($c->offset + $pos <= $c->length - 1) {
+ break;
+ } else {
+ // If the script reaches this point,
+ // the token may span beyond the end
+ // of the current buffer. Therefore,
+ // we increase the size of the buffer
+ // and try again--just to be safe.
+
+ $c->increase_length();
+ }
+ }
+
+ $result = substr($c->buffer, $c->offset - 1, $pos + 1);
+
+ $c->offset += $pos;
+ return $result;
+ }
+ }
+ }
+}
diff --git a/htdocs/includes/modules/action/rapport.pdf.php b/htdocs/includes/modules/action/rapport.pdf.php
index db7288b06e7..50f028eb232 100644
--- a/htdocs/includes/modules/action/rapport.pdf.php
+++ b/htdocs/includes/modules/action/rapport.pdf.php
@@ -22,10 +22,9 @@
* \file htdocs/includes/modules/action/rapport.pdf.php
* \ingroup commercial
* \brief File to build PDF with events
- * \version $Id: rapport.pdf.php,v 1.36 2011/08/10 23:21:13 eldy Exp $
+ * \version $Id: rapport.pdf.php,v 1.37 2011/08/11 12:14:04 eldy Exp $
*/
-require_once(FPDFI_PATH.'fpdi_protection.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/date.lib.php');
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
@@ -83,7 +82,7 @@ class CommActionRapport
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
- if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1';
+ if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
$outputlangs->load("main");
$outputlangs->load("dict");
diff --git a/htdocs/includes/modules/cheque/pdf/modules_chequereceipts.php b/htdocs/includes/modules/cheque/pdf/modules_chequereceipts.php
index ac0b637c4d7..99803015c20 100644
--- a/htdocs/includes/modules/cheque/pdf/modules_chequereceipts.php
+++ b/htdocs/includes/modules/cheque/pdf/modules_chequereceipts.php
@@ -23,10 +23,9 @@
* \file htdocs/includes/modules/cheque/pdf/modules_chequereceipts.php
* \ingroup facture
* \brief File with parent class of check receipt document generators
- * \version $Id: modules_chequereceipts.php,v 1.6 2011/08/10 23:21:12 eldy Exp $
+ * \version $Id: modules_chequereceipts.php,v 1.7 2011/08/11 12:14:03 eldy Exp $
*/
-require_once(FPDFI_PATH.'fpdi_protection.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php');
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
require_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php"); // Requis car utilise dans les classes qui heritent
diff --git a/htdocs/includes/modules/cheque/pdf/pdf_blochet.class.php b/htdocs/includes/modules/cheque/pdf/pdf_blochet.class.php
index f40c2af9411..4162526b5d0 100644
--- a/htdocs/includes/modules/cheque/pdf/pdf_blochet.class.php
+++ b/htdocs/includes/modules/cheque/pdf/pdf_blochet.class.php
@@ -21,10 +21,9 @@
* \file htdocs/includes/modules/cheque/pdf/pdf_blochet.class.php
* \ingroup banque
* \brief File to build cheque deposit receipts
- * \version $Id: pdf_blochet.class.php,v 1.42 2011/08/10 23:21:12 eldy Exp $
+ * \version $Id: pdf_blochet.class.php,v 1.43 2011/08/11 12:14:03 eldy Exp $
*/
-require_once(FPDFI_PATH.'fpdi_protection.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php');
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
require_once(DOL_DOCUMENT_ROOT."/includes/modules/cheque/pdf/modules_chequereceipts.php");
@@ -89,7 +88,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
$sav_charset_output=$outputlangs->charset_output;
- if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1';
+ if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
$outputlangs->load("main");
$outputlangs->load("companies");
diff --git a/htdocs/includes/modules/commande/modules_commande.php b/htdocs/includes/modules/commande/modules_commande.php
index a61543b7a33..92047b54c3e 100644
--- a/htdocs/includes/modules/commande/modules_commande.php
+++ b/htdocs/includes/modules/commande/modules_commande.php
@@ -25,10 +25,9 @@
* \ingroup commande
* \brief Fichier contenant la classe mere de generation des commandes en PDF
* et la classe mere de numerotation des commandes
- * \version $Id: modules_commande.php,v 1.50 2011/08/10 23:21:09 eldy Exp $
+ * \version $Id: modules_commande.php,v 1.51 2011/08/11 12:14:00 eldy Exp $
*/
-require_once(FPDFI_PATH.'fpdi_protection.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php');
require_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php"); // requis car utilise par les classes qui heritent
require_once(DOL_DOCUMENT_ROOT.'/core/class/discount.class.php');
diff --git a/htdocs/includes/modules/commande/pdf_edison.modules.php b/htdocs/includes/modules/commande/pdf_edison.modules.php
index 4d9d364e85d..16d7cbc14ef 100644
--- a/htdocs/includes/modules/commande/pdf_edison.modules.php
+++ b/htdocs/includes/modules/commande/pdf_edison.modules.php
@@ -23,7 +23,7 @@
* \file htdocs/includes/modules/commande/pdf_edison.modules.php
* \ingroup commande
* \brief Fichier de la classe permettant de generer les commandes au modele Edison
- * \version $Id: pdf_edison.modules.php,v 1.90 2011/08/10 17:40:45 hregis Exp $
+ * \version $Id: pdf_edison.modules.php,v 1.91 2011/08/11 12:14:00 eldy Exp $
*/
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/commande/modules_commande.php");
@@ -101,7 +101,7 @@ class pdf_edison extends ModelePDFCommandes
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
- if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1';
+ if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
$outputlangs->load("main");
$outputlangs->load("dict");
diff --git a/htdocs/includes/modules/commande/pdf_einstein.modules.php b/htdocs/includes/modules/commande/pdf_einstein.modules.php
index 49ca9f87f6f..38f142d8d49 100644
--- a/htdocs/includes/modules/commande/pdf_einstein.modules.php
+++ b/htdocs/includes/modules/commande/pdf_einstein.modules.php
@@ -24,7 +24,7 @@
* \ingroup commande
* \brief Fichier de la classe permettant de generer les commandes au modele Einstein
* \author Laurent Destailleur
- * \version $Id: pdf_einstein.modules.php,v 1.164 2011/08/10 17:40:45 hregis Exp $
+ * \version $Id: pdf_einstein.modules.php,v 1.165 2011/08/11 12:14:00 eldy Exp $
*/
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/commande/modules_commande.php");
@@ -117,7 +117,7 @@ class pdf_einstein extends ModelePDFCommandes
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
- if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1';
+ if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
$outputlangs->load("main");
$outputlangs->load("dict");
@@ -588,10 +588,10 @@ class pdf_einstein extends ModelePDFCommandes
if ($tvakey > 0) // On affiche pas taux 0
{
$this->atleastoneratenotnull++;
-
+
$index++;
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
-
+
$tvacompl='';
if (preg_match('/\*/',$tvakey))
{
@@ -601,7 +601,7 @@ class pdf_einstein extends ModelePDFCommandes
$totalvat =$outputlangs->transnoentities("TotalVAT").' ';
$totalvat.=vatrate($tvakey,1).$tvacompl;
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
-
+
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
}
@@ -611,10 +611,10 @@ class pdf_einstein extends ModelePDFCommandes
$index++;
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1);
-
+
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1);
-
+
// Total LocalTax1
if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0)
{
@@ -624,7 +624,7 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1);
}
-
+
// Total LocalTax2
if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0)
{
@@ -645,10 +645,10 @@ class pdf_einstein extends ModelePDFCommandes
if ($tvakey>0) // On affiche pas taux 0
{
//$this->atleastoneratenotnull++;
-
+
$index++;
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
-
+
$tvacompl='';
if (preg_match('/\*/',$tvakey))
{
@@ -658,13 +658,13 @@ class pdf_einstein extends ModelePDFCommandes
$totalvat =$outputlangs->transnoentities("TotalLT1".$mysoc->pays_code).' ';
$totalvat.=vatrate($tvakey,1).$tvacompl;
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
-
+
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
}
}
}
-
+
//Local tax 2
if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
{
@@ -673,10 +673,10 @@ class pdf_einstein extends ModelePDFCommandes
if ($tvakey>0) // On affiche pas taux 0
{
//$this->atleastoneratenotnull++;
-
+
$index++;
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
-
+
$tvacompl='';
if (preg_match('/\*/',$tvakey))
{
@@ -686,7 +686,7 @@ class pdf_einstein extends ModelePDFCommandes
$totalvat =$outputlangs->transnoentities("TotalLT2".$mysoc->pays_code).' ';
$totalvat.=vatrate($tvakey,1).$tvacompl;
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
-
+
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
}
@@ -703,7 +703,7 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetTextColor(0,0,60);
$pdf->SetFillColor(224,224,224);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
-
+
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc), $useborder, 'R', 1);
}
diff --git a/htdocs/includes/modules/dons/modules_don.php b/htdocs/includes/modules/dons/modules_don.php
index e4529ad467e..c87ea245fea 100644
--- a/htdocs/includes/modules/dons/modules_don.php
+++ b/htdocs/includes/modules/dons/modules_don.php
@@ -23,9 +23,8 @@
* \file htdocs/includes/modules/dons/modules_don.php
* \ingroup don
* \brief File of class to manage donation document generation
- * \version $Id: modules_don.php,v 1.22 2011/08/10 23:21:12 eldy Exp $
+ * \version $Id: modules_don.php,v 1.23 2011/08/11 12:14:02 eldy Exp $
*/
-require_once(FPDFI_PATH.'fpdi_protection.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php');
require_once(DOL_DOCUMENT_ROOT."/compta/dons/class/don.class.php");
@@ -84,7 +83,7 @@ class ModeleNumRefDons
return $langs->trans("NoDescription");
}
- /** \brief Renvoi un exemple de num�rotation
+ /** \brief Renvoi un exemple de numerotation
* \return string Example
*/
function getExample()
@@ -94,8 +93,8 @@ class ModeleNumRefDons
return $langs->trans("NoExample");
}
- /** \brief Test si les num�ros d�j� en vigueur dans la base ne provoquent pas d
- * de conflits qui empechera cette num�rotation de fonctionner.
+ /** \brief Test si les numeros deja en vigueur dans la base ne provoquent pas d
+ * de conflits qui empechera cette numerotation de fonctionner.
* \return boolean false si conflit, true si ok
*/
function canBeActivated()
@@ -103,7 +102,7 @@ class ModeleNumRefDons
return true;
}
- /** \brief Renvoi prochaine valeur attribu�e
+ /** \brief Renvoi prochaine valeur attribuee
* \return string Valeur
*/
function getNextValue()
@@ -129,13 +128,13 @@ class ModeleNumRefDons
/**
- \brief Cr�e un don sur disque en fonction du mod�le de DON_ADDON_PDF
- \param db objet base de donn�e
- \param id id du don � cr�er
- \param message message
- \param modele force le modele � utiliser ('' par defaut)
- \param outputlangs objet lang a utiliser pour traduction
- \return int 0 si KO, 1 si OK
+ * \brief Cree un don sur disque en fonction du modele de DON_ADDON_PDF
+ * \param db objet base de donnee
+ * \param id id du don e creer
+ * \param message message
+ * \param modele force le modele a utiliser ('' par defaut)
+ * \param outputlangs objet lang a utiliser pour traduction
+ * \return int 0 si KO, 1 si OK
*/
function don_create($db, $id, $message, $modele, $outputlangs)
{
@@ -175,7 +174,7 @@ function don_create($db, $id, $message, $modele, $outputlangs)
$sav_charset_output=$outputlangs->charset_output;
if ($obj->write_file($id,$outputlangs) > 0)
{
- // Succ�s de la cr�ation de la facture. On g�n�re le fichier meta
+ // Success. We build meta file
don_meta_create($db, $id);
// et on supprime l'image correspondant au preview
don_delete_preview($db, $id);
@@ -199,10 +198,10 @@ function don_create($db, $id, $message, $modele, $outputlangs)
}
/**
- \brief Cr�� un meta fichier � c�t� de la facture sur le disque pour faciliter les recherches en texte plein. Pourquoi ? tout simplement parcequ'en fin d'exercice quand je suis avec mon comptable je n'ai pas de connexion internet "rapide" pour retrouver en 2 secondes une facture non pay�e ou compliqu�e � g�rer ... avec un rgrep c'est vite fait bien fait [eric seigne
- \param db Objet base de donn�e
- \param donid Id du don � cr�er
- \param message Message
+ * \brief Cree un meta fichier a cote de la facture sur le disque pour faciliter les recherches en texte plein. Pourquoi ? tout simplement parcequ'en fin d'exercice quand je suis avec mon comptable je n'ai pas de connexion internet "rapide" pour retrouver en 2 secondes une facture non pay�e ou compliqu�e � g�rer ... avec un rgrep c'est vite fait bien fait [eric seigne
+ * \param db Objet base de donnee
+ * \param donid Id du don a creer
+ * \param message Message
*/
function don_meta_create($db, $donid, $message="")
{
@@ -215,9 +214,9 @@ function don_meta_create($db, $donid, $message="")
/**
- \brief Supprime l'image de pr�visualitation, pour le cas de r�g�n�ration de facture
- \param db Objet base de donn�e
- \param donid Id du don
+ * \brief Supprime l'image de previsualitation, pour le cas de r�g�n�ration de facture
+ * \param db Objet base de donnee
+ * \param donid Id du don
*/
function don_delete_preview($db, $donid)
{
diff --git a/htdocs/includes/modules/expedition/methode_expedition.modules.php b/htdocs/includes/modules/expedition/methode_expedition.modules.php
index ed86d225f8f..b0eb668e889 100644
--- a/htdocs/includes/modules/expedition/methode_expedition.modules.php
+++ b/htdocs/includes/modules/expedition/methode_expedition.modules.php
@@ -22,9 +22,8 @@
* \ingroup expedition
* \brief Fichier contenant la classe mere de generation de bon de livraison en PDF
* et la classe mere de numerotation des bons de livraisons
- * \version $Id: methode_expedition.modules.php,v 1.11 2011/08/10 23:21:12 eldy Exp $
+ * \version $Id: methode_expedition.modules.php,v 1.12 2011/08/11 12:14:02 eldy Exp $
*/
-require_once(FPDFI_PATH.'fpdi_protection.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php');
diff --git a/htdocs/includes/modules/expedition/pdf/ModelePdfExpedition.class.php b/htdocs/includes/modules/expedition/pdf/ModelePdfExpedition.class.php
index 48e0b7a4b47..3a13c10ea8d 100644
--- a/htdocs/includes/modules/expedition/pdf/ModelePdfExpedition.class.php
+++ b/htdocs/includes/modules/expedition/pdf/ModelePdfExpedition.class.php
@@ -22,10 +22,9 @@
* \file htdocs/includes/modules/expedition/pdf/ModelePdfExpedition.class.php
* \ingroup shipping
* \brief Fichier contenant la classe mere de generation des expeditions
- * \version $Id: ModelePdfExpedition.class.php,v 1.17 2011/08/10 23:20:55 eldy Exp $
+ * \version $Id: ModelePdfExpedition.class.php,v 1.18 2011/08/11 12:14:00 eldy Exp $
*/
-require_once(FPDFI_PATH.'fpdi_protection.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php');
diff --git a/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php b/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php
index 6b97bf3d4d5..75c938956ad 100644
--- a/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php
+++ b/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php
@@ -22,7 +22,7 @@
* \file htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php
* \ingroup expedition
* \brief Fichier de la classe permettant de generer les bordereaux envoi au modele Merou
- * \version $Id: pdf_expedition_merou.modules.php,v 1.85 2011/07/31 23:28:13 eldy Exp $
+ * \version $Id: pdf_expedition_merou.modules.php,v 1.86 2011/08/11 12:14:00 eldy Exp $
*/
require_once DOL_DOCUMENT_ROOT."/includes/modules/expedition/pdf/ModelePdfExpedition.class.php";
@@ -81,7 +81,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
- if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1';
+ if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
$outputlangs->load("main");
$outputlangs->load("dict");
@@ -325,7 +325,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
function _pagehead(&$pdf, $object, $outputlangs)
{
global $conf, $langs;
-
+
$default_font_size = pdf_getPDFFontSize($outputlangs);
pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
@@ -384,9 +384,9 @@ Class pdf_expedition_merou extends ModelePdfExpedition
//$this->Code39($Xoff+43, $Yoff+1, $object->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
// Add list of linked elements
- // TODO possibility to use with other elements (business module,...)
+ // TODO possibility to use with other elements (business module,...)
//$object->load_object_linked();
-
+
$origin = $object->origin;
$origin_id = $object->origin_id;
@@ -394,7 +394,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
if ($conf->$origin->enabled)
{
$outputlangs->load('orders');
-
+
$classname = ucfirst($origin);
$linkedobject = new $classname($this->db);
$result=$linkedobject->fetch($origin_id);
@@ -451,7 +451,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
$pdf->SetXY($blSocX-80,$blSocY+23);
$pdf->SetFont('','', $default_font_size - 2);
$pdf->SetTextColor(0,0,0);
-
+
if (! empty($object->tracking_number))
{
$object->GetUrlTrackingStatus($object->tracking_number);
diff --git a/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php b/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php
index 349bb32b719..424aa96c07b 100644
--- a/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php
+++ b/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php
@@ -22,7 +22,7 @@
* \file htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php
* \ingroup expedition
* \brief Fichier de la classe permettant de generer les bordereaux envoi au modele Rouget
- * \version $Id: pdf_expedition_rouget.modules.php,v 1.60 2011/07/31 23:28:13 eldy Exp $
+ * \version $Id: pdf_expedition_rouget.modules.php,v 1.61 2011/08/11 12:14:00 eldy Exp $
*/
require_once DOL_DOCUMENT_ROOT."/includes/modules/expedition/pdf/ModelePdfExpedition.class.php";
@@ -65,7 +65,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
// Recupere emmetteur
$this->emetteur=$mysoc;
if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // By default if not defined
-
+
// Defini position des colonnes
$this->posxdesc=$this->marge_gauche+1;
$this->posxqtyordered=120;
@@ -87,7 +87,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
- if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1';
+ if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
$outputlangs->load("main");
$outputlangs->load("dict");
@@ -159,11 +159,11 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
$tab_top = 90;
$tab_height = 170;
-
+
if (! empty($object->note_public) || ! empty($object->tracking_number))
{
$tab_top = 88;
-
+
// Tracking number
if (! empty($object->tracking_number))
{
@@ -189,14 +189,14 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
$pdf->SetXY ($this->posxdesc-1, $tab_top);
$pdf->MultiCell(190, 3, $outputlangs->convToOutputCharset($object->note_public), 0, 'L');
}
-
+
$nexY = $pdf->GetY();
$height_note=$nexY-$tab_top;
// Rect prend une longueur en 3eme param
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
-
+
$tab_height = $tab_height - $height_note;
$tab_top = $nexY+6;
}
@@ -204,7 +204,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
{
$height_note=0;
}
-
+
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
$nexY = $tab_top + 7;
@@ -257,7 +257,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
$this->error=$langs->transnoentities("ErrorUnknown");
return 0; // Erreur par defaut
}
-
+
/**
* Build table
* @param pdf objet PDF
@@ -265,7 +265,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs)
{
global $conf;
-
+
$default_font_size = pdf_getPDFFontSize($outputlangs);
$pdf->SetTextColor(0,0,0);
@@ -280,11 +280,11 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
$pdf->SetXY ($this->posxdesc-1, $tab_top+1);
$pdf->MultiCell(108, 2, $outputlangs->trans("Description"), '', 'L');
-
+
$pdf->line($this->posxqtyordered-1, $tab_top, $this->posxqtyordered-1, $tab_top + $tab_height);
$pdf->SetXY ($this->posxqtyordered-1, $tab_top+1);
$pdf->MultiCell(40,2, $outputlangs->transnoentities("QtyOrdered"),'','C');
-
+
$pdf->line($this->posxqtytoship-1, $tab_top, $this->posxqtytoship-1, $tab_top + $tab_height);
$pdf->SetXY ($this->posxqtytoship-1, $tab_top+1);
$pdf->MultiCell(40,2, $outputlangs->transnoentities("QtyToShip"),'','C');
@@ -405,7 +405,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
// Add list of linked orders
// TODO possibility to use with other document (business module,...)
//$object->load_object_linked();
-
+
$origin = $object->origin;
$origin_id = $object->origin_id;
@@ -413,7 +413,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
if ($conf->$origin->enabled)
{
$outputlangs->load('orders');
-
+
$classname = ucfirst($origin);
$linkedobject = new $classname($this->db);
$result=$linkedobject->fetch($origin_id);
@@ -430,7 +430,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
$pdf->MultiCell(60, 2, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->commande->date,"%d %b %Y",false,$outputlangs,true), 0, 'R');
}
}
-
+
if ($showaddress)
{
// Sender properties
diff --git a/htdocs/includes/modules/facture/doc/pdf_crabe.modules.php b/htdocs/includes/modules/facture/doc/pdf_crabe.modules.php
index 5eed344e67d..8ad01066f79 100755
--- a/htdocs/includes/modules/facture/doc/pdf_crabe.modules.php
+++ b/htdocs/includes/modules/facture/doc/pdf_crabe.modules.php
@@ -24,7 +24,7 @@
* \ingroup facture
* \brief File of class to generate invoices from crab model
* \author Laurent Destailleur
- * \version $Id: pdf_crabe.modules.php,v 1.13 2011/08/10 17:56:11 hregis Exp $
+ * \version $Id: pdf_crabe.modules.php,v 1.14 2011/08/11 12:14:02 eldy Exp $
*/
require_once(DOL_DOCUMENT_ROOT."/includes/modules/facture/modules_facture.php");
@@ -121,7 +121,7 @@ class pdf_crabe extends ModelePDFFactures
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
- if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1';
+ if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
$outputlangs->load("main");
$outputlangs->load("dict");
diff --git a/htdocs/includes/modules/facture/doc/pdf_oursin.modules.php b/htdocs/includes/modules/facture/doc/pdf_oursin.modules.php
index b702ddae805..b8ffecd6a91 100755
--- a/htdocs/includes/modules/facture/doc/pdf_oursin.modules.php
+++ b/htdocs/includes/modules/facture/doc/pdf_oursin.modules.php
@@ -25,7 +25,7 @@
* \ingroup facture
* \brief Fichier de la classe permettant de generer les factures au modele oursin
* \author Sylvain SCATTOLINI base sur un modele de Laurent Destailleur
- * \version $Id: pdf_oursin.modules.php,v 1.12 2011/08/10 17:56:10 hregis Exp $
+ * \version $Id: pdf_oursin.modules.php,v 1.13 2011/08/11 12:14:02 eldy Exp $
*/
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
@@ -120,7 +120,7 @@ class pdf_oursin extends ModelePDFFactures
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
- if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1';
+ if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
$default_font_size = pdf_getPDFFontSize($outputlangs);
diff --git a/htdocs/includes/modules/facture/modules_facture.php b/htdocs/includes/modules/facture/modules_facture.php
index 122fa59f20e..89e29ee24b5 100644
--- a/htdocs/includes/modules/facture/modules_facture.php
+++ b/htdocs/includes/modules/facture/modules_facture.php
@@ -24,11 +24,9 @@
* \ingroup facture
* \brief Fichier contenant la classe mere de generation des factures en PDF
* et la classe mere de numerotation des factures
- * \version $Id: modules_facture.php,v 1.95 2011/08/10 23:21:13 eldy Exp $
+ * \version $Id: modules_facture.php,v 1.96 2011/08/11 12:14:04 eldy Exp $
*/
-require_once(FPDFI_PATH.'fpdi_protection.php');
-require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php');
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
require_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php"); // Requis car utilise dans les classes qui heritent
require_once(DOL_DOCUMENT_ROOT."/core/class/commondocgenerator.class.php");
diff --git a/htdocs/includes/modules/fichinter/modules_fichinter.php b/htdocs/includes/modules/fichinter/modules_fichinter.php
index b37befb9c50..ea9a3373352 100644
--- a/htdocs/includes/modules/fichinter/modules_fichinter.php
+++ b/htdocs/includes/modules/fichinter/modules_fichinter.php
@@ -23,10 +23,9 @@
* \ingroup ficheinter
* \brief Fichier contenant la classe mere de generation des fiches interventions en PDF
* et la classe mere de numerotation des fiches interventions
- * \version $Id: modules_fichinter.php,v 1.43 2011/08/10 23:21:13 eldy Exp $
+ * \version $Id: modules_fichinter.php,v 1.44 2011/08/11 12:14:03 eldy Exp $
*/
-require_once(FPDFI_PATH.'fpdi_protection.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php');
diff --git a/htdocs/includes/modules/fichinter/pdf_soleil.modules.php b/htdocs/includes/modules/fichinter/pdf_soleil.modules.php
index 73dbde338ed..f1a6ad0debc 100644
--- a/htdocs/includes/modules/fichinter/pdf_soleil.modules.php
+++ b/htdocs/includes/modules/fichinter/pdf_soleil.modules.php
@@ -22,7 +22,7 @@
* \file htdocs/includes/modules/fichinter/pdf_soleil.modules.php
* \ingroup ficheinter
* \brief Fichier de la classe permettant de generer les fiches d'intervention au modele Soleil
- * \version $Id: pdf_soleil.modules.php,v 1.102 2011/07/31 23:28:15 eldy Exp $
+ * \version $Id: pdf_soleil.modules.php,v 1.103 2011/08/11 12:14:03 eldy Exp $
*/
require_once(DOL_DOCUMENT_ROOT."/includes/modules/fichinter/modules_fichinter.php");
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
@@ -87,7 +87,7 @@ class pdf_soleil extends ModelePDFFicheinter
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
- if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1';
+ if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
$outputlangs->load("main");
$outputlangs->load("dict");
diff --git a/htdocs/includes/modules/livraison/modules_livraison.php b/htdocs/includes/modules/livraison/modules_livraison.php
index ea0f0ea0da1..8777355e416 100644
--- a/htdocs/includes/modules/livraison/modules_livraison.php
+++ b/htdocs/includes/modules/livraison/modules_livraison.php
@@ -24,10 +24,9 @@
* \ingroup expedition
* \brief Fichier contenant la classe mere de generation de bon de livraison en PDF
* et la classe mere de numerotation des bons de livraisons
- * \version $Id: modules_livraison.php,v 1.19 2011/08/10 23:21:12 eldy Exp $
+ * \version $Id: modules_livraison.php,v 1.20 2011/08/11 12:14:02 eldy Exp $
*/
-require_once(FPDFI_PATH.'fpdi_protection.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php');
diff --git a/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php b/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php
index c8198051b20..5ea5d69e294 100644
--- a/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php
+++ b/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php
@@ -23,7 +23,7 @@
* \file htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php
* \ingroup livraison
* \brief File of class to manage receving receipts with template Sirocco
- * \version $Id: pdf_sirocco.modules.php,v 1.78 2011/08/08 16:07:48 eldy Exp $
+ * \version $Id: pdf_sirocco.modules.php,v 1.79 2011/08/11 12:14:02 eldy Exp $
*/
require_once(DOL_DOCUMENT_ROOT."/includes/modules/livraison/modules_livraison.php");
@@ -85,7 +85,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
- if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1';
+ if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
$outputlangs->load("main");
$outputlangs->load("dict");
diff --git a/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php b/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php
index dd79a49a827..0bc24d16dde 100644
--- a/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php
+++ b/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php
@@ -24,7 +24,7 @@
* \ingroup livraison
* \brief File of class to manage receving receipts with template Typhon
* \author Laurent Destailleur
- * \version $Id: pdf_typhon.modules.php,v 1.87 2011/08/08 16:07:48 eldy Exp $
+ * \version $Id: pdf_typhon.modules.php,v 1.88 2011/08/11 12:14:02 eldy Exp $
*/
require_once(DOL_DOCUMENT_ROOT."/includes/modules/livraison/modules_livraison.php");
@@ -107,7 +107,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
- if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1';
+ if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
$outputlangs->load("main");
$outputlangs->load("dict");
diff --git a/htdocs/includes/modules/member/cards/modules_cards.php b/htdocs/includes/modules/member/cards/modules_cards.php
index 40d367b7d05..ff7a89715a5 100644
--- a/htdocs/includes/modules/member/cards/modules_cards.php
+++ b/htdocs/includes/modules/member/cards/modules_cards.php
@@ -23,10 +23,9 @@
* \file htdocs/includes/modules/member/cards/modules_cards.php
* \ingroup member
* \brief File of parent class of document generator for members cards.
- * \version $Id: modules_cards.php,v 1.12 2011/08/10 23:20:55 eldy Exp $
+ * \version $Id: modules_cards.php,v 1.13 2011/08/11 12:13:59 eldy Exp $
*/
-require_once(FPDFI_PATH.'fpdi_protection.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php');
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
diff --git a/htdocs/includes/modules/member/cards/pdf_standard.class.php b/htdocs/includes/modules/member/cards/pdf_standard.class.php
index f2463194be2..f049ef0f99b 100644
--- a/htdocs/includes/modules/member/cards/pdf_standard.class.php
+++ b/htdocs/includes/modules/member/cards/pdf_standard.class.php
@@ -60,10 +60,9 @@
* \author Laurent Passebecq
* \author Rodolphe Quiedville
* \author Jean Louis Bergamo.
- * \version $Id: pdf_standard.class.php,v 1.23 2011/08/10 23:20:55 eldy Exp $
+ * \version $Id: pdf_standard.class.php,v 1.24 2011/08/11 12:14:00 eldy Exp $
*/
-require_once(FPDFI_PATH.'fpdi_protection.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/format_cards.lib.php');
@@ -375,7 +374,7 @@ class pdf_standard {
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
- if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1';
+ if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
$outputlangs->load("main");
$outputlangs->load("dict");
diff --git a/htdocs/includes/modules/member/labels/modules_labels.php b/htdocs/includes/modules/member/labels/modules_labels.php
index fb5856b7070..ae78fd03eb7 100644
--- a/htdocs/includes/modules/member/labels/modules_labels.php
+++ b/htdocs/includes/modules/member/labels/modules_labels.php
@@ -23,10 +23,9 @@
* \file htdocs/includes/modules/member/labels/modules_labels.php
* \ingroup member
* \brief File of parent class of document generator for members labels sheets.
- * \version $Id: modules_labels.php,v 1.3 2011/08/10 23:21:11 eldy Exp $
+ * \version $Id: modules_labels.php,v 1.4 2011/08/11 12:14:01 eldy Exp $
*/
-require_once(FPDFI_PATH.'fpdi_protection.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php');
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
diff --git a/htdocs/includes/modules/member/labels/pdf_standardlabel.class.php b/htdocs/includes/modules/member/labels/pdf_standardlabel.class.php
index 8774f9d7bf3..5f3c60eeace 100644
--- a/htdocs/includes/modules/member/labels/pdf_standardlabel.class.php
+++ b/htdocs/includes/modules/member/labels/pdf_standardlabel.class.php
@@ -60,10 +60,9 @@
* \author Laurent Passebecq
* \author Rodolphe Quiedville
* \author Jean Louis Bergamo.
- * \version $Id: pdf_standardlabel.class.php,v 1.14 2011/08/10 23:21:11 eldy Exp $
+ * \version $Id: pdf_standardlabel.class.php,v 1.15 2011/08/11 12:14:01 eldy Exp $
*/
-require_once(FPDFI_PATH.'fpdi_protection.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/format_cards.lib.php');
@@ -354,7 +353,7 @@ class pdf_standardlabel {
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
- if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1';
+ if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
$outputlangs->load("main");
$outputlangs->load("dict");
diff --git a/htdocs/includes/modules/project/modules_project.php b/htdocs/includes/modules/project/modules_project.php
index 908d755325c..9d574ebe143 100644
--- a/htdocs/includes/modules/project/modules_project.php
+++ b/htdocs/includes/modules/project/modules_project.php
@@ -21,9 +21,8 @@
* \ingroup project
* \brief File that contain parent class for projects models
* and parent class for projects numbering models
- * \version $Id: modules_project.php,v 1.13 2011/08/10 23:21:09 eldy Exp $
+ * \version $Id: modules_project.php,v 1.14 2011/08/11 12:14:01 eldy Exp $
*/
-require_once(FPDFI_PATH.'fpdi_protection.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php');
diff --git a/htdocs/includes/modules/project/pdf/pdf_baleine.modules.php b/htdocs/includes/modules/project/pdf/pdf_baleine.modules.php
index fb253da1e8f..d989738c736 100644
--- a/htdocs/includes/modules/project/pdf/pdf_baleine.modules.php
+++ b/htdocs/includes/modules/project/pdf/pdf_baleine.modules.php
@@ -21,7 +21,7 @@
* \ingroup project
* \brief Fichier de la classe permettant de generer les projets au modele Baleine
* \author Regis Houssin
- * \version $Id: pdf_baleine.modules.php,v 1.39 2011/07/31 23:28:18 eldy Exp $
+ * \version $Id: pdf_baleine.modules.php,v 1.40 2011/08/11 12:14:04 eldy Exp $
*/
require_once(DOL_DOCUMENT_ROOT."/includes/modules/project/modules_project.php");
@@ -95,7 +95,7 @@ class pdf_baleine extends ModelePDFProjects
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
- if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1';
+ if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
$outputlangs->load("main");
$outputlangs->load("dict");
diff --git a/htdocs/includes/modules/propale/modules_propale.php b/htdocs/includes/modules/propale/modules_propale.php
index c6bcec12441..5c57ca2f476 100644
--- a/htdocs/includes/modules/propale/modules_propale.php
+++ b/htdocs/includes/modules/propale/modules_propale.php
@@ -23,10 +23,9 @@
* \ingroup propale
* \brief Fichier contenant la classe mere de generation des propales en PDF
* et la classe mere de numerotation des propales
- * \version $Id: modules_propale.php,v 1.65 2011/08/10 23:21:13 eldy Exp $
+ * \version $Id: modules_propale.php,v 1.66 2011/08/11 12:14:03 eldy Exp $
*/
-require_once(FPDFI_PATH.'fpdi_protection.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php');
require_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php"); // Requis car utilise dans les classes qui heritent
diff --git a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php
index afc8e881366..849e8d4a8cc 100644
--- a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php
+++ b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php
@@ -24,7 +24,7 @@
* \ingroup propale
* \brief Fichier de la classe permettant de generer les propales au modele Azur
* \author Laurent Destailleur
- * \version $Id: pdf_propale_azur.modules.php,v 1.244 2011/08/10 17:40:42 hregis Exp $
+ * \version $Id: pdf_propale_azur.modules.php,v 1.245 2011/08/11 12:14:03 eldy Exp $
*/
require_once(DOL_DOCUMENT_ROOT."/includes/modules/propale/modules_propale.php");
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
@@ -117,7 +117,7 @@ class pdf_propale_azur extends ModelePDFPropales
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
$sav_charset_output=$outputlangs->charset_output;
- if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1';
+ if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
$outputlangs->load("main");
$outputlangs->load("dict");
diff --git a/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php b/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php
index 5e68c469b95..b4e826c71c3 100644
--- a/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php
+++ b/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php
@@ -23,7 +23,7 @@
* \file htdocs/includes/modules/propale/pdf_propale_jaune.modules.php
* \ingroup propale
* \brief Fichier de la classe permettant de generer les propales au modele Jaune
- * \version $Id: pdf_propale_jaune.modules.php,v 1.118 2011/08/10 17:40:44 hregis Exp $
+ * \version $Id: pdf_propale_jaune.modules.php,v 1.119 2011/08/11 12:14:03 eldy Exp $
*/
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/modules_propale.php");
@@ -93,7 +93,7 @@ class pdf_propale_jaune extends ModelePDFPropales
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
$sav_charset_output=$outputlangs->charset_output;
- if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1';
+ if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
$outputlangs->load("main");
$outputlangs->load("dict");
diff --git a/htdocs/includes/modules/rapport/pdf_paiement.class.php b/htdocs/includes/modules/rapport/pdf_paiement.class.php
index 92b1196385b..4a08de7634c 100644
--- a/htdocs/includes/modules/rapport/pdf_paiement.class.php
+++ b/htdocs/includes/modules/rapport/pdf_paiement.class.php
@@ -21,9 +21,8 @@
* \file htdocs/includes/modules/rapport/pdf_paiement.class.php
* \ingroup banque
* \brief File to build payment reports
- * \version $Id: pdf_paiement.class.php,v 1.65 2011/08/10 23:21:09 eldy Exp $
+ * \version $Id: pdf_paiement.class.php,v 1.66 2011/08/11 12:14:01 eldy Exp $
*/
-require_once(FPDFI_PATH.'fpdi_protection.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php');
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
@@ -81,7 +80,7 @@ class pdf_paiement
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
- if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1';
+ if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
$this->month=$month;
$this->year=$year;
diff --git a/htdocs/includes/modules/supplier_invoice/modules_facturefournisseur.php b/htdocs/includes/modules/supplier_invoice/modules_facturefournisseur.php
index e93a9ac0b28..78e13367d44 100755
--- a/htdocs/includes/modules/supplier_invoice/modules_facturefournisseur.php
+++ b/htdocs/includes/modules/supplier_invoice/modules_facturefournisseur.php
@@ -20,9 +20,8 @@
* \file htdocs/includes/modules/supplier_invoice/modules_facturefournisseur.php
* \ingroup facture fourniseur
* \brief File that contain parent class for supplier invoices models
- * \version $Id: modules_facturefournisseur.php,v 1.10 2011/08/10 23:21:14 eldy Exp $
+ * \version $Id: modules_facturefournisseur.php,v 1.11 2011/08/11 12:14:04 eldy Exp $
*/
-require_once(FPDFI_PATH.'fpdi_protection.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php');
diff --git a/htdocs/includes/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/includes/modules/supplier_invoice/pdf/pdf_canelle.modules.php
index 91e94490f7c..41af644c10a 100755
--- a/htdocs/includes/modules/supplier_invoice/pdf/pdf_canelle.modules.php
+++ b/htdocs/includes/modules/supplier_invoice/pdf/pdf_canelle.modules.php
@@ -21,7 +21,7 @@
* \file htdocs/includes/modules/supplier_invoice/pdf/pdf_canelle.modules.php
* \ingroup fournisseur
* \brief Class file to generate the supplier invoices with the canelle model
- * \version $Id: pdf_canelle.modules.php,v 1.35 2011/07/31 23:28:18 eldy Exp $
+ * \version $Id: pdf_canelle.modules.php,v 1.36 2011/08/11 12:14:01 eldy Exp $
*/
require_once(DOL_DOCUMENT_ROOT."/includes/modules/supplier_invoice/modules_facturefournisseur.php");
@@ -105,7 +105,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
- if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1';
+ if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
$outputlangs->load("main");
$outputlangs->load("dict");
diff --git a/htdocs/includes/modules/supplier_order/modules_commandefournisseur.php b/htdocs/includes/modules/supplier_order/modules_commandefournisseur.php
index 5da2f11a92a..2e4f206a5a6 100644
--- a/htdocs/includes/modules/supplier_order/modules_commandefournisseur.php
+++ b/htdocs/includes/modules/supplier_order/modules_commandefournisseur.php
@@ -26,9 +26,8 @@
* \ingroup commande
* \brief File that contain parent class for supplier orders models
* and parent class for supplier orders numbering models
- * \version $Id: modules_commandefournisseur.php,v 1.23 2011/08/10 23:21:14 eldy Exp $
+ * \version $Id: modules_commandefournisseur.php,v 1.24 2011/08/11 12:14:04 eldy Exp $
*/
-require_once(FPDFI_PATH.'fpdi_protection.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php');
require_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php"); // requis car utilise par les classes qui heritent
diff --git a/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php
index d856f6eb4d8..3f09393927d 100644
--- a/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php
+++ b/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php
@@ -23,7 +23,7 @@
* \file htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php
* \ingroup fournisseur
* \brief Fichier de la classe permettant de generer les commandes fournisseurs au modele Muscadet
- * \version $Id: pdf_muscadet.modules.php,v 1.87 2011/07/31 23:28:13 eldy Exp $
+ * \version $Id: pdf_muscadet.modules.php,v 1.88 2011/08/11 12:14:00 eldy Exp $
*/
require_once(DOL_DOCUMENT_ROOT."/includes/modules/supplier_order/modules_commandefournisseur.php");
@@ -106,7 +106,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
- if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1';
+ if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
$outputlangs->load("main");
$outputlangs->load("dict");
@@ -667,7 +667,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$text=$this->emetteur->name;
$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
}
-
+
$pdf->SetFont('','B',$default_font_size + 3);
$pdf->SetXY(100,$posy);
$pdf->SetTextColor(0,0,60);
diff --git a/htdocs/lib/pdf.lib.php b/htdocs/lib/pdf.lib.php
index 6a45a7c5ea3..0bfe0b22340 100644
--- a/htdocs/lib/pdf.lib.php
+++ b/htdocs/lib/pdf.lib.php
@@ -24,21 +24,67 @@
* \file htdocs/lib/pdf.lib.php
* \brief Set of functions used for PDF generation
* \ingroup core
- * \version $Id: pdf.lib.php,v 1.102 2011/08/10 22:47:35 eldy Exp $
+ * \version $Id: pdf.lib.php,v 1.103 2011/08/11 12:14:04 eldy Exp $
*/
/**
- * Return a PDF instance object. We create a FPDI instance that instanciate TCPDF (or FPDF if MAIN_USE_FPDF is on)
- * @param format Array(width,height)
+ * Return array with format properties of default PDF format
+ * @return array Array('width'=>w,'height'=>h,'unit'=>u);
+ */
+function pdf_getFormat()
+{
+ global $conf,$db;
+
+ // Default value if setup was not done and/or entry into c_paper_format not defined
+ $width=210; $height=297; $unit='mm';
+
+ $pdfformat=$conf->global->MAIN_PDF_FORMAT;
+ if (empty($pdfformat))
+ {
+ include_once(DOL_DOCUMENT_ROOT.'/lib/functions2.lib.php');
+ $pdfformat=dol_getDefaultFormat();
+ }
+
+ $sql="SELECT code, label, width, height, unit FROM ".MAIN_DB_PREFIX."c_paper_format";
+ $sql.=" WHERE code = '".$pdfformat."'";
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $obj=$db->fetch_object($resql);
+ if ($obj)
+ {
+ $width=$obj->width;
+ $height=$obj->height;
+ $unit=$obj->unit;
+ }
+ }
+
+ //print "pdfformat=".$pdfformat." width=".$width." height=".$height." unit=".$unit;
+ return array('width'=>$width,'height'=>$height,'unit'=>$unit);
+}
+
+/**
+ * Return a PDF instance object. We create a FPDI instance that instanciate TCPDF.
+ * @param format Array(width,height). Keep empty to use default setup.
* @param metric Unit of format ('mm')
* @param pagetype 'P' or 'l'
* @return PDF object
*/
-function pdf_getInstance($format,$metric='mm',$pagetype='P')
+function pdf_getInstance($format='',$metric='mm',$pagetype='P')
{
global $conf;
+ require_once(TCPDF_PATH.'tcpdf.php');
+ require_once(FPDFI_PATH.'fpdi.php');
+
+ //if (! is_array($format) || empty($format) || empty($metric))
+ //{
+ $arrayformat=pdf_getFormat();
+ $format=array($arrayformat['width'],$arrayformat['height']);
+ $metric=$arrayformat['unit'];
+ //}
+
// Protection et encryption du pdf
if ($conf->global->PDF_SECURITY_ENCRYPTION)
{
diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php
index eedd6a8841c..b3f203a8c32 100644
--- a/htdocs/master.inc.php
+++ b/htdocs/master.inc.php
@@ -29,7 +29,7 @@
* \ingroup core
* \brief File that defines environment for all Dolibarr process (pages or scripts)
* This script reads the conf file, init $lang, $db and and empty $user
- * \version $Id: master.inc.php,v 1.352 2011/08/01 12:25:14 hregis Exp $
+ * \version $Id: master.inc.php,v 1.353 2011/08/11 12:14:03 eldy Exp $
*/
@@ -302,9 +302,9 @@ if (! defined('NOREQUIRETRAN'))
*/
// Les path racines
if (! defined('FPDF_PATH')) { define('FPDF_PATH', DOL_DOCUMENT_ROOT .'/includes/fpdf/fpdf/'); }
+if (! defined('TCPDF_PATH')) { define('TCPDF_PATH', DOL_DOCUMENT_ROOT .'/includes/tcpdf/'); }
if (! defined('FPDFI_PATH')) { define('FPDFI_PATH', DOL_DOCUMENT_ROOT .'/includes/fpdf/fpdfi/'); }
if (! defined('MAGPIERSS_PATH')) { define('MAGPIERSS_PATH', DOL_DOCUMENT_ROOT .'/includes/magpierss/'); }
-if (! defined('JPGRAPH_PATH')) { define('JPGRAPH_PATH', DOL_DOCUMENT_ROOT .'/includes/jpgraph/'); }
if (! defined('NUSOAP_PATH')) { define('NUSOAP_PATH', DOL_DOCUMENT_ROOT .'/includes/nusoap/lib/'); }
if (! defined('PHP_WRITEEXCEL_PATH')) { define('PHP_WRITEEXCEL_PATH',DOL_DOCUMENT_ROOT .'/includes/php_writeexcel/'); }
if (! defined('PHPEXCELREADER')) { define('PHPEXCELREADER', DOL_DOCUMENT_ROOT .'/includes/phpexcelreader/'); }
diff --git a/scripts/invoices/rebuild_merge_pdf.php b/scripts/invoices/rebuild_merge_pdf.php
index de043e7f08e..c23225eb4fa 100644
--- a/scripts/invoices/rebuild_merge_pdf.php
+++ b/scripts/invoices/rebuild_merge_pdf.php
@@ -21,7 +21,7 @@
* \file scripts/invoices/rebuild_merge_pdf.php
* \ingroup facture
* \brief Script to rebuild PDF and merge PDF files into one
- * \version $Id: rebuild_merge_pdf.php,v 1.22 2011/08/10 23:31:05 eldy Exp $
+ * \version $Id: rebuild_merge_pdf.php,v 1.23 2011/08/11 12:14:22 eldy Exp $
*/
$sapi_type = php_sapi_name();
@@ -37,7 +37,6 @@ if (substr($sapi_type, 0, 3) == 'cgi') {
// Include Dolibarr environment
require_once($path."../../htdocs/master.inc.php");
// After this $db is an opened handler to database. We close it at end of file.
-require_once(FPDFI_PATH.'fpdi_protection.php');
require_once(DOL_DOCUMENT_ROOT."/cron/functions_cron.lib.php");
require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
require_once(DOL_DOCUMENT_ROOT."/includes/modules/facture/modules_facture.php");
@@ -48,7 +47,7 @@ require_once(DOL_DOCUMENT_ROOT.'/lib/pdf.lib.php');
$langs->load("main");
// Global variables
-$version='$Revision: 1.22 $';
+$version='$Revision: 1.23 $';
$error=0;
@@ -290,10 +289,7 @@ if ( $resql=$db->query($sql) )
//---------------------------------------------------------
// Create empty PDF
- $pdf=new FPDI('P','mm','A4');
- if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
- //$pdf->SetCompression(false);
-
+ $pdf=pdf_getInstance();
if (class_exists('TCPDF'))
{
$pdf->setPrintHeader(false);
@@ -301,6 +297,10 @@ if ( $resql=$db->query($sql) )
}
$pdf->SetFont(pdf_getPDFFont($outputlangs));
+ if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
+ //$pdf->SetCompression(false);
+
+
//$pdf->Open();
//$pdf->AddPage();
//$title=$langs->trans("BillsCustomersUnpaid");