VB.NET - Convert a Crystal Report Viewer Report to PDF

Asked By RAFAEL PADILLA on 01-Jul-04 01:29 PM
I have problem exporting a Crystal Report. He two ways used by me with different errors.  Any help would be appreciated.



--This code I can see my reports that use parameters passed by me....

Crystalreportviewer2.Visible = True
crpt1 = New Overall_Transactions_Performed_by_Individuals()
For Each myTable In crpt1.Database.Tables
    myLogin = myTable.LogOnInfo
    myLogin.ConnectionInfo.Password = pass
    myLogin.ConnectionInfo.UserID = userid
    myTable.ApplyLogOnInfo(myLogin)
Next

    Crystalreportviewer2.ParameterFieldInfo = paramFields
    Crystalreportviewer2.ReportSource = crpt1




'Export Button
 Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
        Dim myDiskFileDestinationOptions As CrystalDecisions.Shared.DiskFileDestinationOptions
        Dim myExportFile As String
        Dim myReport As New Individuals_Productivity_and_Overall_Attendance()
        myExportFile = "c:\inetpub\wwwroot\SPOTReports\" & Session.SessionID.ToString & ".pdf"
        myDiskFileDestinationOptions = New CrystalDecisions.Shared.DiskFileDestinationOptions()
        myDiskFileDestinationOptions.DiskFileName = myExportFile
        myExportOptions = myReport.ExportOptions
        With myExportOptions
            .DestinationOptions = myDiskFileDestinationOptions
            .ExportDestinationType = .ExportDestinationType.DiskFile
            .ExportFormatType = .ExportFormatType.PortableDocFormat
        End With
        myReport.Export()

 End Sub



Missing parameter field current value. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: CrystalDecisions.CrystalReports.Engine.ParameterFieldCurrentValueException: Missing parameter field current value.

Source Error: 


Line 632:            .ExportFormatType = .ExportFormatType.PortableDocFormat
Line 633:        End With
Line 634:        myReport.Export()
Line 635:
Line 636:    End Sub


==========================================================================================================================

'Export Button
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
        Dim myDiskFileDestinationOptions As CrystalDecisions.Shared.DiskFileDestinationOptions
        Dim myExportFile As String
        'Dim myReport As New Individuals_Productivity_and_Overall_Attendance()
        myExportFile = "c:\inetpub\wwwroot\SPOTReports\" & Session.SessionID.ToString & ".pdf"
        myDiskFileDestinationOptions = New CrystalDecisions.Shared.DiskFileDestinationOptions()
        myDiskFileDestinationOptions.DiskFileName = myExportFile
        myExportOptions = crpt1.ExportOptions
        With myExportOptions
            .DestinationOptions = myDiskFileDestinationOptions
            .ExportDestinationType = .ExportDestinationType.DiskFile
            .ExportFormatType = .ExportFormatType.PortableDocFormat
        End With
        crpt1.Export()

    End Sub



Object reference not set to an instance of an object. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error: 


Line 446:        myDiskFileDestinationOptions = New CrystalDecisions.Shared.DiskFileDestinationOptions()
Line 447:        myDiskFileDestinationOptions.DiskFileName = myExportFile
Line 448:        myExportOptions = crpt1.ExportOptions
Line 449:        With myExportOptions
Line 450:            .DestinationOptions = myDiskFileDestinationOptions

Export - Asked By Matthew Martin on 02-Jul-04 10:22 AM

Since you're passing a report document to the viewer, you should have the object. So, we'll call it "rpt" for this purpose.


        Try
            Dim CrExportOptions As ExportOptions
            Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions()
            CrDiskFileDestinationOptions.DiskFileName = "C:\myfilename.pdf"
            CrExportOptions = rpt.ExportOptions
            With CrExportOptions
                .DestinationOptions = CrDiskFileDestinationOptions
                .ExportDestinationType = ExportDestinationType.DiskFile
                .ExportFormatType = ExportFormatType.PortableDocFormat
            End With
            rpt.Export()
        Catch ex As Exception
            MsgBox(ex.ToString)
            Return
        End Try

Export does not recognize reports with parameters - Asked By RAFAEL PADILLA on 06-Jul-04 11:25 AM

Hi Mattew, the Export option does not understand the parameters. The CrystalViewer displays the report correctly but it does not Export()......



Case 0 'Individuals Productivity and Overall Attendance
                CrystalReportViewer1.Visible = True
                crpt = New Individuals_Productivity_and_Overall_Attendance()
                For Each myTable In crpt.Database.Tables
                    myLogin = myTable.LogOnInfo
                    myLogin.ConnectionInfo.Password = pass
                    myLogin.ConnectionInfo.UserID = userid
                    myTable.ApplyLogOnInfo(myLogin)
                Next
                CrystalReportViewer1.ParameterFieldInfo = paramFields
                CrystalReportViewer1.ReportSource = crpt

                Dim CrExportOptions As ExportOptions
                Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions()
                CrDiskFileDestinationOptions.DiskFileName = "C:\myfilename.pdf"
                CrExportOptions = crpt.ExportOptions
                Try
                    With CrExportOptions
                        .DestinationOptions = CrDiskFileDestinationOptions
                        .ExportDestinationType = ExportDestinationType.DiskFile
                        .ExportFormatType = ExportFormatType.PortableDocFormat
                    End With

                    crpt.Export()
                Catch ex As Exception
                    MsgBox(ex.ToString)
                    Return
                End Try



The following error occurs:
Server Error in '/SPOTReports' Application. 
--------------------------------------------------------------------------------

Missing parameter field current value. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: CrystalDecisions.CrystalReports.Engine.ParameterFieldCurrentValueException: Missing parameter field current value.

Source Error: 

Line 223:                End With
Line 224:
Line 225:                crpt.Export()
Line 226:                'Catch ex As Exception
Line 227:                ' MsgBox(ex.ToString)
 

Source File: C:\Inetpub\wwwroot\SPOTReports\WebForm1.aspx.vb    Line: 225 

Stack Trace: 

[ParameterFieldCurrentValueException: Missing parameter field current value.]
   .K(String 
, EngineExceptionErrorID )
   .G(String , Int32 )
   CrystalDecisions.CrystalReports.Engine.FormatEngine.internalSetReportInfo(RequestContext reqContext)
   CrystalDecisions.CrystalReports.Engine.FormatEngine.internalGetViewContext(ReportPageRequestContext reqContext, * viewContext)
   CrystalDecisions.CrystalReports.Engine.FormatEngine.Export(ExportRequestContext reqContext)
   CrystalDecisions.CrystalReports.Engine.FormatEngine.Export()
   CrystalDecisions.CrystalReports.Engine.ReportDocument.Export()
   SPOTReports.WebForm1.StartReport() in C:\Inetpub\wwwroot\SPOTReports\WebForm1.aspx.vb:225
   SPOTReports.WebForm1.Button2_Click(Object sender, EventArgs e) in C:\Inetpub\wwwroot\SPOTReports\WebForm1.aspx.vb:610
   System.Web.UI.WebControls.Button.OnClick(EventArgs e)
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
   System.Web.UI.Page.ProcessRequestMain()

convert word document to pdf from asp net - Asked By Malarvizhi Thangaswamy on 25-Nov-05 01:29 AM

i need to convert the existing msword document to pdf file from asp.net,help me
thanks
regards
malar
crystal report export to PDF - bolton ss replied to RAFAEL PADILLA on 25-Aug-08 03:34 AM

for exporting to PDF check this

            CrDiskFileDestinationOptions.DiskFileName = _
                                        "c:\crystalExport.pdf"
            CrExportOptions = cryRpt.ExportOptions
            With CrExportOptions

check this link also

http://vb.net-informations.com/crystal-report/vb.net_crystal_report_export_pdf.htm


tks.