send multiple reports to the printer

Stimulsoft Reports.WEB discussion
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

send multiple reports to the printer

Post by Ivan »

Hello,
jpascual wrote:Thanks for your answer but the example does not work. Displays the report in black and with only one page when it should have two pages and data.
Please modify your code:

Code: Select all

        Dim report As New StiReport
        report.Load(MapPath("~/report.mrt"))
        report.Compile()
        report.Render(False)

        Dim reportAll As New StiReport
        reportAll.NeedsCompiling = False
        reportAll.IsRendered = True
        reportAll.RenderedPages.Clear()

        Dim Customers(2) As String
        Customers(0) = 719
        Customers(1) = 717
        For k As Integer = 0 To Customers.Length - 2

            Dim CustomerID As Integer = Customers(k)
            report("Variable1") = CustomerID.ToString()
            report.Render(False)

            For Each page As StiPage In report.RenderedPages
                reportAll.RenderedPages.Add(page)
            Next
        Next

        StiWebViewerFx1.Report = reportAll
jpascual wrote:The code is similar to what I had. Just change one line and is similar.
This line of code depends on whether the report is compiled or not.

Thank you.
Raphael Affolter
Posts: 4
Joined: Wed Jun 24, 2015 10:59 am

Re: send multiple reports to the printer

Post by Raphael Affolter »

Thanks for the great sample. But I have two more questions about how to handle the page numbering:

1. how to set the start page of the second report to the total of the first?
2. how to (even more complicated) make "Page n of m" work?

Thanks for your help,
Raphael
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: send multiple reports to the printer

Post by HighAley »

Hello.

Amount of pages you could get from reportAll.RenderedPages.Count and pass to the report's variable.
Then you could use the variable to write Page number.

To use Page of Pages it's necessary to know the count of pages of the whole report.
But if you render it separately it's impossible to do.

Please, try to use several pages in report template to create such report.

Thank you.
Raphael Affolter
Posts: 4
Joined: Wed Jun 24, 2015 10:59 am

Re: send multiple reports to the printer

Post by Raphael Affolter »

Hello,

I tried to set the property PageNumber of the second report but it will be ignored. Of course I can do it with an own variable "StartPage" or similar, but I wonder if there is no Built-In possibility to set the start page.

Regarding Page n/m I managed to change the already rendered text field after both reports have been rendered but before printing. Works great.

Just in case somebody needs the code:

Code: Select all

            foreach (StiPage page in reportAll.RenderedPages)
            {
                foreach (StiComponent c in page.Components)
                {
                    if (c.Name == "ReplaceMe")
                    {
                        (c as StiText).Text = "Total Pages: " + totalPages.ToString();
                    }
                }
            }
Best Regards,
Raphael
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: send multiple reports to the printer

Post by HighAley »

Hello.

Unfortunately, there is no possibility to change the number of start page.

But you could use such code.

There are many ways to do one thing in our product.
Let us know if you need any additional help.

Thank you.
Post Reply