protected PDCIEDictionaryBased() { this(COSDictionary.construct()); }
/** * @return a specification of the mapping from CIDs to glyph indices if * CIDFont is a Type 2 CIDFont. */ public COSObject getCIDToGIDMap() { return this.dictionary.getKey(ASAtom.CID_TO_GID_MAP); }
public PageLabelDictionary(COSDictionary dict, int rangeStartIndex) { this.type = dict.getNameKey(ASAtom.S); String prefixValue = dict.getStringKey(ASAtom.P); this.prefix = prefixValue == null ? "" : prefixValue; Long integerKey = dict.getIntegerKey(ASAtom.ST); this.firstRangePortion = integerKey == null ? 1 : integerKey.intValue(); this.rangeStartIndex = rangeStartIndex; }
private static int colorsFromParams(COSDictionary decodeParams) { if (decodeParams.knownKey(ASAtom.COLORS)) { return decodeParams.getIntegerKey(ASAtom.COLORS).intValue(); } else { return COLORS_DEFAULT; } }
/** * @return true if {@code NeedsRendering} entry in catalog contains * {@code true} value. */ @Override public Boolean getNeedsRendering() { if (!catalog.knownKey(ASAtom.NEEDS_RENDERING).booleanValue()) { return Boolean.valueOf(false); } return catalog.getBooleanKey(ASAtom.NEEDS_RENDERING); }
/** * Constructor from COSDictionary. * * @param dictionary is font dictionary. */ public PDFont(COSDictionary dictionary) { super(new COSObject(dictionary)); if (dictionary == null) { dictionary = (COSDictionary) COSDictionary.construct().get(); } this.dictionary = dictionary; COSObject fd = dictionary.getKey(ASAtom.FONT_DESC); if (fd != null && fd.getType() == COSObjType.COS_DICT) { fontDescriptor = new PDFontDescriptor(fd); } else { fontDescriptor = new PDFontDescriptor(COSDictionary.construct()); } this.fontName = this.dictionary.getStringKey(ASAtom.BASE_FONT); this.subtype = this.dictionary.getNameKey(ASAtom.SUBTYPE); }
return this.equals(((COSObject) obj).get()); if (!that.size().equals(this.size())) { return false; Set<ASAtom> set1 = this.getKeySet(); if (!set1.equals(that.getKeySet())) { return false; COSBase cosBase1 = this.getKey(name).get(); COSBase cosBase2 = that.getKey(name).get(); if (!cosBase1.equals(cosBase2, checkedObjects)) { return false;
private void parseCharStrings() { COSDictionary charProcDict = ((org.verapdf.pd.font.type3.PDType3Font) this.pdFont).getCharProcDict(); if (charProcDict != null) { Set<ASAtom> keySet = charProcDict.getKeySet(); Map<String, PDContentStream> map = new HashMap<>(keySet.size()); for (ASAtom glyphName : keySet) { COSObject charProcStream = charProcDict.getKey(glyphName); if (!charProcStream.empty() && charProcDict.getType() == COSObjType.COS_DICT) { PDType3CharProc charProc = new PDType3CharProc(charProcStream); PDResourcesHandler glyphResources = getResourcesFromCharProcs(charProcStream); GFPDContentStream contentStream = new GFPDContentStream(charProc, glyphResources == null ? this.resources : glyphResources, inheritedGraphicState, new StructureElementAccessObject(this.simpleCOSObject)); map.put(glyphName.getValue(), contentStream); } else { LOGGER.log(Level.SEVERE, "Invalid entry in the char proc dictionary, dictionary is expected."); } } this.charStrings = Collections.unmodifiableMap(map); } else { this.charStrings = Collections.emptyMap(); } }
/** * @return font type (Type entry). */ public String getType() { String type = this.dictionary.getStringKey(ASAtom.TYPE); return type == null ? "" : type; }
/** * Get XMP metadata if it is present */ private List<PDMetadata> getMetadata() { COSDictionary dictionary = (COSDictionary) this.baseObject; COSObject meta = dictionary.getKey(ASAtom.METADATA); ASAtom type = dictionary.getNameKey(ASAtom.TYPE); if (meta != null && meta.getType() == COSObjType.COS_STREAM && type != ASAtom.CATALOG) { ArrayList<PDMetadata> pdMetadatas = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS); org.verapdf.pd.PDMetadata md = new org.verapdf.pd.PDMetadata(meta); pdMetadatas.add(new GFPDMetadata(md, Boolean.FALSE)); return Collections.unmodifiableList(pdMetadatas); } return Collections.emptyList(); }
private void createCIDToNameTableFromDict(COSDictionary encoding) throws IOException { if (encoding.knownKey(ASAtom.BASE_ENCODING)) { ASAtom baseEncoding = encoding.getNameKey(ASAtom.BASE_ENCODING); if (ASAtom.WIN_ANSI_ENCODING.equals(baseEncoding)) { System.arraycopy(TrueTypePredefined.WIN_ANSI_ENCODING, 0, encodingMappingArray, 0, 256); } else if (ASAtom.MAC_ROMAN_ENCODING.equals(baseEncoding)) { System.arraycopy(TrueTypePredefined.MAC_ROMAN_ENCODING, 0, encodingMappingArray, 0, 256); } else if (ASAtom.getASAtom( TrueTypePredefined.MAC_EXPERT_ENCODING_STRING).equals(baseEncoding)) { System.arraycopy(TrueTypePredefined.MAC_EXPERT_ENCODING, 0, encodingMappingArray, 0, 256); } else { throw new IOException("Error in reading /Encoding entry in font dictionary"); } } else { System.arraycopy(TrueTypePredefined.STANDARD_ENCODING, 0, encodingMappingArray, 0, 256); } applyDiffsToEncoding(encoding); for (int i = 0; i < 256; ++i) { if (TrueTypePredefined.NOTDEF_STRING.equals(encodingMappingArray[i])) { encodingMappingArray[i] = TrueTypePredefined.STANDARD_ENCODING[i]; } } }
/** * @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()); } }
public static COSObject construct(final ASAtom key, final boolean value) { return new COSObject(new COSDictionary(key, value)); }
private COSDictionary getCIDSystemInfo() { if (this.getObject().getType() == COSObjType.COS_NAME) { // actually creating COSDictionary with values from predefined CMap. String registry = this.getCMapFile().getRegistry(); String ordering = this.getCMapFile().getOrdering(); int supplement = this.getCMapFile().getSupplement(); COSDictionary res = (COSDictionary) COSDictionary.construct(ASAtom.REGISTRY, registry).get(); res.setStringKey(ASAtom.ORDERING, ordering); res.setIntegerKey(ASAtom.SUPPLEMENT, supplement); return res; } if (cidSystemInfo == null) { COSObject cidSystemInfoObject = this.getObject().getKey(ASAtom.CID_SYSTEM_INFO); if (cidSystemInfoObject.getType() == COSObjType.COS_DICT) { this.cidSystemInfo = (COSDictionary) cidSystemInfoObject.getDirectBase(); } else if (cidSystemInfoObject.getType() == COSObjType.COS_ARRAY) { // see PDF-1.4 specification cidSystemInfoObject = cidSystemInfoObject.at(0); if (cidSystemInfoObject != null && cidSystemInfoObject.getType() == COSObjType.COS_DICT) { this.cidSystemInfo = (COSDictionary) cidSystemInfoObject.getDirectBase(); } } } return this.cidSystemInfo; }
/** * {@inheritDoc} */ @Override public ASAtom getSubtype() { return this.type0FontDict.getNameKey(ASAtom.SUBTYPE); }
public void visitFromDictionary(COSDictionary obj) { this.copy.assign(COSDictionary.construct()); for (Map.Entry<ASAtom, COSObject> entry : obj.getEntrySet()) { COSObject element = new COSObject(); COSCopier copier = new COSCopier(element); entry.getValue().accept(copier); this.copy.setKey(entry.getKey(), element); } }
if (result instanceof InlineImageOperator) { InlineImageOperator imageOperator = (InlineImageOperator) result; COSDictionary imageParameters = (COSDictionary) COSDictionary.construct().get(); lastInlineImageDict = imageParameters; imageOperator.setImageParameters(imageParameters); Object value = parseNextToken(); if (value instanceof COSObject) { imageParameters.setKey(((COSObject) nextToken).getName(), (COSObject) value); } else { LOGGER.log(Level.FINE, "Unexpected token in BI operator parsing: " + value.toString());
/** * @return true if any of the entries /DigestLocation, /DigestMethod, or * /DigestValue is present. */ @Override public Boolean getcontainsDigestEntries() { COSDictionary dictionary = (COSDictionary) this.simpleCOSObject.getDirectBase(); if (dictionary != null) { return Boolean.valueOf(dictionary.knownKey(ASAtom.DIGEST_LOCATION).booleanValue() || dictionary.knownKey(ASAtom.DIGEST_METHOD).booleanValue() || dictionary.knownKey(ASAtom.DIGEST_VALUE).booleanValue()); } return Boolean.FALSE; }
/** * Constructor used by child classes * * @param dictionary greenfield COSDictionary * @param type type of child class */ protected GFCosDict(COSDictionary dictionary, final String type) { super(dictionary, type); this.size = dictionary.size().intValue(); }