List of usage examples for com.lowagie.text.pdf PdfArray remove
public PdfObject remove(int idx)
From source file:questions.stamppages.RemoveAttachmentAnnotations.java
public static void main(String[] args) throws IOException, DocumentException { createPdfWithAttachments();/*from ww w . j a v a 2 s.c o m*/ PdfReader reader = new PdfReader(RESOURCE); PdfDictionary page; PdfDictionary annotation; for (int i = 1; i <= reader.getNumberOfPages(); i++) { page = reader.getPageN(i); PdfArray annots = page.getAsArray(PdfName.ANNOTS); if (annots != null) { for (int j = annots.size() - 1; j >= 0; j--) { annotation = annots.getAsDict(j); if (PdfName.FILEATTACHMENT.equals(annotation.get(PdfName.SUBTYPE))) { annots.remove(j); } } } } reader.removeUnusedObjects(); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(RESULT)); stamper.close(); }