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
145
Multi page PDF report
posted

I have written single page reports but I am now working on multiple page reports and have questions.

These reports have headers and footers with different content on the pages.  The pages have different content for the headers, but the footers have the same content (file name and page number).

ISection has AddHeader(), AddFooter(), AddPage(), and AddPageBreak().  AddPage() returns a ISectionPaage object.

I am confused about how to add pages with different headers and using continuous page numbering in the footers.

I am looking for recommendations.

  • 469350
    Offline posted

    Hi Alf,

    I'm not aware of any way to have different headers and footers on each page. The headers and footers can only implement repeating patterns as far as I know. Of course, you can use AddPageBreak and then add whatever content you want on a page, so you could put some content at the top of each page outside of the header/footer.

    Here's some sample code that shows how to do page numbers in the footer.

           


            private void button1_Click(object sender, EventArgs e)
            {
                Report report = new Report();
                var section = report.AddSection();

                section.PageNumbering = new Infragistics.Documents.Reports.Report.Section.PageNumbering();
                section.PageNumbering.Template = "Page [Page #] of [TotalPages]";
                section.PageNumbering.Continue = true;
                section.PageNumbering.SkipFirst = false;
                section.PageNumbering.Alignment = Infragistics.Documents.Reports.Report.PageNumberAlignment.Right;
                section.PageNumbering.OffsetX = -10;

                var text = section.AddText();
                text.AddContent("This is the first page and it has some text on it.");

                section.AddPageBreak();

                text = section.AddText();
                text.AddContent("This is the second page and it has some text on it.");

                string filename = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "test.pdf");
                report.Publish(filename, FileFormat.PDF);
                Process.Start(filename);
            }