SQL Server Reporting Services: how to print reports automatically without preview from a web application

南笙酒味 提交于 2019-12-23 05:01:46

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/3826338/sql-server-reporting-services-how-to-print-reports-automatically-without-previe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!