diff --git a/src/app/contentManagement/controllers/OnlyOfficeController.php b/src/app/contentManagement/controllers/OnlyOfficeController.php
index 436355097b7256ef230d21e44799ef3007fc52dc..d7fbc7798c4dc5adb2f9d3c861911a4b360dee05 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;
     }