I am building a vertical list of months with a horizontal list of days in each month. To each day I am adding a sized and colored rectangle; the size and color is dependant
cell1.setHorizontalAlignment(PdfPCell.ALIGN_CENTER) align the text of the cell in the center. You can see an example.
PdfPTable tablaTotal = new PdfPTable(2);
PdfPCell cell1 = new PdfPCell(new Phrase("TOTAL"));
cell1.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
cell1.setPadding(5);
tablaTotal.addCell(cell1);
PdfPCell cell2 = new PdfPCell(new Phrase(contrato.getPrecioInmueble() + " €"));
cell2.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
cell2.setPadding(5);
tablaTotal.addCell(cell2);
We create tablaTotal with two columns, cell1 with the text Total, we align the text of the cell1 and add and padding to the cell1. We do the same to cell2 and we add the two cell to tablaTotal.