public PdfPCell GetNewTotal(Object total) { Font font = FontFactory.GetFont(Fuente, fuenteTamaño, Font.BOLD); var pdfPCell = new PdfPCell(tabla.DefaultCell); pdfPCell.PaddingTop = 2; if (MostrarBordes) { pdfPCell.BackgroundColor = BaseColor.LIGHT_GRAY; } else { pdfPCell.BorderWidthTop = 0.5f; } pdfPCell.PaddingBottom = 3; pdfPCell.HorizontalAlignment = Element.ALIGN_RIGHT; if (total is string) { Alineaciones alineacionColumna = columnas [totales.IndexOf(total) % columnas.Count].Alineacion; switch (alineacionColumna) { case Alineaciones.Izquierda: pdfPCell.HorizontalAlignment = Element.ALIGN_LEFT; break; case Alineaciones.Centrado: pdfPCell.HorizontalAlignment = Element.ALIGN_CENTER; break; case Alineaciones.Justificado: pdfPCell.HorizontalAlignment = Element.ALIGN_JUSTIFIED; break; case Alineaciones.Derecha: pdfPCell.HorizontalAlignment = Element.ALIGN_RIGHT; break; default: pdfPCell.HorizontalAlignment = Element.ALIGN_LEFT; break; } } if (total is double) { total = string.Format("{0:#0.00}", total); } if (total is decimal) { total = string.Format("{0:C}", total); } if (total is float) { total = string.Format("{0:#0.0000}", total); } var phrase = new Phrase(total.ToString(), font); pdfPCell.Phrase = phrase; return(pdfPCell); }
public PdfPCell GetNewData(Object dato) { Font font = FontFactory.GetFont(Fuente, fuenteTamaño); var pdfPCell = new PdfPCell(tabla.DefaultCell); pdfPCell.HorizontalAlignment = Element.ALIGN_RIGHT; if (dato is string) { Alineaciones alineacionColumna = columnas [datos.IndexOf(dato) % columnas.Count].Alineacion; switch (alineacionColumna) { case Alineaciones.Izquierda: pdfPCell.HorizontalAlignment = Element.ALIGN_LEFT; break; case Alineaciones.Centrado: pdfPCell.HorizontalAlignment = Element.ALIGN_CENTER; break; case Alineaciones.Justificado: pdfPCell.HorizontalAlignment = Element.ALIGN_JUSTIFIED; break; case Alineaciones.Derecha: pdfPCell.HorizontalAlignment = Element.ALIGN_RIGHT; break; default: pdfPCell.HorizontalAlignment = Element.ALIGN_LEFT; break; } } if (dato is double) { dato = string.Format("{0:#0.00}", dato); } if (dato is decimal) { dato = string.Format("{0:C}", dato); } if (dato is float) { dato = string.Format("{0:#0.0000}", dato); } var phrase = new Phrase(dato.ToString(), font); pdfPCell.Phrase = phrase; return(pdfPCell); }