/** * Returns the entry as an appearance subdictionary. * * @throws IllegalStateException if this entry is not an appearance subdictionary */ public Map<COSName, PDAppearanceStream> getSubDictionary() { if (!isSubDictionary()) { throw new IllegalStateException("This entry is not an appearance subdictionary"); } COSDictionary dict = entry; Map<COSName, PDAppearanceStream> map = new HashMap<>(); for (COSName name : dict.keySet()) { COSBase value = dict.getDictionaryObject(name); // the file from PDFBOX-1599 contains /null as its entry, so we skip non-stream entries if (value instanceof COSStream) { map.put(name, new PDAppearanceStream((COSStream) value)); } } return new COSDictionaryMap<>(map, dict); } }
/** * Returns the appearance stream for this annotation, if any. The annotation state is taken into account, if * present. */ public PDAppearanceStream getNormalAppearanceStream() { PDAppearanceDictionary appearanceDict = getAppearance(); if (appearanceDict == null) { return null; } PDAppearanceEntry normalAppearance = appearanceDict.getNormalAppearance(); if (normalAppearance == null) { return null; } if (normalAppearance.isSubDictionary()) { COSName state = getAppearanceState(); return normalAppearance.getSubDictionary().get(state); } else { return normalAppearance.getAppearanceStream(); } }
/** * 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; }
/** * 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 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; }
private static String getN_type(PDAnnotation annot) { PDAppearanceDictionary appearanceDictionary = annot.getAppearance(); if (appearanceDictionary != null) { PDAppearanceEntry normalAppearance = appearanceDictionary.getNormalAppearance(); if (normalAppearance == null) { return null; } else if (normalAppearance.isSubDictionary()) { return DICT; } else { return STREAM; } } return null; }
/** * Returns the entry as an appearance subdictionary. * * @throws IllegalStateException if this entry is not an appearance subdictionary */ public Map<COSName, PDAppearanceStream> getSubDictionary() { if (!isSubDictionary()) { throw new IllegalStateException(); } COSDictionary dict = (COSDictionary) entry; Map<COSName, PDAppearanceStream> map = new HashMap<COSName, PDAppearanceStream>(); for (COSName name : dict.keySet()) { COSBase value = dict.getDictionaryObject(name); // the file from PDFBOX-1599 contains /null as its entry, so we skip non-stream entries if (value instanceof COSStream) { map.put(name, new PDAppearanceStream((COSStream) value)); } } return new COSDictionaryMap<COSName, PDAppearanceStream>(map, dict); } }
/** * Returns the entry as an appearance subdictionary. * * @throws IllegalStateException if this entry is not an appearance subdictionary */ public Map<COSName, PDAppearanceStream> getSubDictionary() { if (!isSubDictionary()) { throw new IllegalStateException(); } COSDictionary dict = (COSDictionary) entry; Map<COSName, PDAppearanceStream> map = new HashMap<>(); for (COSName name : dict.keySet()) { COSBase value = dict.getDictionaryObject(name); // the file from PDFBOX-1599 contains /null as its entry, so we skip non-stream entries if (value instanceof COSStream) { map.put(name, new PDAppearanceStream((COSStream) value)); } } return new COSDictionaryMap<>(map, dict); } }
/** * Returns the appearance stream for this annotation, if any. The annotation state is taken into account, if * present. */ public PDAppearanceStream getNormalAppearanceStream() { PDAppearanceDictionary appearanceDict = getAppearance(); if (appearanceDict == null) { return null; } PDAppearanceEntry normalAppearance = appearanceDict.getNormalAppearance(); if (normalAppearance == null) { return null; } if (normalAppearance.isSubDictionary()) { COSName state = getAppearanceState(); return normalAppearance.getSubDictionary().get(state); } else { return normalAppearance.getAppearanceStream(); } }
/** * Returns the appearance stream for this annotation, if any. The annotation state is taken into account, if * present. */ public PDAppearanceStream getNormalAppearanceStream() { PDAppearanceDictionary appearanceDict = getAppearance(); if (appearanceDict == null) { return null; } PDAppearanceEntry normalAppearance = appearanceDict.getNormalAppearance(); if (normalAppearance == null) { return null; } if (normalAppearance.isSubDictionary()) { COSName state = getAppearanceState(); return normalAppearance.getSubDictionary().get(state); } else { return normalAppearance.getAppearanceStream(); } }
/** * 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 appearanceEntry = appearanceDictionary.getDownAppearance(); if (appearanceEntry.isSubDictionary()) { appearanceEntry = new PDAppearanceEntry(new COSStream()); appearanceDictionary.setDownAppearance(appearanceEntry); } return appearanceEntry; }
/** * 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 appearanceEntry = appearanceDictionary.getRolloverAppearance(); if (appearanceEntry.isSubDictionary()) { appearanceEntry = new PDAppearanceEntry(new COSStream()); appearanceDictionary.setRolloverAppearance(appearanceEntry); } return appearanceEntry; }
/** * 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; }