This is a migrated thread and some comments may be shown as answers.

how to get TotalPages count after rendering ?

1 Answer 180 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Stephan
Top achievements
Rank 1
Stephan asked on 19 Jun 2012, 11:42 AM
Hi,

how can I extract the number of rendered pages from a Telerik.Reporting.Report ?
The idea is to check via a unit test if no empty pages are generated by a report.
(E.g. report with known data has 2 pages. Changing the layout later on causes an empty page. Report has now 3 pages, unit test detects this problem.)

Regards,
Marco

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 21 Jun 2012, 03:30 PM
Hello Marco,

In order to test for empty pages our suggestion is to use the ReportProcessor to render the report in image format with device info setting - StartPage set to 3. This way the RenderReport method will throw an exception if page 3 is unavailable. Thus you can fail the test if no exception is thrown as shown in the falling sample:

try
{
    var processor = new ReportProcessor();
    var reportSource = new InstanceReportSource();
    reportSource.ReportDocument = new ReportCatalog();
    var deviceInfo = new Hashtable();
    deviceInfo.Add("StartPage", 3);
    processor.RenderReport("Image", reportSource, deviceInfo);
    Assert.Fail("Empty page is rendered.");
}
catch
{
}
Regards,
Peter
the Telerik team

FREE WEBINAR ON THE NEW REPORT DESIGNER! Join us on Friday, June 29 at 10:00 AM for a comprehensive demo of the official version of the standalone Report Designer and find out how easy it is to empower your users with creating, editing and sharing ad-hoc reports. The webinar will go through a real-world scenario of creating reports, embedding them in your application(s), and distributing them within your organization. We will also cover the newly added support for sub-reports, navigation actions (such as drill-down and drill-through), and report sources. Register here and bring your questions with you. We’ll try to address them during the webinar! You may even win a Telerik Ultimate Collection license! Register today >>

Tags
General Discussions
Asked by
Stephan
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or