I am trying to justify the text inside a PdfPTable
cell with the following code:
PdfPTable pTable = new PdfPTable(1);
pTable.setWidthPercentage(98f);
pTable.setSpacingBefore(10f);
pTable.setHorizontalAlignment(Element.ALIGN_JUSTIFIED_ALL);
String content=getContent();
list =XMLWorkerHelper.parseToElementList(content);
for (Element element : list) {
cell = new PdfPCell();
cell.setHorizontalAlignment(PdfPCell.ALIGN_JUSTIFIED_ALL);
cell.setVerticalAlignment(PdfPCell.ALIGN_JUSTIFIED_ALL);
cell.setNoWrap(false);
cell.setBorderWidth(0);
cell.addElement(element);
pTable.addCell(cell);
}
pTable.setSplitLate(false);
paragraph.add(pTable);
But the text is left aligned. I was successful using a Paragraph
object instead of a table, but I need to display text in a table.