I am trying to separate one large PDF into several smaller PDFs of varying lengths. At first I tried reading the original PDF with a FileInputStream
and finding the signature hex strings to split it into smaller files with a FileOutputStream
(as I have done with JPGs). However, I can't seem to find what hex string designates different pages in the original.
I've been looking through the iText API for the PdfWriter
and PdfReader
classes but I'm not exactly sure how to write data from the original to the smaller PDF, let alone how to create a PDF file in the first place.
Which of these approaches makes more sense? Or is there a much simpler, more ideal way?