* @throws IOException If there is an exception while processing the stream.
*/
public void processSubStream( PDPage aPage, PDResources resources, COSStream cosStream ) throws IOException
{
page = aPage;
PDFStreamParser parser = null;
if( resources != null )
{
StreamResources sr = new StreamResources();
sr.fonts = resources.getFonts( documentFontCache );
sr.colorSpaces = resources.getColorSpaces();
sr.xobjects = resources.getXObjects();
sr.graphicsStates = resources.getGraphicsStates();
sr.resources = resources;
streamResourcesStack.push(sr);
}
try
{
List arguments = new ArrayList();
parser = new PDFStreamParser( cosStream );
Iterator<Object> iter = parser.getTokenIterator();
while( iter.hasNext() )
{
Object next = iter.next();
if( next instanceof COSObject )
{
arguments.add( ((COSObject)next).getObject() );
}
else if( next instanceof PDFOperator )
{
processOperator( (PDFOperator)next, arguments );
arguments = new ArrayList();
}
else
{
arguments.add( next );
}
if(log.isDebugEnabled())
{
log.debug("token: " + next);
}
}
}
finally
{
if (parser != null) {
parser.close();
}
if( resources != null )
{
streamResourcesStack.pop();
}