Forum


Replies: 1   Views: 197
Transform to pdf with libreoffice in windows when paths include blank spaces
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 admin  · 22-12-2024 - 11:11

Hello,

Using a Windows server, if the path to LibreOffice contains spaces, you need to wrap it between single quotation marks in the config/phpdocxconfig.ini file, as detailed on (https://www.phpdocx.com/documentation/conversion-plugin/common-problems-and-possible-errors):

path = '"C:\Program Files (x86)\LibreOffice 5\program\soffice.exe"'

Also please note that since the release of phpdocx 14.5, a new escapeshellarg option was included in the conversion plugin based on LibreOffice:

escapeshellarg    bool    False by default. Applies escapeshellarg to escape the source string.

You can enable it to escape the source path.
This same option is explained on https://www.phpdocx.com/documentation/conversion-plugin/common-problems-and-possible-errors:

Avoid using special shell characters such as spaces, percent signs or exclamation marks in the input source when using the conversion plugins based on LibreOffice or MS Word. The conversion plugin based on LibreOffice includes the escapeshellarg option to escape the source string.

You can also use escapeshellarg (https://www.php.net/manual/en/function.escapeshellarg.php) from PHP to escape the paths when calling transformDocument.

Regards.