Package org.pdfbox.cos

Examples of org.pdfbox.cos.COSObject


            {
                while( (nextObject = parseObject()) != null )
                {
                    if( nextObject instanceof COSObject )
                    {
                        COSObject pdfObj = (COSObject)nextObject;
                        document.addObject( pdfObj );
                        wasLastParsedObjectAnXref = false;
                    }
                    else
                    {
View Full Code Here


                    throw new IOException("stream not preceded by dictionary");
                }
                endObjectKey = readString();
            }
            object = getObjectFromPool(new COSObjectKey(number, genNum));
            COSObject pdfObject = (COSObject)object;
            pdfObject.setObject(pb);
            pdfObject.setObjectNumber( new COSInteger( number ) );
            pdfObject.setGenerationNumber( new COSInteger( genNum ) );

            if( !endObjectKey.equals( "endobj" ) )
            {
                if( !pdfSource.isEOF() )
                {
View Full Code Here

        COSDictionary srcRoot = (COSDictionary)srcTrailer.getDictionaryObject( COSName.ROOT );

        COSName openAction = COSName.getPDFName( "OpenAction" );
        if( destRoot.getItem( openAction ) == null )
        {
            COSObject open = (COSObject)srcRoot.getItem( openAction );
            if( open != null )
            {
                destination.addObject( open );
                destRoot.setItem( openAction, open );
            }
        }

        COSName acroForm = COSName.getPDFName( "AcroForm" );
        if( destRoot.getItem( acroForm ) == null )
        {
            COSObject form = (COSObject)srcRoot.getItem( acroForm );
            if( form != null )
            {
                destination.addObject( form );
                destRoot.setItem( acroForm, form );
            }
View Full Code Here

                }
                break;
            }
            case 'R':
                pdfSource.read();
                retval = new COSObject(null);
                break;
            default:
            {
                if( Character.isDigit(c) || c == '-' || c == '+' || c == '.')
                {
View Full Code Here

     *
     * @return The object in the pool or a new one if it has not been parsed yet.
     */
    public COSObject getObjectFromPool(COSObjectKey key)
    {
        COSObject obj = (COSObject) objectPool.get(key);
        if (obj == null)
        {
            // this was a forward reference, make "proxy" object
            obj = new COSObject(null);
            objectPool.put(key, obj);
        }
        return obj;
    }
View Full Code Here

    public PDDocumentCatalog( COSDocument doc )
    {
        document = doc;
        root = new COSDictionary();
        root.setItem( COSName.TYPE, new COSString( "Catalog" ) );
        COSObject rootObj = new COSObject( COSName.ROOT );
        document.addObject( rootObj );
        document.getTrailer().setItem( COSName.ROOT, rootObj );
    }
View Full Code Here

                    COSArray contentsArray = (COSArray)contents;
                    byte[] buffer = new byte[ BUFFER_SIZE ];
                    int amountRead = 0;
                    if( contentsArray.size() > 0 )
                    {
                        COSObject first = (COSObject)contentsArray.get( 0 );
                        COSStream firstStream = (COSStream)first.getObject();
                        COSStream tmpStream =
                            new COSStream( firstStream.getDictionary(),
                                           firstStream.getScratchFile() );
                        OutputStream output = tmpStream.createUnfilteredStream();
                        for( int i=0; i<contentsArray.size(); i++ )
                        {
                            COSObject obj = (COSObject)contentsArray.get( i );
                            COSStream content = (COSStream)obj.getObject();
                            InputStream input = content.getUnfilteredStream();
                            while ( (amountRead = input.read(buffer, 0, BUFFER_SIZE)) != -1)
                            {
                                output.write(buffer, 0, amountRead);
                            }
View Full Code Here

        COSDictionary trailer = new COSDictionary();
        document.setTrailer( trailer );

        //Next we need the root dictionary.
        COSDictionary rootDictionary = new COSDictionary();
        COSObject root = new COSObject( rootDictionary );
        document.addObject( root );
        trailer.setItem( COSName.getPDFName( "Root" ), root );
        rootDictionary.setItem( COSName.getPDFName( "Type" ), COSName.getPDFName( "Catalog" ) );
        rootDictionary.setItem( COSName.getPDFName( "Version" ), COSName.getPDFName( "1.4" ) );

        //next we need the pages tree structure
        COSDictionary pages = new COSDictionary();
        COSObject pagesObject = new COSObject( pages );
        document.addObject( pagesObject );
        rootDictionary.setItem( COSName.getPDFName( "Pages" ), pagesObject );
        pages.setItem( COSName.getPDFName( "Type" ), COSName.getPDFName( "Pages" ) );
        COSArray kidsArray = new COSArray();
        pages.setItem( COSName.getPDFName( "Kids" ), kidsArray );
View Full Code Here

            COSDictionary trailer = document.getTrailer();
            COSDictionary infoDic = (COSDictionary)trailer.getDictionaryObject( infoName );
            if( infoDic == null )
            {
                infoDic = new COSDictionary();
                COSObject infoObj = new COSObject( infoDic );
                trailer.setItem( infoName, infoObj );
                document.addObject( infoObj );
            }
            documentInformation = new PDDocumentInformation( infoDic );
        }
View Full Code Here

     *
     * @throws IOException If there is an error getting the page count
     */
    public int getPageCount() throws IOException
    {
        COSObject catalog = document.getCatalog();
        COSObject pages = (COSObject)catalog.getItem( COSName.PAGES );
        return getPageCount(pages);
    }
View Full Code Here

TOP

Related Classes of org.pdfbox.cos.COSObject

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.