private void assertPageValid(final List<LogicalPageBox> pages, final int page, final long offset) throws Exception { final LogicalPageBox pageBox = pages.get(page); final long pageOffset = pageBox.getPageOffset(); // ModelPrinter.INSTANCE.print(pageBox); final RenderNode[] elementsByNodeType = MatchFactory.findElementsByNodeType(pageBox, LayoutNodeTypes.TYPE_BOX_TABLE_SECTION); Assert.assertEquals(2, elementsByNodeType.length); final TableSectionRenderBox header = (TableSectionRenderBox) elementsByNodeType[0]; Assert.assertEquals(TableSectionRenderBox.Role.HEADER, header.getDisplayRole()); final TableSectionRenderBox body = (TableSectionRenderBox) elementsByNodeType[1]; Assert.assertEquals(TableSectionRenderBox.Role.BODY, body.getDisplayRole()); final RenderNode[] rows = MatchFactory.findElementsByNodeType(body, LayoutNodeTypes.TYPE_BOX_TABLE_ROW); Assert.assertTrue("Have rows on page " + page, rows.length > 0); Assert.assertEquals("Header starts at top of page " + page, pageOffset + offset, header.getY()); Assert.assertEquals( "Row starts after the header on page " + page, header.getY() + header.getHeight(), rows[0].getY()); final RenderNode[] table = MatchFactory.findElementsByNodeType(pageBox, LayoutNodeTypes.TYPE_BOX_TABLE); Assert.assertEquals(1, table.length); final RenderBox box = (RenderBox) table[0]; final RenderNode lastChild = box.getLastChild(); Assert.assertEquals( "Table height extends correctly on page " + page, box.getY() + box.getHeight(), lastChild.getY() + lastChild.getHeight()); }
public void setSectionRenderBox(final TableSectionRenderBox sectionRenderBox) { this.rowSpans.clear(); this.sectionRenderBox = sectionRenderBox; if (this.sectionRenderBox != null) { this.rowModel = sectionRenderBox.getRowModel(); this.bodySection = (sectionRenderBox.getDisplayRole() == TableSectionRenderBox.Role.BODY); } else { this.rowModel = null; this.bodySection = false; } this.rowCount = -1; }