参考 https://gitee.com/zhengqingya/file-convert-util 项目,打包到本地仓库实现doc,docx,html,md,pdf,png转换
https://gitee.com/bestman_456/file-convert-util-ext
1. 安装jar到本地仓库
aspose-words-18.6-jdk16.jar
aspose-cells-8.5.2.jar
Spire.Doc.jar
Spire.Pdf.jar
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-words</artifactId>
<version>18.6</version>
</dependency>
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-cells</artifactId>
<version>8.5.2</version>
</dependency>
<dependency>
<groupId>com.spire</groupId>
<artifactId>spire.doc</artifactId>
<version>2.7.3</version>
</dependency>
<dependency>
<groupId>com.spire</groupId>
<artifactId>spire.pdf</artifactId>
<version>2.6.3</version>
</dependency>
命令
mvn install:install-file -Dfile=D:\workspace\idea_workspace\file-convert-util\lib\Spire.Pdf.jar -DgroupId=com.spire -DartifactId=spire.pdf -Dversion=2.6.3 -Dpackaging=jar
2. 优化代码
保留工具类,去除Application.java,StartAppRunner.java 等
使用FileConvertUtil 工具类API
Word2Html
Word2Pdf
Word2Jpg
Word2Png
Html2Word
Html2Pdf
Html2Jpg
Html2PngBy2
Doc2Docx
Excel2Pdf
Html2Png
Markdown2Html 转换格式不是太完善
Pdf2Word
Pdf2Png
3. 安装
pom.xml添加插件依赖
<!--compiler-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!-- Source -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>default-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<excludes>
<exclude>/logback.xml</exclude>
</excludes>
<includes>
<include>/**</include>
</includes>
</configuration>
</plugin>
mvn clean install后,其他项目可以添加依赖
<dependency>
<groupId>com.yl</groupId>
<artifactId>file-convert-util</artifactId>
<version>1.0.0</version>
</dependency>