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

Joseph edited comment on PDFBOX-5078 at 1/14/21, 8:15 PM:
----------------------------------------------------------

[~tilman] Thanks a lot . Now i am able to understand the issue. However the 
code needs to be altered a little to get the expected output and have modified 
the same. Below is for reference

 

 
{code:java}
int j=1;
 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 cropBoxORIG 
= document.getPage(i).getCropBox(); PDRectangle cropBoxLEFT = new 
PDRectangle(cropBoxORIG.getCOSArray()); 
cropBoxLEFT.setUpperRightX(cropBoxORIG.getLowerLeftX() + cropBoxORIG.getWidth() 
/ 2); page.setCropBox(cropBoxLEFT); outdoc.importPage(page); j = i + j; 
outdoc.save(new File(f.getParent(),"sample_" + (j) + ".pdf")); outdoc = new 
PDDocument(); PDRectangle cropBoxRIGHT = new 
PDRectangle(cropBoxORIG.getCOSArray()); 
cropBoxRIGHT.setLowerLeftX(cropBoxORIG.getLowerLeftX() + cropBoxORIG.getWidth() 
/ 2); page.setCropBox(cropBoxRIGHT); outdoc.importPage(page); j = j + 1; 
outdoc.save(new File(f.getParent(),"sample_" + (j) + ".pdf")); outdoc.close(); }
//document.save("Path");
 document.close();
{code}
 

 

---------------------

 

Now the files got separately nicely and it works great. Thanks a lot for your 
time. 

 

How to merge all the files as a single PDF file? Can you help me with a link or 
example or code for an example. However you can mark this ticket as resolved. 
Thanks again.


was (Author: apostlechristian377):
[~tilman] Thanks a lot . Now i am able to understand the issue. However the 
code needs to be altered a little to get the expected output and have modified 
the same. Below is for reference

 

int j=1;
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 cropBoxORIG = document.getPage(i).getCropBox();
 PDRectangle cropBoxLEFT = new PDRectangle(cropBoxORIG.getCOSArray());
 cropBoxLEFT.setUpperRightX(cropBoxORIG.getLowerLeftX() + 
cropBoxORIG.getWidth() / 2);
 page.setCropBox(cropBoxLEFT);
 outdoc.importPage(page);
 j = i + j;
 outdoc.save(new File(f.getParent(),"sample_" + (j) + ".pdf"));

 outdoc = new PDDocument();
 PDRectangle cropBoxRIGHT = new PDRectangle(cropBoxORIG.getCOSArray());
 cropBoxRIGHT.setLowerLeftX(cropBoxORIG.getLowerLeftX() + 
cropBoxORIG.getWidth() / 2);

 page.setCropBox(cropBoxRIGHT);
 outdoc.importPage(page);
 j = j + 1;
 outdoc.save(new File(f.getParent(),"sample_" + (j) + ".pdf"));
 outdoc.close();
}
//document.save("Path");
document.close();

 

---------------------

 

Now the files got separately nicely and it works great. Thanks a lot for your 
time. 

 

How to merge all the files as a single PDF file? Can you help me with a link or 
example or code for an example. However you can mark this ticket as resolved. 
Thanks again.

> 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
>         Attachments: 64-1212 (4).pdf, sample_2.pdf, screenshot-1.png
>
>
> 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