|
|
@ -9,18 +9,19 @@ class DocxConvertor extends AbstractConvertor |
|
|
|
{ |
|
|
|
public function execute() |
|
|
|
{ |
|
|
|
$this->convertToText(); |
|
|
|
// $this->convertToText();
|
|
|
|
//
|
|
|
|
// $convertor = new TextConvertor($this->storage, "$this->directoryPath/document.txt");
|
|
|
|
//
|
|
|
|
// $convertor->execute();
|
|
|
|
|
|
|
|
$convertor = new TextConvertor($this->storage, "$this->directoryPath/document.txt"); |
|
|
|
$this->convertToPDF(); |
|
|
|
|
|
|
|
$convertor = new PDFConvertor($this->storage, "$this->directoryPath/document.pdf"); |
|
|
|
|
|
|
|
$convertor->execute(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Convert docx file to text |
|
|
|
* |
|
|
|
* @return void |
|
|
|
*/ |
|
|
|
protected function convertToText() |
|
|
|
{ |
|
|
|
(new Process(['export HOME=' . env('USER_HOME_PATH')]))->run(); |
|
|
@ -43,4 +44,24 @@ class DocxConvertor extends AbstractConvertor |
|
|
|
|
|
|
|
$this->deleteOriginalDocument(); |
|
|
|
} |
|
|
|
|
|
|
|
protected function convertToPDF() |
|
|
|
{ |
|
|
|
(new Process(['export HOME=' . env('USER_HOME_PATH')]))->run(); |
|
|
|
|
|
|
|
$process = new Process([ |
|
|
|
'unoconv', |
|
|
|
'-f', |
|
|
|
'pdf', |
|
|
|
$this->storage->path($this->path), |
|
|
|
]); |
|
|
|
|
|
|
|
$process->run(); |
|
|
|
|
|
|
|
if (!$process->isSuccessful()) { |
|
|
|
throw new ProcessFailedException($process); |
|
|
|
} |
|
|
|
|
|
|
|
$this->deleteOriginalDocument(); |
|
|
|
} |
|
|
|
} |