Search code examples
javaspringdocuments4j

How can use documents4j on linux?


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?


Solution

  • 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();
          }