org.apache.pdfbox.cos.COSArray Java Examples

The following examples show how to use org.apache.pdfbox.cos.COSArray. 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: PDStructureElement.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Removes a class name.
 * 
 * @param className the class name
 */
public void removeClassName(String className)
{
    if (className == null)
    {
        return;
    }
    COSName key = COSName.C;
    COSBase c = this.getCOSObject().getDictionaryObject(key);
    COSName name = COSName.getPDFName(className);
    if (c instanceof COSArray)
    {
        COSArray array = (COSArray) c;
        array.remove(name);
        if ((array.size() == 2) && (array.getInt(1) == 0))
        {
            this.getCOSObject().setItem(key, array.getObject(0));
        }
    }
    else
    {
        COSBase directC = c;
        if (c instanceof COSObject)
        {
            directC = ((COSObject) c).getObject();
        }
        if (name.equals(directC))
        {
            this.getCOSObject().setItem(key, null);
        }
    }
}
 
Example #2
Source File: PDStructureElement.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Returns the class names together with their revision numbers (C).
 * 
 * @return the class names as a list, never null.
 */
public Revisions<String> getClassNames()
{
    COSName key = COSName.C;
    Revisions<String> classNames = new Revisions<String>();
    COSBase c = this.getCOSObject().getDictionaryObject(key);
    if (c instanceof COSName)
    {
        classNames.addObject(((COSName) c).getName(), 0);
    }
    if (c instanceof COSArray)
    {
        COSArray array = (COSArray) c;
        Iterator<COSBase> it = array.iterator();
        String className = null;
        while (it.hasNext())
        {
            COSBase item = it.next();
            if (item instanceof COSObject)
            {
                item = ((COSObject) item).getObject();
            }
            if (item instanceof COSName)
            {
                className = ((COSName) item).getName();
                classNames.addObject(className, 0);
            }
            else if (item instanceof COSInteger)
            {
                classNames.setRevisionNumber(className, ((COSInteger) item).intValue());
            }
        }
    }
    return classNames;
}
 
Example #3
Source File: PDSeedValueCertificate.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Returns list of key usages of certificate strings where each string is 9 characters long and each character is
 * one of these values {0, 1, X} 0 for must not set, 1 for must set, X for don't care. each index in the string
 * represents a key usage:
 * <ol>
 * <li>digitalSignature</li>
 * <li>non-Repudiation</li>
 * <li>keyEncipherment</li>
 * <li>dataEncipherment</li>
 * <li>keyAgreement</li>
 * <li>keyCertSign</li>
 * <li>cRLSign</li>
 * <li>encipherOnly</li>
 * <li>decipherOnly</li>
 * </ol>
 * 
 * @return list of key usages
 */
public List<String> getKeyUsage()
{
    COSBase base = this.dictionary.getDictionaryObject(COSName.KEY_USAGE);
    if (base instanceof COSArray)
    {
        COSArray array = (COSArray) base;
        List<String> keyUsageExtensions = new LinkedList<String>();
        for (COSBase item : array)
        {
            if (item instanceof COSString)
            {
                keyUsageExtensions.add(((COSString) item).getString());
            }
        }
        return keyUsageExtensions;
    }
    return null;
}
 
Example #4
Source File: PDOptionalContentProperties.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Enables or disables all optional content groups with the given name.
 *
 * @param groupName the group name
 * @param enable true to enable, false to disable
 * @return true if at least one group with this name already had an on or off setting, false
 * otherwise
 */
public boolean setGroupEnabled(String groupName, boolean enable)
{
    boolean result = false;
    COSArray ocgs = getOCGs();
    for (COSBase o : ocgs)
    {
        COSDictionary ocg = toDictionary(o);
        String name = ocg.getString(COSName.NAME);
        if (groupName.equals(name) && setGroupEnabled(new PDOptionalContentGroup(ocg), enable))
        {
            result = true;
        }
    }
    return result;
}
 
Example #5
Source File: NPEfix17_seventeen_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * This will return all of the documents root fields.
 *
 * A field might have children that are fields (non-terminal field) or does not
 * have children which are fields (terminal fields).
 *
 * The fields within an AcroForm are organized in a tree structure. The documents root fields
 * might either be terminal fields, non-terminal fields or a mixture of both. Non-terminal fields
 * mark branches which contents can be retrieved using {@link PDNonTerminalField#getChildren()}.
 *
 * @return A list of the documents root fields.
 *
 */
public List<PDField> getFields()
{
    COSArray cosFields = (COSArray) dictionary.getDictionaryObject(COSName.FIELDS);
    if (cosFields == null)
    {
        return Collections.emptyList();
    }
    List<PDField> pdFields = new ArrayList<PDField>();
    for (int i = 0; i < cosFields.size(); i++)
    {
        COSDictionary element = (COSDictionary) cosFields.getObject(i);
        if (element != null)
        {
            PDField field = PDField.fromDictionary(this, element, null);
            if (field != null)
            {
                pdFields.add(field);
            }
        }
    }
    return new COSArrayList<PDField>(pdFields, cosFields);
}
 
Example #6
Source File: PDFMergerUtility.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
private void updatePageReferences(PDFCloneUtility cloner,
        COSArray parentTreeEntry, Map<COSDictionary, COSDictionary> objMapping)
        throws IOException
{
    for (int i = 0; i < parentTreeEntry.size(); i++)
    {
        COSBase subEntry = parentTreeEntry.getObject(i);
        if (subEntry instanceof COSArray)
        {
            updatePageReferences(cloner, (COSArray) subEntry, objMapping);
        }
        else if (subEntry instanceof COSDictionary)
        {
            updatePageReferences(cloner, (COSDictionary) subEntry, objMapping);
        }
    }
}
 
Example #7
Source File: PDCIDFontType2Embedder.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
private boolean buildVerticalHeader(COSDictionary cidFont) throws IOException
{
    VerticalHeaderTable vhea = ttf.getVerticalHeader();
    if (vhea == null)
    {
        LOG.warn("Font to be subset is set to vertical, but has no 'vhea' table");
        return false;
    }

    float scaling = 1000f / ttf.getHeader().getUnitsPerEm();

    long v = Math.round(vhea.getAscender() * scaling);
    long w1 = Math.round(-vhea.getAdvanceHeightMax() * scaling);
    if (v != 880 || w1 != -1000)
    {
        COSArray cosDw2 = new COSArray();
        cosDw2.add(COSInteger.get(v));
        cosDw2.add(COSInteger.get(w1));
        cidFont.setItem(COSName.DW2, cosDw2);
    }
    return true;
}
 
Example #8
Source File: ShowTextAdjusted.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public void process(Operator operator, List<COSBase> arguments) throws IOException
{
    if (arguments.isEmpty())
    {
        return;
    }
    COSBase base = arguments.get(0);
    if (!(base instanceof COSArray))
    {
        return;
    }
    if (context.getTextMatrix() == null)
    {
        // ignore: outside of BT...ET
        return;
    }
    COSArray array = (COSArray) base;
    context.showTextStrings(array);
}
 
Example #9
Source File: PDPage.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * This will return a list of the annotations for this page.
 *
 * @param annotationFilter the annotation filter provided allowing to filter out specific annotations
 * @return List of the PDAnnotation objects, never null. The returned list is backed by the
 * annotations COSArray, so any adding or deleting in this list will change the document too.
 * 
 * @throws IOException If there is an error while creating the annotation list.
 */
public List<PDAnnotation> getAnnotations(AnnotationFilter annotationFilter) throws IOException
{
    COSBase base = page.getDictionaryObject(COSName.ANNOTS);
    if (base instanceof COSArray)
    {
        COSArray annots = (COSArray) base;
        List<PDAnnotation> actuals = new ArrayList<PDAnnotation>();
        for (int i = 0; i < annots.size(); i++)
        {
            COSBase item = annots.getObject(i);
            if (item == null)
            {
                continue;
            }
            PDAnnotation createdAnnotation = PDAnnotation.createAnnotation(item);
            if (annotationFilter.accept(createdAnnotation))
            {
                actuals.add(createdAnnotation);
            }
        }
        return new COSArrayList<PDAnnotation>(actuals, annots);
    }
    return new COSArrayList<PDAnnotation>(page, COSName.ANNOTS);
}
 
Example #10
Source File: FDFField.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * This will get the list of kids. This will return a list of FDFField objects. This will return null if the
 * underlying list is null.
 *
 * @return The list of kids.
 */
public List<FDFField> getKids()
{
    COSArray kids = (COSArray) field.getDictionaryObject(COSName.KIDS);
    List<FDFField> retval = null;
    if (kids != null)
    {
        List<FDFField> actuals = new ArrayList<FDFField>();
        for (int i = 0; i < kids.size(); i++)
        {
            actuals.add(new FDFField((COSDictionary) kids.getObject(i)));
        }
        retval = new COSArrayList<FDFField>(actuals, kids);
    }
    return retval;
}
 
Example #11
Source File: PDFMergerUtility.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Update the Pg and Obj references to the new (merged) page.
 */
private void updatePageReferences(PDFCloneUtility cloner,
        Map<Integer, COSObjectable> numberTreeAsMap,
        Map<COSDictionary, COSDictionary> objMapping) throws IOException
{
    for (COSObjectable obj : numberTreeAsMap.values())
    {
        if (obj == null)
        {
            continue;
        }
        PDParentTreeValue val = (PDParentTreeValue) obj;
        COSBase base = val.getCOSObject();
        if (base instanceof COSArray)
        {
            updatePageReferences(cloner, (COSArray) base, objMapping);
        }
        else
        {
            updatePageReferences(cloner, (COSDictionary) base, objMapping);
        }
    }
}
 
Example #12
Source File: PDAnnotation.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
protected PDColor getColor(COSName itemName)
{
    COSBase c = this.getCOSObject().getItem(itemName);
    if (c instanceof COSArray)
    {
        PDColorSpace colorSpace = null;
        switch (((COSArray) c).size())
        {
        case 1:
            colorSpace = PDDeviceGray.INSTANCE;
            break;
        case 3:
            colorSpace = PDDeviceRGB.INSTANCE;
            break;
        case 4:
            colorSpace = PDDeviceCMYK.INSTANCE;
            break;
        default:
            break;
        }
        return new PDColor((COSArray) c, colorSpace);
    }
    return null;
}
 
Example #13
Source File: PDDocumentNameDestinationDictionary.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Returns the destination corresponding to the parameter.
 *
 * @param name The destination name.
 * @return The destination for that name, or null if there isn't any.
 * 
 * @throws IOException if something goes wrong when creating the destination object.
 */
public PDDestination getDestination(String name) throws IOException
{
    COSBase item = nameDictionary.getDictionaryObject(name);

    // "The value of this entry shall be a dictionary in which each key is a destination name
    // and the corresponding value is either an array defining the destination (...) 
    // or a dictionary with a D entry whose value is such an array."                
    if (item instanceof COSArray)
    {
        return PDDestination.create(item);
    }
    else if (item instanceof COSDictionary)
    {
        COSDictionary dict = (COSDictionary) item;
        if (dict.containsKey(COSName.D))
        {
            return PDDestination.create(dict.getDictionaryObject(COSName.D));
        }
    }
    return null;
}
 
Example #14
Source File: PDRectlinearMeasureDictionary.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * This will return the sloaps of a line.
 * 
 * @return the sloaps of a line
 */
public PDNumberFormatDictionary[] getLineSloaps()
{
    COSArray s = (COSArray)this.getCOSObject().getDictionaryObject("S");
    if (s != null)
    {
        PDNumberFormatDictionary[] retval =
            new PDNumberFormatDictionary[s.size()];
        for (int i = 0; i < s.size(); i++)
        {
            COSDictionary dic = (COSDictionary) s.get(i);
            retval[i] = new PDNumberFormatDictionary(dic);
        }
        return retval;
    }
    return null;
}
 
Example #15
Source File: PDStandardAttributeObject.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Gets a single colour or four colours.
 * 
 * @param name the attribute name
 * @return the single ({@link PDGamma}) or a ({@link PDFourColours})
 */
protected Object getColorOrFourColors(String name)
{
    COSArray array =
        (COSArray) this.getCOSObject().getDictionaryObject(name);
    if (array == null)
    {
        return null;
    }
    if (array.size() == 3)
    {
        // only one colour
        return new PDGamma(array);
    }
    else if (array.size() == 4)
    {
        return new PDFourColours(array);
    }
    return null;
}
 
Example #16
Source File: SetColor.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public void process(Operator operator, List<COSBase> arguments) throws IOException
{
    PDColorSpace colorSpace = getColorSpace();
    if (!(colorSpace instanceof PDPattern))
    {
        if (arguments.size() < colorSpace.getNumberOfComponents())
        {
            throw new MissingOperandException(operator, arguments);
        }
        if (!checkArrayTypesClass(arguments, COSNumber.class))
        {
            return;
        }
    }
    COSArray array = new COSArray();
    array.addAll(arguments);
    setColor(new PDColor(array, colorSpace));
}
 
Example #17
Source File: PDExtendedGraphicsState.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * This will get the dash pattern.
 *
 * @return null or the D value in the dictionary.
 */
public PDLineDashPattern getLineDashPattern()
{
    PDLineDashPattern retval = null;
    COSBase dp = dict.getDictionaryObject( COSName.D );
    if( dp instanceof COSArray  && ((COSArray)dp).size() == 2)
    {
        COSBase dashArray = ((COSArray)dp).getObject(0);
        COSBase phase = ((COSArray)dp).getObject(1);
        if (dashArray instanceof COSArray && phase instanceof COSNumber)
        {
            retval = new PDLineDashPattern((COSArray) dashArray, ((COSNumber) phase).intValue());
        }
    }
    return retval;
}
 
Example #18
Source File: PDAnnotationMarkup.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Get one or more disjoint paths that make this annotation.
 *
 * @return An array of arrays, each representing a stroked path. Each array shall be a series of
 * alternating horizontal and vertical coordinates.
 */
public float[][] getInkList()
{
    COSBase base = getCOSObject().getDictionaryObject(COSName.INKLIST);
    if (base instanceof COSArray)
    {
        COSArray array = (COSArray) base;
        float[][] inkList = new float[array.size()][];
        for (int i = 0; i < array.size(); ++i)
        {
            COSBase base2 = array.getObject(i);
            if (base2 instanceof COSArray)
            {
                inkList[i] = ((COSArray) array.getObject(i)).toFloatArray();
            }
            else
            {
                inkList[i] = new float[0];
            }
        }
        return inkList;
    }
    return new float[0][0];
}
 
Example #19
Source File: PDNumberTreeNode.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * This will return a map of numbers.  The key will be a java.lang.Integer, the value will
 * depend on where this class is being used.
 *
 * @return A map of COS objects.
 *
 * @throws IOException If there is a problem creating the values.
 */
public Map<Integer,COSObjectable> getNumbers()  throws IOException
{
    Map<Integer, COSObjectable> indices = null;
    COSBase numBase = node.getDictionaryObject(COSName.NUMS);
    if (numBase instanceof COSArray)
    {
        COSArray numbersArray = (COSArray) numBase;
        indices = new HashMap<Integer, COSObjectable>();
        for (int i = 0; i < numbersArray.size(); i += 2)
        {
            COSBase base = numbersArray.getObject(i);
            if (!(base instanceof COSInteger))
            {
                LOG.error("page labels ignored, index " + i + " should be a number, but is " + base);
                return null;
            }
            COSInteger key = (COSInteger) base;
            COSBase cosValue = numbersArray.getObject(i + 1);
            indices.put(key.intValue(), cosValue == null ? null : convertCOSToPD(cosValue));
        }
        indices = Collections.unmodifiableMap(indices);
    }
    return indices;
}
 
Example #20
Source File: PDTerminalField.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Returns the widget annotations associated with this field.
 *
 * @return The list of widget annotations. Be aware that this list is <i>not</i> backed by the
 * actual widget collection of the field, so adding or deleting has no effect on the PDF
 * document until you call {@link #setWidgets(java.util.List) setWidgets()} with the modified
 * list.
 */
@Override
public List<PDAnnotationWidget> getWidgets()
{
    List<PDAnnotationWidget> widgets = new ArrayList<PDAnnotationWidget>();
    COSArray kids = (COSArray)getCOSObject().getDictionaryObject(COSName.KIDS);
    if (kids == null)
    {
        // the field itself is a widget
        widgets.add(new PDAnnotationWidget(getCOSObject()));
    }
    else if (kids.size() > 0)
    {
        // there are multiple widgets
        for (int i = 0; i < kids.size(); i++)
        {
            COSBase kid = kids.getObject(i);
            if (kid instanceof COSDictionary)
            {
                widgets.add(new PDAnnotationWidget((COSDictionary)kid));
            }
        }
    }
    return widgets;
}
 
Example #21
Source File: DictionaryEncoding.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Creates a new DictionaryEncoding for embedding.
 *
 * @param baseEncoding
 * @param differences
 */
public DictionaryEncoding(COSName baseEncoding, COSArray differences)
{
    encoding = new COSDictionary();
    encoding.setItem(COSName.NAME, COSName.ENCODING);
    encoding.setItem(COSName.DIFFERENCES, differences);
    if (baseEncoding != COSName.STANDARD_ENCODING)
    {
        encoding.setItem(COSName.BASE_ENCODING, baseEncoding);
        this.baseEncoding = Encoding.getInstance(baseEncoding);
    }
    else
    {
        this.baseEncoding = Encoding.getInstance(baseEncoding);
    }

    if (this.baseEncoding == null)
    {
        throw new IllegalArgumentException("Invalid encoding: " + baseEncoding);
    }
    
    codeToName.putAll(this.baseEncoding.codeToName);
    inverted.putAll(this.baseEncoding.inverted);
    applyDifferences();
}
 
Example #22
Source File: PDNumberTreeNode.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Get the highest value for a key in the number map.
 *
 * @return The highest value for a key in the map.
 */
public Integer getUpperLimit()
{
    Integer retval = null;
    COSArray arr = (COSArray)node.getDictionaryObject( COSName.LIMITS );
    if( arr != null && arr.get(0) != null )
    {
        retval = arr.getInt( 1 );
    }
    return retval;
}
 
Example #23
Source File: PDAnnotationLine.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * This will retrieve the horizontal offset of the caption.
 * 
 * @return the horizontal offset of the caption
 */
public float getCaptionHorizontalOffset()
{
    float retval = 0.f;
    COSArray array = (COSArray) this.getCOSObject().getDictionaryObject(COSName.CO);
    if (array != null)
    {
        retval = array.toFloatArray()[0];
    }

    return retval;
}
 
Example #24
Source File: FDFAnnotationLine.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * This will set start and end coordinates of the line (or leader line if LL entry is set).
 *
 * @param line array of 4 floats [x1, y1, x2, y2] line start and end points in default user space.
 */
public void setLine(float[] line)
{
    COSArray newLine = new COSArray();
    newLine.setFloatArray(line);
    annot.setItem(COSName.L, newLine);
}
 
Example #25
Source File: FDFAnnotationFreeText.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * This will get the coordinates of the callout line.
 *
 * @return An array of four or six numbers specifying a callout line attached to the free text
 * annotation. Six numbers [ x1 y1 x2 y2 x3 y3 ] represent the starting, knee point, and ending
 * coordinates of the line in default user space, Four numbers [ x1 y1 x2 y2 ] represent the
 * starting and ending coordinates of the line.
 */
public float[] getCallout()
{
    COSArray array = (COSArray) annot.getDictionaryObject(COSName.CL);
    if (array != null)
    {
        return array.toFloatArray();
    }
    else
    {
        return null;
    }
}
 
Example #26
Source File: Filter.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
protected COSDictionary getDecodeParams(COSDictionary dictionary, int index)
{
    COSBase filter = dictionary.getDictionaryObject(COSName.FILTER, COSName.F);
    COSBase obj = dictionary.getDictionaryObject(COSName.DECODE_PARMS, COSName.DP);
    if (filter instanceof COSName && obj instanceof COSDictionary)
    {
        // PDFBOX-3932: The PDF specification requires "If there is only one filter and that 
        // filter has parameters, DecodeParms shall be set to the filter’s parameter dictionary" 
        // but tests show that Adobe means "one filter name object".
        return (COSDictionary)obj;
    }
    else if (filter instanceof COSArray && obj instanceof COSArray)
    {
        COSArray array = (COSArray)obj;
        if (index < array.size())
        {
            COSBase objAtIndex = array.getObject(index);
            if (objAtIndex instanceof COSDictionary)
            {
                return (COSDictionary)array.getObject(index);
            }
        }
    }
    else if (obj != null && !(filter instanceof COSArray || obj instanceof COSArray))
    {
        LOG.error("Expected DecodeParams to be an Array or Dictionary but found " +
                  obj.getClass().getName());
    }
    return new COSDictionary();
}
 
Example #27
Source File: PDIndexed.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Creates a new indexed color space from the given PDF array.
 * @param indexedArray the array containing the indexed parameters
 * @param resources the resources, can be null. Allows to use its cache for the colorspace.
 * @throws java.io.IOException
 */
public PDIndexed(COSArray indexedArray, PDResources resources) throws IOException
{
    array = indexedArray;
    // don't call getObject(1), we want to pass a reference if possible
    // to profit from caching (PDFBOX-4149)
    baseColorSpace = PDColorSpace.create(array.get(1), resources);
    readColorTable();
    initRgbColorTable();
}
 
Example #28
Source File: PDSeedValueCertificate.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * removes a subject from the list
 *
 * @param subject byte array containing DER-encoded X.509v3 certificate
 */
public void removeSubject(byte[] subject)
{
    COSBase base = this.dictionary.getDictionaryObject(COSName.SUBJECT);
    if (base instanceof COSArray)
    {
        COSArray array = (COSArray) base;
        array.remove(new COSString(subject));
    }
}
 
Example #29
Source File: PDBorderStyleDictionary.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * This will set the dash style used for drawing the border.
 *
 * @param dashArray the dash style to use
 */
public void setDashStyle(COSArray dashArray)
{
    COSArray array = null;
    if (dashArray != null)
    {
        array = dashArray;
    }
    getCOSObject().setItem(COSName.D, array);
}
 
Example #30
Source File: SecurityHandler.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * This will dispatch to the correct method.
 *
 * @param obj The object to decrypt.
 * @param objNum The object number.
 * @param genNum The object generation Number.
 *
 * @throws IOException If there is an error getting the stream data.
 */
public void decrypt(COSBase obj, long objNum, long genNum) throws IOException
{
    if (!(obj instanceof COSString || obj instanceof COSDictionary || obj instanceof COSArray))
    {
        return;
    }
    // PDFBOX-4477: only cache strings and streams, this improves speed and memory footprint
    if (obj instanceof COSString)
    {
        if (objects.contains(obj))
        {
            return;
        }
        objects.add(obj);
        decryptString((COSString) obj, objNum, genNum);
    }
    else if (obj instanceof COSStream)
    {
        if (objects.contains(obj))
        {
            return;
        }
        objects.add(obj);
        decryptStream((COSStream) obj, objNum, genNum);
    }
    else if (obj instanceof COSDictionary)
    {
        decryptDictionary((COSDictionary) obj, objNum, genNum);
    }
    else if (obj instanceof COSArray)
    {
        decryptArray((COSArray) obj, objNum, genNum);
    }
}