locked
How to obtain number of pages in a Crystal Reports .NET report RRS feed

  • Question

  • User-53457868 posted

    I have a web application in which I render one or more Crystal Reports and then merge them into one PDF. What I'd like to do is obtain the number of pages from one CrystalDecisions.CrystalReports.Engine.ReportDocument object then then set that value as a parameter in the subsequent ReportDocument in order to continue the page numbering correctly. Does the ReportDocument class expose a way of obtaining the number of pages? If not, are there other ways?

    I am NOT using a Crystal Report Viewer.

    I am using CrystalReports for Visual Studio 2010 and C# .NET 4.

    Tuesday, April 2, 2013 1:39 PM

Answers

  • User281315223 posted

    I'm not terribly familar with Crystal Reporting but this MSDN thread discusses using the following solution to get the total number of pages within a document : 

    YourReport.FormatEngine.GetLastPageNumber(new CrystalDecisions.Shared.ReportPageRequestContext());

    (This is highly untested from me but it may be worth a shot.)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 2, 2013 1:44 PM

All replies

  • User281315223 posted

    I'm not terribly familar with Crystal Reporting but this MSDN thread discusses using the following solution to get the total number of pages within a document : 

    YourReport.FormatEngine.GetLastPageNumber(new CrystalDecisions.Shared.ReportPageRequestContext());

    (This is highly untested from me but it may be worth a shot.)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 2, 2013 1:44 PM
  • User-53457868 posted

    this is what i needed. i had seen this solution before but for some reason intellisense does not pick up the "FormatEngine" property after the ReportDocument (YourReport) and i thought that i was on the wrong track and that perhaps i had the wrong version of the crystal reports object.

    after typing "FormatEngine" the "GetLastPageNumber" method appeared and the code indeed returns the number of pages in the report.

    thanks

    Tuesday, April 2, 2013 2:09 PM