shaileshmark
asked on
ASP.NET pdf file download
Unable to open adobe pdf files downloaded from an asp.net 2.0 page. "the file is damaged and cannot be repaired" says adobe acrobat (7.0.9). The same file opens alright when opened in the browser with a Response.Redirect(FileURL) . But when downloaded either through Response.WriteFile(Path) or Response.TransmitFile(Path ) -- the entire file gets downloaded alright but adobe cannot open it.
Try this:
string DownloadedFileName = "PDFName.pdf";
string PathOfFile = "/PDFName.pdf";
//Get the file from the server and store it
byte[] temp = System.IO.File.ReadAllByte s(Server.M apPath(Pat hOfFile));
Response.Clear();
Response.ContentType = "application/PDF";
Response.AddHeader("Conten t-Type", "application/PDF");
Response.AddHeader("Conten t-Disposit ion", "attachment;filename=" + DownloadedFileName);
Response.BinaryWrite(PDFim age);
Response.Flush();
Response.End();
string DownloadedFileName = "PDFName.pdf";
string PathOfFile = "/PDFName.pdf";
//Get the file from the server and store it
byte[] temp = System.IO.File.ReadAllByte
Response.Clear();
Response.ContentType = "application/PDF";
Response.AddHeader("Conten
Response.AddHeader("Conten
Response.BinaryWrite(PDFim
Response.Flush();
Response.End();
ASKER
Okay, I should have posted my code
Response.ContentType = "application/pdf";
Response.AppendHeader ( "Content-Disposition", "attachment; filename=\"" + FileName + "\"" );
//Response.WriteFile ( FilePath);
Response.TransmitFile ( FilePath);
strickdd
What is PDFimage in Response.BinaryWrite(PDFim age) in your code above? Is that temp byte[]?
Response.ContentType = "application/pdf";
Response.AppendHeader ( "Content-Disposition", "attachment; filename=\"" + FileName + "\"" );
//Response.WriteFile ( FilePath);
Response.TransmitFile ( FilePath);
strickdd
What is PDFimage in Response.BinaryWrite(PDFim
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Regards