package com.example;
import org.apache.pdfbox.multipdf.Splitter;
import org.apache.pdfbox.pdmodel.PDDocument;
import java.io.File;
import java.io.IOException;
import java.util.List;
public class PDFBoxExample {
public static void main(String[] args) throws IOException {
try (PDDocument source = PDDocument.load(new File("input.pdf"))) {
Splitter splitter = new Splitter();
List<PDDocument> documents = splitter.split(source);
for (int i = 0; i < documents.size(); i++) {
PDDocument document = documents.get(i);
document.save("out" + i + ".pdf");
}
}
}
}