This commit is contained in:
linfso 2024-07-28 16:44:18 +08:00
parent 00dda5bb5e
commit c73a961519
5 changed files with 35 additions and 50 deletions

View File

@ -270,14 +270,5 @@
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-xml:1.14" level="project" />
<orderEntry type="library" name="Maven: xml-apis:xml-apis-ext:1.3.04" level="project" />
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-codec:1.14" level="project" />
<orderEntry type="module-library">
<library name="Maven: com.aspose:aspose-words:15.8.0">
<CLASSES>
<root url="jar://$MODULE_DIR$/../emis-biz/lib/aspose-words-15.8.0-jdk16.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>

View File

@ -229,14 +229,5 @@
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-xml:1.14" level="project" />
<orderEntry type="library" name="Maven: xml-apis:xml-apis-ext:1.3.04" level="project" />
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-codec:1.14" level="project" />
<orderEntry type="module-library">
<library name="Maven: com.aspose:aspose-words:15.8.0">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/aspose-words-15.8.0-jdk16.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>

View File

@ -152,13 +152,13 @@
<version>1.10.6</version>
</dependency>
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-words</artifactId>
<version>15.8.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/aspose-words-15.8.0-jdk16.jar</systemPath>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.aspose</groupId>-->
<!-- <artifactId>aspose-words</artifactId>-->
<!-- <version>15.8.0</version>-->
<!-- <scope>system</scope>-->
<!-- <systemPath>${project.basedir}/lib/aspose-words-15.8.0-jdk16.jar</systemPath>-->
<!-- </dependency>-->
<!-- <dependency>-->

View File

@ -2335,10 +2335,13 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
response.setHeader("Content-Disposition", "attachment;fileName=" + fileName + ".pdf");
ByteArrayOutputStream bos = new ByteArrayOutputStream();
template.write(bos);
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
// 写入流
// template.write(bos);
template.write(outputStream);
// ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
// DocUtils.wordToPdf(bis, outputStream);
DocUtils.wordToPdf(bis, outputStream);
response.flushBuffer();
IOUtils.closeQuietly(fis);

View File

@ -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;
@ -53,13 +53,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 +68,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(DocUtils.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 {