How to print a SSRS LocalReport without using the reportviewer control?

garciave
garciave used Ask the Experts™
on
Hi All,

I have rendered SSRS localreports in different formats (ie PDF, Excel) in memory, so with the code behind, I could attach them to an email or do some other processing.
Now, I'd like to print out the reports that are already rendered without using the reportviewer control and avoiding re-processing time.

How could I print out a report that is already in a memorystream object? I don't want to print directly but through the print dialog, letting the user to select the printer and options he wants.

Below you could see the code I have to generate the report in memory and from that point onwards is when I want the print user dialog to appear.
Dim lr As New LocalReport()
lr.ReportPath = HttpContext.Current.Server.MapPath("~/Reports/Report.rdlc")
 
Dim ta1 As New MyreportTableAdapters.MyreportTableAdapter
Dim ds1 As New ReportDataSource("Myreport_Myreport", ta1.GetData())
 
lr.DataSources.Add(ds1)
 
Dim warnings As Warning() = Nothing
Dim streamids As String() = Nothing
Dim mimeType As String = Nothing
Dim encoding As String = Nothing
Dim extension As String = Nothing
Dim deviceInfo As String = ""
 
Dim bytes As Byte()
 
bytes = lr.Render("PDF", Nothing, mimeType, encoding, extension, streamids, warnings)
 
Dim s As New MemoryStream(bytes)
s.Seek(0, SeekOrigin.Begin)
 
 
At this point, the MemoryStream object s is ready to be attached in an email:
Dim a As New Attachment(s, "Balances.pdf")
 
Alternatively, I'd like to be able to print it out if the user selects and option to do so.
 
 
Tks!

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Hi,

This example will serve your purpose.

http://www.csharphelp.com/archives3/archive545.html

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial