mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-11-16 01:21:16 +01:00
Feature: Choosing between Portrait and Landscape orientation for Multi Page Layout
This commit is contained in:
parent
002bfbad69
commit
84db4e5f2e
@ -51,6 +51,7 @@ public class MultiPageLayoutController {
|
|||||||
|
|
||||||
int pagesPerSheet = request.getPagesPerSheet();
|
int pagesPerSheet = request.getPagesPerSheet();
|
||||||
MultipartFile file = request.getFileInput();
|
MultipartFile file = request.getFileInput();
|
||||||
|
String orientation = request.getOrientation();
|
||||||
boolean addBorder = Boolean.TRUE.equals(request.getAddBorder());
|
boolean addBorder = Boolean.TRUE.equals(request.getAddBorder());
|
||||||
|
|
||||||
if (pagesPerSheet != 2
|
if (pagesPerSheet != 2
|
||||||
@ -69,14 +70,14 @@ public class MultiPageLayoutController {
|
|||||||
PDDocument newDocument =
|
PDDocument newDocument =
|
||||||
pdfDocumentFactory.createNewDocumentBasedOnOldDocument(sourceDocument);
|
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 =
|
PDRectangle a4Landscape =
|
||||||
new PDRectangle(PDRectangle.A4.getHeight(), PDRectangle.A4.getWidth());
|
new PDRectangle(PDRectangle.A4.getHeight(), PDRectangle.A4.getWidth());
|
||||||
|
|
||||||
PDPage newPage =
|
PDPage newPage =
|
||||||
(pagesPerSheet == 2 || pagesPerSheet == 3)
|
"PORTRAIT".equals(orientation)
|
||||||
? new PDPage(a4Landscape)
|
? new PDPage(PDRectangle.A4)
|
||||||
: new PDPage(PDRectangle.A4);
|
: new PDPage(a4Landscape);
|
||||||
newDocument.addPage(newPage);
|
newDocument.addPage(newPage);
|
||||||
|
|
||||||
int totalPages = sourceDocument.getNumberOfPages();
|
int totalPages = sourceDocument.getNumberOfPages();
|
||||||
@ -97,9 +98,9 @@ public class MultiPageLayoutController {
|
|||||||
// Close the current content stream and create a new page and content stream
|
// Close the current content stream and create a new page and content stream
|
||||||
contentStream.close();
|
contentStream.close();
|
||||||
newPage =
|
newPage =
|
||||||
(pagesPerSheet == 2 || pagesPerSheet == 3)
|
"PORTRAIT".equals(orientation)
|
||||||
? new PDPage(a4Landscape)
|
? new PDPage(PDRectangle.A4)
|
||||||
: new PDPage(PDRectangle.A4);
|
: new PDPage(a4Landscape);
|
||||||
newDocument.addPage(newPage);
|
newDocument.addPage(newPage);
|
||||||
contentStream =
|
contentStream =
|
||||||
new PDPageContentStream(
|
new PDPageContentStream(
|
||||||
|
|||||||
@ -19,6 +19,13 @@ public class MergeMultiplePagesRequest extends PDFFile {
|
|||||||
allowableValues = {"2", "3", "4", "9", "16"})
|
allowableValues = {"2", "3", "4", "9", "16"})
|
||||||
private int pagesPerSheet;
|
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")
|
@Schema(description = "Boolean for if you wish to add border around the pages")
|
||||||
private Boolean addBorder;
|
private Boolean addBorder;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1152,6 +1152,7 @@ pipeline.title=Pipeline
|
|||||||
pageLayout.title=Multi Page Layout
|
pageLayout.title=Multi Page Layout
|
||||||
pageLayout.header=Multi Page Layout
|
pageLayout.header=Multi Page Layout
|
||||||
pageLayout.pagesPerSheet=Pages per sheet:
|
pageLayout.pagesPerSheet=Pages per sheet:
|
||||||
|
pageLayout.orientation=Orientation:
|
||||||
pageLayout.addBorder=Add Borders
|
pageLayout.addBorder=Add Borders
|
||||||
pageLayout.submit=Submit
|
pageLayout.submit=Submit
|
||||||
|
|
||||||
|
|||||||
@ -28,6 +28,13 @@
|
|||||||
<option value="16">16</option>
|
<option value="16">16</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="orientation" th:text="#{pageLayout.orientation}"></label>
|
||||||
|
<select class="form-control" id="orientation" name="orientation">
|
||||||
|
<option value="PORTRAIT">Portrait</option>
|
||||||
|
<option value="LANDSCAPE">Landscape</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<div class="form-check mb-3">
|
<div class="form-check mb-3">
|
||||||
<input id="addBorder" name="addBorder" type="checkbox">
|
<input id="addBorder" name="addBorder" type="checkbox">
|
||||||
<label for="addBorder" th:text="#{pageLayout.addBorder}"></label>
|
<label for="addBorder" th:text="#{pageLayout.addBorder}"></label>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user