Forum


Replies: 4   Views: 4487
No output pdf with libreoffice
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by bloofi  · 08-04-2015 - 08:36

Hi, I'm using the corporate licence (version 4.5-ns). I have LibreOffice installed in /home/apache/LibreOffice-4.4.2/, i've set the method and path in phpdocxconfig.ini. I've also set the variable "temp_path" to /home/apache/phpdocx/tmp/ in this config file. When i run the sample_1.php (transformDocument) from CLI, it generates the PDF. Now, in my own application, i'm generating a docx from a template and store it in /home/apache/phpdocx/my_generated_docx.docx. Then, i'm calling transformDocument like this : $transform = new Phpdocx\Create\CreateDocx(); $transform->enableCompatibilityMode(); $transform->transformDocument("/home/apache/phpdocx/my_generated_docx.docx","/home/apache/phpdocx/my_generated_docx_result.pdf", null, array("debug"=> true)); When i run this code, it generates the docx file but it doesn't output the PDF (i also see a file like "documentXXXXXX" in the temp_path). I've added a debug line in TransformDocAdvLibreOffice.inc just before the passthru (line ~82) to see what command is actually executed : PhpdocxLogger::logger('EXECUTE : '.($libreOfficePath . ' --invisible --convert-to ' . $extension . ' ' . $docSource) , 'info'); which gives me something like this : /home/apache/LibreOffice-4.4.2/program/soffice --invisible --convert-to pdf /home/apache/phpdocx/my_generated_docx.docx and if i execute it myself in CLI, it does output the PDF correctly. So, i'm guessing it's a permission issue with apache (the server is running with apache user, and the CLI is in root) but i can't figure out which one. Do you have any ideas ? Here are some more details : - output log : [phpdocx_logger][INFO ] Importing styles from an external docx. [phpdocx_logger][INFO ] Set DOCX name to: /home/apache/phpdocx/my_generated_docx. [phpdocx_logger][INFO ] Set DOCX name to: /home/apache/phpdocx/my_generated_docx. [phpdocx_logger][INFO ] Remove existing template tags. [phpdocx_logger][INFO ] Add word/document.xml content to DOCX file. [phpdocx_logger][INFO ] Close ZIP file [phpdocx_logger][INFO ] Copy DOCX file using a new name. [phpdocx_logger][INFO ] Set language: fr-FR [phpdocx_logger][INFO ] Enable compatibility mode. [phpdocx_logger][INFO ] EXECUTE : /home/apache/LibreOffice-4.4.2/program/soffice --invisible --convert-to pdf /home/apache/phpdocx/my_generated_docx.docx - apache error log : [error] [client 192.168.30.15] PHP Warning: rename(/home/apache/phpdocx/my_generated_docx.pdf,/home/apache/phpdocx/my_generated_docx_result.pdf): No such file or directory in /var/www/my_application/phpdocx_ns/Classes/Phpdocx/Transform/TransformDocAdvLibreOffice.inc on line 92, referer: http://192.168.30.15/ (i guess it can't rename because it doesn't find the pdf because it's not generated)

Posted by admin  · 08-04-2015 - 08:41

Hello, It seems is a problem related to permissions with the Apache user. Please read the 4th point on: http://www.phpdocx.com/documentation/conversion-plugin/debugging-libreoffice Apache needs a .config folder with rw access. For example the default folder is /var/www/.config, if it doesn't exist you can create it manually and set 777 access to test it and then set the right rwx permissions. Regards.

Posted by bloofi  · 08-04-2015 - 08:57

Hi, Thanks for the quick reply ! I forgot to mention that, i have a .config folder with 777 rights on it in /var/www/ and inside this .config folder, i have something like this : .config (drwxrwxrwx 3 root root) __|- libreoffice (drwxr-xr-x 3 apache apache) ____|- 4 (drwx------ 3 apache apache) ______|- user (drwxr-xr-x 11 apache apache) ________|- basic, config, database, and some more folders

Posted by admin  · 08-04-2015 - 10:33

Hello, Please set the option 'method' as script in the transforDocument and try again. If still not working we'd need to access to your server. In this case contact directly to contact[at]phpdocx.com Regards.

Posted by bloofi  · 08-04-2015 - 12:29

Hi, I've tried with the option "method" as "script", it still doesn't output the PDF file in my application. Also, as i did with the "direct" method, i've added a log to see what command is executed in the passthru; i get this : php /var/www/my_application/phpdocx_ns/Classes/Phpdocx/Transform/../../../lib/convertSimple.php -s /home/apache/phpdocx/my_generated_docx.docx -e pdf -p /home/apache/LibreOffice-4.4.2/program/soffice and if i execute this command myself in a terminal as root, it does work as expected. I may contact you directly now i guess :)