Groups | Blog | Home
all groups > sql server reporting services > october 2004 >

sql server reporting services : Generate a report, export to PDF


Pinolian
10/19/2004 1:59:01 PM
I want to programmatically pass in some parameters, generate
a report, export this report to PDF, and pop up adobe acrobat reader in a web
browser in one click while naming the PDF file exactly as I like, including
its path. I currently do this easily with Crystal Reports in one click, but
I need to see if its feasible in RS.

In crystal I use an ASP.net page that does all of this for me. I declare the
report, get the parameters, fill them, set up the username/password for the
database, set a name for the file, and set the export options, and then
generate the report.

If I could get some direction as to how to do some of this stuff, it would
be great =) We are thinking that while its not pretty we are going to use the
URL method if possible to do this stuff, because we already have a custom web
app in place, and no need for a shell etc. We just need a web page that can
do this for us upon hitting submit.

Again, any direction you can offer would be great

Scott Allen
10/19/2004 11:51:13 PM
Hi Pinolian:

From ASP.NET you code access the report server with URL access and the
WebClient or WebRequest classes. Once you have the file pulled down to
the ASP.NET application you could stream the file to the client by
setting the content disposition header and using Response.BinaryWrite.

Some sample code would look like this:

byte[] response;
string url = "http://s/reportserver?Report&rs:Format=PDF";
using(WebClient webClient = new WebClient())
{
webClient.Credentials = CredentialCache.DefaultCredentials;
response = webClient.DownloadData(url);
}


Response.ContentType="application/pdf";
Response.AddHeader(
"content-disposition",
"attachment; filename=MyPDF.PDF"
);
Response.BinaryWrite(response);

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Tue, 19 Oct 2004 13:59:01 -0700, "Pinolian"
[quoted text, click to view]
AddThis Social Bookmark Button