Search in sources :

Example 56 with COSDictionary

use of com.tom_roush.pdfbox.cos.COSDictionary in project PdfBox-Android by TomRoush.

the class PDComplexFileSpecification method setEmbeddedFileDos.

/**
 * Set the embedded dos file for this spec.
 *
 * @param file The dos file to be embedded.
 * @deprecated This method is obsolescent and should not be used by conforming writers.
 */
@Deprecated
public void setEmbeddedFileDos(PDEmbeddedFile file) {
    COSDictionary ef = getEFDictionary();
    if (ef == null && file != null) {
        ef = new COSDictionary();
        fs.setItem(COSName.EF, ef);
    }
    if (ef != null) {
        ef.setItem(COSName.DOS, file);
    }
}
Also used : COSDictionary(com.tom_roush.pdfbox.cos.COSDictionary)

Example 57 with COSDictionary

use of com.tom_roush.pdfbox.cos.COSDictionary in project PdfBox-Android by TomRoush.

the class PDNumberTreeNode method getKids.

/**
 * Return the children of this node.  This list will contain PDNumberTreeNode objects.
 *
 * @return The list of children or null if there are no children.
 */
public List<PDNumberTreeNode> getKids() {
    List<PDNumberTreeNode> retval = null;
    COSArray kids = (COSArray) node.getDictionaryObject(COSName.KIDS);
    if (kids != null) {
        List<PDNumberTreeNode> pdObjects = new ArrayList<PDNumberTreeNode>();
        for (int i = 0; i < kids.size(); i++) {
            pdObjects.add(createChildNode((COSDictionary) kids.getObject(i)));
        }
        retval = new COSArrayList<PDNumberTreeNode>(pdObjects, kids);
    }
    return retval;
}
Also used : COSArray(com.tom_roush.pdfbox.cos.COSArray) COSDictionary(com.tom_roush.pdfbox.cos.COSDictionary) ArrayList(java.util.ArrayList)

Example 58 with COSDictionary

use of com.tom_roush.pdfbox.cos.COSDictionary in project PdfBox-Android by TomRoush.

the class PDPage method getViewports.

/**
 * Get the viewports.
 *
 * @return a list of viewports or null if there is no /VP entry.
 */
public List<PDViewportDictionary> getViewports() {
    COSBase base = page.getDictionaryObject(COSName.VP);
    if (!(base instanceof COSArray)) {
        return null;
    }
    COSArray array = (COSArray) base;
    List<PDViewportDictionary> viewports = new ArrayList<PDViewportDictionary>();
    for (int i = 0; i < array.size(); ++i) {
        COSBase base2 = array.getObject(i);
        if (base2 instanceof COSDictionary) {
            viewports.add(new PDViewportDictionary((COSDictionary) base2));
        } else {
            Log.w("PdfBox-Android", "Array element " + base2 + " is skipped, must be a (viewport) dictionary");
        }
    }
    return viewports;
}
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) COSBase(com.tom_roush.pdfbox.cos.COSBase) PDViewportDictionary(com.tom_roush.pdfbox.pdmodel.interactive.measurement.PDViewportDictionary)

Example 59 with COSDictionary

use of com.tom_roush.pdfbox.cos.COSDictionary in project PdfBox-Android by TomRoush.

the class PDPage method getThreadBeads.

/**
 * This will get a list of PDThreadBead objects, which are article threads in the document. This
 * will return an empty list if there are no thread beads.
 *
 * @return A list of article threads on this page, never null. The returned list is backed by
 * the beads COSArray, so any adding or deleting in this list will change the document too.
 */
public List<PDThreadBead> getThreadBeads() {
    COSArray beads = (COSArray) page.getDictionaryObject(COSName.B);
    if (beads == null) {
        beads = new COSArray();
    }
    List<PDThreadBead> pdObjects = new ArrayList<PDThreadBead>();
    for (int i = 0; i < beads.size(); i++) {
        COSBase base = beads.getObject(i);
        PDThreadBead bead = null;
        // in some cases the bead is null
        if (base instanceof COSDictionary) {
            bead = new PDThreadBead((COSDictionary) base);
        }
        pdObjects.add(bead);
    }
    return new COSArrayList<PDThreadBead>(pdObjects, beads);
}
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) COSBase(com.tom_roush.pdfbox.cos.COSBase) PDThreadBead(com.tom_roush.pdfbox.pdmodel.interactive.pagenavigation.PDThreadBead)

Example 60 with COSDictionary

use of com.tom_roush.pdfbox.cos.COSDictionary in project PdfBox-Android by TomRoush.

the class PDDocumentCatalog method getDests.

/**
 * @return The named destinations dictionary for this document or null if none exists.
 */
public PDDocumentNameDestinationDictionary getDests() {
    PDDocumentNameDestinationDictionary nameDic = null;
    COSDictionary dests = (COSDictionary) root.getDictionaryObject(COSName.DESTS);
    if (dests != null) {
        nameDic = new PDDocumentNameDestinationDictionary(dests);
    }
    return nameDic;
}
Also used : COSDictionary(com.tom_roush.pdfbox.cos.COSDictionary)

Aggregations

COSDictionary (com.tom_roush.pdfbox.cos.COSDictionary)221 COSArray (com.tom_roush.pdfbox.cos.COSArray)68 COSBase (com.tom_roush.pdfbox.cos.COSBase)68 IOException (java.io.IOException)25 ArrayList (java.util.ArrayList)24 COSName (com.tom_roush.pdfbox.cos.COSName)23 COSObject (com.tom_roush.pdfbox.cos.COSObject)22 COSArrayList (com.tom_roush.pdfbox.pdmodel.common.COSArrayList)15 HashMap (java.util.HashMap)14 COSStream (com.tom_roush.pdfbox.cos.COSStream)13 Map (java.util.Map)12 PDPage (com.tom_roush.pdfbox.pdmodel.PDPage)10 COSString (com.tom_roush.pdfbox.cos.COSString)7 PDDocument (com.tom_roush.pdfbox.pdmodel.PDDocument)6 PDResources (com.tom_roush.pdfbox.pdmodel.PDResources)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 List (java.util.List)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 File (java.io.File)5 Test (org.junit.Test)5