Forum


Replies: 6   Views: 1229
Docx to pdf conversion on windows server 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 skilltran  · 14-10-2020 - 16:45

I'm trying to get Docx to Pdf converson working on a Windows 2016 server with LibreOffice. Running check-conversionplugin.php gives me the error 'Unable to read libreoffice main executable in the path. Please check the correct path has been added in config/phpdocxconfig.ini' 

:LibreOffice is installed on version 6.4.6 and working. The path I am using is: path = '"C:\Program Files\LibreOffice\program\soffice.exe"' Taking this path and putting it into file explorer opens LibreOffice like you would expect. No idea what's going on.

Thank you

Posted by admin  · 14-10-2020 - 16:56

Hello,

check-conversionplugin.php uses is_readable (https://www.php.net/manual/en/function.is-readable.php) from PHP to check if it can access the main soffice exec.

Please check your server logs and follow the steps explained on https://www.phpdocx.com/documentation/conversion-plugin/debugging-libreoffice to debug it. We recommend you to test it using PHP CLI, to check if the problem comes from the path or the web server that is blocking PHP to read external or executable files.

Regards.

Posted by skilltran  · 16-10-2020 - 19:05

Ok, I got the path issue fixed. Now I'm having an issue with finding the 'config folder of the user's HOME directory' like it says in the link you sent. I have no idea where that is suppoed to be on windows. The project I am working on is usualy run on an apache server, and on there the pdf conversion is working. I can't find the config folder on the apache server either, but It works there. Converting to docx works on the windows machine, just not the converson into pdf. The error I get is this:

rename(C:\OBWeb\reportcache/SkillTRAN-0d13d705af68dd09d5d46c4618630bfe.pdf,C:\OBWeb\reportcache\SkillTRAN-0d13d705af68dd09d5d46c4618630bfe.pdf): The system cannot find the file specified. (code: 2) in C:\OBWeb\rpcl\phpdocx\classes\TransformDocAdvLibreOffice.php

Posted by admin  · 17-10-2020 - 07:20

Hello,

The rename error appears when the conversion can't be done, it's a generic error. The .config folder is available only in Linux OS (https://wiki.documentfoundation.org/UserProfile/en)

On https://www.phpdocx.com/documentation/conversion-plugin/common-problems-and-possible-errors you can read specific issues for each OS. As requested in our previous reply, please follow the steps explained on https://www.phpdocx.com/documentation/conversion-plugin/debugging-libreoffice (1st and 2nd in your case), are you able to do the conversion running LibreOffice directly as the first step details? does it work using PHP CLI mode? If the transformation can be done using the previous approaches (calling LibreOffice and PHP CLI), the problem comes from some missing permission or setup, what web server are you using?

Regards.

Posted by skilltran  · 02-11-2020 - 21:28

I am able to transform a document with the command line, and using the CLI mode with a sample script. I am using the IIS manager on windows server 2016 for the web server. 

Posted by admin  · 03-11-2020 - 06:30

Hello,

If the problem comes from the IIS web server, then you need to set correct rw access to the temp folder. Please note you can create a custom temp folder (for example in C:\inetpub\wwwroot\temp\libreoffice) and use it when calling the conversion plugin based on LibreOffice:

1. Create a temp folder where the IIS user has full access, this will be used as temp folder. For example, create the folder C:\inetpub\wwwroot\temp\libreoffice and set to the temp and libreoffice folders full access to the IIS user. Right click on the folder => Security => set and apply full access to the user (IUSR is the default one).

2. In path in config/phpdocxconfig.ini set:

path = '"C:\Program Files\LibreOffice\program\soffice.exe" -env:UserInstallation=file:///C:/inetpub/wwwroot/temp/libreoffice'

setting the correct soffice path and the path to the created temp folder of your server.

3. Now, you can do the conversions using PHP CLI mode and web browser setting the outdir option:

$docx->transformDocument('transformDocument_libreoffice_1.docx', 'transformDocument_libreoffice_1.pdf', 'libreoffice', array('outdir' => 'C:\inetpub\wwwroot\phpdocx-premium-10\examples\FormatConversion\transformDocument\libreoffice'));

These instructions have been fully tested in IIS web server, please follow them step by step and setting the correct paths in your server.

Regards.

Posted by skilltran  · 03-11-2020 - 20:37

Creating the temp folder with proper rw access and putting it in the path got it working for me, thank you!