I generate PDF invoices using Reporting from Infragistics. After the report has been generated, I need to know how many total pages the resulting PDF is. I need this in my code to write to SQL table for a Fax Cover sheet that tells the recipient how many pages their invoice is etc. How can i accomplish this?
Hello Travis,
When the report has finished loading, there is an event on the XamReportViewer that is fired called ProcessingCompleted. One of the event arguments for this event is the total number of pages in the report. You can store this value to use later after you export the report to PDF.
I export the report, not process, since I don't actually load it.
IClientExporter clientExporter = viewer.CreateExporter(reportUri); clientExporter.ExportCompleted += exporter_ExportCompleted; clientExporter.ExportCanceled += exporter_ExportCanceled; lock (_locker) { activeExporters += 1; } clientExporter.ExportAsync(stream, StringConstants.FormatPDF);
There is no processing event and no page number property on ExportCompleted
Yeah, it looks like we don't have a property for total pages if you are using the CreateExporter approach. You either need to handle the ProcessingCompleted event on your viewer and then actually load the report in there to get the total pages, or you will have to open the PDF file that you just created and check the pages there. .NET doesn't have a built in API for opening PDF files/streams so you will need to go for a 3rd party API such as iTextSharp.
There is a code example here on how to read the PDF file and view the number of pages.
A TotalPages property seems like a good candidate for our Product Idea website. If you'd like you can submit this as a new idea for the Reporting product here. This will also put you in direct contact with the Product Management team to discuss the idea. If you do, make sure to include a link to this forum thread so the Product Management team can look back here if needed.
OK, thanks, I actually already implemented that example, but just wanted to be sure IG couldn't do this for me. Thanks.