PDF rendering

N

Nautilus

Hi there!

We are rendering some PDF reports from an ASP.NET application, directly
to the IE browser. Those reports are beign generated from a SQL
Reporting Services server. We have the requirement of displaying the
reports inside the browser. In order to do that, we have this:

Response.ClearContent();
Response.ClearHeaders();
Response.AppendHeader("content-length", reportData.Length.ToString());
Response.AppendHeader("content-disposition", "inline;
filename=SalesReport.pdf");
Response.ContentType = "application/pdf";
Response.BinaryWrite(reportData);
Response.Flush();
Response.Close();

The report shows perfectly. But our problem is that inside the Acrobat
Reader "sub window" on the browser, if the user clicks "Send By Email",
the reader creates an outlook email with an attachment called
"Report.ASPX". This one is the ASPX page used for rendering the report,
instead the "SalesReport.pdf" name suggested in the headers. Of course,
the customers complains about seeing garbage when looking at the attach
(really a PDF file, with the wrong extension).

Is there are any other way to indicate the filename to IE? Any ideas or
workaround on this?

Any suggestion is really appreciated. Thanks a ton in advance!!!
 
J

John Timney \( MVP \)

I think you need something like this, specificying an attachment rather than
just a filename

Response.AddHeader("Content-Disposition", "attachment; filename=fred.pdf")
 
N

Nautilus

Hi John! Many thanks for the input!

Unfortunately, that produces that IE treat that as an attachment,
displaying the "Save As / Open" dialog... and we need to display the
PDF right inside the browser window.

That's why we tried with the "inline" option... :(

Thanks again!

Best!
Mariano
 
P

Paul Henderson

You could try adding a 'name' parameter to your Content-Type:

Response.ContentType = "application/pdf; name=SalesReport.pdf";
 
N

Nautilus

Hi there!

Many thanks for the input again! I just tried that, and now IE just
doesn't display anything... :(

It's very frustrating that IE doesn't well interpret the
"content-disposition" headers, and pass that to Acrobat.. as it should
be. I keep trying any kind of workarounds, like using a
"Report.pdf.aspx" page, but it's the same.

Thanks a ton to all!
Mariano
 
A

Andrew Robinson

Why not write the report to disk with a correct filename and then point the
browser at the file. If you need to insure a unique name, you could create a
directory with a based name and then write the pdf inside of that
directory.
 
N

Nautilus

Hi Andrew!

Yes, that would be our last chance... But we are trying to avoid it
because of "performance" problems. In order to have the same
"SalesActivities.pdf" name for each report request, we would need to
create a folder (for example based on a GUID), and put the file
there... and of course, add some background process for erasing the
files, and removing the folders.. :)

At this point, I'm thinking in pushing to change the requirement, and
leave this as is.

Many thanks to all!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top