Answered by:
how to Print a Report without Displaying in asp.net web application using reportviewer

Question
-
User590786421 posted
hi, developing a web application using visual basic 2008. i want to print a report without diplaying / preview it. Is it possible?
Tuesday, March 20, 2012 7:38 PM
Answers
-
User2105670541 posted
yes, you just save the bytes of pdf in a stream and use the link below to print it:
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, March 21, 2012 3:10 AM
All replies
-
User306743125 posted
This should help you... http://blogs.msdn.com/b/brianhartman/archive/2009/02/27/manually-printing-a-report.aspxTuesday, March 20, 2012 11:52 PM -
User2105670541 posted
Yes its possible but you need to do some tweeking, i mean you need to render the report in some format like pdf, need to save it in stream and using the print classes on .net you can print them :
follow the steps below:
Create a reference to the Reporting Services Web Services then get a variable reference for it:
Dim ws As New SQLRS.ReportingService Dim creds As New System.Net.NetworkCredential
Next set the authentication for the web service:
creds.UserName = "RSUser" creds.Password = "SomePassword" ws.Credentials = creds
Finally, set some of the web service variables for how you want the data rendered. You don't have to set all of these, but you will have to pass them all in, so I just like to be clear about what I am doing:
Dim result() As Byte Dim report As String = "/Sample Reports/Sales Order Detail" Dim format As String = "PDF" Dim historyid As String = Nothing Dim devinfo As String = "" Dim credentials() As SQLRS.DataSourceCredentials = Nothing Dim showhide As String = Nothing Dim encoding As String Dim mimetype As String Dim warnings() As SQLRS.Warning = Nothing Dim reporthistoryparams As SQLRS.ParameterValue() = Nothing Dim streamid() As String = Nothing Dim sh As New SQLRS.SessionHeader ws.SessionHeaderValue = sh
Next, get the result from the web service:
result = ws.Render(report, format, historyid, devinfo, parameters, _ credentials, showhide, encoding, mimetype, reporthistoryparams, _ warnings, streamid)
courtsy: http://geekswithblogs.net/bsherwin/archive/2007/04/29/112094.aspx
later when you get the result in byte array and print it with the help of code snippet below:
http://www.codeproject.com/Articles/20640/Creating-PDF-Documents-in-ASP-NET
Wednesday, March 21, 2012 12:01 AM -
User590786421 posted
thank you very much for replying.
I can export the report to PDF and can open it. but what i want, i will not display the report. it will automatically printed when i click Print Button i a web page
Wednesday, March 21, 2012 2:12 AM -
User306743125 posted
Print local report without previewing it http://msdn.microsoft.com/en-us/library/ms252091.aspxWednesday, March 21, 2012 2:36 AM -
User2105670541 posted
yes, you just save the bytes of pdf in a stream and use the link below to print it:
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, March 21, 2012 3:10 AM