Op 9/01/2013 4:06, Andrew Mickish schreef: > My publishing department uses Adobe tools like InDesign to create multi-page > PDF files. Some, but not all of the documents have a full-page disclaimer > as the last page. > > When I use iText to concatenate the files together into a bundle of > documents, the disclaimer appears multiple times in the middle of the > bundle. I want to skip the disclaimer pages in the middle, and only show > the disclaimer page at the end of the bundle. > > I need the publishing department to "tag" their disclaimer pages in Adobe > tools, in a way that I can detect with iText, so I can skip those pages as I > build the bundle. In other words, I want to wrap some conditional around > the last line in this loop: > > for (int p = 1; p <= n; p++) { > final PdfImportedPage page = writer.getImportedPage(reader, > p); > writer.addPage(page); // unless it's a disclaimer page > } > > What is the best way to do this? Or is there a better way to "tag" special > pages in InDesign that will be recognized by iText?
First this: of which type is the writer object in your code snippet? If it's of type PdfWriter, you're doing it wrong! If it's of type PdfCopy or PdfSmartCopy, please read on. There are different ways to solve your problem. You could use iText to parse every page and to omit that page if some specific text is present. Of course: this will only work if the text is always identical and doesn't accidentally appear on a page you want to keep. You could ask the people who create the pages to add an annotation on all the disclaimer pages. Then you can omit all pages that contain this annotation. You could ask the people who create the pages to use "Marked Content" so that you know which content is part of a disclaimer. Now you can create your own parser (similar to what we did with the OCGParser class) and remove all content marked as disclaimer (a lot more work and maybe overkill for what you need). I'm sure there are other solutions available, but these are the first three that come to mind. ------------------------------------------------------------------------------ Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery and much more. Keep your Java skills current with LearnJavaNow - 200+ hours of step-by-step video tutorials by Java experts. SALE $49.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122612 _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions iText(R) is a registered trademark of 1T3XT BVBA. Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/ Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php