refactor: remove redundant variables and fix form copy logic

- Remove redundant variable declarations
- Skip form copying/transformation for portrait orientation
- Skip form copying/transformation when source has rotated pages
This commit is contained in:
OUNZAR Aymane 2025-11-05 14:49:39 +01:00
parent 28f12acef8
commit d7fa60d670

View File

@ -87,8 +87,7 @@ public class MultiPageLayoutController {
pagesPerSheet = cols * rows; pagesPerSheet = cols * rows;
break; break;
default: default:
throw new IllegalArgumentException( throw new IllegalArgumentException("Mode must be CUSTOM or DEFAULT");
"Mode must be CUSTOM or DEFAULT");
} }
MultipartFile file = request.getFileInput(); MultipartFile file = request.getFileInput();
@ -159,8 +158,8 @@ public class MultiPageLayoutController {
int adjustedPageIndex = int adjustedPageIndex =
i % pagesPerSheet; // Close the current content stream and create a new i % pagesPerSheet; // Close the current content stream and create a new
// page and content stream // page and content stream
int rowIndex = 0; int rowIndex;
int colIndex = 0; int colIndex;
switch (pageOrder) { switch (pageOrder) {
case "LR_TD": // LeftRight, then TopDown case "LR_TD": // LeftRight, then TopDown
@ -215,7 +214,7 @@ public class MultiPageLayoutController {
// If any source page is rotated, skip form copying/transformation entirely // If any source page is rotated, skip form copying/transformation entirely
boolean hasRotation = FormUtils.hasAnyRotatedPage(sourceDocument); boolean hasRotation = FormUtils.hasAnyRotatedPage(sourceDocument);
if (hasRotation) { if (hasRotation || "LANDSCAPE".equals(orientation)) {
log.info("Source document has rotated pages; skipping form field copying."); log.info("Source document has rotated pages; skipping form field copying.");
} else { } else {
try { try {