Browse Source

Minor updates to the convertor

master
Radu Liviu Carjan 2 years ago
parent
commit
0c1b319bc0
  1. 13
      app/SearchDisplace/Convertor/Convertor.php

13
app/SearchDisplace/Convertor/Convertor.php

@ -44,6 +44,8 @@ class Convertor {
Log::info( Log::info(
'COMMAND: ' . 'COMMAND: ' .
'soffice ' . 'soffice ' .
'--headless ' .
'--safe-mode ' .
'--convert-to ' . '--convert-to ' .
$to . ' ' . $to . ' ' .
$original . ' ' . $original . ' ' .
@ -55,22 +57,23 @@ class Convertor {
# The "OpenDocument Text Flat XML" parameter contains whitespaces, so we will need to add that as # The "OpenDocument Text Flat XML" parameter contains whitespaces, so we will need to add that as
# a env variable parameter, otherwise the Process class will escape it and it will not work properly. # a env variable parameter, otherwise the Process class will escape it and it will not work properly.
$process = Process::fromShellCommandline( $process = Process::fromShellCommandline(
"soffice --convert-to $to $original --outdir $folder",
null, //base_path(),
"soffice --quickstart=no --headless --safe-mode --convert-to $to $original --outdir $folder",
null,
$env $env
); );
$process->run(function ($type, $buffer) {
$process->start(function ($type, $buffer) {
if (Process::ERR === $type) { if (Process::ERR === $type) {
Log::info("CONVERT ERROR: " . $buffer); Log::info("CONVERT ERROR: " . $buffer);
} }
}, $env); }, $env);
$process->wait();
if (!$process->isSuccessful()) { if (!$process->isSuccessful()) {
throw new ProcessFailedException($process); throw new ProcessFailedException($process);
} }
Storage::deleteDirectory(env('LIBREOFFICE_CONFIG_PATH', 'app/tmp/libreoffice'));
return $path['filename'] . '.' . $to; return $path['filename'] . '.' . $to;
} }
} }
Loading…
Cancel
Save