[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 05/05: Fix problem with PDF , the forced conv
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 05/05: Fix problem with PDF , the forced conversion to image and back to PDF doesnt work properly, it works better with ps2pdf and pdf2ps |
Date: |
Tue, 02 Feb 2016 14:36:18 +0000 |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 12c15fba0c09aa94939c1d7001e3e7d35959aefa
Author: Dany De Bontridder <address@hidden>
Date: Tue Feb 2 15:28:42 2016 +0100
Fix problem with PDF , the forced conversion to image and back to PDF
doesnt work properly, it works better with ps2pdf and pdf2ps
---
include/class/class_document_export.php | 21 ++++++++++++++++++---
include/constant.php | 21 ++++++++++++++++++++-
2 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/include/class/class_document_export.php
b/include/class/class_document_export.php
index 2dfee92..50fa059 100644
--- a/include/class/class_document_export.php
+++ b/include/class/class_document_export.php
@@ -168,10 +168,12 @@ class Document_Export
//-----------------------------------
// Fix broken PDF , actually pdftk can not handle all the PDF
- if ( FIX_BROKEN_PDF == 'YES' ) {
- $stmpt = CONVERT_GIF_PDF." ".
escapeshellarg($this->store_convert . '/' . $file_pdf)." ".
escapeshellarg($this->store_convert . '/' . $file_pdf.'tmp');
+ if ( FIX_BROKEN_PDF == 'YES' && PDF2PS != 'NOT' && PS2PDF !=
'NOT') {
+
+ $stmpt = PDF2PS." ". escapeshellarg($this->store_convert . '/'
. $file_pdf)." ". escapeshellarg($this->store_convert . '/' . $file_pdf.'.ps');
+
passthru($stmpt,$status);
- rename ($this->store_convert . '/' .
$file_pdf.'tmp',$this->store_convert . '/' . $file_pdf);
+
if ($status <> 0)
{
$this->feedback[$cnt_feedback]['file'] =
$this->store_convert . '/' . $file_pdf;
@@ -180,6 +182,19 @@ class Document_Export
$cnt_feedback++;
continue;
}
+ $stmpt = PS2PDF." ". escapeshellarg($this->store_convert . '/'
. $file_pdf.'.ps')." ". escapeshellarg($this->store_convert . '/' .
$file_pdf.'.2');
+
+ passthru($stmpt,$status);
+
+ if ($status <> 0)
+ {
+ $this->feedback[$cnt_feedback]['file'] =
$this->store_convert . '/' . $file_pdf;
+ $this->feedback[$cnt_feedback]['message'] = ' cannot force
to PDF';
+ $this->feedback[$cnt_feedback]['error'] = $status;
+ $cnt_feedback++;
+ continue;
+ }
+ rename ($this->store_convert . '/' .
$file_pdf.'.2',$this->store_convert . '/' . $file_pdf);
}
// output
$output = $this->store_convert . '/stamp_' . $file_pdf;
diff --git a/include/constant.php b/include/constant.php
index 655e629..fec5988 100644
--- a/include/constant.php
+++ b/include/constant.php
@@ -44,7 +44,7 @@ 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
+// with convert , see also PDF2PS and PS2PDF if yes
if ( !defined("FIX_BROKEN_PDF")) define ("FIX_BROKEN_PDF",'NO');
require_once NOALYSS_INCLUDE.'/constant.security.php';
@@ -236,7 +236,26 @@ if (file_exists($convert_gif_pdf))
define ('CONVERT_GIF_PDF','NOT');
}
+/**
+ * PDF2PS is used when the PDF is broken , used with FIX_BROKEN_PDF
+ */
+$pdf2ps='/usr/bin/pdf2ps';
+
+if ( ! file_exists($pdf2ps) )
+ define ('PDF2PS','NOT');
+ else
+ define ('PDF2PS',$pdf2ps);
+/**
+ * PS2PDF is used when the PDF is broken , used with FIX_BROKEN_PDF
+ */
+$ps2pdf='/usr/bin/ps2pdf';
+
+if ( ! file_exists($ps2pdf) )
+ define ('PS2PDF','NOT');
+ else
+ define ('PS2PDF',$ps2pdf);
+
/**
* Outil pour manipuler les PDF
*/
- [Noalyss-commit] [noalyss] branch master updated (759dfab -> 12c15fb), Dany De Bontridder, 2016/02/02
- [Noalyss-commit] [noalyss] 02/05: new tool for developing, Dany De Bontridder, 2016/02/02
- [Noalyss-commit] [noalyss] 04/05: Add FIX_BROKEN_PDF in constant.php by default it is NO, Dany De Bontridder, 2016/02/02
- [Noalyss-commit] [noalyss] 03/05: Improve dev tool, Dany De Bontridder, 2016/02/02
- [Noalyss-commit] [noalyss] 05/05: Fix problem with PDF , the forced conversion to image and back to PDF doesnt work properly, it works better with ps2pdf and pdf2ps,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 01/05: new tool for developing, Dany De Bontridder, 2016/02/02