Posted By

markt22 on 10/12/17


Tagged

PDFBox


Versions (?)

PDFBox: Split document into multiple pages


 / Published in: Java
 

Opens an existing document and splits it into multiple documents, one for each page.

  1. /**
  2.  * @param args the command line arguments
  3.  * @throws java.io.IOException
  4.  */
  5. public static void main(String[] args) throws IOException {
  6. File file = new File("");
  7. PDDocument document = PDDocument.load(file);
  8.  
  9. Splitter splitter = new Splitter();
  10.  
  11. List<PDDocument> Pages = splitter.split(document);
  12.  
  13. Iterator<PDDocument> iterator = Pages.listIterator();
  14.  
  15. for(int i = 1;iterator.hasNext();i++)
  16. {
  17. PDDocument pd = iterator.next();
  18. pd.save("" + i + ".pdf");
  19. }
  20.  
  21. document.close();
  22. }

Report this snippet  

You need to login to post a comment.