Convert office document into PDF format - a project (use openoffice)

  1. Preparing the Environment
    1. wins10 environmental testing: first download the latest version of openoffice tools , installation services ,, win + r to open the command prompt, enter cmd after the installation is complete, cd C: \ Program Files ( x86) \ OpenOffice 4 \ program, execute the statement in the catalog soffice -headless -accept = "socket, host = 127.0.0.1, port = 8100; urp;" -nofirststartwizard; service installation is complete, view the port number netstat -ano | findstr "8100" View service name: tasklist | findstr "8100 "( reference connection )
    2. Linux environment to install openoffice Baidu started just fine.
  2. Dependent jar package
    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 using version 2.2.2, you need to manually import. At present, only official Maven 2.2.1
  3. Download demo (main method can be run directly)
  4. Support .pptx, .docx format conversion
Published 37 original articles · won praise 6 · views 20000 +

Guess you like

Origin blog.csdn.net/qq_37335810/article/details/104370358