How to print collection of reports

Stimulsoft Reports.UWP discussion
Locked
adamaka
Posts: 27
Joined: Wed Oct 10, 2012 3:18 pm

How to print collection of reports

Post by adamaka »

How would you print a collection of reports from code? Such as:

Code: Select all

foreach (var item in CollectionOfDataObjects)
{
     var file = await RetrieveLabelFileFromLocalStorage("Report.mrt");

     if (file == null)
     {
          DialogService.ShowErrorAsync(StringRetriever.GetString("csLabelService_GetLabelFileAsReport"));
          return null;
     }

     // Create the report
     StiReport report = new StiReport();

     // Load the label file into the report
     await report.LoadAsync(file);

      // Register data as business objects
      if (item != null)
          report.RegBusinessObject("Data", "Data", item);

      // Render the report
       await report.RenderAsync();

      // Print the Report
      await StiPrintReport.PrintAsync(report);
       
}
It throws an error because it doesn't wait for user to pick/print the first one before it tries to print the rest. Is there anywhere to say "here is a bunch of data (or StiReports), pick a printer and print them all"?
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: How to print collection of reports

Post by HighAley »

Hello.

Please, try to join all reports to one report and then send it to print.

Code: Select all

List<StiReport> reports = new List<StiReport>();
List<StiReport> reports = new List<StiReport>();
StiReport finalReport = null;
foreach(StiReport report in reports)
{
	await report.RenderAsync();
	if (finalReport == null)
	{
		finalReport = report;
	}
	else
	{
		foreach(StiPage page in report.RenderedPages)
		{
			page.Report = finalReport;
			finalReport.RenderedPages.Add(page);
		}
	}
}

await StiPrintReport.PrintAsync(report);
Thank you.
Locked