Package org.pdfbox.cos

Examples of org.pdfbox.cos.COSBase


                }
            }

            for (Iterator i = doc.getObjects().iterator(); i.hasNext();)
            {
                COSBase base = ((COSObject) i.next()).getObject();
                if (base instanceof COSStream)
                {
                    // just kill the filters
                    COSStream cosStream = (COSStream)base;
                    cosStream.getUnfilteredStream();
View Full Code Here


        COSDictionary resources = (COSDictionary)ap.getDictionaryObject(COSName.RESOURCES);
        COSArray ar = (COSArray) resources.getDictionaryObject(COSName.getPDFName("ProcSet"));
        ar.add(COSName.getPDFName("Text"));
        COSDictionary fontDescriptor = new COSDictionary();
        String fontname = getFontName();
        COSBase fontref = getFontReference(fontname);
        String a = null;
        fontDescriptor.setItem(COSName.getPDFName(fontname), fontref);
        resources.setItem(COSName.FONT, fontDescriptor);
    }
View Full Code Here

            {
                throw new IOException("expected='obj' actual='" + objectKey + "' " + pdfSource );
            }

            skipSpaces();
            COSBase pb = parseDirObject();
            String endObjectKey = readString();
            if( endObjectKey.equals( "stream" ) )
            {
                pdfSource.unread( endObjectKey.getBytes() );
                pdfSource.unread( ' ' );
View Full Code Here

        if( log.isDebugEnabled() )
        {
            log.debug("parseCOSDictionaryValue() " + pdfSource );
        }
        COSBase retval = null;
        COSBase number = parseDirObject();
        skipSpaces();
        char next = (char)pdfSource.peek();
        if( next >= '0' && next <= '9' )
        {
            COSBase generationNumber = parseDirObject();
            skipSpaces();
            char r = (char)pdfSource.read();
            if( r != 'R' )
            {
                throw new IOException( "expected='R' actual='" + r + "' " + pdfSource );
View Full Code Here

                done = true;
            }
            else
            {
                COSName key = parseCOSName();
                COSBase value = parseCOSDictionaryValue();

                if( value == null )
                {
                    throw new IOException("Bad Dictionary Declaration " + pdfSource );
                }
View Full Code Here

                //throw new IOException("expected='0x0D or 0x0A' actual='0x" + Integer.toHexString(whitespace) + "' " + pdfSource);

            }


            COSBase streamLength = dic.getDictionaryObject(COSName.LENGTH);
            long length = -1;
            if( streamLength instanceof COSNumber )
            {
                length = ((COSNumber)streamLength).intValue();
            }
View Full Code Here

        {
            throw new IOException( "expected='[' actual='" + c + "'" );
        }
        pdfSource.read(); //read '[' character
        COSArray po = new COSArray();
        COSBase pbo = null;
        skipSpaces();
        int i = 0;
        while( ((i = pdfSource.peek()) > 0) && ((char)i != ']') )
        {
            pbo = parseDirObject();
View Full Code Here

    {
        if( log.isDebugEnabled() )
        {
            log.debug("parseDirObject() " + pdfSource );
        }
        COSBase retval = null;

        skipSpaces();
        int nextByte = pdfSource.peek();
        char c = (char)nextByte;
        //System.out.println( "parseDirObject() switching on='" + c + "'" );
View Full Code Here

    {
        // todo should access via catalog instead!
        for (Iterator i = doc.getObjects().iterator(); i.hasNext();)
        {
            COSObject obj = (COSObject) i.next();
            COSBase base = obj.getObject();
            if (base instanceof COSDictionary)
            {
                COSDictionary dict = (COSDictionary) base;
                COSBase type = dict.getItem(COSName.TYPE);
                if (type != null && type.equals(COSName.getPDFName("Pages")))
                {
                    return dict;
                }
            }
        }
View Full Code Here

    public void setField(COSDocument doc, String prefix, COSString name, COSString value)
    {
        for (Iterator i = doc.getObjects().iterator(); i.hasNext();)
        {
            COSObject obj = (COSObject) i.next();
            COSBase base = obj.getObject();
            if (base instanceof COSDictionary)
            {
                COSDictionary dict = (COSDictionary) base;
                COSBase type = dict.getItem(COSName.TYPE);
                if (type != null && type.equals(COSName.getPDFName("Annot")))
                {
                    COSBase subtype = dict.getItem(COSName.getPDFName("Subtype"));
                    if (subtype != null && subtype.equals(COSName.getPDFName("Widget")))
                    {
                        // we found the field
                        COSBase fname = dict.getItem(COSName.getPDFName("T"));
                        if (fname != null && fname.equals(name))
                        {
                            dict.setItem(COSName.getPDFName("V"), value);
                            dict.setItem(COSName.getPDFName("T"), new COSString(prefix  + name.getString()));
                        }
                    }
View Full Code Here

TOP

Related Classes of org.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.