1.8
public void processStream( PDPage aPage, PDResources resources, COSStream cosStream ) throws IOException
{
graphicsState = new PDGraphicsState(aPage.findCropBox());
textMatrix = null;
textLineMatrix = null;
graphicsStack.clear();
streamResourcesStack.clear();
processSubStream( aPage, resources, cosStream );
}
public void processSubStream(PDPage aPage, PDResources resources, COSStream cosStream) throws IOException
{
page = aPage;
if (resources != null)
{
streamResourcesStack.push(resources);
try
{
processSubStream(cosStream);
}
finally
{
streamResourcesStack.pop().clear();
}
}
else
{
processSubStream(cosStream);
}
}
private void processSubStream(COSStream cosStream) throws IOException
{
List<COSBase> arguments = new ArrayList<COSBase>();
PDFStreamParser parser = new PDFStreamParser(cosStream, forceParsing);
try
{
Iterator<Object> iter = parser.getTokenIterator();
while (iter.hasNext())
{
Object next = iter.next();
if (LOG.isDebugEnabled())
{
LOG.debug("processing substream token: " + next);
}
if (next instanceof COSObject)
{
arguments.add(((COSObject) next).getObject());
}
else if (next instanceof PDFOperator)
{
processOperator((PDFOperator) next, arguments);
arguments = new ArrayList<COSBase>();
}
else
{
arguments.add((COSBase) next);
}
}
}
finally
{
parser.close();
}
}