Code:
private PdfLayoutResult DrawOverviewResultTable(PdfPage page, PointF startingPoint, IPdfReportModel currentInspection,
IPdfReportModel previousInspection) {
var table = new PdfLightTable();
table.DataSource = PdfLightTableDataSourceType.TableDirect;
table.Columns.Add(new PdfColumn(I18NResourceReader.GetString("PdfReportOverviewSectorsGridLabel")));
foreach (string sectorName in _sectorNameList)
{
table.Columns.Add(new PdfColumn(sectorName));
}
var currentInspectionStatus = new string[currentInspection.SectorsForInspection.Count + 1];
var currentSectorStatus = currentInspection.SectorsForInspection.Select(x => x.TargetAchievement).ToArray();
currentInspectionStatus[0] = I18NResourceReader.GetString("PdfReportOverviewSectorGridCurrentGoalLabel");
for (var i = 0; i < currentInspection.SectorsForInspection.Count; i++)
{
currentInspectionStatus[i + 1] = PercentValueConverter.Convert(currentSectorStatus[i] ?? double.NaN);
}
var previousInspectionStatus = new string[currentInspectionStatus.Length];
previousInspectionStatus[0] = I18NResourceReader.GetString("PdfReportOverviewSectorGridPreviousGoalLabel");
for (int i = 1; i < previousInspectionStatus.Length; i++)
{
previousInspectionStatus[i] = PercentValueConverter.Convert(null);
}
foreach (ISectorForInspectionModel sectorForInspection in previousInspection.SectorsForInspection)
{
previousInspectionStatus[sectorForInspection.Sector.SectorOrder] = PercentValueConverter.Convert(sectorForInspection.TargetAchievement);
}
table.Rows.Add(currentInspectionStatus);
table.Rows.Add(previousInspectionStatus);
table.Rows.Add(new string[] { I18NResourceReader.GetString("PdfReportOverviewSectorGridTotalsLabel"), "10%", "20%", "20%", "30%", "20%" });
var totalStatus = new string[currentInspection.SectorsForInspection.Count + 1];
totalStatus[0] = I18NResourceReader.GetString("PdfReportOverviewSectorGridPartsLabel");
for (var i = 0; i < currentInspection.SectorsForInspection.Count; i++)
{
var sectorStatus = currentSectorStatus[i] ?? double.NaN;
var hygieneStatus = sectorStatus * currentInspection.SectorsForInspection.Select(x => x.Sector.Weight).ToArray()[i];
totalStatus[i + 1] = PercentValueConverter.Convert(hygieneStatus);
}
table.Rows.Add(totalStatus);
var format = new PdfLayoutFormat();
format.Layout = PdfLayoutType.Paginate;
var headerStyle = new PdfCellStyle(PdfReportFonts.FONT_DEFAULT_BOLD, PdfBrushes.Black, PdfReportPens.BORDER_PEN);
headerStyle.BackgroundBrush = PdfReportBrushes.TABLE_HEADER;
table.Style.HeaderStyle = headerStyle;
table.Style.ShowHeader = true;
table.Style.HeaderSource = PdfHeaderSource.ColumnCaptions;
table.Style.DefaultStyle.BorderPen = PdfReportPens.BORDER_PEN;
table.Style.CellPadding = PdfReportConstants.GLOBAL_CELL_PADDING;
table.Style.DefaultStyle.Font = PdfReportFonts.FONT_DEFAULT;
table.Columns[0].Width = 120;
table.BeginRowLayout += table_BeginRowLayout;
var result = table.Draw(page, startingPoint, format);
return result;
}
Stack Trace:
at Syncfusion.Pdf.Tables.PdfLightTable.GetColumnsCaption () [0x00057] in <065e70699219434aaa8a0e6f89c1f20f>:0
at Syncfusion.Pdf.Tables.PdfLightTable.GetColumnCaptions () [0x0005c] in <065e70699219434aaa8a0e6f89c1f20f>:0
at Syncfusion.Pdf.Tables.LightTableLayouter.LayoutOnPage (System.Int32 startRowIndex, Syncfusion.Pdf.Graphics.PdfLayoutParams param, System.Boolean isPageFirst) [0x00135] in <065e70699219434aaa8a0e6f89c1f20f>:0
at Syncfusion.Pdf.Tables.LightTableLayouter.LayoutInternal (Syncfusion.Pdf.Graphics.PdfLayoutParams param) [0x001c7] in <065e70699219434aaa8a0e6f89c1f20f>:0
at Syncfusion.Pdf.Graphics.ElementLayouter.Layout (Syncfusion.Pdf.Graphics.PdfLayoutParams param) [0x0000e] in <065e70699219434aaa8a0e6f89c1f20f>:0
at Syncfusion.Pdf.Tables.PdfLightTable.Layout (Syncfusion.Pdf.Graphics.PdfLayoutParams param) [0x00043] in <065e70699219434aaa8a0e6f89c1f20f>:0
at Syncfusion.Pdf.Graphics.PdfLayoutElement.Draw (Syncfusion.Pdf.PdfPage page, Syncfusion.Drawing.RectangleF layoutRectangle, Syncfusion.Pdf.Graphics.PdfLayoutFormat format) [0x00033] in <065e70699219434aaa8a0e6f89c1f20f>:0
at Syncfusion.Pdf.Graphics.PdfLayoutElement.Draw (Syncfusion.Pdf.PdfPage page, System.Single x, System.Single y, Syncfusion.Pdf.Graphics.PdfLayoutFormat format) [0x00013] in <065e70699219434aaa8a0e6f89c1f20f>:0
at Syncfusion.Pdf.Graphics.PdfLayoutElement.Draw (Syncfusion.Pdf.PdfPage page, Syncfusion.Drawing.PointF location, Syncfusion.Pdf.Graphics.PdfLayoutFormat format) [0x0007b] in <065e70699219434aaa8a0e6f89c1f20f>:0