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 0fc888e86..9006909fb 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 @@ -51,6 +51,7 @@ public class MultiPageLayoutController { int pagesPerSheet = request.getPagesPerSheet(); MultipartFile file = request.getFileInput(); + String orientation = request.getOrientation(); boolean addBorder = Boolean.TRUE.equals(request.getAddBorder()); if (pagesPerSheet != 2 @@ -69,14 +70,14 @@ public class MultiPageLayoutController { PDDocument newDocument = pdfDocumentFactory.createNewDocumentBasedOnOldDocument(sourceDocument); - // Create a new A4 landscape rectangle that will be used when pagesPerSheet is 2 or 3 + // Create a new A4 landscape rectangle that we use when orientation is landscape PDRectangle a4Landscape = new PDRectangle(PDRectangle.A4.getHeight(), PDRectangle.A4.getWidth()); PDPage newPage = - (pagesPerSheet == 2 || pagesPerSheet == 3) - ? new PDPage(a4Landscape) - : new PDPage(PDRectangle.A4); + "PORTRAIT".equals(orientation) + ? new PDPage(PDRectangle.A4) + : new PDPage(a4Landscape); newDocument.addPage(newPage); int totalPages = sourceDocument.getNumberOfPages(); @@ -97,9 +98,9 @@ public class MultiPageLayoutController { // Close the current content stream and create a new page and content stream contentStream.close(); newPage = - (pagesPerSheet == 2 || pagesPerSheet == 3) - ? new PDPage(a4Landscape) - : new PDPage(PDRectangle.A4); + "PORTRAIT".equals(orientation) + ? new PDPage(PDRectangle.A4) + : new PDPage(a4Landscape); newDocument.addPage(newPage); contentStream = new PDPageContentStream( diff --git a/app/core/src/main/java/stirling/software/SPDF/model/api/general/MergeMultiplePagesRequest.java b/app/core/src/main/java/stirling/software/SPDF/model/api/general/MergeMultiplePagesRequest.java index 6d9254023..e600d585d 100644 --- a/app/core/src/main/java/stirling/software/SPDF/model/api/general/MergeMultiplePagesRequest.java +++ b/app/core/src/main/java/stirling/software/SPDF/model/api/general/MergeMultiplePagesRequest.java @@ -19,6 +19,13 @@ public class MergeMultiplePagesRequest extends PDFFile { allowableValues = {"2", "3", "4", "9", "16"}) private int pagesPerSheet; + @Schema( + description = "The orientation of the output PDF pages", + type = "string", + defaultValue = "PORTRAIT", + allowableValues = {"PORTRAIT", "LANDSCAPE"}) + private String orientation; + @Schema(description = "Boolean for if you wish to add border around the pages") private Boolean addBorder; } diff --git a/app/core/src/main/resources/messages_en_US.properties b/app/core/src/main/resources/messages_en_US.properties index e550e9c0d..00791b4e0 100644 --- a/app/core/src/main/resources/messages_en_US.properties +++ b/app/core/src/main/resources/messages_en_US.properties @@ -1152,6 +1152,7 @@ pipeline.title=Pipeline pageLayout.title=Multi Page Layout pageLayout.header=Multi Page Layout pageLayout.pagesPerSheet=Pages per sheet: +pageLayout.orientation=Orientation: pageLayout.addBorder=Add Borders pageLayout.submit=Submit diff --git a/app/core/src/main/resources/templates/multi-page-layout.html b/app/core/src/main/resources/templates/multi-page-layout.html index 0a8f5ebb3..6ab45e773 100644 --- a/app/core/src/main/resources/templates/multi-page-layout.html +++ b/app/core/src/main/resources/templates/multi-page-layout.html @@ -28,6 +28,13 @@ +
+ + +