From aeb7d068be92312dcdcea75e1240bcf2a78dd0fe Mon Sep 17 00:00:00 2001
From: linwe <872216996@qq.com>
Date: Mon, 29 Jul 2024 16:49:58 +0800
Subject: [PATCH] 代码优化
---
src/main/java/org/springblade/common/utils/WordToPdfUtils.java | 28 ++++++++++++----------------
1 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/src/main/java/org/springblade/common/utils/WordToPdfUtils.java b/src/main/java/org/springblade/common/utils/WordToPdfUtils.java
index 011a972..7b23f8c 100644
--- a/src/main/java/org/springblade/common/utils/WordToPdfUtils.java
+++ b/src/main/java/org/springblade/common/utils/WordToPdfUtils.java
@@ -1,9 +1,5 @@
package org.springblade.common.utils;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-
public class WordToPdfUtils {
// https://srgdjczzxtpt.com:2080/gminio/jczz/upload/20240710/ade086b8d725a08631b62d812a63f6da.docx
@@ -15,18 +11,18 @@
// 判断文件后缀名是否doc,ppt,xls
if (fileName.endsWith(".doc") || fileName.endsWith(".docx")) {
// 获取文件流
- URL url = new URL(pdfPath);
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection.setRequestProperty("User-Agent", "Mozilla/5.0");
- // 获取文件名
- String orFileName = fileName.substring(0, fileName.lastIndexOf("."));
- InputStream inputStream = connection.getInputStream();
- long timeMillis = System.currentTimeMillis();
- // String filePathPdf = "/data/app/jczz/pdf/" + orFileName + "_" + timeMillis + ".pdf";
- String filePathPdf = "D:\\公司\\" + orFileName + "_" + timeMillis + ".pdf";
- com.aspose.words.Document doc = new com.aspose.words.Document(inputStream);
- doc.save(filePathPdf, com.aspose.words.SaveFormat.PDF);
- return filePathPdf;
+ // URL url = new URL(pdfPath);
+ // HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ // connection.setRequestProperty("User-Agent", "Mozilla/5.0");
+ // // 获取文件名
+ // String orFileName = fileName.substring(0, fileName.lastIndexOf("."));
+ // InputStream inputStream = connection.getInputStream();
+ // long timeMillis = System.currentTimeMillis();
+ // // String filePathPdf = "/data/app/jczz/pdf/" + orFileName + "_" + timeMillis + ".pdf";
+ // String filePathPdf = "D:\\公司\\" + orFileName + "_" + timeMillis + ".pdf";
+ // com.aspose.words.Document doc = new com.aspose.words.Document(inputStream);
+ // doc.save(filePathPdf, com.aspose.words.SaveFormat.PDF);
+ return "";
} else {
throw new Exception("文件格式不正确");
}
--
Gitblit v1.9.3