I am working on spring mvc web project on windows and my server is installed on linux. I am using documents4j for docx file convert to pdf file and it works fine on windows but when i put the code to the server it doesn't work because my server is on linux. Can documents4j work on linux? Or which library can I use instead of documents4j?
Asked
Active
Viewed 1,482 times
2 Answers
1
documents4j can work on Linux but not all of its converters. If you are using MS Word or MS Excel, naturally, you will have to use Windows.

Rafael Winterhalter
- 42,759
- 13
- 108
- 192
-
That's a pain..documents4j was the only library out of these: opensagres, apachePOI and docx4j that converted the docx file into a pdf with the same formatting and without any errors. When I tried to run this in Bamboo it failed, and I've discovered that it relies on MS converters..Bummer! So how the hell I make this working in unix based envs ? is there any chance to make it work ? Btw, thanks for the contribution to opensource world and to this library ! – brebDev Dec 08 '21 at 14:59
-
1If you can get Word and VBS run on Linux, it could work, but I doubt it's possible. Typically, you run the conversion on a remote Windows server. – Rafael Winterhalter Dec 10 '21 at 09:57
0
documents4j works only if you have MS Word installed in your system, which is not possible on linux. I suggest you to do this : Install libre office on linux and run this :
String command = "libreoffice --headless --convert-to pdf " + inputWordFilePath + " --outdir " + outputPdfPath;
try {
Runtime.getRuntime().exec(command);
} catch (IOException e) {
e.printStackTrace();
}

Anmol Jain
- 336
- 4
- 12