olidev
olidev

Reputation: 20684

response stream and ask for saving pdf file

in asp.net, after creating a reportDocument, I would like to save it as a pdf report without showing it. In other words, I would like to show a response that the user chooses to save it:

ReportDocument reportdoc = new ReportDocument();

reportdoc.Load(Server.MapPath("CrystalReporttest.rpt"));
reportdoc.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, false, "test123.pdf");

So far, I have tried it like this and it shows the pdf report rather than ask for "save it".

It is a directly way to do so in asp.net?

Thanks in advance.

Upvotes: 0

Views: 529

Answers (3)

olidev
olidev

Reputation: 20684

I found the answer,

it is like this:

reportdoc.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "test123.pdf");

Stupid me!

Upvotes: 0

SLaks
SLaks

Reputation: 888223

You need to add a Content-Disposition header.

Upvotes: 1

Chris Felstead
Chris Felstead

Reputation: 1208

You need to store the converted PDF in memory or on the file system and transmit the file like a regular file download using TransmitFile.

Upvotes: 0

Related Questions