Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convertion Failure! Contact Server Admin #29

Open
LeiraT opened this issue Apr 29, 2021 · 5 comments
Open

Convertion Failure! Contact Server Admin #29

LeiraT opened this issue Apr 29, 2021 · 5 comments

Comments

@LeiraT
Copy link

LeiraT commented Apr 29, 2021

Hello, Im using laravel 8. I already install libre office 7.0.5 in centos 7.
I also already update
public function __construct($filename, $tempPath = null, $bin = ' ', $prefixExecWithExportHome = true)
{
if ($this->open($filename)) {
$this->setup($tempPath, $bin, $prefixExecWithExportHome);
}
}

and
protected function makeCommand($outputDirectory, $outputExtension)
{
$oriFile = escapeshellarg($this->file);
$outputDirectory = escapeshellarg($outputDirectory);

    if (pathinfo($this->file,PATHINFO_EXTENSION) == 'docx' || pathinfo($this->file,PATHINFO_EXTENSION) == 'doc' || pathinfo($this->file,PATH_EXTENSION) == 'DOCX' 
    || pathinfo($this->file,PATHINFO_EXTENSION) == 'DOC') { return "soffice --headless --convert-to {$outputExtension} {$oriFile} --outdir {$outputDirectory}";}
    else if(pathinfo($this->file,PATHINFO_EXTENSION) == 'xlsx' || pathinfo($this->file,PATHINFO_EXTENSION) == 'xls' || pathinfo($this->file,PATHINFO_EXTENSION) == 'XLSX'
    || pathinfo($this->file,PATHINFO_EXTENSION) == 'XLS'){ 
       return "scalc --headless --convert-to {$outputExtension} {$oriFile} --outdir {$outputDirectory}";
    }
}

but it still return the Convertion failure. Contact Admin

@fd6130
Copy link

fd6130 commented Oct 15, 2021

I believe it is because the command fail to execute.

Try go to public function convertTo($filename) in OfficeConverter.php and locate $shell = $this->exec($this->makeCommand($outdir, $outputExtension));

You can try to debug that command output in your terminal.

@PoojaJadav
Copy link

I got same issue. that execute command is libreoffice --headless --convert-to pdf inputpath outputdir from this package. if I'm trying to execute command in system /Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to pdf inputpath outputdir in terminal. it's working fine.

Can you guide us on where we need to add exe path in laravel project?

@fd6130
Copy link

fd6130 commented Jul 19, 2022

The issue is cause by the constructor default bin value:

 public function __construct($filename, $tempPath = null, $bin = 'libreoffice', $prefixExecWithExportHome = true)

Try change it to the path where libreoffice located in your system:

$bin = '/Applications/LibreOffice.app/Contents/MacOS/soffice';
$converter = new OfficeConverter('test-file.docx', 'path-to-outdir', $bin);

I got same issue. that execute command is libreoffice --headless --convert-to pdf inputpath outputdir from this package. if I'm trying to execute command in system /Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to pdf inputpath outputdir in terminal. it's working fine.

Can you guide us on where we need to add exe path in laravel project?

@gtcesar
Copy link

gtcesar commented May 21, 2024

In Ubuntu 22.04 I solved it by giving permission to the /var/www directory for the user www-data
sudo chown -R www-data:www-data /var/www/

@carlosmolano
Copy link

In Ubuntu 22.04 I solved it by giving permission to the /var/www directory for the user www-data sudo chown -R www-data:www-data /var/www/

in Ubuntu 20 , It worked for me too, thanks @gtcesar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants