List of usage examples for com.itextpdf.text.pdf PdfString toString
public String toString()
String
value of this PdfString
-object. From source file:com.poet.ar.remover.AnnotationRemover.java
/** * remove annotation that matches keywords * * @param page/* w ww . j a v a2 s . co m*/ * @return count of removed annotations */ private static int doRemoveAnnotation(PdfDictionary page) { // all annotations in page i PdfArray annoArray = page.getAsArray(PdfName.ANNOTS); List<Integer> willRemovedIx = new ArrayList<Integer>(); if (annoArray != null) { PdfDictionary annotation = null; PdfDictionary a = null; PdfString uri = null; for (int i = 0; i < annoArray.size(); i++) { annotation = annoArray.getAsDict(i); if (annotation == null) { continue; } a = annotation.getAsDict(PdfName.A); if (a == null) { continue; } uri = a.getAsString(PdfName.URI); if (uri == null) { continue; } String uriStr = uri.toString().trim(); if (keywords.contains(uriStr)) { willRemovedIx.add(i); } } int i = 0; for (Integer ix : willRemovedIx) { annoArray.remove(ix - i++); } } return willRemovedIx.size(); }