Package org.apache.pdfbox.contentstream.operator

Examples of org.apache.pdfbox.contentstream.operator.Operator


                    for( int j=0; j<tokens.size(); j++)
                    {
                        Object token = tokens.get( j );
                        if( token instanceof Operator)
                        {
                            Operator op = (Operator)token;
                            if( op.getName().equals( "TJ") || op.getName().equals( "Tj" ))
                            {
                                //remove the one argument to this operator
                                newTokens.remove( newTokens.size() -1 );
                                continue;
                            }
View Full Code Here


            {
                String next = readString();
                retval = Operator.getOperator(next);
                if( next.equals( "BI" ) )
                {
                    Operator beginImageOP = (Operator)retval;
                    COSDictionary imageParams = new COSDictionary();
                    beginImageOP.setImageParameters( imageParams );
                    Object nextToken = null;
                    while( (nextToken = parseNextToken()) instanceof COSName )
                    {
                        Object value = parseNextToken();
                        imageParams.setItem( (COSName)nextToken, (COSBase)value );
                    }
                    //final token will be the image data, maybe??
                    Operator imageData = (Operator)nextToken;
                    beginImageOP.setImageData( imageData.getImageData() );
                }
                break;
            }
            case 'I':
            {
                //Special case for ID operator
                String id = "" + (char)pdfSource.read() + (char)pdfSource.read();
                if( !id.equals( "ID" ) )
                {
                    throw new IOException( "Error: Expected operator 'ID' actual='" + id + "'" );
                }
                ByteArrayOutputStream imageData = new ByteArrayOutputStream();
                if( isWhitespace() )
                {
                    //pull off the whitespace character
                    pdfSource.read();
                }
                int lastByte = pdfSource.read();
                int currentByte = pdfSource.read();
                // PDF spec is kinda unclear about this. Should a whitespace
                // always appear before EI? Not sure, so that we just read
                // until EI<whitespace>.
                // Be aware not all kind of whitespaces are allowed here. see PDFBOX-1561
                while( !(lastByte == 'E' &&
                         currentByte == 'I' &&
                         hasNextSpaceOrReturn() &&
                         hasNoFollowingBinData( pdfSource )) &&
                       !pdfSource.isEOF() )
                {
                    imageData.write( lastByte );
                    lastByte = currentByte;
                    currentByte = pdfSource.read();
                }
                // the EI operator isn't unread, as it won't be processed anyway
                retval = Operator.getOperator("ID");
                // save the image data to the operator, so that it can be accessed later
                ((Operator)retval).setImageData( imageData.toByteArray() );
                break;
            }
            case ']':
            {
                // some ']' around without its previous '['
View Full Code Here

            output.write( COSWriter.DICT_CLOSE );
            output.write( SPACE );
        }
        else if( o instanceof Operator)
        {
            Operator op = (Operator)o;
            if( op.getName().equals( "BI" ) )
            {
                output.write( "BI".getBytes("ISO-8859-1") );
                COSDictionary dic = op.getImageParameters();
                for( COSName key : dic.keySet() )
                {
                    Object value = dic.getDictionaryObject( key );
                    key.writePDF( output );
                    output.write( SPACE );
                    writeObject( value );
                    output.write( EOL );
                }
                output.write( "ID".getBytes("ISO-8859-1") );
                output.write( EOL );
                output.write( op.getImageData() );
            }
            else
            {
                output.write( op.getName().getBytes("ISO-8859-1") );
                output.write( EOL );
            }
        }
        else
        {
View Full Code Here

     * @param arguments The list of arguments.
     * @throws IOException If there is an error processing the operation.
     */
    public void processOperator(String operation, List<COSBase> arguments) throws IOException
    {
        Operator operator = Operator.getOperator(operation);
        processOperator(operator, arguments);
    }
View Full Code Here

TOP

Related Classes of org.apache.pdfbox.contentstream.operator.Operator

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.