/** * Returns the resource names of the given kind. */ private Iterable<COSName> getNames(COSName kind) { COSDictionary dict = (COSDictionary)resources.getDictionaryObject(kind); if (dict == null) { return Collections.emptySet(); } return dict.keySet(); }
/** * This will get the keys of all metadata information fields for the document. * * @return all metadata key strings. * @since Apache PDFBox 1.3.0 */ public Set<String> getMetadataKeys() { Set<String> keys = new TreeSet<>(); for (COSName key : info.keySet()) { keys.add(key.getName()); } return keys; }
/** * Returns list of maps that contains subject distinguished names like [(cn: John Doe, o: Doe), * (cn: John Smith)] both keys are typically of the form 'cn', 'o', 'email', '2.5.4.43'; and * values are text strings. */ public List<Map<String, String>> getSubjectDN() { COSBase base = this.dictionary.getDictionaryObject(COSName.SUBJECT_DN); if (base instanceof COSArray) { COSArray cosArray = (COSArray) base; List subjectDNList = cosArray.toList(); List<Map<String, String>> result = new LinkedList<>(); for (Object subjectDNItem : subjectDNList) { if (subjectDNItem instanceof COSDictionary) { COSDictionary subjectDNItemDict = (COSDictionary) subjectDNItem; Map<String, String> subjectDNMap = new HashMap<>(); for (COSName key : subjectDNItemDict.keySet()) { subjectDNMap.put(key.getName(), subjectDNItemDict.getString(key)); } result.add(subjectDNMap); } } return result; } return null; }
/** * 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 = entry; Map<COSName, PDAppearanceStream> map = new HashMap<>(); 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<>(map, dict); } }
/** * Returns a unique key for a new resource. */ private COSName createKey(COSName kind, String prefix) { COSDictionary dict = (COSDictionary)resources.getDictionaryObject(kind); if (dict == null) { return COSName.getPDFName(prefix + 1); } // find a unique key String key; int n = dict.keySet().size(); do { ++n; key = prefix + n; } while (dict.containsKey(key)); return COSName.getPDFName(key); }
boolean t = false; for (Object key : linearizedDict.keySet())
/** * According to the PDF Reference, A linearized PDF contain a dictionary as first object (linearized dictionary) and * only this one in the first section. * * @param document the document to validate. * @return the linearization dictionary or null. */ protected COSDictionary getLinearizedDictionary(PDDocument document) { // ---- Get Ref to obj COSDocument cDoc = document.getDocument(); List<?> lObj = cDoc.getObjects(); for (Object object : lObj) { COSBase curObj = ((COSObject) object).getObject(); if (curObj instanceof COSDictionary && ((COSDictionary) curObj).keySet().contains(COSName.getPDFName(DICTIONARY_KEY_LINEARIZED))) { return (COSDictionary) curObj; } } return null; }
for( COSName key : dic.keySet() )
/** * Returns a map of colorants and their associated Separation color space. * @return map of colorants to color spaces, never null. * @throws IOException If there is an error reading a color space */ public Map<String, PDSeparation> getColorants() throws IOException { Map<String,PDSeparation> actuals = new HashMap<>(); COSDictionary colorants = (COSDictionary)dictionary.getDictionaryObject(COSName.COLORANTS); if(colorants == null) { colorants = new COSDictionary(); dictionary.setItem(COSName.COLORANTS, colorants); } for(COSName name : colorants.keySet()) { COSBase value = colorants.getDictionaryObject(name); actuals.put(name.getName(), (PDSeparation)PDColorSpace.create(value)); } return new COSDictionaryMap<>(actuals, colorants); }
/** * Create a list of ExtGState dictionaries using the given Resource dictionary and the COSDocument. * * @param context the context which contains the Resource dictionary. * @param egsEntry a resource COSDictionary. * @return the list of ExtGState dictionaries. * @throws ValidationException thrown if an Extended Graphic State isn't valid. */ public List<COSDictionary> extractExtGStateDictionaries(PreflightContext context, COSDictionary egsEntry) throws ValidationException { List<COSDictionary> listOfExtGState = new ArrayList<>(0); COSDocument cosDocument = context.getDocument().getDocument(); COSDictionary extGStates = COSUtils.getAsDictionary(egsEntry, cosDocument); if (extGStates != null) { for (Object object : extGStates.keySet()) { COSName key = (COSName) object; COSBase gsBase = extGStates.getItem(key); COSDictionary gsDict = COSUtils.getAsDictionary(gsBase, cosDocument); if (gsDict == null) { throw new ValidationException("The Extended Graphics State dictionary is invalid"); } listOfExtGState.add(gsDict); } } return listOfExtGState; }
List<COSName> keys = new ArrayList<>(dict.keySet()); Collections.sort( keys ); for( int i=0; retval == -1 && i<keys.size(); i++ )
resources.setItem(COSName.FONT, fontsDictionary); for (COSName fontName : fontsDictionary.keySet())
for( COSName key : map.keySet() )
List<COSName> keys = new ArrayList<>(dict.keySet()); Collections.sort( keys ); COSName key = keys.get( index );
for (COSName key : dic.keySet())
if (aaDict != null) for (Object key : aaDict.keySet())
for (COSName name : cp.keySet())
Set<COSName> keyList = dicFonts.keySet(); for (Object key : keyList)
for( COSName key : dict.keySet() )