By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,373 Members | 1,763 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,373 IT Pros & Developers. It's quick & easy.

Download Pdf file

P: n/a
I am trying to use the below source codes in ASP.NET application to download pdf file
================================================== =========================
Response.Clear()
Response.AddHeader("content-disposition", @"attachment; filename=" + strFilenm + "")
Response.ContentType = application/pdf
Response.OutputStream.Write(btDownload,0,btDownloa d.Length-1);
Response.End()
================================================== =========================
However, after i click the "Save" button, the "document" object which i have used in my javascript seems throws a run-time exception. When the Download windows pop up after executing the above source codes, if i click "Cancel" or "Open" buttons, there is no problem, problem only occurs when i click "Save" Button. For your information, when i tried the same application in Netscape 7.1, there is totally no problems at all. Please advice, thanks ...
Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Machi wrote:
I am trying to use the below source codes in ASP.NET application to
download pdf file.
================================================== ========================== Response.Clear();
Response.AddHeader("content-disposition", @"attachment; filename=" +
strFilenm + "");
Response.ContentType = application/pdf;
Response.OutputStream.Write(btDownload,0,btDownloa d.Length-1);
Response.End();
================================================== ========================== However, after i click the "Save" button, the "document" object which
i have used in my javascript seems throws a run-time exception. When
the Download windows pop up after executing the above source codes,
if i click "Cancel" or "Open" buttons, there is no problem, problem
only occurs when i click "Save" Button. For your information, when i
tried the same application in Netscape 7.1, there is totally no
problems at all. Please advice, thanks ...


Response.OutputStream.Write(btDownload,0,btDownloa d.Length-1) is most likely
wrong. The third parameter passed to Write() is the amount of bytes to be
written, not the end index of the byte array passed as 1st parameter. Use
Response.OutputStream.Write(btDownload,0,btDownloa d.Length)
instead.

Most versions of the Adobe Acrobat plugin require you to specify a
Content-Length header in the HTTP response. Thus, add
Reponse.AppendHeader("Cotent-Length", btDownload.Length);

Cheers,

--
Joerg Jooss
jo*********@gmx.net

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.