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: 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: 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="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> </component>
</module> </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: 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: 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="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> </component>
</module> </module>

View File

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

View File

@ -2335,10 +2335,13 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
response.setHeader("Content-Disposition", "attachment;fileName=" + fileName + ".pdf"); response.setHeader("Content-Disposition", "attachment;fileName=" + fileName + ".pdf");
ByteArrayOutputStream bos = new ByteArrayOutputStream(); 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(); response.flushBuffer();
IOUtils.closeQuietly(fis); IOUtils.closeQuietly(fis);

View File

@ -1,6 +1,6 @@
package com.xdadan.erp.emis.service.warehouse; package com.xdadan.erp.emis.service.warehouse;
import com.aspose.words.*; //import com.aspose.words.*;
import com.deepoove.poi.XWPFTemplate; import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.config.Configure; import com.deepoove.poi.config.Configure;
import com.deepoove.poi.data.PictureType; import com.deepoove.poi.data.PictureType;
@ -53,13 +53,13 @@ public class DocUtils {
} }
// 查看缺少的字体 // 查看缺少的字体
private static class FontSubstitutionWarningCollector implements IWarningCallback { // private static class FontSubstitutionWarningCollector implements IWarningCallback {
public void warning(WarningInfo info) { // public void warning(WarningInfo info) {
if (info.getWarningType() == WarningType.FONT_SUBSTITUTION) { // if (info.getWarningType() == WarningType.FONT_SUBSTITUTION) {
log.error("==>font miss==>{}", info.getDescription()); // log.error("==>font miss==>{}", info.getDescription());
} // }
} // }
} // }
/** /**
* word转换为pdf * word转换为pdf
@ -68,24 +68,24 @@ public class DocUtils {
* @throws Exception * @throws Exception
*/ */
public static void wordToPdf(InputStream wordInput, OutputStream pdfOutput) throws Exception { public static void wordToPdf(InputStream wordInput, OutputStream pdfOutput) throws Exception {
getLicense(); // getLicense();
//通过aspose-words.jar中的类转换文件 // //通过aspose-words.jar中的类转换文件
Document wordDoc = new Document(wordInput); // Document wordDoc = new Document(wordInput);
FontSubstitutionWarningCollector callback = new FontSubstitutionWarningCollector(); // FontSubstitutionWarningCollector callback = new FontSubstitutionWarningCollector();
wordDoc.setWarningCallback(callback); // wordDoc.setWarningCallback(callback);
if(!StringUtils.isEmpty(DocUtils.FONT_PATH)) { // if(!StringUtils.isEmpty(DocUtils.FONT_PATH)) {
FontSettings.setFontsFolder(DocUtils.FONT_PATH, false); // FontSettings.setFontsFolder(DocUtils.FONT_PATH, false);
} // }
PdfSaveOptions pso = new PdfSaveOptions(); // PdfSaveOptions pso = new PdfSaveOptions();
wordDoc.save(pdfOutput, pso); // wordDoc.save(pdfOutput, pso);
} }
@SneakyThrows @SneakyThrows
private static void getLicense() { private static void getLicense() {
try (InputStream is = DocUtils.class.getClassLoader().getResourceAsStream("License.xml")) { // try (InputStream is = DocUtils.class.getClassLoader().getResourceAsStream("License.xml")) {
License license = new License(); // License license = new License();
license.setLicense(is); // license.setLicense(is);
} // }
} }
public static void genPdfByDocxTpl(InputStream tplStream,Map fillDataMap,OutputStream os) throws Exception { public static void genPdfByDocxTpl(InputStream tplStream,Map fillDataMap,OutputStream os) throws Exception {