From 68b49efb4da346edb42a5d8ebb39af47207402bd Mon Sep 17 00:00:00 2001
From: yxh <172933527@qq.com>
Date: 星期一, 12 十月 2026 11:14:13 +0800
Subject: [PATCH] 修改了报销校验
---
ruoyi-common/src/main/java/com/ruoyi/common/utils/MergeFilesToPDFUtils.java | 40 ++++++++++++++++++++++++++--------------
1 files changed, 26 insertions(+), 14 deletions(-)
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/MergeFilesToPDFUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/MergeFilesToPDFUtils.java
index ac164ca..ba13ac9 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/MergeFilesToPDFUtils.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/MergeFilesToPDFUtils.java
@@ -76,11 +76,16 @@
* @param outputPath
*/
public Boolean wordtoPdf(String inputPath, String outputPath) {
+ // Spire.Doc 鐨� Document 鎸佹湁鏂囦欢鍙ユ焺锛屽繀椤绘樉寮忓叧闂紝鍚﹀垯鍙ユ焺瑕佺瓑 finalize 鎵嶉噴鏀撅紝涓斾細鍗犵敤婧愭枃浠�
Document doc = new Document();
- //鍔犺浇Word
- doc.loadFromFile(inputPath);
- //淇濆瓨涓篜DF鏍煎紡
- doc.saveToFile(outputPath, FileFormat.PDF);
+ try {
+ //鍔犺浇Word
+ doc.loadFromFile(inputPath);
+ //淇濆瓨涓篜DF鏍煎紡
+ doc.saveToFile(outputPath, FileFormat.PDF);
+ } finally {
+ doc.close();
+ }
return true;
}
@@ -91,18 +96,25 @@
com.itextpdf.text.Document document = new com.itextpdf.text.Document();
log.info("fileName鐨勫叏璺緞锛歿}", archived + "/" + fileName);
PdfCopy copy = new PdfCopy(document, new FileOutputStream(archived + "/" + fileName));
- document.open();
-
- for (String pdfFile : pdfFiles) {
- PdfReader reader = new PdfReader(pdfFile);
- int totalPages = reader.getNumberOfPages();
- for (int page = 1; page <= totalPages; page++) {
- PdfImportedPage importedPage = copy.getImportedPage(reader, page);
- copy.addPage(importedPage);
+ // 鍚堝苟杩囩▼涓换浣曚竴姝ユ姏寮傚父閮藉繀椤诲叧闂� document锛歞ocument.close() 浼氱骇鑱斿叧闂� PdfWriter 鍙婂叾杈撳嚭娴侊紝
+ // 鍚﹀垯杈撳嚭娴佸彞鏌勪細琚暱鏃堕棿鍗犵敤锛堜緷璧� finalize 鎵嶈兘閲婃斁锛夛紝涓斿紓甯告椂鏂囦欢鍐呭涓嶅畬鏁�
+ try {
+ document.open();
+ for (String pdfFile : pdfFiles) {
+ PdfReader reader = new PdfReader(pdfFile);
+ try {
+ int totalPages = reader.getNumberOfPages();
+ for (int page = 1; page <= totalPages; page++) {
+ PdfImportedPage importedPage = copy.getImportedPage(reader, page);
+ copy.addPage(importedPage);
+ }
+ } finally {
+ reader.close();
+ }
}
- reader.close();
+ } finally {
+ document.close();
}
- document.close();
}
}
--
Gitblit v1.9.3