I am trying to send a crystal report to PDF through a binary stream using the code below:
Code:
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(MyExportReque stContext)
a ParameterFieldCurrentValue exception is thrown saying there is a missing parameter.
Any suggestions are greatly appreciated. Thanks in advance.
Donna