We produce pdfs from a software system, but on occasion the pdfs may have a blank page or two. I saw that there is java code to automatically remove these blank pages, but I did not find any .Net code. Has anyone ever written .Net code to remove blank pages? If so, would you guys be able to help me? Here is the java code.
rivate int blankPdfsize = 20; public void removeBlankPdfPages(String pdfSourceFile, String pdfDestinationFile, boolean debug) { try { PdfReader r = new PdfReader(pdfSourceFile); RandomAccessFileOrArray raf = new RandomAccessFileOrArray(pdfSourceFile); Document document = new Document(r.getPageSizeWithRotation(1)); // step 2: create a writer that listens to the document PdfCopy writer = new PdfCopy(document, new FileOutputStream(pdfDestinationFile)); // step 3: we open the document document.open(); // step 4: we add content PdfImportedPage page = null; if (debug) { System.err.println("number of pages for "+pdfSourceFile+" = "+r.getNumberOfPages()); } for (int i=1;i<=r.getNumberOfPages();i++) { byte bContent [] = r.getPageContent(i,raf); ByteArrayOutputStream bs = new ByteArrayOutputStream(); bs.write(bContent); if (debug) { System.err.println("page content length of page "+i+" = "+bs.size()); } if (bs.size() > blankPdfsize) { page = writer.getImportedPage(r, i); writer.addPage(page); } } document.close(); writer.close(); raf.close(); r.close(); } catch(Exception e) { System.err.println("IOException in removing blank pages from "+pdfSourceFile+" = "+e); } } -- View this message in context: http://www.nabble.com/Detecting-blank-pages-in-a-pdf-tp22040725p22040725.html Sent from the iText - General mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php