I am adding new rows to an empty table. The document has a Calibri font but when I add a new row, its using the default font. What is the best way to keep the same font?
Here is the sample code:
Bookmark bookmark = getBookmarkContainsName(doc, "sampletable");
Table table = (bookmark != null) ? ((Table)bookmark.getBookmarkStart().getAncestor(NodeType.TABLE)) : null;
if (table != null) {
int amdSize = listofHM.size();
for (int i = 0; i < amdSize; i++) {
HashMap < String,
String > amdHM = listofHM.get(i);
Row row = new Row(doc);
Cell cell1 = new Cell(doc);
row.appendChild(cell1);
cell1.appendChild(new Paragraph(doc));
cell1.getFirstParagraph().appendChild(new Run(doc, amdHM.get("date_submitted")));
Cell cell2 = new Cell(doc);
row.appendChild(cell2);
cell2.appendChild(new Paragraph(doc));
cell2.getFirstParagraph().appendChild(new Run(doc, amdHM.get("date_received")));
Cell cell3 = new Cell(doc);
row.appendChild(cell3);
cell3.appendChild(new Paragraph(doc));
cell3.getFirstParagraph().appendChild(new Run(doc, amdHM.get("briefdescription")));
table.appendChild(row);
}
}