Search in sources :

Example 16 with COSArrayList

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

the class FDFDictionary method getPages.

/**
 * This will get the list of FDF Pages. This will return a list of FDFPage objects.
 *
 * @return A list of FDF pages.
 */
public List<FDFPage> getPages() {
    List<FDFPage> retval = null;
    COSArray pageArray = (COSArray) fdf.getDictionaryObject(COSName.PAGES);
    if (pageArray != null) {
        List<FDFPage> pages = new ArrayList<FDFPage>();
        for (int i = 0; i < pageArray.size(); i++) {
            pages.add(new FDFPage((COSDictionary) pageArray.get(i)));
        }
        retval = new COSArrayList<FDFPage>(pages, pageArray);
    }
    return retval;
}
Also used : 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 17 with COSArrayList

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

the class FDFField method getOptions.

/**
 * This will return a list of options for a choice field. The value in the list will be 1 of 2 types.
 * java.lang.String or FDFOptionElement.
 *
 * @return A list of all options.
 */
public List<Object> getOptions() {
    List<Object> retval = null;
    COSArray array = (COSArray) field.getDictionaryObject(COSName.OPT);
    if (array != null) {
        List<Object> objects = new ArrayList<Object>();
        for (int i = 0; i < array.size(); i++) {
            COSBase next = array.getObject(i);
            if (next instanceof COSString) {
                objects.add(((COSString) next).getString());
            } else {
                COSArray value = (COSArray) next;
                objects.add(new FDFOptionElement(value));
            }
        }
        retval = new COSArrayList<Object>(objects, array);
    }
    return retval;
}
Also used : COSArray(com.tom_roush.pdfbox.cos.COSArray) ArrayList(java.util.ArrayList) COSArrayList(com.tom_roush.pdfbox.pdmodel.common.COSArrayList) COSBase(com.tom_roush.pdfbox.cos.COSBase) COSString(com.tom_roush.pdfbox.cos.COSString)

Example 18 with COSArrayList

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

the class FDFTemplate method getFields.

/**
 * This will get a list of fields that are part of this template.
 *
 * @return A list of fields.
 */
public List<FDFField> getFields() {
    List<FDFField> retval = null;
    COSArray array = (COSArray) template.getDictionaryObject(COSName.FIELDS);
    if (array != null) {
        List<FDFField> fields = new ArrayList<FDFField>();
        for (int i = 0; i < array.size(); i++) {
            fields.add(new FDFField((COSDictionary) array.getObject(i)));
        }
        retval = new COSArrayList<FDFField>(fields, 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)

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