private LayoutPage getLayoutPage(PDDocument doc) throws IOException
{
PDDocumentCatalog catalog = doc.getDocumentCatalog();
PDPage page = (PDPage)catalog.getAllPages().get(0);
COSBase contents = page.getCOSDictionary().getDictionaryObject(COSName.CONTENTS);
PDResources resources = page.findResources();
if (resources == null)
{
resources = new PDResources();
}
return new LayoutPage(page.getMediaBox(), createContentStream(contents), resources.getCOSDictionary());