Improvement analysis of version 4.1.0 of jodconverter4.1.0

  libreoffice, pdf

Order

Jodconverter version 4.1.0 improves the structure of api and adds local and online modules. this article will analyze it.

maven

        <dependency>
            <groupId>org.jodconverter</groupId>
            <artifactId>jodconverter-spring-boot-starter</artifactId>
            <version>4.1.0</version>
        </dependency>

Dependent change

In the new version, the original jodconverter-core is detached, and the dependency on libreoffice related jar packages is extracted from the core module and drawn into the jodconverter-local module.
In addition, the jodconverter-online module has been added to support remote calling of libreoffice online server.

  • Uno
    The local method is to start libreoffice locally and then use uno to program and operate the local office.

Uno-Arc

The jar dependencies are as follows

<dependency>
    <groupId>org.libreoffice</groupId>
    <artifactId>juh</artifactId>
    <version>5.4.2</version>
</dependency>
<dependency>
    <groupId>org.libreoffice</groupId>
    <artifactId>jurt</artifactId>
    <version>5.4.2</version>
</dependency>
<dependency>
    <groupId>org.libreoffice</groupId>
    <artifactId>ridl</artifactId>
    <version>5.4.2</version>
</dependency>
<dependency>
    <groupId>org.libreoffice</groupId>
    <artifactId>unoil</artifactId>
    <version>5.4.2</version>
</dependency>
  • online

This is LibreOffice Online, which provides basic collaborative editing of documents in a browser by re-using the LibreOffice core. Rendering fidelity should be excellent, and interoperability match that of LibreOffice.
It can be deployed to its own private cloud, and then can be operated through ui interface and provide api service externally through http.

such as

    - API: HTTP POST to /lool/convert-to/<format>
        - the format is e.g. "png", "pdf" or "txt"
        - the file itself in the payload
    - example
        - curl -F "data=@test.txt" https://localhost:9980/lool/convert-to/docx > out.docx
    - or in html:
          <form action="https://localhost:9980/lool/convert-to/docx" enctype="multipart/form-data" method="post">
              File: <input type="file" name="data"><br/>
              <input type="submit" value="Convert to DOCX">
          </form>

The jodconverter-online module uses apache http client to encapsulate the client and optimize the connection pool based on this api.

Api changes

Version 4.1.0 improves api to facilitate streaming operation
The old version is as follows

jodConverter.convert(inputFile, outputFile);

The new edition reads as follows

File inputFile = new File("spreadsheet.xls");
File outputFile = new File("spreadsheet.ods");
JodConverter
         .convert(inputFile)
         .to(outputFile)
         .execute();

Or ..

InputStream inputStream = ...
OutputStream outputStream = ...
JodConverter
         .convert(inputStream)
         .as(DefaultDocumentFormatRegistry.XLS)
         .to(outputStream)
         .as(DefaultDocumentFormatRegistry.ODS)
         .execute();

doc