Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to split a PDF using Apache PDFBox? [closed]

Tags:

java

pdf

pdfbox

I am using Apache PDFBox to handle PDF files in my Java application. I would like to split a PDF document, for example, on every page.

Is it possible to do this wirth Apache PDFBox? If so, how?

like image 354
Shaheedul Islam Avatar asked Dec 04 '25 03:12

Shaheedul Islam


1 Answers

This is possible using a Splitter.

This is a sample code that will split a document on every page:

PDDocument document = PDDocument.load(myPDF);
Splitter splitter = new Splitter();
List<PDDocument> splittedDocuments = splitter.split(document);

You can control the number of pages on every splitted PDF using setSplitAtPage(split).

like image 74
Tunaki Avatar answered Dec 06 '25 16:12

Tunaki