[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 01/01: Add FIX_BROKEN_PDF to workaround an is
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 01/01: 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 |
Date: |
Fri, 29 Jan 2016 09:44:45 +0000 |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 8289422f278ec89f70cf4e74ab2f031acaf41b3a
Author: Dany De Bontridder <address@hidden>
Date: Fri Jan 29 10:37:11 2016 +0100
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 deletions(-)
diff --git a/include/class/class_document_export.php
b/include/class/class_document_export.php
index cf6d66a..f4ce0ed 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 c8e561d..7397b44 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';