From 2ea8f85e41384c1829c777dbaa902d488e27e264 Mon Sep 17 00:00:00 2001
From: Guillaume Heurtier <guillaume.heurtier@maarch.org>
Date: Mon, 20 Jul 2020 09:50:05 +0200
Subject: [PATCH] FEAT #14242 TIME 0:10 fix convert pdf to 1.4 after conversion
 by only office

---
 .../contentManagement/controllers/OnlyOfficeController.php | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/app/contentManagement/controllers/OnlyOfficeController.php b/src/app/contentManagement/controllers/OnlyOfficeController.php
index 436355097b7..d7fbc7798c4 100644
--- a/src/app/contentManagement/controllers/OnlyOfficeController.php
+++ b/src/app/contentManagement/controllers/OnlyOfficeController.php
@@ -447,6 +447,13 @@ class OnlyOfficeController
             return ['errors' => 'Cannot save converted document'];
         }
 
+        $tmpFilename =  $tmpPath . "tmp_{$GLOBALS['id']}_" . rand() . ".pdf";
+        $command = "gs -dCompatibilityLevel=1.4 -q -sDEVICE=pdfwrite -dNOPAUSE -dQUIET -dBATCH -o {$tmpFilename} {$filename} 2>&1; mv {$tmpFilename} {$filename}";
+        exec($command, $output, $return);
+        if (!empty($output)) {
+            return ['errors' => implode(",", $output)];
+        }
+
         return true;
     }
 
-- 
GitLab