Browse Source

Minor update to the convertor class

master
Radu Liviu Carjan 2 years ago
parent
commit
67a0a97f9a
  1. 15
      app/SearchDisplace/Convertor/Convertor.php

15
app/SearchDisplace/Convertor/Convertor.php

@ -35,7 +35,7 @@ class Convertor {
];
if ($extension == 'odt') {
$to = $to . ':"$FILTER"';
$to = $to . ':"${:FILTER}"';
$env['FILTER'] = 'OpenDocument Text Flat XML';
}
@ -65,14 +65,21 @@ class Convertor {
// 'FILTER' => 'OpenDocument Text Flat XML'
// ]
// );
# We will run the process from a shell command line, which allows us to add parameters
# 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",
base_path(),
$env
);
$process->run(null, $env);
Log::info("OUTPUT: " . $process->getOutput());
$process->run(function ($type, $buffer) {
if (Process::ERR === $type) {
Log::info("CONVERT ERROR: " . $buffer);
} else {
// Log::info("CONVERT OUTPUT: " . $buffer);
}
}, $env);
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);

Loading…
Cancel
Save