From abf842b0548e58321ae68b13bab91e4ee09e5865 Mon Sep 17 00:00:00 2001 From: github-479 <54458909+github-479@users.noreply.github.com> Date: Sun, 27 Mar 2022 08:15:52 -0600 Subject: [PATCH 1/3] Support CSV add CSV to getAllowedConverter function. This converts includes CSV extensions. --- src/OfficeConverter/OfficeConverter.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/OfficeConverter/OfficeConverter.php b/src/OfficeConverter/OfficeConverter.php index 2b29a93..9b853ea 100755 --- a/src/OfficeConverter/OfficeConverter.php +++ b/src/OfficeConverter/OfficeConverter.php @@ -212,6 +212,7 @@ private function getAllowedConverter($extension = null) 'Jfif' => ['pdf'], 'rtf' => ['docx', 'txt', 'pdf'], 'txt' => ['pdf', 'odt', 'doc', 'docx', 'html'], + 'csv' => ['pdf'], ]; if (null !== $extension) { From c3d5b117777d0a3cdb40a1b092aa4d7125428388 Mon Sep 17 00:00:00 2001 From: Nooruliman <84498635+Nooruliman@users.noreply.github.com> Date: Sat, 9 Apr 2022 12:32:51 +0500 Subject: [PATCH 2/3] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index fbcf804..4ecd72e 100755 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ } ], "require" : { - "php" : ">=5.4.4" + "php" : "^7.3|^8.0" }, "require-dev" : { "phpunit/phpunit": "7.*", From 143eca2ac7b09ca946af2a20bea4a404340de4ab Mon Sep 17 00:00:00 2001 From: neopheus Date: Tue, 13 Sep 2022 13:23:05 +0200 Subject: [PATCH 3/3] Add Log --- src/OfficeConverter/OfficeConverter.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/OfficeConverter/OfficeConverter.php b/src/OfficeConverter/OfficeConverter.php index 2b29a93..28d69e8 100755 --- a/src/OfficeConverter/OfficeConverter.php +++ b/src/OfficeConverter/OfficeConverter.php @@ -16,6 +16,8 @@ class OfficeConverter private $basename; /** @var bool */ private $prefixExecWithExportHome; + /** @var string */ + private $logPath; /** * OfficeConverter constructor. @@ -25,10 +27,10 @@ class OfficeConverter * @param string $bin * @param bool $prefixExecWithExportHome */ - public function __construct($filename, $tempPath = null, $bin = 'libreoffice', $prefixExecWithExportHome = true) + public function __construct($filename, $tempPath = null, $bin = 'libreoffice', $prefixExecWithExportHome = true, $logPath = null) { if ($this->open($filename)) { - $this->setup($tempPath, $bin, $prefixExecWithExportHome); + $this->setup($tempPath, $bin, $prefixExecWithExportHome, $logPath); } } @@ -84,7 +86,7 @@ protected function open($filename) * * @throws OfficeConverterException */ - protected function setup($tempPath, $bin, $prefixExecWithExportHome) + protected function setup($tempPath, $bin, $prefixExecWithExportHome, $logPath) { //basename $this->basename = pathinfo($this->file, PATHINFO_BASENAME); @@ -114,6 +116,9 @@ protected function setup($tempPath, $bin, $prefixExecWithExportHome) //use prefix export home or not $this->prefixExecWithExportHome = $prefixExecWithExportHome; + + // log path + $this->logPath = realpath($logPath); } /** @@ -126,8 +131,9 @@ protected function makeCommand($outputDirectory, $outputExtension) { $oriFile = escapeshellarg($this->file); $outputDirectory = escapeshellarg($outputDirectory); + $logCmd = $this->logPath ? ">> {$this->logPath}" : ""; - return "{$this->bin} --headless --convert-to {$outputExtension} {$oriFile} --outdir {$outputDirectory}"; + return "{$this->bin} --headless --convert-to {$outputExtension} {$oriFile} --outdir {$outputDirectory} {$logCmd}"; } /**