private void renderGroupHeader(IEnumerable <CellData> row) { applySpacingThreshold(); if (SharedData.Header == null) { return; } var groupHeader = SharedData.Header.RenderingGroupHeader(SharedData.PdfDoc, SharedData.PdfWriter, row.ToList(), SharedData.ColumnCellsSummaryData); if (groupHeader == null) { return; } if (SharedData.ShouldWrapTablesInColumns) { MainGroupTable.AddCell(new PdfPCell(groupHeader) { Border = 0 }); } else { SharedData.PdfDoc.Add(groupHeader); } }
/// <summary> /// Finalizing the MainTable's rendering /// </summary> public void CloseMainTable() { if (_dataSourceIsEmpty) { if (SharedData.MainTableEvents != null) { SharedData.MainTableEvents.MainTableAdded(new EventsArguments { PdfDoc = SharedData.PdfDoc, PdfWriter = SharedData.PdfWriter, Table = MainTable, ColumnCellsSummaryData = SharedData.ColumnCellsSummaryData, PreviousTableRowData = _previousTableRowData, PageSetup = SharedData.PageSetup, PdfFont = SharedData.PdfFont, PdfColumnsAttributes = SharedData.PdfColumnsAttributes }); } return; } MainTable.ElementComplete = true; //print the last footer if (SharedData.ShouldWrapTablesInColumns) { MainGroupTable.AddCell(new PdfPCell(MainTable) { Border = 0 }); MainGroupTable.AddCell(new PdfPCell(TableHelper.CreateEmptyRowTable(fixedHeight: 30)) { Border = 0 }); GroupsManager.AddAllGroupsSummary(); new TablesInColumns { PdfDoc = SharedData.PdfDoc, PdfWriter = SharedData.PdfWriter, PageSetup = SharedData.PageSetup, CurrentRowInfoData = CurrentRowInfoData }.Wrap(MainGroupTable); } else { MainTable.SpacingAfter += MainTable.HeaderHeight + 2.5f; tryFitToContent(); SharedData.PdfDoc.Add(MainTable); var lastRow = SharedData.ColumnCellsSummaryData.OrderByDescending(x => x.OverallRowNumber).FirstOrDefault(); if (lastRow != null) { CurrentRowInfoData.LastRenderedRowNumber = lastRow.OverallRowNumber; } GroupsManager.AddAllGroupsSummary(); } if (MainTable.Rows.Any()) { MainTable.DeleteBodyRows(); } mainTableAdded(); }
/// <summary> /// Starts a new group by creating a new table and initializing its properties. /// </summary> /// <param name="groupHeaderRowCellsData">New group's header row data</param> /// <param name="shouldCheckOneGroupPerPage">Do we need a new page again?</param> public void StartNewGroup(IEnumerable <CellData> groupHeaderRowCellsData, bool shouldCheckOneGroupPerPage) { MainTable.ElementComplete = true; //print the last footer var hasRows = MainTable.Rows.Any(); if (hasRows) { if (SharedData.ShouldWrapTablesInColumns) { MainGroupTable.AddCell(new PdfPCell(MainTable) { Border = 0 }); } else { MainTable.SpacingAfter += MainTable.HeaderHeight + 2.5f; tryFitToContent(); SharedData.PdfDoc.Add(MainTable); MainTable.DeleteBodyRows(); } } if (SharedData.MainTableEvents != null && _groupNumber > 0) { SharedData.MainTableEvents.GroupAdded(new EventsArguments { PdfDoc = SharedData.PdfDoc, PdfWriter = SharedData.PdfWriter, Table = MainGroupTable, ColumnCellsSummaryData = SharedData.ColumnCellsSummaryData, PreviousTableRowData = CurrentRowInfoData.PreviousTableRowData, PageSetup = SharedData.PageSetup, PdfFont = SharedData.PdfFont, PdfColumnsAttributes = SharedData.PdfColumnsAttributes }); } _groupNumber++; if (shouldCheckOneGroupPerPage) { showOneGroupPerPage(); } renderGroupHeader(groupHeaderRowCellsData); initMainTable(); RowsManager.TableInitAddHeaderAndFooter(); reset(); }
// Public Methods (3) /// <summary> /// Creates a new summary row table to display summary of the all of the available groups /// </summary> public void AddAllGroupsSummary() { if (!SharedData.IsGroupingEnabled) { return; } if (SharedData.SummarySettings == null) { return; } if (!SharedData.SummarySettings.OverallSummarySettings.ShowOnEachPage && !SharedData.SummarySettings.PreviousPageSummarySettings.ShowOnEachPage) { return; } if (SharedData.PageSetup.PagePreferences.RunDirection == null) { SharedData.PageSetup.PagePreferences.RunDirection = PdfRunDirection.LeftToRight; } var mainTableAbsoluteWidths = MainTable.AbsoluteWidths; var len = SharedData.ColumnsWidths.Length; if (SharedData.IsMainTableHorizontalStackPanel) { len = SharedData.HorizontalStackPanelColumnsPerRow; } MainTable = new PdfGrid(len) { RunDirection = (int)SharedData.PageSetup.PagePreferences.RunDirection, WidthPercentage = SharedData.PageSetup.MainTablePreferences.WidthPercentage, HeadersInEvent = true, HeaderRows = 0, FooterRows = 1, SkipFirstHeader = true, SplitLate = SharedData.PageSetup.MainTablePreferences.SplitLate, SpacingAfter = spacingAfterAllGroupsSummary, SpacingBefore = spacingBeforeAllGroupsSummary, KeepTogether = SharedData.PageSetup.MainTablePreferences.KeepTogether, SplitRows = SharedData.PageSetup.MainTablePreferences.SplitRows }; setSetTotalWidths(mainTableAbsoluteWidths); TableCellHelper = new TableCellHelper { SharedData = SharedData, MainTable = MainTable, ShowAllGroupsSummaryRow = showAllGroupsSummaryRow, CurrentRowInfoData = CurrentRowInfoData }; RowsManager.MainTable = MainTable; RowsManager.TableCellHelper = TableCellHelper; if (showAllGroupsSummaryRow) { RowsManager.AddFooterRow(RowType.AllGroupsSummaryRow); } MainTable.ElementComplete = true; //print footer if (SharedData.ShouldWrapTablesInColumns) { MainGroupTable.AddCell(new PdfPCell(MainTable) { Border = 0 }); } else { MainTable.SpacingAfter += MainTable.HeaderHeight + 2.5f; SharedData.PdfDoc.Add(MainTable); } }