Click here to Skip to main content
15,898,935 members

Comments by Member 11644848 (Top 3 by date)

Member 11644848 27-Apr-15 21:56pm View    
I tried this one. But I can't seem to work it out.



Imports System.Net

Partial Class VBCodetoShowPDF
Inherits System.Web.UI.Page
Protected Sub Page_Load(sender As Object, e As EventArgs)

End Sub
Protected Sub btnpdf_Click(sender As Object, e As EventArgs)
Dim path As String = Server.MapPath("sample.pdf")
Dim client As New WebClient()
Dim buffer As Byte = client.DownloadData(path)

If buffer IsNot Nothing Then
Response.ContentType = "application/pdf"
Response.AddHeader("content-length", buffer.Length.ToString())
Response.BinaryWrite(buffer)
End If
End Sub
End Class
Member 11644848 27-Apr-15 21:55pm View    
hi,
I haven't tried it yet. But I want it a simple code. I'm newbie in ASP.net. :D
Member 11644848 27-Apr-15 21:30pm View    
Hi ankur,

I've searched in Google but some of it has C# codes. I'm not yet familiar with C#. Below is the code that I'm trying to apply but I can't seem to get it. I want to view the PDF in my localhost and web server. Please help. Thanks. (newbie)

===========================================================

Imports System.Net

Partial Class VBCodetoShowPDF
Inherits System.Web.UI.Page
Protected Sub Page_Load(sender As Object, e As EventArgs)

End Sub
Protected Sub btnpdf_Click(sender As Object, e As EventArgs)
Dim path As String = Server.MapPath("sample.pdf")
Dim client As New WebClient()
Dim buffer As Byte = client.DownloadData(path)

If buffer IsNot Nothing Then
Response.ContentType = "application/pdf"
Response.AddHeader("content-length", buffer.Length.ToString())
Response.BinaryWrite(buffer)
End If
End Sub
End Class

===========================================================