/** * Parse the values of the trailer dictionary and return the root object. * * @param trailer The trailer dictionary. * @return The parsed root object. * @throws IOException If an IO error occurs or if the root object is missing in the trailer dictionary. */ protected COSBase parseTrailerValuesDynamically(COSDictionary trailer) throws IOException { // PDFBOX-1557 - ensure that all COSObject are loaded in the trailer // PDFBOX-1606 - after securityHandler has been instantiated for (COSBase trailerEntry : trailer.getValues()) { if (trailerEntry instanceof COSObject) { COSObject tmpObj = (COSObject) trailerEntry; parseObjectDynamically(tmpObj, false); } } // parse catalog or root object COSObject root = trailer.getCOSObject(COSName.ROOT); if (root == null) { throw new IOException("Missing root object specification in trailer."); } return root.getObject(); }
/** * Resolves all not already parsed objects of a dictionary recursively. * * @param dictionaryObject dictionary to be parsed * @throws IOException if something went wrong * */ private void parseDictionaryRecursive(COSObject dictionaryObject) throws IOException { parseObjectDynamically(dictionaryObject, true); if (!(dictionaryObject.getObject() instanceof COSDictionary)) { // we can't be lenient here, this is called by prepareDecryption() // to get the encryption directory throw new IOException("Dictionary object expected at offset " + source.getPosition()); } COSDictionary dictionary = (COSDictionary) dictionaryObject.getObject(); for (COSBase value : dictionary.getValues()) { if (value instanceof COSObject) { COSObject object = (COSObject) value; if (object.getObject() == null) { parseDictionaryRecursive(object); } } } }
if( info != null ) for (COSBase cosBase : info.getValues())
/** * Get all values of the dictionary */ private List<CosObject> getValues() { COSDictionary dictionary = (COSDictionary) this.baseObject; List<CosObject> list = new ArrayList<>(dictionary.size()); for (COSBase value : dictionary.getValues()) { if (value != null) { list.add(getFromValue(value, this.document, this.flavour)); } } return Collections.unmodifiableList(list); }
private List<PDSeparation> getColorants(COSDictionary colorantsDict) { ArrayList<PDSeparation> list = new ArrayList<>(colorantsDict.size()); for (COSBase value : colorantsDict.getValues()) { try { org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace colorSpace = org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace.create(value); if (colorSpace instanceof org.apache.pdfbox.pdmodel.graphics.color.PDSeparation) { list.add((PBoxPDSeparation) ColorSpaceFactory.getColorSpace(colorSpace, this.document, this.flavour)); } } catch (IOException e) { LOGGER.debug("Problems with color space obtain.", e); } } return Collections.unmodifiableList(list); } }
/** * Parse the values of the trailer dictionary and return the root object. * * @param trailer The trailer dictionary. * @return The parsed root object. * @throws IOException If an IO error occurs or if the root object is missing in the trailer dictionary. */ protected COSBase parseTrailerValuesDynamically(COSDictionary trailer) throws IOException { // PDFBOX-1557 - ensure that all COSObject are loaded in the trailer // PDFBOX-1606 - after securityHandler has been instantiated for (COSBase trailerEntry : trailer.getValues()) { if (trailerEntry instanceof COSObject) { COSObject tmpObj = (COSObject) trailerEntry; parseObjectDynamically(tmpObj, false); } } // parse catalog or root object COSObject root = trailer.getCOSObject(COSName.ROOT); if (root == null) { throw new IOException("Missing root object specification in trailer."); } return root.getObject(); }
/** * Parse the values of the trailer dictionary and return the root object. * * @param trailer The trailer dictionary. * @return The parsed root object. * @throws IOException If an IO error occurs or if the root object is * missing in the trailer dictionary. */ protected COSBase parseTrailerValuesDynamically(COSDictionary trailer) throws IOException { // PDFBOX-1557 - ensure that all COSObject are loaded in the trailer // PDFBOX-1606 - after securityHandler has been instantiated for (COSBase trailerEntry : trailer.getValues()) { if (trailerEntry instanceof COSObject) { COSObject tmpObj = (COSObject) trailerEntry; parseObjectDynamically(tmpObj, false); } } // parse catalog or root object COSObject root = (COSObject) trailer.getItem(COSName.ROOT); if (root == null) { throw new IOException("Missing root object specification in trailer."); } return root.getObject(); }
// Check if COSDictionary has '/ProcSet [/PDF /Text]' string in the stream private static boolean isXobjectHasTextFieldInPdf(COSDictionary dictionary) { boolean isHasTextField = false; for (COSBase cosBase : dictionary.getValues()) { // go to a recursion because COSDictionary can have COSDictionaries inside if (cosBase instanceof COSDictionary) { COSDictionary cosDictionaryNew = (COSDictionary) cosBase; // check if '/ProcSet' has '/Text' param if (cosDictionaryNew.containsKey(COSName.PROC_SET)) { COSBase procSet = cosDictionaryNew.getDictionaryObject(COSName.PROC_SET); if (procSet instanceof COSArray) { for (COSBase procSetIterator : ((COSArray) procSet)) { if (procSetIterator instanceof COSName && ((COSName) procSetIterator).getName().equals("Text")) { return true; } } } else if (procSet instanceof COSString && ((COSString) procSet).getString().equals("Text")) { return true; } } // go to the COSDictionary children isHasTextField = isXobjectHasTextFieldInPdf(cosDictionaryNew); } } return isHasTextField; }
for (COSBase val : apnDict.getValues())
/** * Resolves all not already parsed objects of a dictionary recursively. * * @param dictionaryObject dictionary to be parsed * @throws IOException if something went wrong * */ private void parseDictionaryRecursive(COSObject dictionaryObject) throws IOException { parseObjectDynamically(dictionaryObject, true); COSDictionary dictionary = (COSDictionary)dictionaryObject.getObject(); for(COSBase value : dictionary.getValues()) { if (value instanceof COSObject) { COSObject object = (COSObject)value; if (object.getObject() == null) { parseDictionaryRecursive(object); } } } }
/** * Resolves all not already parsed objects of a dictionary recursively. * * @param dictionaryObject dictionary to be parsed * @throws IOException if something went wrong * */ private void parseDictionaryRecursive(COSObject dictionaryObject) throws IOException { parseObjectDynamically(dictionaryObject, true); if (!(dictionaryObject.getObject() instanceof COSDictionary)) { // we can't be lenient here, this is called by prepareDecryption() // to get the encryption directory throw new IOException("Dictionary object expected at offset " + source.getPosition()); } COSDictionary dictionary = (COSDictionary) dictionaryObject.getObject(); for (COSBase value : dictionary.getValues()) { if (value instanceof COSObject) { COSObject object = (COSObject) value; if (object.getObject() == null) { parseDictionaryRecursive(object); } } } }
if( info != null ) for (COSBase cosBase : info.getValues())
if( info != null ) for (COSBase cosBase : info.getValues())
for (COSBase val : apnDict.getValues())
for (COSBase val : apnDict.getValues())