提交 b662d533 作者: ZhangJingKun

换word解析jar包 zhangjingkun

上级 cf818d6e
...@@ -184,13 +184,22 @@ ...@@ -184,13 +184,22 @@
<artifactId>spring-boot-starter-thymeleaf</artifactId> <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency> </dependency>
<!--word-html处理工具--> <!--word-html处理工具-->
<!-- <dependency>-->
<!-- <groupId>com.aspose</groupId>-->
<!-- <artifactId>aspose-words</artifactId>-->
<!-- <version>15.12.0</version>-->
<!-- <scope>system</scope>-->
<!-- <systemPath>${basedir}/lib/aspose-words-15.12.0-jdk16.jar</systemPath>-->
<!-- </dependency>-->
<dependency> <dependency>
<groupId>com.aspose</groupId> <groupId>com.aspose</groupId>
<artifactId>aspose-words</artifactId> <artifactId>aspose-words</artifactId>
<version>15.12.0</version> <version>18.6</version>
<scope>system</scope> <scope>system</scope>
<systemPath>${basedir}/lib/aspose-words-15.12.0-jdk16.jar</systemPath> <systemPath>${basedir}/lib/aspose-words-18.6-jdk16-crack.jar</systemPath>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.fusesource.hawtbuf</groupId> <groupId>org.fusesource.hawtbuf</groupId>
<artifactId>hawtbuf</artifactId> <artifactId>hawtbuf</artifactId>
......
...@@ -139,20 +139,21 @@ public class DocUtil { ...@@ -139,20 +139,21 @@ public class DocUtil {
* @throws Exception * @throws Exception
*/ */
public static byte[] convertDocHtml2Doc(String content, Boolean isPage) throws Exception { public static byte[] convertDocHtml2Doc(String content, Boolean isPage) throws Exception {
getLicense(); // getLicense();
if (SystemUtils.IS_OS_LINUX) { // if (SystemUtils.IS_OS_LINUX) {
logger.info("doc set font folder"); // logger.info("doc set font folder");
FontSettings.setFontsFolder(fontsPath, false); // FontSettings.setFontsFolder(fontsPath, false);
} // }
Document doc = new Document(); // Document doc = new Document();
DataByteArrayOutputStream dataByteArrayOutputStream = new DataByteArrayOutputStream(); // DataByteArrayOutputStream dataByteArrayOutputStream = new DataByteArrayOutputStream();
DocumentBuilder builder = new DocumentBuilder(doc); // DocumentBuilder builder = new DocumentBuilder(doc);
if (!isPage) // if (!isPage)
content = convertDocHtml2Page(content); // content = convertDocHtml2Page(content);
builder.insertHtml(content); // builder.insertHtml(content);
doc.save(dataByteArrayOutputStream, SaveFormat.DOCX); // doc.save(dataByteArrayOutputStream, SaveFormat.DOCX);
//
return dataByteArrayOutputStream.getData(); // return dataByteArrayOutputStream.getData();
return null;
} }
/** /**
...@@ -160,39 +161,39 @@ public class DocUtil { ...@@ -160,39 +161,39 @@ public class DocUtil {
* @return * @return
* @throws Exception * @throws Exception
*/ */
public static byte[] convertDocHtml2Png(String content, Boolean isPage) throws Exception { // public static byte[] convertDocHtml2Png(String content, Boolean isPage) throws Exception {
getLicense(); // getLicense();
if (SystemUtils.IS_OS_LINUX) { // if (SystemUtils.IS_OS_LINUX) {
logger.info("cover png set font folder"); // logger.info("cover png set font folder");
FontSettings.setFontsFolder(fontsPath, false); // FontSettings.setFontsFolder(fontsPath, false);
} // }
Document doc = new Document(); // Document doc = new Document();
DataByteArrayOutputStream dataByteArrayOutputStream = new DataByteArrayOutputStream(); // DataByteArrayOutputStream dataByteArrayOutputStream = new DataByteArrayOutputStream();
DocumentBuilder builder = new DocumentBuilder(doc); // DocumentBuilder builder = new DocumentBuilder(doc);
if (!isPage) // if (!isPage)
content = convertDocHtml2Page(content); // content = convertDocHtml2Page(content);
builder.insertHtml(content); // builder.insertHtml(content);
doc.save(dataByteArrayOutputStream, SaveFormat.PNG); // doc.save(dataByteArrayOutputStream, SaveFormat.PNG);
//
return dataByteArrayOutputStream.getData(); // return dataByteArrayOutputStream.getData();
} // }
public static byte[] convertDocHtml2Pdf(String content, boolean isPage) throws Exception {
getLicense();
if (SystemUtils.IS_OS_LINUX) {
logger.info("pdf set font folder");
FontSettings.setFontsFolder(fontsPath, false);
}
Document doc = new Document();
DataByteArrayOutputStream dataByteArrayOutputStream = new DataByteArrayOutputStream();
DocumentBuilder builder = new DocumentBuilder(doc);
if (!isPage)
content = convertDocHtml2Page(content);
builder.insertHtml(content);
doc.save(dataByteArrayOutputStream, SaveFormat.PDF);
return dataByteArrayOutputStream.getData(); // public static byte[] convertDocHtml2Pdf(String content, boolean isPage) throws Exception {
} // getLicense();
// if (SystemUtils.IS_OS_LINUX) {
// logger.info("pdf set font folder");
// FontSettings.setFontsFolder(fontsPath, false);
// }
// Document doc = new Document();
// DataByteArrayOutputStream dataByteArrayOutputStream = new DataByteArrayOutputStream();
// DocumentBuilder builder = new DocumentBuilder(doc);
// if (!isPage)
// content = convertDocHtml2Page(content);
// builder.insertHtml(content);
// doc.save(dataByteArrayOutputStream, SaveFormat.PDF);
//
// return dataByteArrayOutputStream.getData();
// }
/** /**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论