jodconverter4.1.0版本改进解析

jodconverter 4.1.0版本的话,改进了api的结构,同时新增了local以及online的模块,本文就来分析一下。

maven

        <dependency>
            <groupId>org.jodconverter</groupId>
            <artifactId>jodconverter-spring-boot-starter</artifactId>
            <version>4.1.0</version>
        </dependency>复制代码

依赖变化

新版的话,对原来的jodconverter-core进行了抽离,将对libreoffice相关jar包的依赖从core模块中抽取出来,抽到jodconverter-local模块当中。
另外也新增了jodconverter-online模块,以支持libreoffice online server的远程调用。

  • Uno
    local方式是本地启动libreoffice,然后使用uno进行编程,操作本地的office。
    Uno-Arc

相关的jar依赖如下

<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.
    可以部署到自己的私有云端,然后通过有ui界面可以操作,也通过http对外提供api服务。

比如

    - 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>复制代码

jodconverter-online模块基于这个api使用apache http client进行了client端的封装并进行连接池的优化处理。

api变化

4.1.0版本改进了api,方便进行流式操作
旧版的如下

jodConverter.convert(inputFile, outputFile);复制代码

新版如下

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

或者

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

doc

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值