Actual code (Copy past issue). Issue is with cellstyle? But I don't get it.
var g = page.Graphics;
/* Header */
var element = new PdfTextElement("UNRESOLVED ISSUED FROM PREVIOUS VISITS", SubHeadingFont);
element.Brush = new PdfSolidBrush(new PdfColor(34, 83, 142));
result = element.Draw(page, new PointF(10, result.Bounds.Bottom + 25));
g.DrawLine(new PdfPen(new PdfColor(34, 83, 142), 0.70f), new PointF(0, result.Bounds.Bottom + 3), new PointF(g.ClientSize.Width, result.Bounds.Bottom + 3));
/* Output */
if (previousIssues.Count == 0)
{
element = new PdfTextElement("No issues.", BodyFont,BlackSolidBrush);
element.Draw(page, new PointF(10, result.Bounds.Bottom + 10));
}
else
{
PdfGrid grid = new PdfGrid();
grid.Columns.Add(3);
grid.Headers.Add(1);
grid.Columns[1].Width = 80;
grid.Columns[2].Width = 180;
PdfGridRow pdfGridHeader = grid.Headers[0];
pdfGridHeader.Cells[0].Value = "Description";
pdfGridHeader.Cells[1].Value = "Responsibility";
pdfGridHeader.Cells[2].Value = "Complete By";
pdfGridHeader.ApplyStyle(GridHeaderStyle);
foreach (var issue in previousIssues)
{
PdfGridRow pdfGridRow = grid.Rows.Add();
PdfGridCellStyle cellStyle = new PdfGridCellStyle();
cellStyle.Font = BodyFont;
cellStyle.TextBrush = PdfBrushes.Black;
cellStyle.CellPadding = new PdfPaddings(5f, 5f, 5f, 5f);
cellStyle.StringFormat = new PdfStringFormat();
cellStyle.Borders.All = PdfPens.Gray;
// Wraps word
cellStyle.StringFormat.WordWrap = PdfWordWrapType.Word;
pdfGridRow.ApplyStyle(cellStyle);
pdfGridRow.Cells[0].Value = issue.Description;
pdfGridRow.Cells[1].Value = issue.Responsibility.ToString();
pdfGridRow.Cells[2].Value = issue.CompleteBy.ToString("D");
}
PdfGridLayoutFormat layoutFormat = new PdfGridLayoutFormat();
layoutFormat.Layout = PdfLayoutType.Paginate;
PdfGridLayoutResult gridResult = grid.Draw(page, new RectangleF(new PointF(0, result.Bounds.Bottom + 10), new SizeF(g.ClientSize.Width, g.ClientSize.Height - 100)), layoutFormat);
return gridResult;