|
|
@ -31,15 +31,8 @@ class Office |
|
|
|
|
|
|
|
protected function runConversion($convertTo, $filePath, $directoryPath) |
|
|
|
{ |
|
|
|
$pdfAdditionalOption = ''; |
|
|
|
|
|
|
|
if ($this->fileIsPDF($filePath)) { |
|
|
|
$pdfAdditionalOption = "--infilter='writer_pdf_import'"; |
|
|
|
} |
|
|
|
|
|
|
|
$process = new Process([ |
|
|
|
'soffice', |
|
|
|
$pdfAdditionalOption, |
|
|
|
'--accept="pipe,name=soffice-pipe-' . $this->id . ';urp;StarOffice.ServiceMananger"', |
|
|
|
'-env:UserInstallation=file:///tmp/' . $this->directory, |
|
|
|
'--headless', |
|
|
@ -50,20 +43,13 @@ class Office |
|
|
|
$directoryPath |
|
|
|
]); |
|
|
|
|
|
|
|
$process->setTimeout(10); |
|
|
|
$process->setTimeout(20); |
|
|
|
|
|
|
|
$process->run(); |
|
|
|
|
|
|
|
return $process->isSuccessful(); |
|
|
|
} |
|
|
|
|
|
|
|
protected function fileIsPDF($filePath) |
|
|
|
{ |
|
|
|
$s = '.pdf'; |
|
|
|
|
|
|
|
return substr($filePath, - strlen($s)) === $s; |
|
|
|
} |
|
|
|
|
|
|
|
protected function makeTemporaryDirectory() |
|
|
|
{ |
|
|
|
(new Process(['mkdir /tmp/' . $this->directory]))->run(); |
|
|
|