diff --git a/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java b/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java index d9cb2686..78df1f41 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java @@ -52,7 +52,7 @@ public class RearrangePagesPDFController { } private enum CustomMode { - REVERSE_ORDER, DUPLEX_SORT, BOOKLET_SORT, ODD_EVEN_SPLIT, REMOVE_FIRST, REMOVE_LAST, REMOVE_FIRST_AND_LAST, + REVERSE_ORDER, DUPLEX_SORT, BOOKLET_SORT, SIDE_STITCH_BOOKLET_SORT, ODD_EVEN_SPLIT, REMOVE_FIRST, REMOVE_LAST, REMOVE_FIRST_AND_LAST, } private List removeFirst(int totalPages) { @@ -114,6 +114,18 @@ public class RearrangePagesPDFController { return newPageOrder; } + private List sideStitchBooklet(int totalPages) { + List newPageOrder = new ArrayList<>(); + for (int i = 0; i < (totalPages + 3) / 4; i++) { + int begin = i * 4; + newPageOrder.add(Math.min(begin + 3, totalPages - 1)); + newPageOrder.add(Math.min(begin, totalPages - 1)); + newPageOrder.add(Math.min(begin + 1, totalPages - 1)); + newPageOrder.add(Math.min(begin + 2, totalPages - 1)); + } + return newPageOrder; + } + private List oddEvenSplit(int totalPages) { List newPageOrder = new ArrayList<>(); for (int i = 1; i <= totalPages; i += 2) { @@ -135,6 +147,8 @@ public class RearrangePagesPDFController { return duplexSort(totalPages); case BOOKLET_SORT: return bookletSort(totalPages); + case SIDE_STITCH_BOOKLET_SORT: + return sideStitchBooklet(totalPages); case ODD_EVEN_SPLIT: return oddEvenSplit(totalPages); case REMOVE_FIRST: diff --git a/src/main/resources/templates/pdf-organizer.html b/src/main/resources/templates/pdf-organizer.html index 96944649..c6e1508f 100644 --- a/src/main/resources/templates/pdf-organizer.html +++ b/src/main/resources/templates/pdf-organizer.html @@ -23,6 +23,7 @@ + @@ -53,4 +54,4 @@
- \ No newline at end of file +