How can I use OpenOffice in server mode as a multithreaded service?

前端 未结 6 1284
孤街浪徒
孤街浪徒 2020-12-04 20:13

What is the experience of working with OpenOffice in server mode? I know OpenOffice is not multithreaded and now I need to use its services in our server.
What can I do

6条回答
  •  感情败类
    2020-12-04 20:38

    With the current version of JODConverter (3.0-SNAPSHOT), it's quite easy to handle multiple threads of OOo in headless-mode, as the library now supports starting up several instances and keeping them in a pool, by just providing several port numbers or named pipes when constructing a OfficeManager instance:

    final OfficeManager om = new DefaultOfficeManagerConfiguration()
      .setOfficeHome("/usr/lib/openoffice")
      .setPortNumbers(8100, 8101, 8102, 8103)
      .buildOfficeManager();
    
    om.start();
    

    You can then us the library e.g. for converting documents without having to deal with the pool of OOo instances in the background:

    OfficeDocumentConverter converter = new OfficeDocumentConverter(om);
    converter.convert(new File("src/test/resources/test.odt"), new File("target/test.pdf"));
    

提交回复
热议问题