From 0ab9dfd8f122195e4e9f09bd50c59e0a47450bec Mon Sep 17 00:00:00 2001
From: mitao <2763622819@qq.com>
Date: 星期三, 19 三月 2025 15:50:03 +0800
Subject: [PATCH] fix: resolve merge conflicts in .gitignore

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/PdfUtils.java |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/PdfUtils.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/PdfUtils.java
index 720e6f6..ba43f3f 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/PdfUtils.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/PdfUtils.java
@@ -139,8 +139,7 @@
             }
             String absolutePath = pdfFile.getAbsolutePath();
 
-
-            MultipartFile multipartFile = convertToMultipartFile(stream,fileName.substring(0,fileName.lastIndexOf(".")) );
+            MultipartFile multipartFile = convertFileToMultipartFile(pdfFile);
             String s = tencentCosUtil.upLoadFile(multipartFile,"/wordToPdf");
             return s;
 
@@ -148,6 +147,22 @@
             throw new RuntimeException("PDF转换失败: " + e.getMessage(), e);
         }
     }
+
+    public MultipartFile convertFileToMultipartFile(File file) throws IOException {
+        // 读取文件内容到字节数组
+        byte[] fileContent = Files.readAllBytes(file.toPath());
+
+        // 创建 MultipartFile 对象
+        MultipartFile multipartFile = new MockMultipartFile(
+                file.getName(),       // 文件名
+                file.getName(),       // 原始文件名
+                "application/pdf",  // 内容类型,根据实际情况调整
+                fileContent           // 文件内容
+        );
+
+        return multipartFile;
+    }
+
     // 在使用前检查和配置环境
     public static void setupEnvironment() {
         try {

--
Gitblit v1.7.1