linwe
2024-07-29 aeb7d068be92312dcdcea75e1240bcf2a78dd0fe
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("文件格式不正确");
      }