Browse Source

Minor updates to the convertor

master
Radu Liviu Carjan 1 year 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(
'COMMAND: ' .
'soffice ' .
'--headless ' .
'--safe-mode ' .
'--convert-to ' .
$to . ' ' .
$original . ' ' .
@ -55,22 +57,23 @@ class Convertor {
# 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.
$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
);
$process->run(function ($type, $buffer) {
$process->start(function ($type, $buffer) {
if (Process::ERR === $type) {
Log::info("CONVERT ERROR: " . $buffer);
}
}, $env);
$process->wait();
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
Storage::deleteDirectory(env('LIBREOFFICE_CONFIG_PATH', 'app/tmp/libreoffice'));
return $path['filename'] . '.' . $to;
}
}
Loading…
Cancel
Save