private static COSDictionary getDescendantCOSDictionary(COSDictionary dict) { if (dict != null) { COSArray array = (COSArray) dict.getKey(ASAtom.DESCENDANT_FONTS).getDirectBase(); if (array != null) { return (COSDictionary) array.at(0).getDirectBase(); } } return null; }
/** * @return dictionary with char proc values. */ public COSDictionary getCharProcDict() { return (COSDictionary) this.dictionary.getKey(ASAtom.CHAR_PROCS).getDirectBase(); }
private List<CosUnicodeName> getColorantName() { COSObject name = ((org.verapdf.pd.colors.PDSeparation) this.simplePDObject).getColorantName(); if (name.getType() == COSObjType.COS_NAME) { List<CosUnicodeName> list = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS); list.add(new GFCosUnicodeName((COSName) name.getDirectBase())); return Collections.unmodifiableList(list); } return Collections.emptyList(); } }
private static void addArrayElements(List<byte[]> res, COSArray arg) { for (COSObject element : arg) { if (element != null && element.getType() == COSObjType.COS_STRING) { res.add(((COSString) element.getDirectBase()).get()); } } }
private COSObject decryptCOSString(COSObject string) { StandardSecurityHandler ssh = this.document.getStandardSecurityHandler(); try { ssh.decryptString((COSString) string.getDirectBase(), this.keyOfCurrentObject); return string; } catch (IOException | GeneralSecurityException e) { LOGGER.log(Level.WARNING, "Can't decrypt string in object " + this.keyOfCurrentObject); return string; } } }
public COSStream getPS() { COSObject ps = getKey(ASAtom.PS); if (ps != null && ps.getType() == COSObjType.COS_STREAM) { return (COSStream) ps.getDirectBase(); } return null; }
/** * @return COSObject that is font dictionary for descendant font. */ public COSObject getDescendantFontObject() { if (this.type0FontDict != null) { COSArray array = (COSArray) this.type0FontDict.getKey(ASAtom.DESCENDANT_FONTS).getDirectBase(); if (array != null) { return array.at(0); } } return null; }
public COSName getIntent() { COSObject object = getKey(ASAtom.INTENT); if (object != null && object.getType() == COSObjType.COS_NAME) { return (COSName) object.getDirectBase(); } return null; }
public COSName getCOSStructureType() { COSObject object = getKey(ASAtom.S); if (object != null && object.getType() == COSObjType.COS_NAME) { return (COSName) object.getDirectBase(); } return null; }
public COSArray getID() { if (trailer != null) { COSObject res = trailer.getKey(ASAtom.ID); if (res.getType() == COSObjType.COS_ARRAY) { return (COSArray) res.getDirectBase(); } } return null; }
public COSName getCOSRenderingIntentName() { COSObject name = getKey(ASAtom.RI); if (name != null && name.getType() == COSObjType.COS_NAME) { return (COSName) name.getDirectBase(); } return null; }
private COSString getCOSString(ASAtom key) { COSObject o = getKey(key); if (o != null && o.getType() == COSObjType.COS_STRING) { return (COSString) o.getDirectBase(); } return null; }
/** * @return COSString that contains Contents of PDSignature. */ public COSString getContents() { COSObject res = this.getKey(ASAtom.CONTENTS); if (res.getType() == COSObjType.COS_STRING) { return (COSString) res.getDirectBase(); } return null; }
/** * @return true if document-level metadata stream shall be be encrypted. */ public boolean isEncryptMetadata() { COSObject encryptMetadata = getKey(ASAtom.ENCRYPT_META_DATA); if (encryptMetadata != null && encryptMetadata.getType() == COSObjType.COS_BOOLEAN) { return encryptMetadata.getDirectBase().getBoolean(); } return DEFAULT_ENCRYPT_METADATA; }
private COSDictionary getCatalog() { COSBase catalogLocal = cosDocument.getTrailer().getRoot().getDirectBase(); if (catalogLocal != null && catalogLocal.getType() == COSObjType.COS_DICT) { return (COSDictionary) catalogLocal; } return null; }
private void addLabelsFromArray(COSArray nums) { for (int i = 0; i < nums.size(); i+=2) { COSObject cosKey = nums.at(i); Long key = cosKey == null ? null : cosKey.getInteger(); COSObject cosValue = nums.at(i+1); if (key != null && cosValue != null && !cosValue.empty() && cosValue.getType() == COSObjType.COS_DICT) { PageLabelDictionary pageLabelDictionary = new PageLabelDictionary((COSDictionary) cosValue.getDirectBase(), key.intValue()); this.labelsMap.put(key.intValue(), pageLabelDictionary); } } }
private void getNamesEmbeddedFiles(List<CosFileSpecification> files, PDNameTreeNode node) { Map<String, COSObject> names = node.getNames(); for (COSObject value : names.values()) { if (value != null && value.getType().isDictionaryBased()) { files.add(new GFCosFileSpecification((COSDictionary) value.getDirectBase())); } } for (PDNameTreeNode kid : node.getKids()) { getNamesEmbeddedFiles(files, kid); } }
private byte[] getID() { if (this.id != null && this.id.getType() == COSObjType.COS_ARRAY) { COSObject id1 = id.at(0); if (id1.getType() == COSObjType.COS_STRING) { return getBytesOfHexString((COSString) id1.getDirectBase()); } } return null; }
public COSNumber getCOSFontSize() { COSObject fontArray = getKey(ASAtom.FONT); if (fontArray != null && fontArray.getType() == COSObjType.COS_ARRAY) { COSObject res = fontArray.at(1); if (res != null && res.getType().isNumber()) { return (COSNumber) res.getDirectBase(); } } return null; }
private void initializeContents(final COSObject pageDict) { COSObject contents = pageDict.getKey(ASAtom.CONTENTS); if (!contents.empty() && contents.getType() == COSObjType.COS_STREAM) { this.content = new PDPageContentStream(contents); } else if (!contents.empty() && contents.getType() == COSObjType.COS_ARRAY) { try { this.content = new PDPageContentStream(COSStream.concatenateStreams((COSArray) contents.getDirectBase())); } catch (IOException e) { this.content = new PDPageContentStream(contents.at(0)); } } }