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);
}
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;
}
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;
}
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;
}
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;
}
Aggregations