I was looking for an opensource Java solution to convert DOC/DOCX to PDF without loosing the design of the document.
I came to know about the usage of LibreOffice on Linux machine for the same in the following post. Thank you, Anmol.
https://stackoverflow.com/a/73711219/3085879
So, I gave a try installing LibreOffice on windows machine, and running the following command.
*C:\Users\ABCD\Desktop\sofficetest>"C:\Program Files\LibreOffice\program\soffice.exe" --convert-to pdf:writer_pdf_Export --outdir "C:\Users\ABCD\Desktop\sofficetest\output" .docx
Please note that I have used double quotes for paths to avoid space related issues. It works like a charm. :)
I found the syntax of the command when I ran the following command on the command prompt.
C:\Users\ABCD\Desktop\sofficetest>"C:\Program Files\LibreOffice\program\soffice.exe" --help
Please refer the highlighted section in the command run result screenshot.
The environment and software details are as follows.