Subject: Printing Crystal Report as PDF
Posted By: dkspivey Post Date: 1/5/2006 10:32:57 AM
I am trying to send a crystal report to PDF through a binary stream using the code below:


Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            strFrom = Session("From")
            strTo = Session("To")
            strDivision = Session("Division")

            SpWithViewer(strFrom, strTo, strDivision)

            Report = New Routed()
            PrintToPdfWithStream(Report)
            
        Catch er As Exception
            LogError(er.ToString, "RoutedReport")
            Exit Try
        Finally
        End Try
    End Sub

Public Sub PrintToPdfWithStream(ByVal MyReport As CrystalDecisions.CrystalReports.Engine.ReportDocument)
        Dim MyExportOptions As New CrystalDecisions.Shared.ExportOptions()
        MyExportOptions.ExportFormatType = CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat
        Dim MyExportRequestContext As New CrystalDecisions.Shared.ExportRequestContext()
        MyExportRequestContext.ExportInfo = MyExportOptions
        Dim MyStream As System.IO.Stream
        MyStream = MyReport.FormatEngine.ExportToStream(MyExportRequestContext)
        Response.ClearHeaders()
        Response.ClearContent()
        Response.ContentType = "application/pdf"
        Dim MyBuffer(MyStream.Length) As Byte
        MyStream.Read(MyBuffer, 0, CType(MyStream.Length, Integer))
        Response.BinaryWrite(MyBuffer)
        Response.End()
 End Sub


However, every time it gets to this line:
    MyStream = MyReport.FormatEngine.ExportToStream(MyExportRequestContext)
a ParameterFieldCurrentValue exception is thrown saying there is a missing parameter.

Any suggestions are greatly appreciated. Thanks in advance.
Donna

Go to topic 38334

Return to index page 403
Return to index page 402
Return to index page 401
Return to index page 400
Return to index page 399
Return to index page 398
Return to index page 397
Return to index page 396
Return to index page 395
Return to index page 394