将office文档转换成PDF格式--项目一(使用openoffice)

  1. 环境准备
    1. wins10环境测试:首先下载最新版的openoffice工具,安装完成之后安装服务,, win+r打开命令提示符 输入cmd,cd C:\Program Files (x86)\OpenOffice 4\program,在该目录下执行语句 soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard;服务安装完成了,查看端口号  netstat -ano|findstr "8100"  查看服务名称: tasklist|findstr "8100"  (参考连接
    2. Linux环境下把openoffice百度安装启动就好。
      1. Ubuntu安装(Ubuntu 安装OpenOffice操作_不忘初心的博客-CSDN博客
      2. Linux启动OpenOfice命令(CentOS 安装openoffice
        soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard &

      3. 其他

       

    3. openoffice-V4.1.7
      1. wins版本[下载]
      2. Linux版本[下载]
  2. 依赖jar包
    1. pom.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
          <modelVersion>4.0.0</modelVersion>
          <parent>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-starter-parent</artifactId>
              <version>2.2.4.RELEASE</version>
              <relativePath/> <!-- lookup parent from repository -->
          </parent>
          <groupId>com.test</groupId>
          <artifactId>office2pdf</artifactId>
          <version>0.0.1-SNAPSHOT</version>
          <name>office2pdf</name>
          <description>Demo project for Spring Boot</description>
      
          <properties>
              <java.version>1.8</java.version>
          </properties>
      
          <dependencies>
      
              <dependency>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter-web</artifactId>
              </dependency>
      
              <dependency>
                  <groupId>com.artofsolving</groupId>
                  <artifactId>jodconverter</artifactId>
                  <version>2.2.2</version><!--2.2.2是红色的,因为Maven官方只有2.2.1版本,这里是手动导入的-->
              </dependency>
      
              <dependency>
                  <groupId>org.openoffice</groupId>
                  <artifactId>juh</artifactId>
                  <version>3.2.1</version>
              </dependency>
              <dependency>
                  <groupId>org.openoffice</groupId>
                  <artifactId>ridl</artifactId>
                  <version>3.2.1</version>
              </dependency>
              <dependency>
                  <groupId>org.openoffice</groupId>
                  <artifactId>unoil</artifactId>
                  <version>3.2.1</version>
              </dependency>
              <dependency>
                  <groupId>commons-cli</groupId>
                  <artifactId>commons-cli</artifactId>
                  <version>1.1</version>
                  <optional>true</optional>
              </dependency>
              <dependency>
                  <groupId>commons-io</groupId>
                  <artifactId>commons-io</artifactId>
                  <version>1.4</version>
              </dependency>
              <dependency>
                  <groupId>com.thoughtworks.xstream</groupId>
                  <artifactId>xstream</artifactId>
                  <version>1.3.1</version>
              </dependency>
      
          </dependencies>
      
          <build>
              <plugins>
                  <plugin>
                      <groupId>org.springframework.boot</groupId>
                      <artifactId>spring-boot-maven-plugin</artifactId>
                  </plugin>
              </plugins>
          </build>
      
      </project>
      

    2. jodconverter使用的是2.2.2版本,需要手动导入。Maven官方目前只有2.2.1
  3. demo下载地址(直接运行main方法即可)
  4. 支持.pptx,.docx格式转换

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

墨咖

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值