run libreoffice from php

0

I'm doing a php script to convert PPT files to PDF. I have my ubuntu instance running on Amazon Ec2. The problem is that when I run from the console:

libreoffice --headless --convert-to pdf prueba.ppt

It works fine but when I do from php:

exec('libreoffice --headless --convert-to pdf prueba.ppt');

It does not work, it does not give an error, nor does it create the file. Can someone help me with what I'm doing wrong? Thanks!

    
asked by Patricio 26.08.2017 в 02:31
source

1 answer

0

First you must know what is the error you are having, for this you can try first to get the output of the execution you are launching:

Exec (" /usr/bin/soffice  --headless --convert-to pdf  prueba.docx  >> out.txt  2>&1 ");

You open then out.txt to analyze it. In many cases the following error is obtained:

[Java framework] Error in function createSettingsDocument (elements.cxx).
javaldx failed!
Warning: failed to read path from javaldx

If this is the case you must previously set a home work folder for the libreoffice

Exec (" export export HOME=/RutaAMisScripts/Temp/ && /usr/bin/soffice  --headless --convert-to pdf  prueba.docx  >> out.txt  2>&1 ");
    
answered by 03.10.2017 в 23:40