Supraja

Supraja

  • NA
  • 25
  • 7.4k

How to convert Binary Data to PDF file when click on Button

Jul 11 2016 2:07 AM
I have Binary data in sql when user click on button it should convert binary data to pdf file for this i created aspx page in that i have date and report name and button when user select name and date and click on button then it should search for the date in sql and get the binary data to pdf file to download.
 
Private Sub btnTrade_Click(sender As Object, e As EventArgs) Handles btnTrade.Click
Dim cn As New SqlConnection
cn.ConnectionString = conStrEMC
Dim bytes As Byte()
Context.Response.Buffer = True
Context.Response.Charset = ""
'If context.Request.QueryString("download") = "1" Then
' context.Response.AppendHeader("Content-Disposition", Convert.ToString("attachment; filename=") & STLId)
'End If
Context.Response.Cache.SetCacheability(HttpCacheability.NoCache)
Context.Response.ContentType = "application/pdf"
Context.Response.BinaryWrite(bytes)
Context.Response.Flush()
Context.Response.[End]()
End Sub
 

Answers (4)