Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
UltraGridDocumentExporter exporting to PDF needs header and footer information on each page

Is it possible to put page level header and footer information when exporting an UltraGrid to PDF using the UltraGridDocumentExporter?

  • 469350
    Verified Answer
    Offline posted

    Hi Kenneth,

    Yes, there's a sample of this included in NetAdvantage (assuming you chose to install the samples). If you open up the grid SamplesExplorer (\WinForms\2014.1\Samples\Grid\CS\SamplesExplorer), take a look at frmDocumentExport.cs.

    In particular, take a look at the AddPageNumbers method.

    #region AddPageNumbers
            private void AddPageNumbers(ISection section)
                string pageNumberLocation = this.cboPageNumbers.SelectedItem.ToString();

                if (pageNumberLocation == "None")

                // Set the template. The template is the key property for turning on page numbers.
                // If the template is blank, no page numbers will display.
                section.PageNumbering.Template = SamplesExplorer.Strings.frmDocumentExport_PageNumberTemplate;

                // Don't skip the first page number.
                section.PageNumbering.SkipFirst = false;

                // Align the page numbers.
                PageNumberAlignment pageNumberAlignment;
                if (pageNumberLocation == "Top")
                    pageNumberAlignment  = new PageNumberAlignment(Alignment.Center, Alignment.Top);
                    pageNumberAlignment = new PageNumberAlignment(Alignment.Center, Alignment.Bottom);

                section.PageNumbering.Alignment = pageNumberAlignment;

                // Specify the font of the Page Numbers.
                Infragistics.Documents.Reports.Graphics.Font pageNumberFont = new Infragistics.Documents.Reports.Graphics.Font("Tahoma", 8.25f);

                // Specify the brush - this determines the color of the text.
                Infragistics.Documents.Reports.Graphics.Brush pageNumberBrush = Infragistics.Documents.Reports.Graphics.Brushes.DarkGray;

                // Create a style which includes the Font and Brush.
                Style pageNumberStyle = new Style(pageNumberFont, pageNumberBrush);

                // Assign the style to the PageNumbering object.
                section.PageNumbering.Style = pageNumberStyle;

                // Set the format to Decimal - normal numbers.
                section.PageNumbering.Format = PageNumberFormat.Decimal;
                // PageNumbers display on the page at a specified point and are not part of the header
                // or footer. So in order to prevent the grid from overrunning the page numbers,
                // we need to set the PageSpacings to leave room.
                // The font size here does not account for ascent or descent and we do not want the
                // page numbers to touch the grid row, so add in 5 points of padding.
                if (pageNumberLocation == "Top")
                    section.PageMargins.Top = pageNumberFont.Size + 5;
                    section.PageMargins.Bottom = pageNumberFont.Size + 5;
            #endregion //AddPageNumbers

Reply Children
No Data