From 853a160e926ca814cc46e46f20fb6f7bd3ce9057 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Aug 2011 16:09:52 +0000 Subject: [PATCH] Add option MAIN_DISABLE_FPDI to allow packages without FPDI --- htdocs/lib/pdf.lib.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/htdocs/lib/pdf.lib.php b/htdocs/lib/pdf.lib.php index 0bfe0b22340..017f02ffa4d 100644 --- a/htdocs/lib/pdf.lib.php +++ b/htdocs/lib/pdf.lib.php @@ -24,7 +24,7 @@ * \file htdocs/lib/pdf.lib.php * \brief Set of functions used for PDF generation * \ingroup core - * \version $Id: pdf.lib.php,v 1.103 2011/08/11 12:14:04 eldy Exp $ + * \version $Id: pdf.lib.php,v 1.104 2011/08/11 16:09:52 eldy Exp $ */ @@ -76,14 +76,12 @@ function pdf_getInstance($format='',$metric='mm',$pagetype='P') global $conf; require_once(TCPDF_PATH.'tcpdf.php'); - require_once(FPDFI_PATH.'fpdi.php'); + // We need to instantiate fpdi object (instead of tcpdf) to use merging features. But we can disable it. + if (empty($conf->global->MAIN_DISABLE_FPDI)) 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']; - //} + $arrayformat=pdf_getFormat(); + $format=array($arrayformat['width'],$arrayformat['height']); + $metric=$arrayformat['unit']; // Protection et encryption du pdf if ($conf->global->PDF_SECURITY_ENCRYPTION) @@ -99,15 +97,17 @@ function pdf_getInstance($format='',$metric='mm',$pagetype='P') - print-high : Print the document to a representation from which a faithful digital copy of the PDF content could be generated. When this is not set, printing is limited to a low-level representation of the appearance, possibly of degraded quality. - owner : (inverted logic - only for public-key) when set permits change of encryption and enables all other permissions. */ - if ($conf->global->MAIN_USE_FPDF) + if (! empty($conf->global->MAIN_USE_FPDF)) { + require_once(FPDFI_PATH.'fpdi_protection.php'); $pdf = new FPDI_Protection($pagetype,$metric,$format); // For FPDF, we specify permission we want to open $pdfrights = array('print'); } else { - $pdf = new FPDI($pagetype,$metric,$format); + if (class_exists('FPDI')) $pdf = new FPDI($pagetype,$metric,$format); + else $pdf = new TCPDF($pagetype,$metric,$format); // For TCPDF, we specify permission we want to block $pdfrights = array('modify','copy'); } @@ -117,7 +117,8 @@ function pdf_getInstance($format='',$metric='mm',$pagetype='P') } else { - $pdf=new FPDI($pagetype,$metric,$format); + if (class_exists('FPDI')) $pdf = new FPDI($pagetype,$metric,$format); + else $pdf = new TCPDF($pagetype,$metric,$format); } return $pdf; }