/** * Factory method for create a new {@link PdfPTable} with the given count of columns and the * column header names * * @param numColumns * the count of columns of the table * @param headerNames * the column header names * @return the new {@link PdfPTable} */ public static PdfPTable newPdfPTable(int numColumns, List<String> headerNames) { PdfPTable table = new PdfPTable(numColumns); headerNames.stream().forEach(columnHeaderName -> { PdfPCell header = new PdfPCell(); header.setBackgroundColor(BaseColor.LIGHT_GRAY); header.setBorderWidth(2); header.setPhrase(new Phrase(columnHeaderName)); table.addCell(header); }); return table; }
private static PdfPCell createCell(final Phrase text, final int index, final BaseColor bgColor) { final PdfPCell cell = new PdfPCell(text); cell.setHorizontalAlignment(index == 0 ? Element.ALIGN_LEFT : Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(bgColor); cell.setBorderWidth(0); cell.setPaddingBottom(PADDING_BOTTOM); cell.setPaddingTop(PADDING_TOP); cell.setPaddingLeft(PADDING_LEFT); cell.setPaddingRight(PADDING_RIGHT); return cell; }
if (value != null) border = Float.parseFloat(value); cell.setBorderWidth(border);
if (value != null) border = Float.parseFloat(value); cell.setBorderWidth(border);
c.setBorder(img.getBorder()); c.setBorderColor(img.getBorderColor()); c.setBorderWidth(img.getBorderWidth()); c.setBackgroundColor(img.getBackgroundColor()); t.addCell(c);
c.setBorder(img.getBorder()); c.setBorderColor(img.getBorderColor()); c.setBorderWidth(img.getBorderWidth()); c.setBackgroundColor(img.getBackgroundColor()); t.addCell(c);