none
Export a report directly to pdf by passing the Report Viewer Control (ASP.NET using VB.NET syntax) RRS feed

  • Question

  • I am trying to export a report directly to pdf without having to go through the ReportViewer Control first.  The report I created opens and exports to pdf with no problems manually.  I am looking to put a command button on my ASP.NET page that will open the report in pdf automatically.  From what I have read, that is possible.  Can someone help me with the syntax using VB.NET?

     

    Thanks for any assistance you can give me.

     

    Additional Info:  My report name is Report1.rdlc and it uses DataSet1.xsd which has 5 table adapters all using the same parameters.

    Wednesday, June 20, 2007 6:51 PM

All replies

  • I was able to use this VB.NET code to open the file in adobe.  I am wondering if some once can look at this code and identify any flaws, mistakes, or things that do not make sense.

     

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim warnings As Microsoft.Reporting.WebForms.Warning() = Nothing

    Dim streamids As String() = Nothing

    Dim mimeType As String = Nothing

    Dim encoding As String = Nothing

    Dim extension As String = Nothing

    Dim deviceInfo As String

    Dim bytes As Byte()

    Dim lr As New Microsoft.Reporting.WebForms.LocalReport

    lr.ReportPath = "Report1.rdlc"

    deviceInfo = "<DeviceInfo><SimplePageHeaders>True</SimplePageHeaders></DeviceInfo>"

    bytes = ReportViewer1.LocalReport.Render("PDF", deviceInfo, mimeType, encoding, extension, streamids, warnings)

    Response.ClearContent()

    Response.ClearHeaders()

    Response.ContentType = "application/pdf"

    Response.BinaryWrite(bytes)

    Response.Flush()

    Response.Close()

    End Sub

    Thursday, June 21, 2007 3:52 PM