diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/StampController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/StampController.java index e11ffbaf..3b541b6c 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/StampController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/StampController.java @@ -88,8 +88,6 @@ public class StampController { // Load the input PDF PDDocument document = Loader.loadPDF(pdfFile.getBytes()); - - List pageNumbers = request.getPageNumbersList(document, false); for (int pageIndex : pageNumbers) { @@ -319,4 +317,4 @@ public class StampController { private float calculateTextCapHeight(PDFont font, float fontSize) { return font.getFontDescriptor().getCapHeight() / 1000 * fontSize; } -} \ No newline at end of file +} diff --git a/src/main/java/stirling/software/SPDF/model/api/PDFWithPageNums.java b/src/main/java/stirling/software/SPDF/model/api/PDFWithPageNums.java index 850eb927..5e15d64d 100644 --- a/src/main/java/stirling/software/SPDF/model/api/PDFWithPageNums.java +++ b/src/main/java/stirling/software/SPDF/model/api/PDFWithPageNums.java @@ -24,7 +24,6 @@ public class PDFWithPageNums extends PDFFile { "The pages to select, Supports ranges (e.g., '1,3,5-9'), or 'all' or functions in the format 'an+b' where 'a' is the multiplier of the page number 'n', and 'b' is a constant (e.g., '2n+1', '3n', '6n-5')\"") private String pageNumbers; - @Hidden public List getPageNumbersList(boolean zeroCount) { int pageCount = 0; @@ -36,9 +35,9 @@ public class PDFWithPageNums extends PDFFile { } return GeneralUtils.parsePageString(pageNumbers, pageCount, zeroCount); } - + @Hidden - public List getPageNumbersList(PDDocument doc,boolean zeroCount ) { + public List getPageNumbersList(PDDocument doc, boolean zeroCount) { int pageCount = 0; pageCount = doc.getNumberOfPages(); return GeneralUtils.parsePageString(pageNumbers, pageCount, zeroCount); diff --git a/src/main/java/stirling/software/SPDF/utils/GeneralUtils.java b/src/main/java/stirling/software/SPDF/utils/GeneralUtils.java index 674de8b0..d1a58087 100644 --- a/src/main/java/stirling/software/SPDF/utils/GeneralUtils.java +++ b/src/main/java/stirling/software/SPDF/utils/GeneralUtils.java @@ -116,9 +116,11 @@ public class GeneralUtils { } public static List parsePageString(String pageOrder, int totalPages) { - return parsePageString(pageOrder, totalPages , false ); + return parsePageString(pageOrder, totalPages, false); } - public static List parsePageString(String pageOrder, int totalPages, boolean isOneBased) { + + public static List parsePageString( + String pageOrder, int totalPages, boolean isOneBased) { if (pageOrder == null || pageOrder.isEmpty()) { return Collections.singletonList(1); } @@ -128,21 +130,22 @@ public class GeneralUtils { } return parsePageList(pageOrder.split(","), totalPages, isOneBased); } + public static List parsePageList(String[] pageOrderArr, int totalPages) { - return parsePageList(pageOrderArr, totalPages, false); + return parsePageList(pageOrderArr, totalPages, false); } - - - public static List parsePageList(String[] pageOrderArr, int totalPages, boolean isOneBased) { + + public static List parsePageList( + String[] pageOrderArr, int totalPages, boolean isOneBased) { List newPageOrder = new ArrayList<>(); int adjustmentFactor = isOneBased ? 1 : 0; - + // loop through the page order array for (String element : pageOrderArr) { if ("all".equalsIgnoreCase(element)) { for (int i = 0; i < totalPages; i++) { - newPageOrder.add(i+ adjustmentFactor); + newPageOrder.add(i + adjustmentFactor); } // As all pages are already added, no need to check further break;