Search in sources :

Example 1 with COSDictionaryMap

use of com.tom_roush.pdfbox.pdmodel.common.COSDictionaryMap in project PdfBox-Android by TomRoush.

the class PDAppearanceEntry method getSubDictionary.

/**
 * 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 = (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);
}
Also used : COSStream(com.tom_roush.pdfbox.cos.COSStream) COSDictionary(com.tom_roush.pdfbox.cos.COSDictionary) COSName(com.tom_roush.pdfbox.cos.COSName) HashMap(java.util.HashMap) COSBase(com.tom_roush.pdfbox.cos.COSBase) COSDictionaryMap(com.tom_roush.pdfbox.pdmodel.common.COSDictionaryMap)

Aggregations

COSBase (com.tom_roush.pdfbox.cos.COSBase)1 COSDictionary (com.tom_roush.pdfbox.cos.COSDictionary)1 COSName (com.tom_roush.pdfbox.cos.COSName)1 COSStream (com.tom_roush.pdfbox.cos.COSStream)1 COSDictionaryMap (com.tom_roush.pdfbox.pdmodel.common.COSDictionaryMap)1 HashMap (java.util.HashMap)1