Search in sources :

Example 1 with PDAppearanceDictionary

use of org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary in project pdfbox by apache.

the class PDDocument method assignAppearanceDictionary.

private void assignAppearanceDictionary(PDSignatureField signatureField, COSDictionary apDict) {
    // read and set Appearance Dictionary
    PDAppearanceDictionary ap = new PDAppearanceDictionary(apDict);
    apDict.setDirect(true);
    signatureField.getWidgets().get(0).setAppearance(ap);
}
Also used : PDAppearanceDictionary(org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary)

Example 2 with PDAppearanceDictionary

use of org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary in project pdfbox by apache.

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(org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary) COSDictionary(org.apache.pdfbox.cos.COSDictionary)

Example 3 with PDAppearanceDictionary

use of org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary in project pdfbox by apache.

the class PDCheckBox method getOnValue.

/**
 * Get the value which sets the check box to the On state.
 *
 * <p>The On value should be 'Yes' but other values are possible
 * so we need to look for that. On the other hand the Off value shall
 * always be 'Off'. If not set or not part of the normal appearance keys
 * 'Off' is the default</p>
 *
 * @return the value setting the check box to the On state.
 *          If an empty string is returned there is no appearance definition.
 */
public String getOnValue() {
    PDAnnotationWidget widget = this.getWidgets().get(0);
    PDAppearanceDictionary apDictionary = widget.getAppearance();
    String onValue = "";
    if (apDictionary != null) {
        PDAppearanceEntry normalAppearance = apDictionary.getNormalAppearance();
        if (normalAppearance != null) {
            Set<COSName> entries = normalAppearance.getSubDictionary().keySet();
            for (COSName entry : entries) {
                if (COSName.Off.compareTo(entry) != 0) {
                    onValue = entry.getName();
                }
            }
        }
    }
    return onValue;
}
Also used : PDAppearanceEntry(org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceEntry) PDAppearanceDictionary(org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary) COSName(org.apache.pdfbox.cos.COSName) PDAnnotationWidget(org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget)

Example 4 with PDAppearanceDictionary

use of org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary in project pdfbox by apache.

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(org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary)

Example 5 with PDAppearanceDictionary

use of org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary in project pdfbox by apache.

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()) {
        // TODO replace with "document.getDocument().createCOSStream()"
        downAppearanceEntry = new PDAppearanceEntry(new COSStream());
        appearanceDictionary.setDownAppearance(downAppearanceEntry);
    }
    return downAppearanceEntry;
}
Also used : COSStream(org.apache.pdfbox.cos.COSStream) PDAppearanceEntry(org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceEntry) PDAppearanceDictionary(org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary)

Aggregations

PDAppearanceDictionary (org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary)11 PDAppearanceEntry (org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceEntry)5 PDAppearanceStream (org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceStream)4 COSStream (org.apache.pdfbox.cos.COSStream)3 PDResources (org.apache.pdfbox.pdmodel.PDResources)3 PDRectangle (org.apache.pdfbox.pdmodel.common.PDRectangle)3 PDAnnotationWidget (org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget)3 COSDictionary (org.apache.pdfbox.cos.COSDictionary)2 PDDocument (org.apache.pdfbox.pdmodel.PDDocument)2 PDPage (org.apache.pdfbox.pdmodel.PDPage)2 PDFormXObject (org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject)2 PDImageXObject (org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject)2 Matrix (org.apache.pdfbox.util.Matrix)2 Point2D (java.awt.geom.Point2D)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 COSName (org.apache.pdfbox.cos.COSName)1