office-converter: Convertion Failure! Contact Server Admin.

Here is my code:

// this way is using LibreOffice
    $converter = new OfficeConverter($filename);
    $nameFile = pathinfo($filename, PATHINFO_FILENAME) . ".html";
    $content = "";
    try {
        $converter->convertTo($nameFile); //generates pdf file in same directory as test-file.docx
        $content = file_get_contents(dirname($filename)."\\".$nameFile);
        return $content;

    } catch (\NcJoes\OfficeConverter\OfficeConverterException $e) {
        return $e->getMessage();
    }

And when I run, It return message: Convertion Failure! Contact Server Admin. I am using Yii2 PHP Framework to convert .doc to .html then to plain text. Please help me!

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16

Most upvoted comments

@ChavaBerman @tayfunyazici1 This wrapper generates command and execute that. I am using the LibreOffice 6.4 which doesn’t have the ‘libreoffice’ command instead it has the ‘soffice’(for .doc and .docx), 'scalc (for xls & xlsx) ', ‘sbase’, ‘sdraw’ and ‘simpress’. at the same time I think that the code is written for linux not for windows. I did brought some change for example, i set the $bin attribute to ‘soffice’ in constructor instead of ‘libreoffice’ line 27, and at line 233 i changed the ‘export’ to ‘set’ it converts now the docx to pdf and html perfectly. Also add the ‘C:\Program Files\LibreOffice\program’ to the System environment path.