public List<PDOutputIntent> getOutputIntents() { COSObject base = getKey(ASAtom.OUTPUT_INTENTS); if (base != null && base.getType() == COSObjType.COS_ARRAY) { if (base.isIndirect()) { base = base.getDirect(); } List<PDOutputIntent> result = new ArrayList<>(base.size()); for (COSObject obj : (COSArray) base.getDirectBase()) { if (obj != null && obj.getType().isDictionaryBased()) { result.add(new PDOutputIntent(obj)); } } return Collections.unmodifiableList(result); } return Collections.emptyList(); }
public Map<ASAtom, PDAppearanceStream> getSubDictionary() { if (!isSubDictionary()) { throw new IllegalStateException("Current appearance entry is a stream"); } Map<ASAtom, PDAppearanceStream> res = new HashMap<>(); for (ASAtom key : getObject().getKeySet()) { COSObject obj = getKey(key); if (obj.isIndirect()) { obj = obj.getDirect(); } if (obj != null && obj.getType() == COSObjType.COS_STREAM) { res.put(key, new PDAppearanceStream(obj)); } } return Collections.unmodifiableMap(res); }
public List<PDAnnotation> getAnnotations() { COSObject annots = getKey(ASAtom.ANNOTS); if (!annots.empty() && annots.getType() == COSObjType.COS_ARRAY) { List<PDAnnotation> res = new ArrayList<>(); if (annots.isIndirect()) { annots = annots.getDirect(); } for (COSObject annot : (COSArray) annots.getDirectBase()) { if (annot != null && annot.getType() == COSObjType.COS_DICT) { res.add(new PDAnnotation(annot)); } } return Collections.unmodifiableList(res); } else if (annots.empty()) { annots = COSArray.construct(); this.setKey(ASAtom.ANNOTS, annots); } return Collections.emptyList(); }
private COSKey getObjectKey(final COSObject base) { COSKey res = null; if (base.isIndirect()) { COSObject item = base; while (item.isIndirect()) { res = item.getObjectKey(); item = base.getDirect(); } } else { res = base.getObjectKey(); } return res; }
public COSKey setObject(COSObject obj) { COSKey key = obj.getKey(); //TODO : fix this method for document save if (key == null) { key = this.xref.next(); this.body.set(key, obj.isIndirect() ? obj.getDirect() : obj); obj = COSIndirect.construct(key, this); } this.xref.newKey(key); return key; }
/** * @return resources as presented in type 3 font dictionary. */ public PDResources getResources() { COSObject resources = this.dictionary.getKey(ASAtom.RESOURCES); if (!resources.empty() && resources.getType() == COSObjType.COS_DICT) { if (resources.isIndirect()) { resources = resources.getDirect(); } return new PDResources(resources); } else { return new PDResources(COSDictionary.construct()); } }