From d7fa60d6707d0f26ff87bac7411b7a76aa4d4e27 Mon Sep 17 00:00:00 2001 From: OUNZAR Aymane Date: Wed, 5 Nov 2025 14:49:39 +0100 Subject: [PATCH] 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 --- .../SPDF/controller/api/MultiPageLayoutController.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/core/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java b/app/core/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java index 2cbf30e4a..1ac51b719 100644 --- a/app/core/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java +++ b/app/core/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java @@ -87,8 +87,7 @@ public class MultiPageLayoutController { pagesPerSheet = cols * rows; break; default: - throw new IllegalArgumentException( - "Mode must be CUSTOM or DEFAULT"); + throw new IllegalArgumentException("Mode must be CUSTOM or DEFAULT"); } MultipartFile file = request.getFileInput(); @@ -159,8 +158,8 @@ public class MultiPageLayoutController { int adjustedPageIndex = i % pagesPerSheet; // Close the current content stream and create a new // page and content stream - int rowIndex = 0; - int colIndex = 0; + int rowIndex; + int colIndex; switch (pageOrder) { case "LR_TD": // Left→Right, then Top→Down @@ -215,7 +214,7 @@ public class MultiPageLayoutController { // If any source page is rotated, skip form copying/transformation entirely boolean hasRotation = FormUtils.hasAnyRotatedPage(sourceDocument); - if (hasRotation) { + if (hasRotation || "LANDSCAPE".equals(orientation)) { log.info("Source document has rotated pages; skipping form field copying."); } else { try {