Pre Merge pull request !314 from no honor/wzz/master

This commit is contained in:
no honor 2025-04-14 08:11:29 +00:00 committed by Gitee
commit 175328e12a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 16 additions and 1 deletions

View File

@ -110,6 +110,8 @@ convertMedias = ${KK_CONVERTMEDIAS:avi,mov,wmv,mkv,3gp,rm}
#PDF预览模块设置
#配置PDF文件生成图片的像素大小dpi 越高图片质量越清晰同时也会消耗更多的计算资源
pdf2jpg.dpi = ${KK_PDF2JPG_DPI:144}
# 配置PDF文件生成图片的最大页数
pdf2jpg.maxPageSize = ${KK_PDF2JPG_MAXPAGESIZE:1000000}
#PDF转换超时设置 (低于50页) 温馨提示这里数字仅供参考
pdf.timeout =${KK_pdf_TIMEOUT:90}
#PDF转换超时设置 (高于50小于200页)

View File

@ -50,6 +50,7 @@ public class ConfigConstants {
private static String size;
private static String password;
private static int pdf2JpgDpi;
private static int pdf2JpgMaxPageSize;
private static String officeTypeWeb;
private static String cadPreviewType;
private static Boolean deleteSourceFile;
@ -503,6 +504,18 @@ public class ConfigConstants {
ConfigConstants.pdf2JpgDpi = pdf2JpgDpi;
}
public static int getPdf2JpgMaxPageSize() {
return pdf2JpgMaxPageSize;
}
@Value("${pdf2jpg.maxPageSize:1000000}")
public void pdf2JpgMaxPageSize(int pdf2JpgMaxPageSize) {
setPdf2JpgMaxPageSize(pdf2JpgMaxPageSize);
}
public static void setPdf2JpgMaxPageSize(int pdf2JpgMaxPageSize) {
ConfigConstants.pdf2JpgMaxPageSize = pdf2JpgMaxPageSize;
}
public static String getOfficeTypeWeb() {
return officeTypeWeb;
}

View File

@ -262,7 +262,7 @@ public class FileHandlerService implements InitializingBean {
try {
doc = Loader.loadPDF(pdfFile, filePassword);
doc.setResourceCache(new NotResourceCache());
pageCount[0] = doc.getNumberOfPages();
pageCount[0] = Math.min(doc.getNumberOfPages(), ConfigConstants.getPdf2JpgMaxPageSize());
} catch (IOException e) {
Throwable[] throwableArray = ExceptionUtils.getThrowables(e);
for (Throwable throwable : throwableArray) {