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

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

Introduction

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

Prototype

Splitter

Source Link

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;/*from ww w. j  a  va 2 s.  co  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;
}