private static boolean areColorantsPresent(Set<ASAtom> colorantDictionaryEntries, List<COSObject> colorantsArray) { for (int i = 0; i < colorantsArray.size(); ++i) { COSObject object = colorantsArray.get(i); if (object != null && !isNone(object) && !IGNORED_COLORANTS.contains(object.getName()) && !colorantDictionaryEntries.contains(object.getName())) { return false; } } return true; }
public final ASAtom getNameKey(final ASAtom key) { return getKey(key).getName(); }
public ASAtom getName() { return getDirect().getName(); }
private static boolean isNone(COSObject obj) { return obj.getType() == COSObjType.COS_NAME && obj.getName() == ASAtom.NONE; }
/** * @return method used by crypt filter: None, V2 or AESV2. */ public ASAtom getMethod() { COSObject obj = getKey(ASAtom.CFM); if(obj != null && obj.getType() == COSObjType.COS_NAME) { return obj.getName(); } return ASAtom.NONE; }
@Override public Long getHalftoneType() { PDHalftone halftone = (PDHalftone) this.simplePDObject; COSObject object = halftone.getObject(); if (object.getType() == COSObjType.COS_NAME && object.getName() == ASAtom.DEFAULT) { return Long.valueOf(1L); } return halftone.getHalftoneType(); }
public ASAtom getFT() { COSObject object = getInheritedObject(ASAtom.FT); return object == null || object.getType() != COSObjType.COS_NAME ? null : object.getName(); }
protected void updateFromObject() { COSObject filters = getObject(); if(filters.getType().equals(COSObjType.COS_ARRAY)) { int size = filters.size(); this.entries.clear(); for (int i = 0; i < size; i++) { this.entries.add(filters.at(i).getName()); } } else if (filters.getType().equals(COSObjType.COS_NAME)) { this.entries.clear(); this.entries.add(filters.getName()); } }
public List<ASAtom> getFilters() { COSObject filters = getObject().getKey(ASAtom.FILTER); if (filters != null) { List<ASAtom> res = new ArrayList<>(); if (filters.getType() == COSObjType.COS_NAME) { res.add(filters.getName()); } else if (filters.getType() == COSObjType.COS_ARRAY) { for (COSObject filter : ((COSArray)filters.getDirectBase())) { if (filter == null || filter.getType() != COSObjType.COS_NAME) { LOGGER.log(Level.FINE, "Filter array contains non name value"); return Collections.emptyList(); } res.add(filter.getName()); } } return Collections.unmodifiableList(res); } return Collections.emptyList(); }
public static StructureType createStructureType(COSObject type, COSObject ns) { if (type != null && type.getType() == COSObjType.COS_NAME) { if (ns != null && ns.getType() == COSObjType.COS_DICT) { return new StructureType(type.getName(), PDStructureNameSpace.createNameSpace(ns)); } else { return new StructureType(type.getName(), null); } } return null; }
public String getSubtype() { COSObject base = getKey(ASAtom.S); if (base != null && base.getType() == COSObjType.COS_NAME) { return base.getName().getValue(); } return null; }
private boolean parseSignatureNameValuePair() throws IOException { COSObject key = getName(); if (key.getType() != COSObjType.COS_NAME) { LOGGER.log(Level.FINE, "Invalid signature dictionary"); return false; } if (key.getName() != ASAtom.CONTENTS) { passCOSDictionaryValue(); return false; } parseSignatureValue(); return true; }
private static String getStringProperty(COSObject property) { if (property == null || property.empty() || property.getType() == COSObjType.COS_NULL) { return null; } if (property.getType() == COSObjType.COS_NAME) { return property.getName().getValue(); } return property.toString(); }
@Override public String getHalftoneName() { PDHalftone halftone = (PDHalftone) this.simplePDObject; COSObject object = halftone.getObject(); if (object.getType() == COSObjType.COS_NAME && object.getName() == ASAtom.DEFAULT) { return null; } return halftone.getHalftoneName(); }
public String getHalftoneName() { COSObject base = getObject(); if (base.getType() == COSObjType.COS_NAME) { return base.getName().getValue(); } return base.getStringKey(ASAtom.HALFTONE_NAME); } }
@Override public String getTransferFunction() { COSObject tf = this.simplePDObject.getKey(ASAtom.getASAtom("TransferFunction")); if (tf == null || tf.empty() || tf.getType() == COSObjType.COS_NULL) { return null; } if (tf.getType() == COSObjType.COS_NAME) { return tf.getName().getValue(); } return tf.toString(); }
private static boolean areColorantsPresent(org.verapdf.pd.colors.PDDeviceN simplePDObject) { COSObject attributes = simplePDObject.getAttributes(); if (attributes != null && attributes.getType() == COSObjType.COS_DICT) { COSObject colorantsDict = attributes.getKey(ASAtom.COLORANTS); List<COSObject> colorantsArray = simplePDObject.getNames(); Set<ASAtom> componentNames = new TreeSet<>(); if (colorantsDict != null && colorantsDict.getType() == COSObjType.COS_DICT) { componentNames.addAll(colorantsDict.getKeySet()); } COSArray components = getProcessComponents(attributes); if (components != null) { for (COSObject component : components) { if (component.getType() == COSObjType.COS_NAME) { componentNames.add(component.getName()); } } } return GFPDDeviceN.areColorantsPresent(componentNames, colorantsArray); } return false; }
private static COSObject psCopyObject(COSObject toCopy) { switch (toCopy.getType()) { case COS_BOOLEAN: return COSBoolean.construct(toCopy.getBoolean()); case COS_INTEGER: return COSInteger.construct(toCopy.getInteger()); case COS_NAME: return COSName.construct(toCopy.getName()); case COS_REAL: return COSReal.construct(toCopy.getReal()); default: // In all other cases copied object share the same memory location return toCopy; } } }
private void parseJPXAndColorSpace() { List<ASAtom> filters = getFilters(); if (filters.contains(ASAtom.JPX_DECODE)) { this.jpxStream = JPEG2000.fromStream(getObject().getData()); this.imageCS = this.imageCS == null ? this.jpxStream.getImageColorSpace() : this.imageCS; } COSObject rawColorSpace = getKey(ASAtom.COLORSPACE); if (rawColorSpace != null && !rawColorSpace.empty() && rawColorSpace.getType() != COSObjType.COS_NULL) { if (rawColorSpace.getType() == COSObjType.COS_NAME) { this.colorSpaceName = rawColorSpace.getName(); } if (rawColorSpace.getType() == COSObjType.COS_ARRAY) { this.imageCS = ColorSpaceFactory.getColorSpace(rawColorSpace, resources); } } }
public PDColorSpace getImageCS() { COSObject cs = getKey(ASAtom.CS); if (cs.empty()) { cs = getKey(ASAtom.COLORSPACE); } if (cs != null && cs.getType() == COSObjType.COS_NAME) { replaceAbbreviation((COSName) cs.getDirectBase()); PDColorSpace result = getDefaultColorSpace(cs.getName()); if (result != null) { return result; } } PDColorSpace result = ColorSpaceFactory.getColorSpace(cs, imageResources); if (result == null) { result = ColorSpaceFactory.getColorSpace(cs, pageResources); } return result; }