Hello,
What version of LibreOffice are you using? Maybe you are using a very old version?
We are sure that the problem comes from not using the correct Module1.xba or an external problem we can't guess. We recommend you to install the latest release of libreoffice (https://www.libreoffice.org/) and try the same macro using libreoffice directly. Running LibreOffice macros from the command line is a common task:
To be able to use them with PHP, first, they need to work directly with LibreOffice. And also note that PHP may use another home folder than calling the main libreoffice exec from the command line, so first you need to be able to call the macro using the command line:
/opt/libreoffice6.4/program/soffice --invisible "macro:///Standard.Module1.LosslessPdf(/var/www/document/output.docx)"
Using --backtrace you can debug the output of LibreOffice: https://ask.libreoffice.org/en/question/40490/enable-debug-or-log-errors-using-libreoffice-for-linux/
Regards.