Groups | Blog | Home
all groups > asp.net > may 2004 >

asp.net : Download Pdf file


Machi
5/2/2004 11:56:03 PM
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,btDownload.Length-1);
Response.End()
===========================================================================
Joerg Jooss
5/9/2004 10:11:11 AM
[quoted text, click to view]

Response.OutputStream.Write(btDownload,0,btDownload.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,btDownload.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
joerg.jooss@gmx.net
AddThis Social Bookmark Button