Search in sources :

Example 1 with PDAppearanceDictionary

use of com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary in project PdfBox-Android by TomRoush.

the class PDAbstractAppearanceHandler method getDownAppearance.

/**
 * Get the annotations down appearance.
 *
 * <p>
 * This will get the annotations down appearance. If this is not existent an
 * empty appearance entry will be created.
 *
 * @return the appearance entry representing the down appearance.
 */
PDAppearanceEntry getDownAppearance() {
    PDAppearanceDictionary appearanceDictionary = getAppearance();
    PDAppearanceEntry downAppearanceEntry = appearanceDictionary.getDownAppearance();
    if (downAppearanceEntry.isSubDictionary()) {
        downAppearanceEntry = new PDAppearanceEntry(createCOSStream());
        appearanceDictionary.setDownAppearance(downAppearanceEntry);
    }
    return downAppearanceEntry;
}
Also used : PDAppearanceEntry(com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAppearanceEntry) PDAppearanceDictionary(com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary)

Example 2 with PDAppearanceDictionary

use of com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary in project PdfBox-Android by TomRoush.

the class PDAbstractAppearanceHandler method getAppearance.

/**
 * Get the annotations appearance dictionary.
 *
 * <p>
 * This will get the annotations appearance dictionary. If this is not
 * existent an empty appearance dictionary will be created.
 *
 * @return the annotations appearance dictionary
 */
PDAppearanceDictionary getAppearance() {
    PDAppearanceDictionary appearanceDictionary = annotation.getAppearance();
    if (appearanceDictionary == null) {
        appearanceDictionary = new PDAppearanceDictionary();
        annotation.setAppearance(appearanceDictionary);
    }
    return appearanceDictionary;
}
Also used : PDAppearanceDictionary(com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary)

Example 3 with PDAppearanceDictionary

use of com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary in project PdfBox-Android by TomRoush.

the class PDAbstractAppearanceHandler method getNormalAppearance.

/**
 * Get the annotations normal appearance.
 *
 * <p>
 * This will get the annotations normal appearance. If this is not existent
 * an empty appearance entry will be created.
 *
 * @return the appearance entry representing the normal appearance.
 */
private PDAppearanceEntry getNormalAppearance() {
    PDAppearanceDictionary appearanceDictionary = getAppearance();
    PDAppearanceEntry normalAppearanceEntry = appearanceDictionary.getNormalAppearance();
    if (normalAppearanceEntry == null || normalAppearanceEntry.isSubDictionary()) {
        normalAppearanceEntry = new PDAppearanceEntry(createCOSStream());
        appearanceDictionary.setNormalAppearance(normalAppearanceEntry);
    }
    return normalAppearanceEntry;
}
Also used : PDAppearanceEntry(com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAppearanceEntry) PDAppearanceDictionary(com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary)

Example 4 with PDAppearanceDictionary

use of com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary in project PdfBox-Android by TomRoush.

the class FDFField method getAppearanceDictionary.

/**
 * This will get the appearance dictionary that specifies the appearance of a pushbutton field.
 *
 * @return The AP entry of this dictionary.
 */
public PDAppearanceDictionary getAppearanceDictionary() {
    PDAppearanceDictionary retval = null;
    COSDictionary dict = (COSDictionary) field.getDictionaryObject(COSName.AP);
    if (dict != null) {
        retval = new PDAppearanceDictionary(dict);
    }
    return retval;
}
Also used : PDAppearanceDictionary(com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary) COSDictionary(com.tom_roush.pdfbox.cos.COSDictionary)

Example 5 with PDAppearanceDictionary

use of com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary 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);
    }
}
Also used : PDAppearanceDictionary(com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary) PDRectangle(com.tom_roush.pdfbox.pdmodel.common.PDRectangle) PDAnnotationUnknown(com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAnnotationUnknown)

Aggregations

PDAppearanceDictionary (com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary)11 PDAppearanceEntry (com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAppearanceEntry)5 PDRectangle (com.tom_roush.pdfbox.pdmodel.common.PDRectangle)3 PDAppearanceStream (com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAppearanceStream)3 PDAnnotationWidget (com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget)2 COSDictionary (com.tom_roush.pdfbox.cos.COSDictionary)1 COSName (com.tom_roush.pdfbox.cos.COSName)1 PDFormFieldAdditionalActions (com.tom_roush.pdfbox.pdmodel.interactive.action.PDFormFieldAdditionalActions)1 PDAnnotationUnknown (com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAnnotationUnknown)1