Search in sources :

Example 6 with COSArrayList

use of com.tom_roush.pdfbox.pdmodel.common.COSArrayList in project PdfBox-Android by TomRoush.

the class FDFPage method getTemplates.

/**
 * This will get a list of FDFTemplage objects that describe the named pages that serve as templates.
 *
 * @return A list of templates.
 */
public List<FDFTemplate> getTemplates() {
    List<FDFTemplate> retval = null;
    COSArray array = (COSArray) page.getDictionaryObject(COSName.TEMPLATES);
    if (array != null) {
        List<FDFTemplate> objects = new ArrayList<FDFTemplate>();
        for (int i = 0; i < array.size(); i++) {
            objects.add(new FDFTemplate((COSDictionary) array.getObject(i)));
        }
        retval = new COSArrayList<FDFTemplate>(objects, array);
    }
    return retval;
}
Also used : COSArray(com.tom_roush.pdfbox.cos.COSArray) COSDictionary(com.tom_roush.pdfbox.cos.COSDictionary) COSArrayList(com.tom_roush.pdfbox.pdmodel.common.COSArrayList) ArrayList(java.util.ArrayList)

Example 7 with COSArrayList

use of com.tom_roush.pdfbox.pdmodel.common.COSArrayList in project PdfBox-Android by TomRoush.

the class PDAction method getNext.

/**
 * This will get the next action, or sequence of actions, to be performed after this one.
 * The value is either a single action dictionary or an array of action dictionaries
 * to be performed in order.
 *
 * @return The Next action or sequence of actions.
 */
public List<PDAction> getNext() {
    List<PDAction> retval = null;
    COSBase next = action.getDictionaryObject(COSName.NEXT);
    if (next instanceof COSDictionary) {
        PDAction pdAction = PDActionFactory.createAction((COSDictionary) next);
        retval = new COSArrayList<PDAction>(pdAction, next, action, COSName.NEXT);
    } else if (next instanceof COSArray) {
        COSArray array = (COSArray) next;
        List<PDAction> actions = new ArrayList<PDAction>();
        for (int i = 0; i < array.size(); i++) {
            actions.add(PDActionFactory.createAction((COSDictionary) array.getObject(i)));
        }
        retval = new COSArrayList<PDAction>(actions, array);
    }
    return retval;
}
Also used : COSArrayList(com.tom_roush.pdfbox.pdmodel.common.COSArrayList) COSDictionary(com.tom_roush.pdfbox.cos.COSDictionary) COSArray(com.tom_roush.pdfbox.cos.COSArray) COSBase(com.tom_roush.pdfbox.cos.COSBase) List(java.util.List) COSArrayList(com.tom_roush.pdfbox.pdmodel.common.COSArrayList) ArrayList(java.util.ArrayList)

Example 8 with COSArrayList

use of com.tom_roush.pdfbox.pdmodel.common.COSArrayList in project PdfBox-Android by TomRoush.

the class PDPage method getAnnotations.

/**
 * 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);
}
Also used : COSArrayList(com.tom_roush.pdfbox.pdmodel.common.COSArrayList) COSArray(com.tom_roush.pdfbox.cos.COSArray) PDAnnotation(com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAnnotation) ArrayList(java.util.ArrayList) COSArrayList(com.tom_roush.pdfbox.pdmodel.common.COSArrayList) COSBase(com.tom_roush.pdfbox.cos.COSBase)

Example 9 with COSArrayList

use of com.tom_roush.pdfbox.pdmodel.common.COSArrayList in project PdfBox-Android by TomRoush.

the class PDAcroForm method getFields.

/**
 * 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, never null. If there are no fields then this
 * method returns an empty list.
 */
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);
}
Also used : COSArrayList(com.tom_roush.pdfbox.pdmodel.common.COSArrayList) COSArray(com.tom_roush.pdfbox.cos.COSArray) COSDictionary(com.tom_roush.pdfbox.cos.COSDictionary) ArrayList(java.util.ArrayList) COSArrayList(com.tom_roush.pdfbox.pdmodel.common.COSArrayList)

Example 10 with COSArrayList

use of com.tom_roush.pdfbox.pdmodel.common.COSArrayList in project PdfBox-Android by TomRoush.

the class PDSeedValue method getSubFilter.

/**
 * If <b>SubFilter</b> is not null and the {@link #isSubFilterRequired()} indicates this
 * entry is a required constraint, then the first matching encodings shall be used when
 * signing; otherwise, signing shall not take place. If {@link #isSubFilterRequired()}
 * indicates that this is an optional constraint, then the first matching encoding shall
 * be used if it is available. If it is not available, a different encoding may be used
 * instead.
 *
 * @return the subfilter that shall be used by the signature handler
 */
public List<String> getSubFilter() {
    List<String> retval = null;
    COSArray fields = (COSArray) dictionary.getDictionaryObject(COSName.SUB_FILTER);
    if (fields != null) {
        List<String> actuals = new ArrayList<String>();
        for (int i = 0; i < fields.size(); i++) {
            String element = fields.getName(i);
            if (element != null) {
                actuals.add(element);
            }
        }
        retval = new COSArrayList<String>(actuals, fields);
    }
    return retval;
}
Also used : COSArray(com.tom_roush.pdfbox.cos.COSArray) COSArrayList(com.tom_roush.pdfbox.pdmodel.common.COSArrayList) ArrayList(java.util.ArrayList)

Aggregations

COSArray (com.tom_roush.pdfbox.cos.COSArray)18 COSArrayList (com.tom_roush.pdfbox.pdmodel.common.COSArrayList)18 ArrayList (java.util.ArrayList)17 COSDictionary (com.tom_roush.pdfbox.cos.COSDictionary)10 COSBase (com.tom_roush.pdfbox.cos.COSBase)4 PDAnnotation (com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAnnotation)2 COSDocument (com.tom_roush.pdfbox.cos.COSDocument)1 COSString (com.tom_roush.pdfbox.cos.COSString)1 PDFileSpecification (com.tom_roush.pdfbox.pdmodel.common.filespecification.PDFileSpecification)1 PDAnnotationWidget (com.tom_roush.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget)1 PDAcroForm (com.tom_roush.pdfbox.pdmodel.interactive.form.PDAcroForm)1 PDField (com.tom_roush.pdfbox.pdmodel.interactive.form.PDField)1 PDSignatureField (com.tom_roush.pdfbox.pdmodel.interactive.form.PDSignatureField)1 PDThread (com.tom_roush.pdfbox.pdmodel.interactive.pagenavigation.PDThread)1 PDThreadBead (com.tom_roush.pdfbox.pdmodel.interactive.pagenavigation.PDThreadBead)1 List (java.util.List)1