HashMap<Integer,LayoutPage> layoutPages = new HashMap<Integer, Overlay.LayoutPage>(numberOfPages);
for (int i=0;i<numberOfPages;i++)
{
PDPage page = (PDPage) catalog.getAllPages().get(i);
COSBase contents = page.getCOSDictionary().getDictionaryObject(COSName.CONTENTS);
PDResources resources = page.findResources();
if (resources == null)
{
resources = new PDResources();
}
layoutPages.put(i,new LayoutPage(page.getMediaBox(), createContentStream(contents), resources.getCOSDictionary()));