Code with Finding: |
class PdfContentStreamProcessor {
/**
* Processes PDF syntax.
* <b>Note:</b> If you re-use a given {@link PdfContentStreamProcessor}, you must call {@link PdfContentStreamProcessor#reset()}
* @param contentBytes the bytes of a content stream
* @param resources the resources that come with the content stream
*/
public void processContent(byte[] contentBytes, PdfDictionary resources){
this.resources.push(resources);
try {
PRTokeniser tokeniser = new PRTokeniser(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())){
// we don't call invokeOperator for embedded images - this is one area of the PDF spec that is particularly nasty and inconsistent
PdfDictionary colorSpaceDic = resources != null ? resources.getAsDict(PdfName.COLORSPACE) : null;
ImageRenderInfo renderInfo = ImageRenderInfo.createForEmbeddedImage(gs().ctm, InlineImageUtils.parseInlineImage(ps, colorSpaceDic), colorSpaceDic);
renderListener.renderImage(renderInfo);
} else {
invokeOperator(operator, operands);
}
}
}
catch (Exception e) {
throw new ExceptionConverter(e);
}
this.resources.pop();
}
}
|