|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package util.convertPDF;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
|
|
import com.aspose.words.License;
|
|
|
|
|
import com.aspose.words.SaveFormat;
|
|
|
|
|
import com.itextpdf.text.Document;
|
|
|
|
@ -41,7 +42,7 @@ public final class PDFConverUtil {
|
|
|
|
|
types.put(EXCEL, Arrays.asList("XLS", "XLSX"));
|
|
|
|
|
types.put(PPT, Arrays.asList("PPT"));
|
|
|
|
|
types.put(PPTX, Arrays.asList("PPTX"));
|
|
|
|
|
types.put(IMG, Arrays.asList("JPEG", "JPG", "PNG"));
|
|
|
|
|
// types.put(IMG, Arrays.asList("JPEG", "JPG", "PNG"));
|
|
|
|
|
types.put(OTHER, Arrays.asList("OOXML", "RTF HTML", "OpenDocument", "EPUB", "XPS", "SWF"));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -477,6 +478,15 @@ public final class PDFConverUtil {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 判断是否可以生成PDF文件
|
|
|
|
|
* @param fileName
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public static boolean isCreatePdf(String fileName) {
|
|
|
|
|
return types.values().stream().anyMatch(item -> item.contains(getFileSuffix(fileName).toUpperCase()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能描述: <br>
|
|
|
|
|
* 取文件名后缀
|
|
|
|
@ -487,6 +497,7 @@ public final class PDFConverUtil {
|
|
|
|
|
* @Date: 2022/12/13 21:51
|
|
|
|
|
*/
|
|
|
|
|
private static String getFileSuffix(String fileName) {
|
|
|
|
|
Assert.isTrue(fileName.contains("."), "非法的文件名,文件名必须要有文件类型!");
|
|
|
|
|
String[] split = fileName.split("\\.");
|
|
|
|
|
return split[split.length - 1];
|
|
|
|
|
}
|
|
|
|
|