views:

4757

answers:

4

While I realize that I could just show the form off-screen and hide it, along with many other forms of WinForms hackish wizardry, I'd rather stick with the zen path and get this done right. I have a SSRS local report (so no server) that I want to give the user the option of either viewing or printing (in other words, I don't want to force them to view to print). Unfortunately, the ReportViewer control complains about its "state" when I try to print it either as a component I'm creating explicitly in my code (inside a using() block, of course) or if I try to instantiate my viewer form and just print without ever showing it.

Is there a means to do this that will sit well with me, or should I just show it off-screen and move on with my life?

+2  A: 

Check this out and see if it helps...http://scruffylookingcatherder.com/archive/2007/12/07/printing-reporting-services-2005-reports.aspx

A little explanation: It's using the SSRS web service to render the report to an EMF image then send the image to the printer.

Mozy
Unfortunately, this is a local report using data from a DataSet from a SqlCe 3.5 database, so anything to do with SSRS itself is probably out of the question.
Adam Robinson
@Mozy the link that you provided is not working. The correct link is http://scruffylookingcatherder.com/post/2007/12/08/Printing-Reporting-Services-2005-Reports.aspx
N30
+3  A: 

I have a sample that does this posted on my blog here: http://blogs.msdn.com/brianhartman/archive/2009/02/27/manually-printing-a-report.aspx

The LocalReport object can be instantiated independently of the ReportViewer control and used directly in the sample code attached to that blog post. Or you can pass in ReportViewer.LocalReport even if you don't first display the report in the UI.

Brian Hartman
Thanks, Brian. I'll take a look at this solution first thing at work tomorrow.
Adam Robinson
Excellent solution; worked perfectly! Congrats on getting your first SO points from a bounty question ;)
Adam Robinson
A: 

Very interesting. Can we use the MS report functionality to create a PDF in the background to email out as opposed to printing?

Scott
A: 

I'm looking for the same kind of functionality but for WebForms. Any ideas?

davandries
If you have a different (even if it's related) question, please post it as a new question, not as an answer to an existing question.
Adam Robinson
http://stackoverflow.com/questions/3826338/sql-server-reporting-services-how-to-print-reports-automatically-without-preview/3826482#3826482
davandries