Forum


Replies: 11   Views: 2309
Pdf lossless compression doesn't work?
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  · 30-03-2020 - 19:28

Hello,

We never remove the Sub Main method, but it should work without it. Anyway, please restore it.

Maybe you haven't added the macro to the correct Module1? Please note that the macro should be added to the Module1.xba file of the user that is running LibreOffice; each user may have its own .config folder and Module1.xba file.

As we can't connect to your server, please do the following tests, using the command line, please run libreoffice directly:

/opt/libreoffice6.4/program/soffice --invisible "macro:///Standard.Module1.LosslessPdf(/var/www/document/output.docx)"

Changing /opt/libreoffice6.4/program/soffice by the path where LibreOffice is installed. And /var/www/document/output.docx by the absolute path of the DOCX to be transformed. Please run this command in the folder of the DOCX to be transformed. Please note that LosslessPdf is the name of the added macro, do not use LosslessCompressionPdf in Module1.xba but LosslessPdf.

If the previous test works, then please create a simple script to run the code from PHP:

<?php
passthru('/opt/libreoffice6.4/program/soffice --invisible "macro:///Standard.Module1.LosslessPdf(/var/www/document/output.docx)"');

We are doing many tests and in all cases, it is working correctly. The previous command is used by phpdocx to transform the DOCX to PDF using LosslessPdf.

Regards.