Example usage for org.apache.pdfbox.multipdf Splitter split

List of usage examples for org.apache.pdfbox.multipdf Splitter split

Introduction

In this page you can find the example usage for org.apache.pdfbox.multipdf Splitter split.

Prototype

public List<PDDocument> split(PDDocument document) throws IOException 

Source Link

Document

This will take a document and split into several other documents.

Usage

From source file:org.freeeed.ocr.ImageTextParser.java

License:Apache License

private static String splitPages(String filePath) throws IOException {
    File file = new File(filePath);
    String pagePath;/* w ww  .  j  a  v a 2  s  .  c  o m*/
    try (PDDocument document = PDDocument.load(file)) {
        Splitter splitter = new Splitter();
        List<PDDocument> pages = splitter.split(document);
        Iterator<PDDocument> iterator = pages.listIterator();
        int i = 0;
        pagePath = createTempPath(file);
        LOGGER.debug("pagePath = " + pagePath);
        while (iterator.hasNext()) {
            PDDocument pd = iterator.next();
            pd.save(pagePath + i++ + ".pdf");
            pd.close();
        }
    }
    return pagePath;
}