Creating a report from multiple templates, with each template having its own data source

I have created templates, each template has its own data source.

The template may appear in the report several times, but each time it has a data source with different parameters and is never right behind it.

for example.

Template A with source A1 - one side.

Template D with source D - one page.

Template B with source B1 - two pages.

Template A with source A2 - two side.

Template C with C source - one page.

Template B with source B2 - three pages.


then I need the pages to be numbered 1 - N

The only thing I achieved is that the page contained data according to the last data source of the template.


Thanks for any advice, I'm already desperate.

Josef

Comments

  • Hello!

    To merge several templates into a single document with continuous pagination (Page i of N) during the Prepare(append: true) stage, the preceding segments do not yet know the total number of pages in the future segments (Page 1 of 1, Page 2 of 2...), so insert or update the footer text by iterating through `report.PreparedPages` after all `Prepare(true)` calls have completed:

    for (int i = 0; i < templates.Length; i++)
    {
    report.Load(templates[i].Path);
    report.RegisterData(templates[i].Data, ‘Data’);
    report.Prepare(append: i > 0);
    }
    
    int total = report.PreparedPages.Count;
    for (int p = 0; p < total; p++)
    {
    var page = report.PreparedPages.GetPage(p);
    if (page.FindObject(‘FooterPageText’) is TextObject txt)
    {
    txt.Text = $‘Page {p + 1} of {total}’;
    report.PreparedPages.ModifyPage(p, page);
    }
    }
    
This discussion has been closed.