diff --git a/src/main/java/stirling/software/SPDF/controller/api/SplitPdfBySectionsController.java b/src/main/java/stirling/software/SPDF/controller/api/SplitPdfBySectionsController.java index 4fcba55c..29a2f426 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/SplitPdfBySectionsController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/SplitPdfBySectionsController.java @@ -42,10 +42,10 @@ public class SplitPdfBySectionsController { PDDocument sourceDocument = PDDocument.load(file.getInputStream()); // Process the PDF based on split parameters - int horiz = request.getHorizontalDivisions(); - int verti = request.getVerticalDivisions(); + int horiz = request.getHorizontalDivisions() + 1; + int verti = request.getVerticalDivisions() + 1; - List splitDocuments = splitPdfPages(sourceDocument, horiz, verti); + List splitDocuments = splitPdfPages(sourceDocument, verti, horiz); for (PDDocument doc : splitDocuments) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); doc.save(baos); @@ -108,7 +108,7 @@ public class SplitPdfBySectionsController { try (PDPageContentStream contentStream = new PDPageContentStream(subDoc, subPage)) { // Set clipping area and position float translateX = -subPageWidth * i; - float translateY = height - subPageHeight * (j + 1) - subPageHeight; + float translateY = height - subPageHeight * (verticalDivisions - j); contentStream.saveGraphicsState(); contentStream.addRect(0, 0, subPageWidth, subPageHeight); @@ -129,6 +129,7 @@ public class SplitPdfBySectionsController { } + } diff --git a/src/main/resources/templates/split-pdf-by-sections.html b/src/main/resources/templates/split-pdf-by-sections.html index 9978ca50..5fdc1e48 100644 --- a/src/main/resources/templates/split-pdf-by-sections.html +++ b/src/main/resources/templates/split-pdf-by-sections.html @@ -17,13 +17,70 @@
- +
- +
- + + +
+ +