views:

65

answers:

2

I'm using SQL Server Reporting Services and viewing the reports in a web application in ASP.NET. To display the reports, I'm using Report viewer Web control which brings funcionalities of exporting the report and/or printing it, but requires to display a preview of the report before printing it.

I need to print a report without doing a preview in the web page? It seems like there's a way to do it in WinForms, but I didn't find a way to do it in WebForms. Any ideas?

Thanks David

A: 

I don't think this is possible. The SSRS webforms reportviewer is quite rigid.

What's even much worse: The printing function only exists in IE, not in other browsers. Firefox, Safari, Chrome and Opera users have to download the file as PDF or Word and print from there.

Adrian Grigore
A: 

I've rendered SSRS reports without using the ReportViewer control, most recently using LocalReports. You can in code configure the ReportViewer, force it to generate a PDF, and grab the byte stream of the PDF. I stopped there and rendered the PDF to the screen b/c that was my set of requirements, but I'm sure its much easier to find a way to print a byte stream of a PDF file then it is to deal with anything with the ReportViewer.

Here is how to get the LocalReport to a byte array of a PDF file:

LocalReport lclRpt = new LocalReport();
//Do Stuff like bind DataSources, ReportParameters, SubReportProcessing Delegates, etc.
string strMIMEType = String.Empty;
string strEncoding = String.Empty;
string strFileNameExtension = string.Empty;
string[] strarrStreams;
Warning[] warnLocalReportWarnings;
byte[] bytarrPDF = lclRpt.Render("PDF", "<DeviceInfo><StartPage>0</StartPage></DeviceInfo>", out strMIMEType, out strEncoding, out strFileNameExtension, out strarrStreams, out warnLocalReportWarnings);
return bytarrPDF;

I'm not 100% on how to accomplish your last step, might need a .pdf utility or there might be a way to do it straight from the code.

ben f.