Try
            
Dim pdf As String = "./Files/ty1.pdf"
            pdf 
= Server.MapPath(pdf)

            
'read all bytes
            If File.Exists(pdf) = False Then
                
Throw New Exception("This report is not created")
            
End If
            
Dim fs As FileStream = File.Open(pdf, FileMode.Open)
            
Dim buffer() As Byte = New Byte(fs.Length) {}
            fs.Read(buffer, 
0, buffer.Length)
            fs.Close()

            
'write to response
            Response.Clear()
            Response.ContentType 
= "application/pdf"
            Response.AddHeader(
"content-disposition""filename=ty1.pdf")
            Response.AddHeader(
"content-length", buffer.Length.ToString())
            Response.BinaryWrite(buffer)
            Response.End()
        
Catch ex As Exception

        
End Try

 

一定要装PDF阅读器,否者是读不出来的

相关文章:

  • 2021-09-22
  • 2022-12-23
  • 2022-12-23
  • 2021-12-28
  • 2021-05-15
  • 2022-02-04
  • 2021-11-20
  • 2022-02-14
猜你喜欢
  • 2021-06-13
  • 2022-12-23
  • 2021-04-03
  • 2021-12-06
  • 2021-12-14
  • 2021-06-09
  • 2021-06-30
相关资源
相似解决方案