private Font getFont(FormCell formCell) { Font font = pgInfo.getFontInfo().defaultF(); if (formCell.getFont() != null) { font = formCell.getFont(); } font = new Font(font); if (formCell.isBold()) { font.setStyle(Font.BOLD); } else { font.setStyle(Font.NORMAL); } return font; }
public PdfPTable getAsPdfPTable() { PdfPTable tabla = new PdfPTable(getColsWidths()); tabla.setWidthPercentage(getWidthPercentaje()); List<FormTableRow> rows = getRows(); for (FormTableRow row : rows) { FormCell formCell = row.getNextCell(); while (formCell != null) { PdfPCell pdfPCell = null; if (formCell.containsImage()) { pdfPCell = new PdfPCell(formCell.getImage()); } else { Paragraph paragraph = new Paragraph(formCell.getFormattedValue(), getFont(formCell)); pdfPCell = new PdfPCell(paragraph); } pdfPCell.setColspan(formCell.getColSpan()); if (formCell.getHorizontalAlignment() != -1) { pdfPCell.setHorizontalAlignment(formCell.getHorizontalAlignment()); } else { FormColumnInfo formColumnInfo = columnsInfo[formCell.getColumn()]; pdfPCell.setHorizontalAlignment(formColumnInfo.getHorizontalAlignment()); } if (formCell.isPaintBorder() == null) { FormColumnInfo formColumnInfo = columnsInfo[formCell.getColumn()]; if (!formColumnInfo.isPaintBorder()) { pdfPCell.setBorder(Rectangle.NO_BORDER); } } else if (!formCell.isPaintBorder()) { pdfPCell.setBorder(Rectangle.NO_BORDER); } tabla.addCell(pdfPCell); formCell = row.getNextCell(); } } return tabla; }