Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: Re: Printing a Crystal Report on client's default printer


Message #1 by "Rafael Gava de Oliveira" <rgoliveira@f...> on Mon, 12 Aug 2002 22:19:56
I´m having trouble in Crystal. I have a report with parameter and when 
I´m trying export I always receive a message: 

Missing parameter field current value.

How can I solve this problem?


> if it is on asp.net and your client is not in your lan, then crystal 
reports
says that you can it in two ways.

1. put off all the pagebreaks, turn on navigation bar and selection column
on the left and then print like a normal web page. on this solution it is
not guaranteed that all page breaks appear in preferred order. (i don't
recommend this way.)

   code looks like this:
        CrystalReportViewer1.SeparatePages = False
        CrystalReportViewer1.DisplayGroupTree = False
        CrystalReportViewer1.DisplayToolbar = False

2. show your report just normal, and put a button named like "printer
friendly".. on that button, you should convert your report to another 
format
like pdf or word doc. and just send this output as reponse. client has to
have that software that can open your format installed. (this works fine)

   code of pdf looks like this:
        'The following line of code loads the sample report "Chart.rpt" 
that
installs
        ' with Visual Studio .NET
        crReportDocument.Load("C:\Program Files\Microsoft Visual Studio
.NET\Crystal Reports\Samples\Reports\Feature Examples\Chart.rpt")

        Fname = "c:\exports\" & Session.SessionID.ToString 
& ".pdf"    'this
folder has to be created before
        crDiskFileDestinationOptions = New DiskFileDestinationOptions()
        crDiskFileDestinationOptions.DiskFileName = Fname
        crExportOptions = crReportDocument.ExportOptions
        With crExportOptions
            .DestinationOptions = crDiskFileDestinationOptions
            .ExportDestinationType = ExportDestinationType.DiskFile
            .ExportFormatType = ExportFormatType.PortableDocFormat
        End With
        crReportDocument.Export()

        ' The following code writes the pdf file to the Client's browser.
        Response.ClearContent()
        Response.ClearHeaders()
        Response.ContentType = "application/pdf"
        Response.WriteFile(Fname)
        Response.Flush()
        Response.Close()

        'delete the exported file from disk
        System.IO.File.Delete(Fname)


  Return to Index