Package org.apache.pdfbox.cos

Examples of org.apache.pdfbox.cos.COSBase


     * @return The action to perform when the document is opened.
     * @throws IOException If there is an error creating the destination or action.
     */
    public PDDestinationOrAction getOpenAction() throws IOException
    {
        COSBase openAction = root.getDictionaryObject(COSName.OPEN_ACTION);
        if (openAction == null)
        {
            return null;
        }
        else if (openAction instanceof COSDictionary)
View Full Code Here


     * @return The Next action or sequence of actions.
     */
    public List getNext()
    {
        List retval = null;
        COSBase next = action.getDictionaryObject( "Next" );
        if( next instanceof COSDictionary )
        {
            PDAction pdAction = PDActionFactory.createAction( (COSDictionary) next );
            retval = new COSArrayList(pdAction, next, action, COSName.getPDFName( "Next" ));
        }
View Full Code Here

     */
    public COSString getDefaultAppearance()
    {
        if (defaultAppearance == null)
        {
            COSBase daValue =  getDictionary().getItem(COSName.DA);
            if (daValue != null)
            {
                defaultAppearance = (COSString)daValue;
            }
        }
View Full Code Here

     * @return a list of objects for the kids
     */
    public List<Object> getKids()
    {
        List<Object> kidObjects = new ArrayList<Object>();
        COSBase k = this.getCOSDictionary().getDictionaryObject(COSName.K);
        if (k instanceof COSArray)
        {
            Iterator<COSBase> kids = ((COSArray) k).iterator();
            while (kids.hasNext())
            {
                COSBase kid = kids.next();
                Object kidObject = this.createObject(kid);
                if (kidObject != null)
                {
                    kidObjects.add(kidObject);
                }
View Full Code Here

    {
        if (object == null)
        {
            return;
        }
        COSBase k = this.getCOSDictionary().getDictionaryObject(COSName.K);
        if (k == null)
        {
            // currently no kid: set new kid as kids
            this.getCOSDictionary().setItem(COSName.K, object);
        }
View Full Code Here

    {
        if ((newKid == null) || (refKid == null))
        {
            return;
        }
        COSBase k = this.getCOSDictionary().getDictionaryObject(COSName.K);
        if (k == null)
        {
            return;
        }
        COSBase refKidBase = null;
        if (refKid instanceof COSObjectable)
        {
            refKidBase = ((COSObjectable) refKid).getCOSObject();
        }
        else if (refKid instanceof COSInteger)
        {
            refKidBase = (COSInteger) refKid;
        }
        if (k instanceof COSArray)
        {
            COSArray array = (COSArray) k;
            int refIndex = array.indexOfObject(refKidBase);
            array.add(refIndex, newKid.getCOSObject());
        }
        else
        {
            boolean onlyKid = k.equals(refKidBase);
            if (!onlyKid && (k instanceof COSObject))
            {
                COSBase kObj = ((COSObject) k).getObject();
                onlyKid = kObj.equals(refKidBase);
            }
            if (onlyKid)
            {
                COSArray array = new COSArray();
                array.add(newKid);
View Full Code Here

    {
        if (object == null)
        {
            return false;
        }
        COSBase k = this.getCOSDictionary().getDictionaryObject(COSName.K);
        if (k == null)
        {
            // no kids: objectable is not a kid
            return false;
        }
        else if (k instanceof COSArray)
        {
            // currently more than one kid: remove kid from existing array
            COSArray array = (COSArray) k;
            boolean removed = array.removeObject(object);
            // if now only one kid: set remaining kid as kids
            if (array.size() == 1)
            {
                this.getCOSDictionary().setItem(COSName.K, array.getObject(0));
            }
            return removed;
        }
        else
        {
            // currently one kid: if current kid equals given object, remove kids entry
            boolean onlyKid = k.equals(object);
            if (!onlyKid && (k instanceof COSObject))
            {
                COSBase kObj = ((COSObject) k).getObject();
                onlyKid = kObj.equals(object);
            }
            if (onlyKid)
            {
                this.getCOSDictionary().setItem(COSName.K, null);
                return true;
View Full Code Here

        // if the Decode array exists and consists of (1,0)
        if (decode != null && decode.getInt(0) == 1)
        {
            blackis1 = 1;
        }
        COSBase dicOrArrayParms = options.getDictionaryObject(COSName.DECODE_PARMS);
        COSDictionary decodeParms = null;
        if (dicOrArrayParms instanceof COSDictionary)
        {
            decodeParms = (COSDictionary) dicOrArrayParms;
        }
View Full Code Here

        {
            kidDic = (COSDictionary) kid;
        }
        else if (kid instanceof COSObject)
        {
            COSBase base = ((COSObject) kid).getObject();
            if (base instanceof COSDictionary)
            {
                kidDic = (COSDictionary) base;
            }
        }
View Full Code Here

     * @param parentTreeEntry
     * @param objMapping mapping between old and new references
     */
    private void updatePageReferences(COSDictionary parentTreeEntry, HashMap<COSDictionary, COSDictionary> objMapping)
    {
        COSBase page = parentTreeEntry.getDictionaryObject(COSName.PG);
        if (page instanceof COSDictionary)
        {
            if (objMapping.containsKey(page))
            {
                parentTreeEntry.setItem(COSName.PG, objMapping.get(page));
            }
        }
        COSBase obj = parentTreeEntry.getDictionaryObject(COSName.OBJ);
        if (obj instanceof COSDictionary)
        {
            if (objMapping.containsKey(obj))
            {
                parentTreeEntry.setItem(COSName.OBJ, objMapping.get(obj));
            }
        }
        COSBase kSubEntry = parentTreeEntry.getDictionaryObject(COSName.K);
        if (kSubEntry instanceof COSArray)
        {
            updatePageReferences((COSArray) kSubEntry, objMapping);
        }
        else if (kSubEntry instanceof COSDictionary)
View Full Code Here

TOP

Related Classes of org.apache.pdfbox.cos.COSBase

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.