From 764d883b5ea3bdc06abbec548b6df0511e567978 Mon Sep 17 00:00:00 2001
From: linwe <872216996@qq.com>
Date: Tue, 03 Sep 2024 09:46:05 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/binlog' into binlog

---
 src/main/java/org/springblade/common/utils/WordToPdfUtils.java |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/src/main/java/org/springblade/common/utils/WordToPdfUtils.java b/src/main/java/org/springblade/common/utils/WordToPdfUtils.java
new file mode 100644
index 0000000..7b23f8c
--- /dev/null
+++ b/src/main/java/org/springblade/common/utils/WordToPdfUtils.java
@@ -0,0 +1,34 @@
+package org.springblade.common.utils;
+
+public class WordToPdfUtils {
+	// https://srgdjczzxtpt.com:2080/gminio/jczz/upload/20240710/ade086b8d725a08631b62d812a63f6da.docx
+
+	public static String wordToPdf(String fileName, String pdfPath) throws Exception {
+		// 判断入参是否有空
+		if (fileName == null || pdfPath == null) {
+			throw new Exception("入参不能为空");
+		}
+		// 判断文件后缀名是否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 "";
+		} else {
+			throw new Exception("文件格式不正确");
+		}
+	}
+
+	public static void main(String[] args) throws Exception {
+		wordToPdf(" 测试.docx", "https://srgdjczzxtpt.com:2080/gminio/jczz/upload/20240710/ade086b8d725a08631b62d812a63f6da.docx");
+	}
+}

--
Gitblit v1.9.3