public static void Cell(PdfPTable table, string txt, Font font, PdfPCellBorderType bordertype, int rolspan = 0, int colspan = 0, BaseColor bgcolor = null, bool settextdefault = true) { if (string.IsNullOrEmpty(txt) && settextdefault) { txt = "-"; } PdfPCell c1 = new PdfPCell(new Phrase(txt, font)); c1.HorizontalAlignment = PdfPCell.ALIGN_LEFT; SetCellBorderWidth(c1, bordertype); c1.Padding = 5f; if (rolspan > 0) { c1.Rowspan = rolspan; } if (colspan > 0) { c1.Colspan = colspan; } if (bgcolor != null) { c1.BackgroundColor = bgcolor; } table.AddCell(c1); }
public static void CellImage(PdfPTable table, Image img, Font font, PdfPCellBorderType bordertype, int rolspan = 0, int colspan = 0, BaseColor bgcolor = null) { PdfPCell c1 = new PdfPCell(); c1.HorizontalAlignment = PdfPCell.ALIGN_LEFT; c1.AddElement(img); c1.Padding = 5f; SetCellBorderWidth(c1, bordertype); if (rolspan > 0) { c1.Rowspan = rolspan; } if (colspan > 0) { c1.Colspan = colspan; } table.AddCell(c1); }
private static void SetCellBorderWidth(PdfPCell c1, PdfPCellBorderType bordertype) { c1.BorderWidth = 1; //if (bordertype == PdfPCellBorderType.TopLeft) //{ // c1.BorderWidthLeft = 1; // c1.BorderWidthTop = 1; //} //else if (bordertype == PdfPCellBorderType.TopCenter) //{ // c1.BorderWidthLeft = 1; // c1.BorderWidthTop = 1; //} //else if (bordertype == PdfPCellBorderType.TopRight) //{ // c1.BorderWidthLeft = 1; // c1.BorderWidthRight = 1; // c1.BorderWidthTop = 1; //} //else if (bordertype == PdfPCellBorderType.MidLeft) //{ // c1.BorderWidthLeft = 1; // c1.BorderWidthTop = 1; //} //else if (bordertype == PdfPCellBorderType.MidCenter) //{ // c1.BorderWidthLeft = 1; // c1.BorderWidthTop = 1; //} //else if (bordertype == PdfPCellBorderType.MidRight) //{ // c1.BorderWidthLeft = 1; // c1.BorderWidthRight = 1; // c1.BorderWidthTop = 1; //} //else if (bordertype == PdfPCellBorderType.ButtomLeft) //{ // c1.BorderWidthLeft = 1; // c1.BorderWidthTop = 1; // c1.BorderWidthBottom = 1; //} //else if (bordertype == PdfPCellBorderType.ButtomCenter) //{ // c1.BorderWidthLeft = 1; // c1.BorderWidthTop = 1; // c1.BorderWidthBottom = 1; //} //else if (bordertype == PdfPCellBorderType.ButtomRight) //{ // c1.BorderWidthLeft = 1; // c1.BorderWidthRight = 1; // c1.BorderWidthTop = 1; // c1.BorderWidthBottom = 1; //} //else if (bordertype == PdfPCellBorderType.FullBorder) //{ // c1.BorderWidthLeft = 1; // c1.BorderWidthRight = 1; // c1.BorderWidthTop = 1; // c1.BorderWidthBottom = 1; //} }