use of com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAnnotationUnknown in project PdfBox-Android by TomRoush.
the class PageDrawer method showAnnotation.
@Override
public void showAnnotation(PDAnnotation annotation) throws IOException {
lastClip = null;
// Device checks shouldn't be needed
if (annotation.isNoView()) {
return;
}
if (annotation.isHidden()) {
return;
}
if (annotation.isInvisible() && annotation instanceof PDAnnotationUnknown) {
// of the standard annotation types and no annotation handler is available."
return;
}
if (isHiddenOCG(annotation.getOptionalContent())) {
return;
}
PDAppearanceDictionary appearance = annotation.getAppearance();
if (appearance == null || appearance.getNormalAppearance() == null) {
annotation.constructAppearances(renderer.document);
}
if (annotation.isNoRotate() && getCurrentPage().getRotation() != 0) {
PDRectangle rect = annotation.getRectangle();
android.graphics.Matrix savedTransform = canvas.getMatrix();
// "The upper-left corner of the annotation remains at the same point in
// default user space; the annotation pivots around that point."
canvas.rotate(getCurrentPage().getRotation(), rect.getLowerLeftX(), rect.getUpperRightY());
super.showAnnotation(annotation);
canvas.setMatrix(savedTransform);
} else {
super.showAnnotation(annotation);
}
}
use of com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAnnotationUnknown in project PdfBox-Android by TomRoush.
the class PDObjectReference method getReferencedObject.
/**
* Gets a higher-level object for the referenced object.
* Currently this method may return a {@link PDAnnotation},
* a {@link PDXObject} or <code>null</code>.
*
* @return a higher-level object for the referenced object
*/
public COSObjectable getReferencedObject() {
COSBase obj = this.getCOSObject().getDictionaryObject(COSName.OBJ);
if (!(obj instanceof COSDictionary)) {
return null;
}
try {
if (obj instanceof COSStream) {
// <-- TODO: valid?
PDXObject xobject = PDXObject.createXObject(obj, null);
if (xobject != null) {
return xobject;
}
}
COSDictionary objDictionary = (COSDictionary) obj;
PDAnnotation annotation = PDAnnotation.createAnnotation(obj);
/*
* COSName.TYPE is optional, so if annotation is of type unknown and
* COSName.TYPE is not COSName.ANNOT it still may be an annotation.
* TODO shall we return the annotation object instead of null?
* what else can be the target of the object reference?
*/
if (!(annotation instanceof PDAnnotationUnknown) || COSName.ANNOT.equals(objDictionary.getDictionaryObject(COSName.TYPE))) {
return annotation;
}
} catch (IOException exception) {
// this can only happen if the target is an XObject.
}
return null;
}
Aggregations