前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >jodconverter4.1.0版本改进解析

jodconverter4.1.0版本改进解析

作者头像
code4it
发布2018-09-17 15:14:40
3.2K0
发布2018-09-17 15:14:40
举报
文章被收录于专栏:码匠的流水账码匠的流水账

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

maven

代码语言:javascript
复制
        <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

相关的jar依赖如下

代码语言:javascript
复制
<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服务。

比如

代码语言:javascript
复制
    - 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,方便进行流式操作 旧版的如下

代码语言:javascript
复制
jodConverter.convert(inputFile, outputFile);

新版如下

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

或者

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

doc

  • Uno
  • LibreOffice online
  • libreoffice online docker
  • liebreoffice online wsd api
  • LibreOffice online with file manager
  • jodconverter Java-Library
本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2017-10-21,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 码匠的流水账 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • maven
  • 依赖变化
  • api变化
  • doc
相关产品与服务
容器服务
腾讯云容器服务(Tencent Kubernetes Engine, TKE)基于原生 kubernetes 提供以容器为核心的、高度可扩展的高性能容器管理服务,覆盖 Serverless、边缘计算、分布式云等多种业务部署场景,业内首创单个集群兼容多种计算节点的容器资源管理模式。同时产品作为云原生 Finops 领先布道者,主导开源项目Crane,全面助力客户实现资源优化、成本控制。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档