From c5b71cce5614ad22716efbf941a98688589ef65a Mon Sep 17 00:00:00 2001
From: shichongfu <shi_chongfu@163.com>
Date: 星期五, 09 六月 2023 08:57:36 +0800
Subject: [PATCH] 打印转换

---
 src/main/java/com/product/file/util/FileUtils.java |   18 +++++-------------
 1 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/src/main/java/com/product/file/util/FileUtils.java b/src/main/java/com/product/file/util/FileUtils.java
index 77416f6..d97c2bc 100644
--- a/src/main/java/com/product/file/util/FileUtils.java
+++ b/src/main/java/com/product/file/util/FileUtils.java
@@ -557,10 +557,9 @@
             if (placeLocation.indexOf("/") != 0) {
                 placeLocation += "/";
             }
-           
             //绾跨▼鍚屾
             if (threadSync) {
-                boolean b = convertPdf(uploadServer, isEncrypt, file, placeLocation, fileName +"."+tail);
+                boolean b = convertPdf(uploadServer, isEncrypt, file, placeLocation, fileName,tail);
                 if (deleteFile && file.isFile()) {
                     file.delete();
                 }
@@ -570,7 +569,7 @@
                 String finalPlaceLocation = placeLocation;
                 final File ff = FileUtil.copyFile(file, Global.getSystemConfig("temp.dir", "") + "/" + "temp_convert_pdf_" + RandomUtil.randomString(5) + "_" + file.getName(), 0);
                 executorService.submit(() -> {
-                    convertPdf(uploadServer, isEncrypt, ff, finalPlaceLocation, fileName+"."+tail);
+                    convertPdf(uploadServer, isEncrypt, ff, finalPlaceLocation, fileName,tail);
                     if (ff.isFile()) {
                         ff.delete();
                     }
@@ -583,21 +582,14 @@
         return false;
     }
 
-    private static boolean convertPdf(boolean uploadServer, boolean isEncrypt, File file, String placeLocation, String fileName) throws BaseException {
+    private static boolean convertPdf(boolean uploadServer, boolean isEncrypt, File file, String placeLocation, String fileName,String officeType) throws BaseException {
         File pdfFile = null;
         String random = RandomUtil.randomString(5);
         String tempPath = Global.getSystemConfig("temp.dir", "./attachment/temp") + "/" + "convertPDF_" + random + "_" + file.getName();
         String tempPathSuccess = Global.getSystemConfig("temp.dir", "./attachment/temp") + "/" + "convertPDF_success_" + random + ".pdf";
         try {
-            int lastIndex = fileName.lastIndexOf(".");
-            String officeType = fileName.substring(lastIndex+1);
-            fileName=fileName.substring(0,lastIndex);
             FileUtil.copyFile(file, tempPath, 0);
-            if(Global.getPropertyToBoolean("open.office.isEnable", "true")) {//鍚敤oepn office杞崲
-            	pdfFile = PdfConcurrenceUtil.convertToPdf(tempPath, tempPathSuccess);
-            }else{
-            	pdfFile = new File(AsposeUtil.OfficeToPdf(tempPath, tempPathSuccess,officeType));
-        	}
+            pdfFile = PdfConcurrenceUtil.convertToPdf(tempPath, tempPathSuccess,officeType);
             String s = Global.getSystemConfig("temp.dir", "") + "/" + "convertPDF_encryptTemp_" + random + ".pdf";
             FileUtil.copyFile(pdfFile, s, isEncrypt ? 1 : 0);
             pdfFile.delete();
@@ -612,7 +604,7 @@
             throw new BaseException(FileCode.CONVERT_PDF_FILE_FAIL);
         } finally {
             try {
-                if (pdfFile !=null && pdfFile.isFile()) {
+                if (pdfFile!=null && pdfFile.isFile()) {
                     pdfFile.delete();
                 }
                 com.product.common.io.FileUtils.delFile(tempPath);

--
Gitblit v1.9.2