|
@@ -3,7 +3,6 @@ package com.qmth.distributed.print.business.service.impl;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.aliyun.oss.common.utils.BinaryUtil;
|
|
|
-import com.aspose.words.PaperSize;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.itextpdf.text.DocumentException;
|
|
|
import com.itextpdf.text.pdf.PdfReader;
|
|
@@ -18,7 +17,10 @@ import com.qmth.distributed.print.business.enums.PageSizeEnum;
|
|
|
import com.qmth.distributed.print.business.enums.UploadFileEnum;
|
|
|
import com.qmth.distributed.print.business.mapper.BasicAttachmentMapper;
|
|
|
import com.qmth.distributed.print.business.service.BasicAttachmentService;
|
|
|
-import com.qmth.distributed.print.business.util.*;
|
|
|
+import com.qmth.distributed.print.business.util.HtmlToPdfUtil;
|
|
|
+import com.qmth.distributed.print.business.util.OssUtil;
|
|
|
+import com.qmth.distributed.print.business.util.PdfUtil;
|
|
|
+import com.qmth.distributed.print.business.util.ServletUtil;
|
|
|
import com.qmth.distributed.print.common.contant.SystemConstant;
|
|
|
import com.qmth.distributed.print.common.enums.ExceptionResultEnum;
|
|
|
import com.qmth.distributed.print.common.util.HexUtils;
|
|
@@ -61,9 +63,6 @@ public class BasicAttachmentServiceImpl extends ServiceImpl<BasicAttachmentMappe
|
|
|
@Autowired
|
|
|
private DictionaryConfig dictionaryConfig;
|
|
|
|
|
|
- @Resource
|
|
|
- AsposePdfUtil asposePdfUtil;
|
|
|
-
|
|
|
/**
|
|
|
* 保存附件
|
|
|
*
|
|
@@ -143,13 +142,13 @@ public class BasicAttachmentServiceImpl extends ServiceImpl<BasicAttachmentMappe
|
|
|
String destUrl = SystemConstant.PDF_TEMP_FILES_DIR + File.separator + pdfDirName;
|
|
|
// destUrl = destUrl.replaceAll("\\\\","/");
|
|
|
|
|
|
-// HtmlToPdfUtil.convert(localHtmlFile.getPath(), destUrl, PageSizeEnum.A3);
|
|
|
- File pdfFile = asposePdfUtil.documentToPdf(localHtmlFile.getPath(), destUrl, PaperSize.A3);
|
|
|
-// File pdfFile = new File(destUrl);
|
|
|
-// if (!pdfFile.exists()) {
|
|
|
-// pdfFile.getParentFile().mkdirs();
|
|
|
-// pdfFile.createNewFile();
|
|
|
-// }
|
|
|
+ HtmlToPdfUtil.convert(localHtmlFile.getPath(), destUrl, PageSizeEnum.A3);
|
|
|
+// File pdfFile = asposePdfUtil.documentToPdf(localHtmlFile.getPath(), destUrl, PaperSize.A3);
|
|
|
+ File pdfFile = new File(destUrl);
|
|
|
+ if (!pdfFile.exists()) {
|
|
|
+ pdfFile.getParentFile().mkdirs();
|
|
|
+ pdfFile.createNewFile();
|
|
|
+ }
|
|
|
pdfDto = PdfUtil.addPdfPage(pdfFile);
|
|
|
localFileList.add(new PdfDto(pdfFile.getPath(), PageSizeEnum.A3, pdfDto.getPageCount()));
|
|
|
fileMd5 = DigestUtils.md5Hex(new FileInputStream(pdfFile));
|
|
@@ -167,8 +166,8 @@ public class BasicAttachmentServiceImpl extends ServiceImpl<BasicAttachmentMappe
|
|
|
jsonObject.put(SystemConstant.TYPE, SystemConstant.LOCAL);
|
|
|
jsonObject.put(SystemConstant.PATH, stringJoiner.toString());
|
|
|
String destUrl = finalFile.getPath().replaceAll(SystemConstant.HTML_PREFIX, SystemConstant.PDF_PREFIX).replaceAll(UploadFileEnum.HTML.name().toLowerCase(), UploadFileEnum.PDF.name().toLowerCase());
|
|
|
-// HtmlToPdfUtil.convert(finalFile.getPath(), destUrl, PageSizeEnum.A3);
|
|
|
- File pdfFile = asposePdfUtil.documentToPdf(finalFile.getPath(), destUrl, PaperSize.A3);
|
|
|
+ HtmlToPdfUtil.convert(finalFile.getPath(), destUrl, PageSizeEnum.A3);
|
|
|
+// File pdfFile = asposePdfUtil.documentToPdf(finalFile.getPath(), destUrl, PaperSize.A3);
|
|
|
jsonObject.put(SystemConstant.PDF_PATH, destUrl);
|
|
|
}
|
|
|
jsonObject.put(SystemConstant.UPLOAD_TYPE, new UploadFileEnum[]{
|
|
@@ -298,13 +297,13 @@ public class BasicAttachmentServiceImpl extends ServiceImpl<BasicAttachmentMappe
|
|
|
String pdfDirName = pdfStringJoiner.toString();
|
|
|
String destUrl = SystemConstant.PDF_TEMP_FILES_DIR + File.separator + pdfDirName;
|
|
|
|
|
|
-// File pdfFile = new File(destUrl);
|
|
|
-// if (!pdfFile.exists()) {
|
|
|
-// pdfFile.getParentFile().mkdirs();
|
|
|
-// pdfFile.createNewFile();
|
|
|
-// }
|
|
|
-// HtmlToPdfUtil.convert(htmlFile.getPath(), destUrl, PageSizeEnum.A4);
|
|
|
- File pdfFile = asposePdfUtil.documentToPdf(htmlFile.getPath(), destUrl, PaperSize.A4);
|
|
|
+ File pdfFile = new File(destUrl);
|
|
|
+ if (!pdfFile.exists()) {
|
|
|
+ pdfFile.getParentFile().mkdirs();
|
|
|
+ pdfFile.createNewFile();
|
|
|
+ }
|
|
|
+ HtmlToPdfUtil.convert(htmlFile.getPath(), destUrl, PageSizeEnum.A4);
|
|
|
+// File pdfFile = asposePdfUtil.documentToPdf(htmlFile.getPath(), destUrl, PaperSize.A4);
|
|
|
String htmlFileMd5 = DigestUtils.md5Hex(new FileInputStream(htmlFile));
|
|
|
String pdfFileMd5 = DigestUtils.md5Hex(new FileInputStream(pdfFile));
|
|
|
PdfDto pdfDto = null;
|