ReportViewer to PDF inside div/image/object

前端 未结 1 2024
既然无缘
既然无缘 2021-01-28 23:57

Been searching for the past couple of days and haven\'t been able to find what I\'m looking for, hopefully I haven\'t missed it.

I have an ASP.NET (4.0) site that I\'m p

1条回答
  •  悲哀的现实
    2021-01-29 00:32

    First, create a Generic Handler called GeneratePDF.ashx. Note I didn't write the below code and I'm not a VB.NET programmer, so I can't guarantee it'll work.

    'generate bytes, perhaps based on Request.QueryString parameters
    `write bytes to output
    Response.Buffer = True
    Response.Clear()
    Response.ContentType = "application/pdf"
    Response.AddHeader("content-disposition", "inline; filename=" & filename & "." & extension)
    Response.BinaryWrite(bytes)
    Response.Flush()
    

    Then on our page, we use one of the techiques from the below link to embed the PDF, making sure to give the URL that points to our generic handler, and passing any parameters needed to generate the PDF via query string.

    
    

    Above code adapted from Recommended way to embed PDF in HTML?

    0 讨论(0)
提交回复
热议问题