- Home
- Forum
- Xamarin.Forms
- Null reference exception Syncfusion.Pdf.Tables.PdfLightTable.GetColumnsCaption
Null reference exception Syncfusion.Pdf.Tables.PdfLightTable.GetColumnsCaption
Code:
Stack Trace:
at Syncfusion.Pdf.Tables.PdfLightTable.GetColumnsCaption () [0x00057] in <065e70699219434aaa8a0e6f89c1f20f>:0
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
SIGN IN To post a reply.
5 Replies
RB
Ravikumar Baladhandapani
Syncfusion Team
March 16, 2020 12:56 PM UTC
Hi Evgeni,
Currently we are working on this reported issue and we will update the further details on March 18th 2020.
However, please provide more information about the issue like simple sample to reproduce the issue.
Regards,
Ravikumar
Hi Evgeni,Currently we are working on this reported issue and we will update the further details on March 18th 2020.However, please provide more information about the issue like simple sample to reproduce the issue.Regards,Ravikumar
any updates?
SL
Sowmiya Loganathan
Syncfusion Team
March 19, 2020 12:39 PM UTC
Hi Evgeni,
Sorry for the delay.
We have analyzed the provided code snippet and found that you have tried to assign the PdfLightTableDataSourceType to DataSourceinstead of DataSourceType. So kindly use the below code snippet to overcome the reported issue,
Codesnippet:
|
//Declare a PdfLightTable
PdfLightTable table = new PdfLightTable();
//Set the Data source as direct
table.DataSourceType = PdfLightTableDataSourceType.TableDirect; |
We have created the sample to illustrate this and please find the download link from below,
Please try the above sample and let us know the result.
Regards,
Sowmiya Loganathan
EV
Evgeni
March 23, 2020 12:42 PM UTC
Thanks for help, it works. It's just odd because in the previous version 17.1.0.43 everything was okay.
PN
Preethi Nesakkan Gnanadurai
Syncfusion Team
March 24, 2020 05:45 AM UTC
Hi Evgeni,
Most welcome.
Regards,
Preethi
SIGN IN To post a reply.
- 5 Replies
- 4 Participants
-
EV Evgeni
- Mar 13, 2020 12:14 PM UTC
- Mar 24, 2020 05:45 AM UTC