Hi.
I am currently using iText to create and copy PDFs. I have
some pdfs that have blank pages (no text, no image), and I would like to detect
and remove those pages when I come across them. If I can detect them,
then I can remove them, however I’ve had trouble detecting them. Any
suggestions?
This is the code I am using to read the pages.
PdfImportedPage page;
PdfReader reader = new PdfReader(path);
reader.consolidateNamedDestinations();
int n = reader.getNumberOfPages();
document = new Document(reader.getPageSizeWithRotation(1));
writer = new PdfCopy(document, new
FileOutputStream(outFile));
document.open();
for (int i = 0; i < n; ) {
++i;
page = writer.getImportedPage(reader, i);
// I know I need to modify something in this space.
writer.addPage(page);
}
Disclaimer: this is based off of sample code
Dan