[ 
https://issues.apache.org/jira/browse/PDFBOX-5078?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17263852#comment-17263852
 ] 

Tilman Hausherr edited comment on PDFBOX-5078 at 1/13/21, 4:07 AM:
-------------------------------------------------------------------

Below is the code which i have tried to convert the booklet to A4 pdf to cut 
vertically...However cropping X or Y axis and importing a page has different 
result. you can take any  booklet pdf and give a try. 

Each Page would have two sides - one on left hand side and other on right hand 
side. Booklet sample
 * 2 page booklet: Type 4,1,- 1st page and 2nd page - 2,3 

 * 4 page booklet: Type 8,1,2,7,6,3,4,5

 * 10 page booklet: Type 20,1,2,19,18,3,4,17,16,5,6,15,14,7,8,13,12,9,10,11

if front and back printed it would be 1 paper, 

if front and back printed it would be 2 paper, 

if front and back printed it would be 5 page, 

 
{code}
for(int i=0; i<noOfPages; i++) {
 System.out.println("Page No (PDF From Booklet): "+ (i+1));
 PDDocument outdoc = new PDDocument();
 PDPage page = document.getPage(i);
 PDRectangle cropBox = document.getPage(i).getCropBox();
 float upperRightY = cropBox.getUpperRightY();
 float lowerLeftY = cropBox.getLowerLeftY();

 cropBox.setLowerLeftY(upperRightY/2);
 page.setCropBox(cropBox);
 outdoc.importPage(page);

 cropBox = page.getCropBox();
 cropBox.setUpperRightY(upperRightY/2);
 cropBox.setLowerLeftY(lowerLeftY/2);
 page.setCropBox(cropBox);
 outdoc.importPage(page);

 outdoc.save(f.getParent()+File.separator+"sample_"+(i+1)+".pdf");
 outdoc.close();
}
{code}



was (Author: apostlechristian377):
Below is the code which i have tried to convert the booklet to A4 pdf to cut 
vertically...However cropping X or Y axis and importing a page has different 
result. you can take any  booklet pdf and give a try. 

Each Page would have two sides - one on left hand side and other on right hand 
side. Booklet sample
 * 2 page booklet: Type 4,1,- 1st page and 2nd page - 2,3 

 * 4 page booklet: Type 8,1,2,7,6,3,4,5

 * 10 page booklet: Type 20,1,2,19,18,3,4,17,16,5,6,15,14,7,8,13,12,9,10,11

if front and back printed it would be 1 paper, 

if front and back printed it would be 2 paper, 

if front and back printed it would be 5 page, 

 

for(int i=0; i<noOfPages; i++) {
 System.out.println("Page No (PDF From Booklet): "+ (i+1));
 PDDocument outdoc = new PDDocument();
 PDPage page = document.getPage(i);
 PDRectangle cropBox = document.getPage(i).getCropBox();
 float upperRightY = cropBox.getUpperRightY();
 float lowerLeftY = cropBox.getLowerLeftY();

 cropBox.setLowerLeftY(upperRightY/2);
 page.setCropBox(cropBox);
 outdoc.importPage(page);

 cropBox = page.getCropBox();
 cropBox.setUpperRightY(upperRightY/2);
 cropBox.setLowerLeftY(lowerLeftY/2);
 page.setCropBox(cropBox);
 outdoc.importPage(page);

 outdoc.save(f.getParent()+File.separator+"sample_"+(i+1)+".pdf");
 outdoc.close();
}

> How to Split A PDF Page vertically into 2 Pieces via PDFBOX
> -----------------------------------------------------------
>
>                 Key: PDFBOX-5078
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-5078
>             Project: PDFBox
>          Issue Type: Bug
>            Reporter: Joseph
>            Priority: Major
>
> We can able to convert A4 PDF to Booklet PDF via PrintDF open source 
> ([https://github.com/Raudius/PrintDF/blob/master/src/us/raudi/printdf/PrintDF.java)]
> However not able to convert Booklet to A4 i.e that is cutting vertically of a 
> Booklet PDF page and resequence all the pages.
> 1st problem is not sure how to cut veritically each and every PDF page and 
> save as 2 separate PDF page or file
> 2nd re-sequence of the booklet to proper sequence as 1, 2, 3, 4, 5 by first 
> identifying the actual book sequence 
> (http://www.boooks.org/index.php?page=21&lng=1)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to