简体   繁体   English

如何在 linux 上使用documents4j?

[英]How can use documents4j on linux?

I am working on spring mvc web project on windows and my server is installed on linux.我正在处理 windows 上的 spring mvc web 项目,我的服务器安装在 ZE206A54E9760EE89CCEZ5 上。 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.我正在使用documents4j将docx文件转换为pdf文件,它在windows上运行良好,但是当我将代码放到服务器上时它不起作用,因为我的服务器在ZE206A54E97690CCE50CC872DDZEE7上。 Can documents4j work on linux? documents4j 可以在 linux 上工作吗? Or which library can I use instead of documents4j?或者我可以使用哪个库来代替documents4j?

documents4j can work on Linux but not all of its converters. documents4j 可以在 Linux 上工作,但不是所有的转换器。 If you are using MS Word or MS Excel, naturally, you will have to use Windows.如果您使用的是 MS Word 或 MS Excel,当然,您将不得不使用 Windows。

But I can suggest you to do this: Install libre office on linux and run this:但我可以建议你这样做:在 linux 上安装 libre office 并运行:

  String command = "libreoffice --headless --convert-to pdf " + inputPath + " --outdir " + outputPath;
 
 try {
         Runtime.getRuntime().exec(command);
      } catch (IOException e) {
         e.printStackTrace();
      }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM