Example usage for org.apache.pdfbox.contentstream.operator Operator getImageData

List of usage examples for org.apache.pdfbox.contentstream.operator Operator getImageData

Introduction

In this page you can find the example usage for org.apache.pdfbox.contentstream.operator Operator getImageData.

Prototype

public byte[] getImageData() 

Source Link

Document

This is the special case for the ID operator where there are just random bytes inlined the stream.

Usage

From source file:org.apache.fop.render.pdf.pdfbox.PDFWriter.java

License:Apache License

public String writeText(PDStream pdStream) throws IOException {
    PDFStreamParser pdfStreamParser = new PDFStreamParser(pdStream);
    pdfStreamParser.parse();//from ww w. j av  a2s  . co  m
    List<Object> it = pdfStreamParser.getTokens();
    List<COSBase> arguments = new ArrayList<COSBase>();
    for (Object o : it) {
        if (o instanceof Operator) {
            Operator op = (Operator) o;
            readPDFArguments(op, arguments);
            s.append(op.getName() + "\n");
            arguments.clear();
            if (op.getImageParameters() != null) {
                for (Map.Entry<COSName, COSBase> cn : op.getImageParameters().entrySet()) {
                    arguments.add(cn.getKey());
                    arguments.add(cn.getValue());
                }
                readPDFArguments(op, arguments);
                s.append("ID " + new String(op.getImageData(), "ISO-8859-1"));
                arguments.clear();
                s.append("EI\n");
            }
        } else {
            arguments.add((COSBase) o);
        }
    }
    return s.toString();
}