try {
TextDocument doc = TextDocument.newTextDocument();
Header header = doc.getHeader();
Assert.assertNotNull(header);
Table table = header.addTable();
table.setTableName("headerTable");
int rowCount = table.getRowCount();
int columnCount = table.getColumnCount();
String expectedCellValue = "header table cell";
table.getCellByPosition(1, 1).setStringValue(expectedCellValue);
Cell cell = table.getCellByPosition(4, 0);
cell.setImage(ResourceUtilities.getURI("image_list_item.png"));
// first page
header = doc.getHeader(true);
Assert.assertNotNull(header);
table = header.addTable();
table.setTableName("headerHTable");
doc.save(ResourceUtilities.newTestOutputFile(headerDocumentPath));
// load the document again.
doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream(headerDocumentPath));
header = doc.getHeader();
table = header.getTableByName("headerTable");
Assert.assertEquals(rowCount, table.getRowCount());
Assert.assertEquals(columnCount, table.getColumnCount());
Assert.assertEquals(expectedCellValue, table.getCellByPosition(1, 1).getStringValue());
cell = table.getCellByPosition(4, 0);
Assert.assertEquals(34, cell.getBufferedImage().getHeight(null));
table.getColumnByIndex(4).setWidth(15);
header = doc.getHeader(true);
table = header.getTableByName("headerHTable");
Assert.assertNotNull(table);
} catch (Exception e) {