Examples of PDFStreamParser


Examples of org.apache.pdfbox.pdfparser.PDFStreamParser

    {
        List<Object> tokens = new ArrayList<Object>();
        if (string != null)
        {
            ByteArrayInputStream stream = new ByteArrayInputStream(string.getBytes());
            PDFStreamParser parser = new PDFStreamParser(stream);
            parser.parse();
            tokens = parser.getTokens();
        }
        return tokens;
    }
View Full Code Here

Examples of org.apache.pdfbox.pdfparser.PDFStreamParser

    private List<Object> getStreamTokens(COSStream stream) throws IOException
    {
        List<Object> tokens = new ArrayList<Object>();
        if (stream != null)
        {
            PDFStreamParser parser = new PDFStreamParser(stream);
            parser.parse();
            tokens = parser.getTokens();
        }
        return tokens;
    }
View Full Code Here

Examples of org.apache.pdfbox.pdfparser.PDFStreamParser

        }
        printWriter.println("BT");
        if (defaultAppearance != null)
        {
            String daString = defaultAppearance.getString();
            PDFStreamParser daParser = new PDFStreamParser(new ByteArrayInputStream(
                    daString.getBytes("ISO-8859-1")));
            daParser.parse();
            List<Object> daTokens = daParser.getTokens();
            fontSize = calculateFontSize(pdFont, boundingBox, tokens, daTokens);
            int fontIndex = daTokens.indexOf(Operator.getOperator("Tf"));
            if (fontIndex != -1)
            {
                daTokens.set(fontIndex - 1, new COSFloat(fontSize));
View Full Code Here

Examples of org.apache.pdfbox.pdfparser.PDFStreamParser

            COSString da = getDefaultAppearance();
            if (da != null)
            {
                String data = da.getString();
                PDFStreamParser streamParser = new PDFStreamParser(new ByteArrayInputStream(
                        data.getBytes("ISO-8859-1")));
                streamParser.parse();
                tokens = streamParser.getTokens();
            }

            int setFontIndex = tokens.indexOf(Operator.getOperator("Tf"));
            COSName cosFontName = (COSName) tokens.get(setFontIndex - 2);
            retval = streamResources.getFont(cosFontName);
View Full Code Here

Examples of org.apache.pdfbox.pdfparser.PDFStreamParser

    public List<Object> getStreamTokens() throws IOException
    {
        List<Object> retval = null;
        if( streams.size() > 0 )
        {
            PDFStreamParser parser = new PDFStreamParser( this );
            parser.parse();
            retval = parser.getTokens();
        }
        else
        {
            retval = new ArrayList<Object>();
        }
View Full Code Here

Examples of org.apache.pdfbox.pdfparser.PDFStreamParser

        contentStream.setNonStrokingColor(0.1f, 0.2f, 0.3f, 0.4f);
        contentStream.close();

        // now read the PDF stream and verify that the CMYK values are correct
        COSStream stream = page.getStream().getStream();
        PDFStreamParser parser = new PDFStreamParser(stream);
        parser.parse();
        java.util.List<Object>  pageTokens = parser.getTokens();
        // expected five tokens :
        // [0] = COSFloat{0.1}
        // [1] = COSFloat{0.2}
        // [2] = COSFloat{0.3}
        // [3] = COSFloat{0.4}
        // [4] = PDFOperator{"k"}
        assertEquals(0.1f, ((COSFloat)pageTokens.get(0)).floatValue());
        assertEquals(0.2f, ((COSFloat)pageTokens.get(1)).floatValue());
        assertEquals(0.3f, ((COSFloat)pageTokens.get(2)).floatValue());
        assertEquals(0.4f, ((COSFloat)pageTokens.get(3)).floatValue());
        assertEquals("k", ((Operator) pageTokens.get(4)).getName());

        // same as above but for PDPageContentStream#setStrokingColor
        page = new PDPage();
        doc.addPage(page);

        contentStream = new PDPageContentStream(doc, page, false, false);
        // pass a non-stroking color in CMYK color space
        contentStream.setStrokingColor(0.5f, 0.6f, 0.7f, 0.8f);
        contentStream.close();

        // now read the PDF stream and verify that the CMYK values are correct
        stream = page.getStream().getStream();
        parser = new PDFStreamParser(stream);
        parser.parse();
        pageTokens = parser.getTokens();
        // expected five tokens  :
        // [0] = COSFloat{0.5}
        // [1] = COSFloat{0.6}
        // [2] = COSFloat{0.7}
        // [3] = COSFloat{0.8}
View Full Code Here

Examples of org.apache.pdfbox.pdfparser.PDFStreamParser

                    System.err.println( "Error: Encrypted documents are not supported for this example." );
                    System.exit( 1 );
                }
                for( PDPage page : document.getPages() )
                {
                    PDFStreamParser parser = new PDFStreamParser(page.getStream());
                    parser.parse();
                    List tokens = parser.getTokens();
                    List newTokens = new ArrayList();
                    for( int j=0; j<tokens.size(); j++)
                    {
                        Object token = tokens.get( j );
                        if( token instanceof Operator)
View Full Code Here

Examples of org.apache.pdfbox.pdfparser.PDFStreamParser

        // fixme: stream matrix
        Matrix oldSubStreamMatrix = subStreamMatrix;
        subStreamMatrix = getGraphicsState().getCurrentTransformationMatrix();

        List<COSBase> arguments = new ArrayList<COSBase>();
        PDFStreamParser parser = new PDFStreamParser(contentStream.getContentStream(), forceParsing);
        try
        {
            Iterator<Object> iter = parser.getTokenIterator();
            while (iter.hasNext())
            {
                Object token = iter.next();
                if (token instanceof COSObject)
                {
                    arguments.add(((COSObject) token).getObject());
                }
                else if (token instanceof Operator)
                {
                    processOperator((Operator) token, arguments);
                    arguments = new ArrayList<COSBase>();
                }
                else
                {
                    arguments.add((COSBase) token);
                }
            }
        }
        finally
        {
            parser.close();
        }

        // fixme: stream matrix
        subStreamMatrix = oldSubStreamMatrix;
    }
View Full Code Here

Examples of org.apache.pdfbox.pdfparser.PDFStreamParser

        }
    }

    private List<Object> getStreamTokens( PDDocument doc, String string ) throws IOException
    {
        PDFStreamParser parser;

        List<Object> tokens = null;
        if( string != null )
        {
            ByteArrayInputStream stream = new ByteArrayInputStream( string.getBytes() );
            parser = new PDFStreamParser( stream );
            parser.parse();
            tokens = parser.getTokens();
        }
        return tokens;
    }
View Full Code Here

Examples of org.apache.pdfbox.pdfparser.PDFStreamParser

        return tokens;
    }

    private List<Object> getStreamTokens( PDDocument doc, COSStream stream ) throws IOException
    {
        PDFStreamParser parser;

        List<Object> tokens = null;
        if( stream != null )
        {
            parser = new PDFStreamParser( stream );
            parser.parse();
            tokens = parser.getTokens();
        }
        return tokens;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.