PdfContentStreamProcessor { public void processContent(byte[] contentBytes, PdfDictionary resources){ this.resources.push(resources); try { PRTokeniser tokeniser = new PRTokeniser(new RandomAccessFileOrArray(new RandomAccessSourceFactory().createSource(contentBytes))); PdfContentParser ps = new PdfContentParser(tokeniser); ArrayList<PdfObject> operands = new ArrayList<PdfObject>(); while (ps.parse(operands).size() > 0){ PdfLiteral operator = (PdfLiteral)operands.get(operands.size()-1); if ("BI".equals(operator.toString())){ PdfDictionary colorSpaceDic = resources != null ? resources.getAsDict(PdfName.COLORSPACE) : null; handleInlineImage(InlineImageUtils.parseInlineImage(ps, colorSpaceDic), colorSpaceDic); } else { invokeOperator(operator, operands); } } } catch (Exception e) { throw new ExceptionConverter(e); } this.resources.pop(); } PdfContentStreamProcessor(RenderListener renderListener); XObjectDoHandler registerXObjectDoHandler(PdfName xobjectSubType, XObjectDoHandler handler); ContentOperator registerContentOperator(String operatorString, ContentOperator operator); Collection<String> getRegisteredOperatorStrings(); void reset(); GraphicsState gs(); void processContent(byte[] contentBytes, PdfDictionary resources); RenderListener getRenderListener(); static final String DEFAULTOPERATOR; }
@Test public void testInlineImageWithUnsupportedDecodeFilter() throws IOException { PdfReader reader= TestResourceUtils.getResourceAsPdfReader(this, "inlineImages01.pdf"); PdfReaderContentParser parser = new PdfReaderContentParser(reader); Integer page = reader.getNumberOfPages(); LocationTextExtractionStrategy strategy = parser.processContent(page, new LocationTextExtractionStrategy()); }