Reputation: 4997
I want to automatically convert my SSRS to pdf and store to a location on my hard drive (say C:\My Reports) How can this target be achieved?
Thanks
Upvotes: 1
Views: 7127
Reputation: 4504
Use the reporting services web service. A nice post where this is done is: http://geekswithblogs.net/bsherwin/archive/2007/04/29/112094.aspx
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)
Dim stream As FileStream = File.Create("C:\My Reports\report.pdf", results.Length)
stream.Write(results, 0, results.Length)
stream.Close()
Upvotes: 2