File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
src/main/java/formflow/library/file Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,9 @@ public class FileConversionService {
51
51
@ Value ("${form-flow.uploads.file-conversion.max-conversion-size:}" )
52
52
private Integer maxConversionSize ;
53
53
54
+ @ Value ("${form-flow.uploads.file-conversion.max-pages:}" )
55
+ private Integer maxPages ;
56
+
54
57
@ Value ("${form-flow.uploads.max-file-size}" )
55
58
Integer maxFileSize ;
56
59
@@ -313,6 +316,12 @@ private Set<MultipartFile> convertOfficeDocumentToPDF(MultipartFile file) {
313
316
314
317
reader = new PdfReader (compressedPDFFile .getAbsolutePath ());
315
318
int totalPages = reader .getNumberOfPages ();
319
+
320
+ if (maxPages != null && totalPages > maxPages ) {
321
+ log .warn ("Too many pages found for PDF conversion. Only converting {} of {} pages." , maxPages , totalPages );
322
+ totalPages = maxPages ;
323
+ }
324
+
316
325
if (totalPages > 1 ) {
317
326
for (int i = 1 ; i <= totalPages ; i ++) {
318
327
String outputFilePath = compressedPDFFile .getAbsolutePath () + "_page_" + i + ".pdf" ;
You can’t perform that action at this time.
0 commit comments