Browse Source

资源转换bug修改

东方国信-蔡芳 6 months ago
parent
commit
cac1ebdb99

+ 12 - 2
snowy-plugin/snowy-plugin-disk/snowy-plugin-disk-func/src/main/java/vip/xiaonuo/disk/util/FileToPdfUtils.java

@@ -4,12 +4,13 @@ import com.aspose.cells.Workbook;
 import com.aspose.slides.Presentation;
 import com.aspose.slides.SaveFormat;
 import com.aspose.words.Document;
+import lombok.extern.slf4j.Slf4j;
 
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.InputStream;
 
-
+@Slf4j
 public class FileToPdfUtils {
 /**
  * 文件转换
@@ -110,6 +111,8 @@ public static boolean getDocLicense() {
  * @Date: 2019/10/10 13:41
  */
 public static void excel2pdf(String source, String target, String fileExt) {
+    log.error("excel2pdf:source路径=======================》"+source);
+    log.error("excel2pdf:target路径=======================》"+target);
     // 验证License 若不验证则转化出的pdf文档会有水印产生
     if (!getExcelLicense()) {
         return;
@@ -130,9 +133,11 @@ public static void excel2pdf(String source, String target, String fileExt) {
         // 输出路径
         File pdfFile = new File(target +  File.separator + (fileName.replace(fileExt, "pdf")));
         FileOutputStream fileOS = new FileOutputStream(pdfFile);
+        log.error("====================走没走到这===========================");
         wb.save(fileOS, com.aspose.cells.SaveFormat.PDF);
     } catch (Exception e) {
         e.printStackTrace();
+        log.error("excel转成pdf=====================================>"+e.getMessage());
     }
 }
 
@@ -144,6 +149,8 @@ public static void excel2pdf(String source, String target, String fileExt) {
  * @Date: 2019/10/10 13:46
  */
 public static void ppt2pdf(String source, String target, String fileExt) {
+    log.error("ppt2pdf:source路径=======================》"+source);
+    log.error("ppt2pdf:target路径=======================》"+target);
     // 验证License 若不验证则转化出的pdf文档会有水印产生
     if (!getPPTLicense()) {
         return;
@@ -164,10 +171,12 @@ public static void ppt2pdf(String source, String target, String fileExt) {
         //输入pdf路径
         Presentation pres = new Presentation(source);
         FileOutputStream fileOS = new FileOutputStream(file);
+        log.error("====================走没走到这===========================");
         pres.save(fileOS, SaveFormat.Pdf);
         fileOS.close();
     } catch (Exception e) {
         e.printStackTrace();
+        log.error("ppt转成pdf=====================================>"+e.getMessage());
     }
 }
 
@@ -202,12 +211,13 @@ public static void doc2pdf(String source, String target, String fileExt) {
         doc.save(os, com.aspose.words.SaveFormat.PDF);
     } catch (Exception e) {
         e.printStackTrace();
+        log.error("doc转成pdf=====================================>"+e.getMessage());
     }
 }
 
 
     public static void main(String[] args) {
-        FileToPdfUtils.officeToPdf("C:\\Users\\Lenovo\\AppData\\Local\\Temp\\minio-converter\\10380841-1caa-44d8-be4e-0ca147fa0a7a_4126f65c6160e8daa287c6309e06a020.docx", "C:\\Users\\Lenovo\\AppData\\Local\\Temp\\minio-converter\\");
+        FileToPdfUtils.officeToPdf("D:\\xwechat_files\\wxid_iymttuatgsb222_b16a\\msg\\file\\2025-08\\kj飞行学院(合同约定)(2)(1).xlsx", "C:\\Users\\Lenovo\\AppData\\Local\\Temp\\minio-converter\\");
     }