The below example would explain on how to Display a PDF document in browser using ASP.NET/VB.NET

Dim Fs As FileStream
Dim FileSize As Long
Dim filePath As String = "C:\Test.Pdf"

'Open the file.

Fs = New FileStream(filePath, FileMode.Open)
FileSize = Fs.Length

'Convert the file into array of bytes.
Dim Buffer(CInt(FileSize)) As Byte
Fs.Read(Buffer, 0, CInt(FileSize))

'Write the binary content directly to the HTTP Output Stream.

Response.ContentType = "application/pdf"
Response.OutputStream.Write(Buffer, 0, FileSize)

1 Responses to How to display a PDF document in browser using ASP.NET and VB.NET?

  1. Mike Says:
  2. Hi,

    I use PDF Duo .NET converting component for create/convert HTML to PDF. This component doesn't use any additional software.

    It is very easy in use and has a method to show a PDF after converting. More details see on web page




Post a Comment