You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1000 B
44 lines
1000 B
<?php
|
|
|
|
namespace App\Ingest;
|
|
|
|
use Symfony\Component\Process\Exception\ProcessFailedException;
|
|
use Symfony\Component\Process\Process;
|
|
|
|
class OtherConvertor extends AbstractConvertor
|
|
{
|
|
public function execute()
|
|
{
|
|
$this->convertToDocx();
|
|
|
|
$convertor = new DocxConvertor($this->storage, "$this->directoryPath/document.docx");
|
|
|
|
$convertor->execute();
|
|
}
|
|
|
|
/**
|
|
* Convert doc,dot,rtf,odt,pdf,docx to docx
|
|
*
|
|
*
|
|
* @return string|void
|
|
*/
|
|
private function convertToDocx()
|
|
{
|
|
/**
|
|
* Convert doc,dot,rtf,odt to docx
|
|
*/
|
|
$office = new Office();
|
|
|
|
$success = $office->run(
|
|
'docx',
|
|
$this->storage->path($this->path),
|
|
$this->storage->path($this->directoryPath)
|
|
);
|
|
|
|
if (! $success) {
|
|
throw new \Exception('Something went wrong while tried converting to DOCX for file: ' . $this->path);
|
|
}
|
|
|
|
$this->deleteOriginalDocument();
|
|
}
|
|
}
|