Output PDF Binary to Browser in ASP.NET
Here is the code to output PDF Binary to the browser using ASP.NET / VB.NET.
Note: This code assumes that you already have the PDF binary data stored in a byte() array called data.
Response.ClearHeaders()
Response.ClearContent()
Response.ContentType = "application/pdf"
Response.BinaryWrite(buffer)
Response.End()
Response.ClearContent()
Response.ContentType = "application/pdf"
Response.BinaryWrite(buffer)
Response.End()
To add an Open / Save dialog window:
Response.AddHeader("content-disposition","attachment;filename=report.pdf")
If you encounter errors in Adobe Reader, make sure that your aspx page contains only the page directive:
<% @ Page Language="vb" … %>
Related posts:
