【更新】优化代码,pdf文件预览无需转换
This commit is contained in:
parent
ce70caa824
commit
7e2eeaef7c
@ -96,4 +96,29 @@ public interface MediaTypeConstant {
|
||||
* 文档pptx格式
|
||||
*/
|
||||
String DOC_PPTX = "pptx";
|
||||
|
||||
/**
|
||||
* 文档pdf格式
|
||||
*/
|
||||
String DOC_PDF = "pdf";
|
||||
|
||||
/**
|
||||
* 文件html格式
|
||||
*/
|
||||
String FILE_HTML = "html";
|
||||
|
||||
/**
|
||||
* 文件htm格式
|
||||
*/
|
||||
String FILE_HTM = "htm";
|
||||
|
||||
/**
|
||||
* 文件swf格式
|
||||
*/
|
||||
String FILE_SWF = "swf";
|
||||
|
||||
/**
|
||||
* 文件flash格式
|
||||
*/
|
||||
String FILE_FLASH = "flash";
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ public class LibreOfficeUtil {
|
||||
* @date 2020/7/6 15:02
|
||||
*/
|
||||
public static void convertToPdf(InputStream inputStream, OutputStream outputStream, String fileSuffix) {
|
||||
if(!MediaTypeConstant.DOC_PDF.equals(fileSuffix)) {
|
||||
init();
|
||||
final DocumentFormatEnum documentFormatEnum = DocumentFormatEnum.valueOf(fileSuffix.toUpperCase());
|
||||
final DocumentFormat format = documentFormatEnum.getFormFormat();
|
||||
@ -59,6 +60,7 @@ public class LibreOfficeUtil {
|
||||
}
|
||||
log.info(">>> 文件转换结束");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据文件后缀判断是否图片
|
||||
@ -88,7 +90,8 @@ public class LibreOfficeUtil {
|
||||
|| MediaTypeConstant.DOC_XLS.equals(fileSuffix)
|
||||
|| MediaTypeConstant.DOC_XLSX.equals(fileSuffix)
|
||||
|| MediaTypeConstant.DOC_PPT.equals(fileSuffix)
|
||||
|| MediaTypeConstant.DOC_PPTX.equals(fileSuffix);
|
||||
|| MediaTypeConstant.DOC_PPTX.equals(fileSuffix)
|
||||
|| MediaTypeConstant.DOC_PDF.equals(fileSuffix);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -103,7 +106,8 @@ public class LibreOfficeUtil {
|
||||
|| MediaTypeConstant.DOC_DOC.equals(fileSuffix)
|
||||
|| MediaTypeConstant.DOC_DOCX.equals(fileSuffix)
|
||||
|| MediaTypeConstant.DOC_PPT.equals(fileSuffix)
|
||||
|| MediaTypeConstant.DOC_PPTX.equals(fileSuffix)) {
|
||||
|| MediaTypeConstant.DOC_PPTX.equals(fileSuffix)
|
||||
|| MediaTypeConstant.DOC_PDF.equals(fileSuffix)) {
|
||||
return MediaType.APPLICATION_PDF_VALUE;
|
||||
} else {
|
||||
//否则是html类型
|
||||
|
Loading…
x
Reference in New Issue
Block a user