protected APDMetaObject getMetaObject(PDAnnotation annotation, String lastString) { // Avoid empty entries // support repligo highlights if (annotation.getClass() == PDHighlightAnnotation.class) { // ignore Highlight if Subject is "Highlight" and Contents is "" if (((PDHighlightAnnotation) annotation).getSubject() != null && ((PDHighlightAnnotation) annotation).getSubject().length() > 0 && ((PDHighlightAnnotation) annotation).getSubject().equals("Highlight") && annotation.getContents().equals("")) { return null; } } else if (!(annotation.getClass() == PDSquigglyAnnotation.class) && !(annotation.getClass() == PDUnderlineAnnotation.class) && !(annotation.getClass() == PDStrikeOutAnnotation.class) && !(annotation.getClass() == PDTextMarkupAnnotation.class)) { // ignore annotations with Contents is "" if ("".equals(annotation.getContents())/* && !annotation.isMarkupAnnotation() */) { return null; } // Avoid double entries (Foxit Reader) if (annotation.getContents().equals(lastString)) { return null; } lastString = annotation.getContents(); } APDMetaObject metaObject = getComment(annotation); if(metaObject == null) { metaObject = getHighlight(annotation); } return metaObject; }
if (annotation.getContents() != null && annotation.getContents().length() > 0) { meta.setText(annotation.getContents());
public APDMetaObject getComment(PDAnnotation annotation) { if ((annotation.getClass() == PDAnyAnnotation.class || annotation.getClass() == PDTextAnnotation.class) && !ignoreComments()) { Integer objectNumber = annotation.cosGetObject().getIndirectObject().getObjectNumber(); COSObjectContext context = new COSObjectContext(annotation); APDMetaObject meta = new CommentAnnotation(getOrCreateUID(context), context); meta.setObjectNumber(objectNumber); meta.setText(annotation.getContents()); meta.setDestination(getDestination(annotation)); return meta; } return null; }