calico-cat
calico-cat

Reputation: 1322

SSRS: How to print a report without bringing up the rendered report?

I'm wondering how to print a SSRS report without bringing up a report viewer. Right now my users have to press the Print button, bring up the rendered report, and then press Print again.

Current Code:

Dim report as new ReportViewer
'snip - fill datasets, set data sources, blah blah blah
report.ReportViewer1.LocalReport.DataSources.Add(datasource)
report.Show()

This brings up a viewer window, which I don't really want, since my users then have to press Print again.

So I added the following:

report.PrintDialog()

The above code results in an invalidOperationException because it hasn't finished rendering. I understand that, but is there a way to render the report programmatically (rather than onscreen) and send the user straight to the printer dialogue?

EDIT: OK, I'm 90% there. PrintDialog() isn't the way to go. I found this article but it results in an InvalidXMLException. It doesn't tell me why it's wrong, just that it's wrong... The API is totally unhelpful so... help?

Upvotes: 0

Views: 9853

Answers (4)

ibrahim
ibrahim

Reputation: 1

try to put the command report.PrintDialog() on the RenderingComplete event of the ReportViewer Control.

this will insure that the report is already rendered before you call the print dialog

Upvotes: 0

user1431616
user1431616

Reputation: 31

Here's what I found on the subject, followed, and worked for me: http://printssrsreport.blogspot.com/2011/09/print-ssrs-report-using.html

It's important you follow "Step 1" and add the reference to "ReportExecution2005.asmx". This was confusing to me as I am using Reporting Services 2008 R2. But it is what it is, and it works.

The rest should be straight forward and work for you.

Upvotes: 1

beakersoft
beakersoft

Reputation: 2356

Why not just put the reports on a schedule, get them to save as a pdf to a folder then use something like Batch print pro to print them?

Upvotes: 0

DaveRead
DaveRead

Reputation: 3413

You could use the SSRS Web Service to programmatically render the report (i.e. as a PDF) and then print it from your application.

http://msdn.microsoft.com/en-us/library/ms152952.aspx

Upvotes: 1

Related Questions