示例#1
0
        /// <summary>
        /// Called when a page is started.
        /// </summary>
        /// <param name="writer">Writer the <see cref="iTextSharp.text.pdf.PdfWriter"/> for this document</param>
        /// <param name="document">Current document</param>
        public override void OnStartPage(PdfWriter writer, Document document)
        {
            base.OnStartPage(writer, document);

            #region initialize
            var table    = TabularWriter.Provider.Input.Model.Table;
            var provider = TabularWriter.Provider;
            #endregion

            #region add logo
            document.AddLogo(table.Logo);
            #endregion

            #region sets vertical table position
            document.SetVerticalLocationFrom(table.Location);
            #endregion

            #region add top aggregates
            var tempTable = new PdfPTable(PdfTable.NumberOfColumns);
            tempTable.SetTotalWidth(PdfTable.AbsoluteWidths);
            tempTable.HorizontalAlignment = PdfTable.HorizontalAlignment;
            tempTable.LockedWidth         = table.AutoFitColumns == YesNo.Yes;

            if (writer.PageNumber == 1)
            {
                tempTable.AddAggregateByLocation(
                    table,
                    RawData,
                    provider.SpecialChars.ToArray(),
                    KnownAggregateLocation.Top);
            }
            #endregion

            #region add column headers
            tempTable.AddColumnHeaders(table);
            #endregion

            #region add field headers
            tempTable.AddFieldHeaders(table);
            #endregion

            #region add table to this document
            document.Add(tempTable);
            #endregion
        }