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
2387
Adding a footer with page count
posted

I am taking the section example in the documentation and trying to add a footer to it, the page number is not lining up with footer.  What do I need to do to get things to line up correctly?  I would like the footer to be lowered, not the page number raised:

 

public static void Run()

{

    Report report = new Report();

    // Create the main Section

    ISection section = report.AddSection();

 

    section.PageMargins.All = 40;            

 

    // CreateHeader(section);

 

    // Get a reference to the section's PageNumbering object.

    Infragistics.Documents.Report.Section.PageNumbering pn = section.PageNumbering;

 

    // Create a style for the page numbering font.

    pn.Style = new Infragistics.Documents.Report.Text.Style(Fonts.Arial, Infragistics.Documents.Graphics.Brushes.Black);

 

    // The Template property is the actual string that

    // shows the page numbering. Use the [Page #] place-

    // holder for the current page and the [TotalPages]

    // place-holder for the total amount of pages in

    // the entire document.

    pn.Template = "Page [Page #] of [TotalPages]";

 

    // Setting SkipFirst to true does not place page

    // numbering on the first page of the section. This

    // is useful if the first page is a Title page.

    pn.SkipFirst = false;

 

    // The page numbering will be aligned with the

    // right side of the page. Valid values off the

    // Alignment enum include Left, Center, and Right.

    pn.Alignment.Horizontal = Infragistics.Documents.Report.Alignment.Right;

 

    // The page numbering will be located at the 

    // bottom of the page. Valid values off the

    // Alignment enum include Top and Bottom.

    pn.Alignment.Vertical = Infragistics.Documents.Report.Alignment.Bottom;

 

    // The page numbering is at the extreme bottom

    // of the page, so we need to change the Y Offset

    // in order to bring it in line with the rest of

    // the page footer text.

    pn.OffsetY = -18;

 

    ISectionFooter footer = section.AddFooter();

    footer.Height = 30;

    IText text = footer.AddText(0, -18);

    text.AddContent(string.Format("Date printed: {0}", DateTime.Now.ToString("dd-MM-yyyy")));

 

    string reportName = GetPDFName(".pdf");

    report.Publish(reportName, FileFormat.PDF);

    System.Diagnostics.Process.Start(reportName);

}

Parents Reply Children
No Data