mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-11-16 01:21:16 +01:00
Improve default layout for multi-page sheets
This commit is contained in:
parent
06efab5cb2
commit
002bfbad69
@ -68,7 +68,15 @@ public class MultiPageLayoutController {
|
|||||||
PDDocument sourceDocument = pdfDocumentFactory.load(file);
|
PDDocument sourceDocument = pdfDocumentFactory.load(file);
|
||||||
PDDocument newDocument =
|
PDDocument newDocument =
|
||||||
pdfDocumentFactory.createNewDocumentBasedOnOldDocument(sourceDocument);
|
pdfDocumentFactory.createNewDocumentBasedOnOldDocument(sourceDocument);
|
||||||
PDPage newPage = new PDPage(PDRectangle.A4);
|
|
||||||
|
// Create a new A4 landscape rectangle that will be used when pagesPerSheet is 2 or 3
|
||||||
|
PDRectangle a4Landscape =
|
||||||
|
new PDRectangle(PDRectangle.A4.getHeight(), PDRectangle.A4.getWidth());
|
||||||
|
|
||||||
|
PDPage newPage =
|
||||||
|
(pagesPerSheet == 2 || pagesPerSheet == 3)
|
||||||
|
? new PDPage(a4Landscape)
|
||||||
|
: new PDPage(PDRectangle.A4);
|
||||||
newDocument.addPage(newPage);
|
newDocument.addPage(newPage);
|
||||||
|
|
||||||
int totalPages = sourceDocument.getNumberOfPages();
|
int totalPages = sourceDocument.getNumberOfPages();
|
||||||
@ -88,7 +96,10 @@ public class MultiPageLayoutController {
|
|||||||
if (i != 0 && i % pagesPerSheet == 0) {
|
if (i != 0 && i % pagesPerSheet == 0) {
|
||||||
// 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 = new PDPage(PDRectangle.A4);
|
newPage =
|
||||||
|
(pagesPerSheet == 2 || pagesPerSheet == 3)
|
||||||
|
? new PDPage(a4Landscape)
|
||||||
|
: new PDPage(PDRectangle.A4);
|
||||||
newDocument.addPage(newPage);
|
newDocument.addPage(newPage);
|
||||||
contentStream =
|
contentStream =
|
||||||
new PDPageContentStream(
|
new PDPageContentStream(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user