From 8289422f278ec89f70cf4e74ab2f031acaf41b3a Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Fri, 29 Jan 2016 10:37:11 +0100 Subject: [PATCH] Add FIX_BROKEN_PDF to workaround an issue with PDFTK , it can not deal with all the PDF versions, we use CONVERT to fix it first --- include/class/class_document_export.php | 9 ++++++++- include/constant.php | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/class/class_document_export.php b/include/class/class_document_export.php index cf6d66ade..f4ce0edef 100644 --- a/include/class/class_document_export.php +++ b/include/class/class_document_export.php @@ -137,7 +137,7 @@ class Document_Export $cnt_feedback++; continue; } - } + } // Create a image with the stamp + formula $img = imagecreatefromgif(NOALYSS_INCLUDE . '/template/template.gif'); @@ -151,6 +151,13 @@ class Document_Export $stmt = CONVERT_GIF_PDF . " " . escapeshellarg($this->store_convert . '/' . 'stamp.gif') . " " . escapeshellarg($this->store_convert . '/stamp.pdf'); passthru($stmt, $status); + //----------------------------------- + // Fix broken PDF , actually pdftk can not handle all the PDF + if ( define ('FIX_BROKEN_PDF') == 'YES' ) { + $stmpt = CONVERT_GIF_PDF." ". escapeshellarg($this->store_convert . '/' . $file_pdf)." ". escapeshellarg($this->store_convert . '/' . $file_pdf.'tmp'); + passthru($stmpt,$status); + rename ($this->store_convert . '/' . $file_pdf.'tmp',$this->store_convert . '/' . $file_pdf); + } if ($status <> 0) { $this->feedback[$cnt_feedback]['file'] = 'stamp.pdf'; diff --git a/include/constant.php b/include/constant.php index c8e561d65..7397b443f 100644 --- a/include/constant.php +++ b/include/constant.php @@ -43,6 +43,9 @@ if ( !defined("NOALYSS_HOME")) define ("NOALYSS_HOME",dirname($dirname)."/html") if ( !defined("NOALYSS_PLUGIN")) define ("NOALYSS_PLUGIN",$g_ext_dir); if ( !defined("NOALYSS_INCLUDE")) define ("NOALYSS_INCLUDE",$g_include_dir); if ( !defined("NOALYSS_TEMPLATE")) define ("NOALYSS_TEMPLATE",$g_template_dir); +// pdftk can deal with all the PDF , for some of them it is preferable to fix it +// with convert +if ( !defined("FIX_BROKEN_PDF")) define ("FIX_BROKEN_PDF",'NO'); require_once NOALYSS_INCLUDE.'/constant.security.php';