/// <summary> /// Cria o cabeçalho de uma tabela no documento pdf /// </summary> /// <param name="document">objeto document</param> /// <param name="headerFields">lista de campos do cabeçalho</param> /// <param name="totalWidths">lista da largura de cada campo do cabeçalho</param> public static void AddTableHeader(Document document, string[] headerFields, float[] totalWidths) { int qtdeCells = headerFields.Count(); PdfPTable table = new PdfPTable(qtdeCells); table.SetTotalWidth(totalWidths); PdfPCell[] cells = new PdfPCell[qtdeCells]; string texto = ""; for (int i = 0; i < qtdeCells; i++) { texto = headerFields[i].ToString(); cells[i] = new PdfPCell(new Phrase(new Chunk(texto, FontFactory.GetFont("Arial", 8f, BaseColor.BLACK)))); cells[i].BackgroundColor = WebColors.GetRGBColor("#B5B5B5"); cells[i].HorizontalAlignment = Element.ALIGN_LEFT; cells[i].Border = PdfPCell.NO_BORDER; table.AddCell(cells[i]); } table.WidthPercentage = 96.7f; table.DefaultCell.FixedHeight = 15f; document.Add(table); //return table; }
public static PdfPTable RodapeRelatorioFrequencia(Document document, string periodoTotal, int qtdeCells, float[] totalWidths) { PdfPTable table = new PdfPTable(qtdeCells); table.SetTotalWidth(totalWidths); PdfPCell[] cells = new PdfPCell[qtdeCells]; for (int i = 0; i < qtdeCells; i++) { string texto = ""; if (i == 0) { texto = "Total Mês"; } else if (i == 3) { texto = periodoTotal; } cells[i] = new PdfPCell(new Phrase(new Chunk(texto, FontFactory.GetFont("Arial", 8f, BaseColor.BLACK)))); cells[i].BackgroundColor = WebColors.GetRGBColor("#B5B5B5"); cells[i].HorizontalAlignment = i == 0 ? Element.ALIGN_CENTER : Element.ALIGN_LEFT; cells[i].Border = PdfPCell.NO_BORDER; table.AddCell(cells[i]); } table.WidthPercentage = 96.7f; table.DefaultCell.FixedHeight = 15f; document.Add(table); return(table); }