{
Iterator pagesIter = pages.iterator();
while( pagesIter.hasNext() )
{
PDPage page = (PDPage)pagesIter.next();
COSBase contents = page.getCOSDictionary().getDictionaryObject( COSName.CONTENTS );
PDResources resources = page.findResources();
if( resources == null )
{
resources = new PDResources();
page.setResources( resources );
}
COSDictionary res = resources.getCOSDictionary();
if( contents instanceof COSStream )
{
COSStream stream = (COSStream) contents;
Map objectNameMap = new TreeMap();
stream = makeUniqObjectNames(objectNameMap, stream);
layoutPages.add(new LayoutPage(stream, res, objectNameMap));
}
else if( contents instanceof COSArray )
{
throw new UnsupportedOperationException("Layout pages with COSArray currently not supported.");
// layoutPages.add(new LayoutPage(contents, res));
}
else
{
throw new IOException( "Contents are unknown type:" + contents.getClass().getName() );
}
}
}