diff --git a/emis-biz/pom.xml b/emis-biz/pom.xml index f841ab799..e8f7fc176 100644 --- a/emis-biz/pom.xml +++ b/emis-biz/pom.xml @@ -106,13 +106,13 @@ - - - - - - - + + com.mascloud + massdk + 1.0.3 + system + ${project.basedir}/lib/masmgc.sdk.sms-1.0.3-SNAPSHOT.jar + diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/service/warehouse/DocUtils.java b/emis-biz/src/main/java/com/xdadan/erp/emis/service/warehouse/DocUtils.java index f9a5da9ae..f24dc0fdf 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/service/warehouse/DocUtils.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/service/warehouse/DocUtils.java @@ -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 {