Repo for the search and displace ingest module that takes odf, docx and pdf and transforms it into .md to be used with search and displace operations
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.

41 lines
902 B

  1. <?php
  2. namespace App\Ingest;
  3. class OtherConvertor extends AbstractConvertor
  4. {
  5. public function execute()
  6. {
  7. $this->convertToDocx();
  8. $convertor = new DocxAndOdtConvertor($this->storage, "$this->directoryPath/document.docx");
  9. $convertor->execute();
  10. }
  11. /**
  12. * Convert doc,dot,rtf,odt,pdf,docx to docx
  13. *
  14. *
  15. * @return string|void
  16. */
  17. private function convertToDocx()
  18. {
  19. /**
  20. * Convert doc,dot,rtf,odt to docx
  21. */
  22. $office = new Office();
  23. $success = $office->run(
  24. 'docx',
  25. $this->storage->path($this->path),
  26. $this->storage->path($this->directoryPath)
  27. );
  28. if (! $success) {
  29. throw new \Exception('Something went wrong while tried converting to DOCX for file: ' . $this->path);
  30. }
  31. $this->deleteOriginalDocument();
  32. }
  33. }