void RenderSections()
        {
            SectionRenderer sectionrenderer = new SectionRenderer(this._template);
            var             table           = new PdfPTable(this._template.Columns.Count);

            table.WidthPercentage = 100;
            table.SetWidths(this._template.Columns.Select(x => (float)x.Width).ToArray());

            for (int x = 0; x < this._template.Sections.Count; x++)
            {
                var section = this._template.Sections[x];

                if (!string.IsNullOrEmpty(section.DataSource))
                {
                    if (this._datasource.ContainsKey(section.DataSource) &&
                        this._datasource[section.DataSource] != null)
                    {
                        var lastValues = new Dictionary <string, string>();

                        foreach (var datarow in this._datasource[section.DataSource])
                        {
                            sectionrenderer.Render(section.Rows.Select(row =>
                                                                       row.FromData(datarow, lastValues)).ToList(), table);
                        }
                    }
                }
                else
                {
                    sectionrenderer.Render(section.Rows, table);
                }
            }

            this._document.Add(table);
        }
        float getHeaderHeight(global::iTextSharp.text.Rectangle pageSize)
        {
            if (this._template.Header == null)
            {
                return(0);
            }
            SectionRenderer renderer  = new SectionRenderer(this._template);
            PdfPTable       tblHeader = new PdfPTable(this._template.Columns.Count);

            tblHeader.WidthPercentage = 100;
            tblHeader.SetWidths(this._template.Columns.Select(x => (float)x.Width).ToArray());
            tblHeader.TotalWidth = pageSize.Width - ((float)(this._template.PageOptions.Margins.Left - this._template.PageOptions.Margins.Left));
            renderer.Render(_template.Header.Rows, tblHeader);
            return(tblHeader.CalculateHeights());
        }
        void RenderHeader(PdfWriter writer, Document document)
        {
            if (this._template.Header == null)
            {
                return;
            }
            PdfContentByte  cb        = writer.DirectContent;
            SectionRenderer renderer  = new SectionRenderer(this._template);
            PdfPTable       tblHeader = new PdfPTable(this._template.Columns.Count);

            tblHeader.WidthPercentage = 100;
            tblHeader.SetWidths(this._template.Columns.Select(x => (float)x.Width).ToArray());
            tblHeader.TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin;
            renderer.Render(_template.Header.Rows, tblHeader);
            tblHeader.WriteSelectedRows(0, -1,
                                        document.LeftMargin, document.PageSize.Height - ((float)this._template.PageOptions.Margins.Top),
                                        cb);
        }