diff --git a/app/Console/Commands/AnalyzePerformance.php b/app/Console/Commands/AnalyzePerformance.php index 303f3ba..11b73ed 100644 --- a/app/Console/Commands/AnalyzePerformance.php +++ b/app/Console/Commands/AnalyzePerformance.php @@ -58,10 +58,13 @@ class AnalyzePerformance extends Command $redis->set('analyze_performance_remaining_files', count($allFiles)); foreach ($allFiles as $index => $file) { + $document = new UploadedFile($file, "File {$index}"); + $handler = new DocumentHandler( $index, 'md', - new UploadedFile($file, "File {$index}"), + $document->getMimeType(), + $document, false ); diff --git a/app/Ingest/DataJsonConvertor.php b/app/Ingest/DataJsonConvertor.php index fcb66de..d2325ac 100644 --- a/app/Ingest/DataJsonConvertor.php +++ b/app/Ingest/DataJsonConvertor.php @@ -53,8 +53,14 @@ class DataJsonConvertor extends AbstractConvertor { $office = new Office(); + $convertTo = 'docx'; + + if ($this->fileIsPDF($this->path)) { + $convertTo = 'docx:writer_pdf_Export'; + } + $success = $office->run( - 'docx', + $convertTo, $this->storage->path($this->path), $this->storage->path($this->directoryPath) ); @@ -73,4 +79,11 @@ class DataJsonConvertor extends AbstractConvertor $this->type = 'docx'; } + + protected function fileIsPDF($filePath) + { + $s = '.pdf'; + + return substr($filePath, - strlen($s)) === $s; + } } diff --git a/app/Ingest/DocxConvertor.php b/app/Ingest/DocxConvertor.php index b1e179b..6992127 100644 --- a/app/Ingest/DocxConvertor.php +++ b/app/Ingest/DocxConvertor.php @@ -53,7 +53,7 @@ class DocxConvertor extends AbstractConvertor */ public function convertToPdfWithLibreOffice() { - $this->convertToFormat('pdf'); + $this->convertToFormat('pdf:writer_pdf_Export'); } /** diff --git a/app/Ingest/Office.php b/app/Ingest/Office.php index 45413e2..156e98b 100644 --- a/app/Ingest/Office.php +++ b/app/Ingest/Office.php @@ -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();