Forum


Replies: 1   Views: 1524
Libreoffice pdf export concurrency problems
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 michael.stubenvoll  · 19-04-2021 - 08:27

Hi,
I just encountred a problem with docx to pdf libreoffice conversion.
Everything works fine, when only one File is converted by LibreOffice at the same time.
But if you start a second conversion, while an other conversion is running, libreoffice will fail without warnings or errors. This problem will occur, when the conversion process is started with phpdocx in php or directly via command line: soffice --invisible --convert-to pdf test.docx


phpdoxc will then throw a rename(..., ...)No such file or directory Exception


In the end I found out that the problem can be solved by creating a separate config file for each export.
Like this:

$docx->transformDocument("test.docx", 
"test.pdf", 
null,
array('homeFolder' => '/home/testUser/libreOfficeConfig/'. Str::random())

(Str::random() just generates a 16 characters long random String)

Now I would be intrested if you already know this problem, because I coudnĀ“t find anything about it, in the commen problems section: https://www.phpdocx.com/documentation/conversion-plugin/common-problems-and-possible-errors. There is only mentioned, that LibreOffice needs permissions to read and write in the .config directory.

I think I could not be the first one, who has this problem?
And is that a possible way to solve the problem? Or does maybe a more robust solution exist?

Greetings
Michael

Posted by admin  · 19-04-2021 - 08:50

Hello,

Your solution is correct to work with concurrency conversions: using a not unique home folder but random ones in an existing folder. An alternative solution would be using a custom UserInstallation parameter with a random folder when doing the conversion in the tmp path (or other path):

$docx->transformDocument('document.docx', 'output.pdf', 'libreoffice', array('extraOptions' => '"-env:UserInstallation=file:///tmp/temp_lo_{randomid}"'));

replacing {randomid} with a random value (the extraOptions option is available since phpdocx 11).

On the documentation page available on https://www.phpdocx.com/documentation/conversion-plugin/common-problems-and-possible-errors you can find information about doing concurrency conversions with the conversion plugin based on LibreOffice.

Regards.