@Override public void createAppearanceDictionary(PDFormXObject holderForml, PDSignatureField signatureField) throws IOException { PDAppearanceDictionary appearance = new PDAppearanceDictionary(); appearance.getCOSObject().setDirect(true); PDAppearanceStream appearanceStream = new PDAppearanceStream(holderForml.getCOSObject()); appearance.setNormalAppearance(appearanceStream); signatureField.getWidgets().get(0).setAppearance(appearance); pdfStructure.setAppearanceDictionary(appearance); LOG.info("PDF appearance dictionary has been created"); }
/** * This will return a list of appearances. In the case where there is only one appearance the map will contain one * entry whose key is the string "default". If there is no rollover appearance then the normal appearance will be * returned. Which means that this method will never return null. * * @return A list of key(java.lang.String) value(PDAppearanceStream) pairs */ public PDAppearanceEntry getDownAppearance() { COSBase entry = dictionary.getDictionaryObject(COSName.D); if (entry instanceof COSDictionary) { return new PDAppearanceEntry((COSDictionary) entry); } else { return getNormalAppearance(); } }
/** * 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; }
/** * 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.isSubDictionary()) { //TODO replace with "document.getDocument().createCOSStream()" normalAppearanceEntry = new PDAppearanceEntry(new COSStream()); appearanceDictionary.setNormalAppearance(normalAppearanceEntry); } return normalAppearanceEntry; }
private Set<String> getAnnotationResourcesDependencies(PDAnnotation annot) { PDAppearanceDictionary dic = annot.getAppearance(); Set<String> appearances = new HashSet<>(); if (dic != null) { COSBase baseNormal = dic.getCOSObject().getItem(COSName.N); if (baseNormal != null) { appearances.addAll(getAppearanceEntryDependencies(dic.getNormalAppearance(), baseNormal)); } COSBase baseRollover = dic.getCOSObject().getItem(COSName.R); if (baseRollover != null) { appearances.addAll(getAppearanceEntryDependencies(dic.getRolloverAppearance(), baseRollover)); } COSBase baseDown = dic.getCOSObject().getItem(COSName.D); if (baseDown != null) { appearances.addAll(getAppearanceEntryDependencies(dic.getDownAppearance(), baseDown)); } } return appearances; }
dict.setItem(COSName.getPDFName("" + radioCnt), docFormsStateContainer.getRadioOnStream()); dict.setItem(COSName.Off, docFormsStateContainer.getRadioOffStream()); PDAppearanceDictionary appearanceDict = new PDAppearanceDictionary(); appearanceDict.getCOSObject().setItem(COSName.N, dict);
if (appearanceDict == null) appearanceDict = new PDAppearanceDictionary(); widget.setAppearance(appearanceDict); PDAppearanceEntry appearance = appearanceDict.getNormalAppearance(); appearanceDict.setNormalAppearance(appearanceStream);
private static List<PDAppearanceStream> getAllAppearances(PDAnnotation annotation) { List<PDAppearanceStream> res = new ArrayList<>(); if (annotation != null) { PDAppearanceDictionary appearance = annotation.getAppearance(); if (appearance != null) { addAllAppearances(appearance.getNormalAppearance(), res); addAllAppearances(appearance.getDownAppearance(), res); addAllAppearances(appearance.getRolloverAppearance(), res); } } return res; }
apNDict.setItem(options.get(i), createCheckBoxAppearanceStream(document, widget, true)); PDAppearanceDictionary appearance = new PDAppearanceDictionary(); PDAppearanceEntry appearanceNEntry = new PDAppearanceEntry(apNDict); appearance.setNormalAppearance(appearanceNEntry); widget.setAppearance(appearance); widget.setAppearanceState("Off"); // don't forget this, or button will be invisible
/** * This will get the appearance dictionary associated with this annotation. This may return null. * * @return This annotations appearance. */ public PDAppearanceDictionary getAppearance() { COSBase base = dictionary.getDictionaryObject(COSName.AP); if (base instanceof COSDictionary) { return new PDAppearanceDictionary((COSDictionary) base); } return null; }
contents.close(); PDAppearanceDictionary appearanceDictionary = new PDAppearanceDictionary(); PDAppearanceStream normal = createAppearanceStream(document, textWidth, font, "0.5 0.5 0.5 rg"); PDAppearanceStream rollover = createAppearanceStream(document, textWidth, font, "1 0.7 0.5 rg"); PDAppearanceStream down = createAppearanceStream(document, textWidth, font, "0 0 0 rg"); appearanceDictionary.setNormalAppearance(normal); appearanceDictionary.setRolloverAppearance(rollover); appearanceDictionary.setDownAppearance(down); annotation.setAppearance(appearanceDictionary);
private void parseAppearance() { PDAppearanceDictionary appearanceDictionary = ((PDAnnotation) this.simplePDObject).getAppearance(); if (appearanceDictionary != null) { COSDictionary dictionary = appearanceDictionary.getCOSObject(); COSBase normalAppearanceBase = dictionary.getDictionaryObject(COSName.N); COSBase downAppearanceBase = dictionary.getDictionaryObject(COSName.D); COSBase rolloverAppearanceBase = dictionary.getDictionaryObject(COSName.R); if (normalAppearanceBase != null || downAppearanceBase != null || rolloverAppearanceBase != null) { List<PDContentStream> appearances = new ArrayList<>(); addContentStreamsFromAppearanceEntry(normalAppearanceBase, appearances); addContentStreamsFromAppearanceEntry(downAppearanceBase, appearances); addContentStreamsFromAppearanceEntry(rolloverAppearanceBase, appearances); this.appearance = Collections.unmodifiableList(appearances); } else { this.appearance = Collections.emptyList(); } } else { this.appearance = Collections.emptyList(); } }
widget.setBorderStyle(borderStyleDictionary); PDAppearanceDictionary ap = new PDAppearanceDictionary(); widget.setAppearance(ap); PDAppearanceEntry normalAppearance = ap.getNormalAppearance();
/** * Get the annotations rollover appearance. * * <p> * This will get the annotations rollover appearance. If this is not * existent an empty appearance entry will be created. * * @return the appearance entry representing the rollover appearance. */ PDAppearanceEntry getRolloverAppearance() { PDAppearanceDictionary appearanceDictionary = getAppearance(); PDAppearanceEntry rolloverAppearanceEntry = appearanceDictionary.getRolloverAppearance(); if (rolloverAppearanceEntry.isSubDictionary()) { //TODO replace with "document.getDocument().createCOSStream()" rolloverAppearanceEntry = new PDAppearanceEntry(new COSStream()); appearanceDictionary.setRolloverAppearance(rolloverAppearanceEntry); } return rolloverAppearanceEntry; }
dict.setItem(COSName.getPDFName("" + radioCnt), docFormsStateContainer.getRadioOnStream()); dict.setItem(COSName.Off, docFormsStateContainer.getRadioOffStream()); PDAppearanceDictionary appearanceDict = new PDAppearanceDictionary(); appearanceDict.getCOSObject().setItem(COSName.N, dict);
if (appearanceDict == null) appearanceDict = new PDAppearanceDictionary(); widget.setAppearance(appearanceDict); PDAppearanceEntry appearance = appearanceDict.getNormalAppearance(); appearanceDict.setNormalAppearance(appearanceStream);
PDAppearanceDictionary appearance = new PDAppearanceDictionary(new COSDictionary()); appearance.setNormalAppearance(myDic); rubberStamp.setAppearance(appearance); rubberStamp.setRectangle(rect);
/** * 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; }
if (ap != null) COSDictionary apDict = ap.getCOSObject();
/** * 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 appearanceEntry = appearanceDictionary.getNormalAppearance(); if (appearanceEntry.isSubDictionary()) { appearanceEntry = new PDAppearanceEntry(new COSStream()); appearanceDictionary.setNormalAppearance(appearanceEntry); } return appearanceEntry; }