md
This commit is contained in:
parent
96fe57dad8
commit
e998ad2a33
@ -106,13 +106,13 @@
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.mascloud</groupId>-->
|
||||
<!-- <artifactId>massdk</artifactId>-->
|
||||
<!-- <version>1.0.3</version>-->
|
||||
<!-- <scope>system</scope>-->
|
||||
<!-- <systemPath>${project.basedir}/lib/masmgc.sdk.sms-1.0.3-SNAPSHOT.jar</systemPath>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.mascloud</groupId>
|
||||
<artifactId>massdk</artifactId>
|
||||
<version>1.0.3</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/masmgc.sdk.sms-1.0.3-SNAPSHOT.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package com.xdadan.erp.emis.service.warehouse;
|
||||
|
||||
//import com.aspose.words.*;
|
||||
import com.aspose.words.*;
|
||||
import com.deepoove.poi.XWPFTemplate;
|
||||
import com.deepoove.poi.config.Configure;
|
||||
import com.deepoove.poi.data.PictureType;
|
||||
@ -12,9 +12,6 @@ import com.xdadan.erp.common.utils.StringUtils;
|
||||
import com.xdadan.erp.emis.domain.vo.Cargo;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
@ -25,17 +22,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DocUtils {
|
||||
|
||||
// 字体目录
|
||||
public static String FONT_PATH="";
|
||||
|
||||
@Value("${system.fontPath}")
|
||||
public void setFontPath(String fontPath) {
|
||||
DocUtils.FONT_PATH = fontPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充数据
|
||||
* @param input 输入word文件数据流
|
||||
@ -53,13 +41,13 @@ public class DocUtils {
|
||||
}
|
||||
|
||||
// 查看缺少的字体
|
||||
// private static class FontSubstitutionWarningCollector implements IWarningCallback {
|
||||
// public void warning(WarningInfo info) {
|
||||
// if (info.getWarningType() == WarningType.FONT_SUBSTITUTION) {
|
||||
// log.error("==>font miss==>{}", info.getDescription());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
private static class FontSubstitutionWarningCollector implements IWarningCallback {
|
||||
public void warning(WarningInfo info) {
|
||||
if (info.getWarningType() == WarningType.FONT_SUBSTITUTION) {
|
||||
log.error("==>font miss==>{}", info.getDescription());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* word转换为pdf
|
||||
@ -68,24 +56,24 @@ public class DocUtils {
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void wordToPdf(InputStream wordInput, OutputStream pdfOutput) throws Exception {
|
||||
// getLicense();
|
||||
// //通过aspose-words.jar中的类转换文件
|
||||
// Document wordDoc = new Document(wordInput);
|
||||
// FontSubstitutionWarningCollector callback = new FontSubstitutionWarningCollector();
|
||||
// wordDoc.setWarningCallback(callback);
|
||||
// if(!StringUtils.isEmpty(DocUtils.FONT_PATH)) {
|
||||
// FontSettings.setFontsFolder(DocUtils.FONT_PATH, false);
|
||||
// }
|
||||
// PdfSaveOptions pso = new PdfSaveOptions();
|
||||
// wordDoc.save(pdfOutput, pso);
|
||||
getLicense();
|
||||
//通过aspose-words.jar中的类转换文件
|
||||
Document wordDoc = new Document(wordInput);
|
||||
FontSubstitutionWarningCollector callback = new FontSubstitutionWarningCollector();
|
||||
wordDoc.setWarningCallback(callback);
|
||||
if(!StringUtils.isEmpty(Config.FONT_PATH)) {
|
||||
FontSettings.setFontsFolder(DocUtils.FONT_PATH, false);
|
||||
}
|
||||
PdfSaveOptions pso = new PdfSaveOptions();
|
||||
wordDoc.save(pdfOutput, pso);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private static void getLicense() {
|
||||
// try (InputStream is = DocUtils.class.getClassLoader().getResourceAsStream("License.xml")) {
|
||||
// License license = new License();
|
||||
// license.setLicense(is);
|
||||
// }
|
||||
try (InputStream is = DocUtils.class.getClassLoader().getResourceAsStream("License.xml")) {
|
||||
License license = new License();
|
||||
license.setLicense(is);
|
||||
}
|
||||
}
|
||||
|
||||
public static void genPdfByDocxTpl(InputStream tplStream,Map fillDataMap,OutputStream os) throws Exception {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user