Java Code Examples for org.apache.pdfbox.cos.COSDictionary#getValues()
The following examples show how to use
org.apache.pdfbox.cos.COSDictionary#getValues() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: COSParser.java From gcs with Mozilla Public License 2.0 | 6 votes |
/** * 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(); }
Example 2
Source File: COSParser.java From gcs with Mozilla Public License 2.0 | 6 votes |
/** * 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); } } } }
Example 3
Source File: ExtractText.java From testarea-pdfbox2 with Apache License 2.0 | 5 votes |
void removeToUnicodeMaps(PDResources pdResources) throws IOException { COSDictionary resources = pdResources.getCOSObject(); COSDictionary fonts = asDictionary(resources, COSName.FONT); if (fonts != null) { for (COSBase object : fonts.getValues()) { while (object instanceof COSObject) object = ((COSObject)object).getObject(); if (object instanceof COSDictionary) { COSDictionary font = (COSDictionary)object; font.removeItem(COSName.TO_UNICODE); } } } for (COSName name : pdResources.getXObjectNames()) { PDXObject xobject = pdResources.getXObject(name); if (xobject instanceof PDFormXObject) { PDResources xobjectPdResources = ((PDFormXObject)xobject).getResources(); removeToUnicodeMaps(xobjectPdResources); } } }