ncjoes / office-converter

PHP Wrapper for LibreOffice
MIT License
197 stars 75 forks source link

ConvertTo function is not working properly. No return #46

Open sxaxmz opened 1 year ago

sxaxmz commented 1 year ago

Hi, Issue with using the tool as the error is with this part of the code as the command is not made properly and its not returning.

 public function convertTo($filename)
    {
        $outputExtension = pathinfo($filename, PATHINFO_EXTENSION);
        $supportedExtensions = $this->getAllowedConverter($this->extension);

        if (!in_array($outputExtension, $supportedExtensions)) {
            throw new OfficeConverterException("Output extension({$outputExtension}) not supported for input file({$this->basename})");
        }

        $outdir = $this->tempPath;
        $shell = $this->exec($this->makeCommand($outdir, $outputExtension));
        if (0 != $shell['return']) {
            throw new OfficeConverterException('Convertion Failure! Contact Server Admin.');
        }

        return $this->prepOutput($outdir, $filename, $outputExtension);
    }

The error:

Fatal error: Uncaught NcJoes\OfficeConverter\OfficeConverterException: Convertion Failure! Contact Server Admin. in C:\xampp\htdocs\vendor\ncjoes\office-converter\src\OfficeConverter\OfficeConverter.php:54
Stack trace:
#0 C:\xampp\htdocs\a\create_thumbnail.php(136): NcJoes\OfficeConverter\OfficeConverter->convertTo('Architecture_xy...')
#1 C:\xampp\htdocs\a\create_thumbnail.php(181): getThumbnail('../uploads/ppt/...', 'Architecture_xy...', 'C:/xampp/htdocs...', '../uploads/tmp/', 'ppt', '146', Object(mysqli))
#2 {main}
  thrown in C:\xampp\htdocs\vendor\ncjoes\office-converter\src\OfficeConverter\OfficeConverter.php on line 54