How can use documents4j on linux?

1.9k views Asked by At

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?

2

There are 2 answers

0
Anmol Jain On BEST ANSWER

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();
      }
2
Rafael Winterhalter On

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.