Last post Mar 21, 2012 03:10 AM by Ashutosh Pathak
Mar 20, 2012 07:38 PM|mazez1971|LINK
hi, developing a web application using visual basic 2008. i want to print a report without diplaying / preview it. Is it possible?
Mar 20, 2012 11:52 PM|Basquiat|LINK
Mar 21, 2012 12:01 AM|Ashutosh Pathak|LINK
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, _
later when you get the result in byte array and print it with the help of code snippet below:
Mar 21, 2012 02:12 AM|mazez1971|LINK
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
Mar 21, 2012 02:36 AM|Basquiat|LINK
Mar 21, 2012 03:10 AM|Ashutosh Pathak|LINK
yes, you just save the bytes of pdf in a stream and use the link below to print it: