Display PDF from Reporting Services

I would like to display a PDF created in Reporting Services from my WinForms application.

I tried the following:

Uri uri = new Uri("http://myReportServer?MyReport&rs%3aCommand=Render&rs:Format=pdf");
System.Diagnostics.Process.Start(uri.ToString());

Which launches the browser, which then, in turn, offers me to open or save this file.

Ideally, I would like to display only the file, either in a browser or in a PDF viewer. The problem is that I have to open a browser and then a PDF viewer that users do not want.

Is there an easy way to do this using just the URL?

My other alternative is to just write C # code that seems straightforward. Here are some examples:

http://geekswithblogs.net/bsherwin/archive/2007/04/29/112094.aspx

and here:

http://www.codeproject.com/KB/reporting-services/PDFUsingSQLRepServices.aspx

+5
1

PDF , Process.Start, .

:

        Uri uriDownload = new Uri("http://myReportServer?MyReport&rs%3aCommand=Render&rs:Format=pdf");
        string strSavePath = @"C:\test\test123.pdf";

        System.Net.WebClient wcli = new System.Net.WebClient();
        wcli.DownloadFile(uriDownload, strSavePath);
        System.Diagnostics.Process.Start(strSavePath);

UPDATE:

, wcli.DownloadFile():

        wcli.Credentials = new NetworkCredential("username", "password", "domain");
        wcli.Headers.Add(HttpRequestHeader.UserAgent, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
+4

All Articles