public PdfPCell Write(PdfPCellModel pdfPCellModel) { Font cellFont = FontFactory.GetFont(pdfPCellModel.Font.Familyname, pdfPCellModel.Font.Size, pdfPCellModel.IsBold ? Font.BOLD : Font.NORMAL, pdfPCellModel.Font.Color); var pdfPCell = new PdfPCell(new Phrase(pdfPCellModel.Value, cellFont)); pdfPCell.Border = pdfPCellModel.Borders.HasValue ? pdfPCellModel.Borders.Value : Rectangle.NO_BORDER; pdfPCell.HorizontalAlignment = pdfPCellModel.Alignment.HasValue ? pdfPCellModel.Alignment.Value : Rectangle.ALIGN_LEFT; if (pdfPCellModel.Colspan.HasValue) { pdfPCell.Colspan = pdfPCellModel.Colspan.Value; } pdfPCell.PaddingBottom = pdfPCellModel.PaddingBottom.HasValue ? pdfPCellModel.PaddingBottom.Value : 5f; pdfPCell.PaddingTop = pdfPCellModel.PaddingTop.HasValue ? pdfPCellModel.PaddingTop.Value : 5f; pdfPCell.PaddingLeft = 5f; pdfPCell.PaddingRight = 5f; if (pdfPCellModel.FixedHeight.HasValue) { pdfPCell.FixedHeight = pdfPCellModel.FixedHeight.Value; } return(pdfPCell); }
public PdfPTable WriteTable(PdfPCellModel pdfPCellModel, PdfPAddress pdfPAddress) { PdfPTable addressPdfPTable = new PdfPTable(1); WriteToTable(pdfPCellModel, addressPdfPTable, pdfPAddress); return(addressPdfPTable); }
public void WriteToTable(PdfPCellModel pdfPCellModel, PdfPTable addressPdfPTable, PdfPAddress pdfPAddress) { var pdfPCell = new PdfPCell(); pdfPCell.Border = pdfPCellModel.Borders.HasValue ? pdfPCellModel.Borders.Value : Rectangle.NO_BORDER; pdfPCell.HorizontalAlignment = Rectangle.ALIGN_RIGHT; pdfPCell.PaddingLeft = 5f; if (!string.IsNullOrEmpty(pdfPAddress.AddressLine1)) { pdfPCell.AddElement(ParagraphWriter.Instance.Write(pdfPAddress.AddressLine1.ToUpper(), pdfPCellModel.Font)); } if (!string.IsNullOrEmpty(pdfPAddress.AddressLine2)) { pdfPCell.AddElement(ParagraphWriter.Instance.Write(pdfPAddress.AddressLine2.ToUpper(), pdfPCellModel.Font)); } if (!string.IsNullOrEmpty(pdfPAddress.Suburb)) { pdfPCell.AddElement(ParagraphWriter.Instance.Write(pdfPAddress.Suburb.ToUpper(), pdfPCellModel.Font)); } if (!string.IsNullOrEmpty(pdfPAddress.City)) { pdfPCell.AddElement(ParagraphWriter.Instance.Write(pdfPAddress.City.ToUpper(), pdfPCellModel.Font)); } if (!string.IsNullOrEmpty(pdfPAddress.PostalCode)) { pdfPCell.AddElement(ParagraphWriter.Instance.Write(pdfPAddress.PostalCode.ToUpper(), pdfPCellModel.Font)); } if (!string.IsNullOrEmpty(pdfPAddress.Province)) { pdfPCell.AddElement(ParagraphWriter.Instance.Write(pdfPAddress.Province.ToUpper(), pdfPCellModel.Font)); } if (!string.IsNullOrEmpty(pdfPAddress.Country)) { pdfPCell.AddElement(ParagraphWriter.Instance.Write(pdfPAddress.Country.ToUpper(), pdfPCellModel.Font)); } addressPdfPTable.AddCell(pdfPCell); }
public PdfPCell WriteHeader(PdfPCellModel pdfPCellModel) { Font cellFont = FontFactory.GetFont("Arial Bold", 11, BaseColor.DarkGray); //Font cellFont = new Font(BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, BaseFont.NOT_EMBEDDED), 15, Font.NORMAL); var pdfPCell = new PdfPCell(new Phrase(pdfPCellModel.Value, cellFont)); pdfPCell.Border = pdfPCellModel.Borders.HasValue ? pdfPCellModel.Borders.Value : Rectangle.NO_BORDER; pdfPCell.HorizontalAlignment = pdfPCellModel.Alignment.HasValue ? pdfPCellModel.Alignment.Value : Rectangle.ALIGN_LEFT; if (pdfPCellModel.Colspan.HasValue) { pdfPCell.Colspan = pdfPCellModel.Colspan.Value; } pdfPCell.PaddingBottom = 10f; pdfPCell.PaddingTop = 10f; return(pdfPCell); }