/** * Creates a new COSStream using the current configuration for scratch files. * Not for public use. Only COSParser should call this method. * * @param dictionary the corresponding dictionary * @return the new COSStream */ public COSStream createCOSStream(COSDictionary dictionary) { COSStream stream = new COSStream(scratchFile); for (Map.Entry<COSName, COSBase> entry : dictionary.entrySet()) { stream.setItem(entry.getKey(), entry.getValue()); } return stream; }
/** * This will add all of the dictionaries keys/values to this dictionary, but * only if they are not in an exclusion list and if they don't already * exist. If a key already exists in this dictionary then nothing is * changed. * * @param src The source dictionary to get the keys/values from. * @param dst The destination dictionary to merge the keys/values into. * @param exclude Names of keys that shall be skipped. */ private void mergeInto(COSDictionary src, COSDictionary dst, Set<COSName> exclude) { for (Map.Entry<COSName, COSBase> entry : src.entrySet()) { if (!exclude.contains(entry.getKey()) && !dst.containsKey(entry.getKey())) { dst.setItem(entry.getKey(), entry.getValue()); } } } }
/** * This will add all of the dictionaries keys/values to this dictionary. * Only called when adding keys to a trailer that already exists. * * @param dic The dictionaries to get the keys from. */ public void addAll(COSDictionary dic) { for (Map.Entry<COSName, COSBase> entry : dic.entrySet()) { /* * If we're at a second trailer, we have a linearized pdf file, meaning that the first Size entry represents * all of the objects so we don't need to grab the second. */ if (!entry.getKey().getName().equals("Size") || !items.containsKey(COSName.getPDFName("Size"))) { setItem(entry.getKey(), entry.getValue()); } } }
/** * Gets the attribute names. * * @return the attribute names */ public List<String> getAttributeNames() { List<String> attrNames = new ArrayList<>(); for (Entry<COSName, COSBase> entry : this.getCOSObject().entrySet()) { COSName key = entry.getKey(); if (!COSName.O.equals(key)) { attrNames.add(key.getName()); } } return attrNames; }
private void transferDict(COSDictionary orgDict, COSDictionary targetDict, Set<String> filter, boolean inclusive) throws IOException { for (Map.Entry<COSName, COSBase> entry : orgDict.entrySet()) { COSName key = entry.getKey(); if (inclusive && !filter.contains(key.getName())) { continue; } else if (!inclusive && filter.contains(key.getName())) { continue; } targetDict.setItem(key, cloner.cloneForNewDocument(entry.getValue())); } }
for (Map.Entry<COSName, COSBase> x : ((COSDictionary) base).entrySet())
private void mergeRoleMap(PDStructureTreeRoot srcStructTree, PDStructureTreeRoot destStructTree) { COSDictionary srcDict = srcStructTree.getCOSObject().getCOSDictionary(COSName.ROLE_MAP); COSDictionary destDict = destStructTree.getCOSObject().getCOSDictionary(COSName.ROLE_MAP); if (srcDict == null) { return; } if (destDict == null) { destStructTree.getCOSObject().setItem(COSName.ROLE_MAP, srcDict); // clone not needed return; } for (Map.Entry<COSName, COSBase> entry : srcDict.entrySet()) { if (destDict.containsKey(entry.getKey())) { LOG.warn("key " + entry.getKey() + " already exists in destination RoleMap"); } else { destDict.setItem(entry.getKey(), entry.getValue()); } } }
/** * Copy all Trailer Information to this file. * * @param trailerDict dictionary to be added as trailer info */ public void addTrailerInfo(COSDictionary trailerDict) { Set<Entry<COSName, COSBase>> entrySet = trailerDict.entrySet(); for ( Entry<COSName, COSBase> entry : entrySet ) { COSName key = entry.getKey(); if (COSName.INFO.equals(key) || COSName.ROOT.equals(key) || COSName.ENCRYPT.equals(key) || COSName.ID.equals(key) || COSName.PREV.equals(key)) { stream.setItem(key, entry.getValue()); } } }
for (Map.Entry<COSName, COSBase> entry : obj.entrySet())
for (Map.Entry<COSName, COSBase> entry : dictionary.entrySet())
retval = new COSDictionary(); clonedVersion.put( base, retval ); for( Map.Entry<COSName, COSBase> entry : dic.entrySet() )
if (mapOfXObj != null) for (Entry<COSName, COSBase> entry : mapOfXObj.entrySet())
for( Map.Entry<COSName, COSBase> entry : dic.entrySet() )
for (Map.Entry<COSName, COSBase> entry : dict.entrySet())
for (Map.Entry<COSName, COSBase> entry : obj.entrySet())
/** * Creates a new COSStream using the current configuration for scratch files. * Not for public use. Only COSParser should call this method. * * @param dictionary the corresponding dictionary * @return the new COSStream */ public COSStream createCOSStream(COSDictionary dictionary) { COSStream stream = new COSStream(scratchFile); for (Map.Entry<COSName, COSBase> entry : dictionary.entrySet()) { stream.setItem(entry.getKey(), entry.getValue()); } return stream; }
/** * Creates a new COSStream using the current configuration for scratch files. * Not for public use. Only COSParser should call this method. * * @param dictionary the corresponding dictionary * @return the new COSStream */ public COSStream createCOSStream(COSDictionary dictionary) { COSStream stream = new COSStream(scratchFile); for (Map.Entry<COSName, COSBase> entry : dictionary.entrySet()) { stream.setItem(entry.getKey(), entry.getValue()); } return stream; }
/** * Gets the attribute names. * * @return the attribute names */ public List<String> getAttributeNames() { List<String> attrNames = new ArrayList<String>(); for (Entry<COSName, COSBase> entry : this.getCOSObject().entrySet()) { COSName key = entry.getKey(); if (!COSName.O.equals(key)) { attrNames.add(key.getName()); } } return attrNames; }
private void transferDict(COSDictionary orgDict, COSDictionary targetDict, Set<String> filter, boolean inclusive) throws IOException { for (Map.Entry<COSName, COSBase> entry : orgDict.entrySet()) { COSName key = entry.getKey(); if (inclusive && !filter.contains(key.getName())) { continue; } else if (!inclusive && filter.contains(key.getName())) { continue; } targetDict.setItem(key, cloner.cloneForNewDocument(entry.getValue())); } }
/** * Copy all Trailer Information to this file. * * @param trailerDict dictionary to be added as trailer info */ public void addTrailerInfo(COSDictionary trailerDict) { Set<Entry<COSName, COSBase>> entrySet = trailerDict.entrySet(); for ( Entry<COSName, COSBase> entry : entrySet ) { COSName key = entry.getKey(); if (COSName.INFO.equals(key) || COSName.ROOT.equals(key) || COSName.ENCRYPT.equals(key) || COSName.ID.equals(key) || COSName.PREV.equals(key)) { stream.setItem(key, entry.getValue()); } } }