print crystal report directly to printer in

  • Hi All i am sharing how can we print crystal report with preview in

    i am print report on button click by using below code.

        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim crReportDocument As CrystalDecisions.CrystalReports.Engine.ReportDocument
            crReportDocument = New CrystalDecisions.CrystalReports.Engine.ReportDocument()
            '//Create an instance of a report
            crReportDocument = New CrystalReport1()

            '//Use error handling in case an error occurs

                '//Set the printer name to print the report to.  By default the sample
                '//report does not have a defult printer specified.  This will tell the
                '//engine to use the specified printer to print the report.  Print out 
                '//a test page (from Printer properties) to get the correct value.

                Dim printDocument As System.Drawing.Printing.PrintDocument = New System.Drawing.Printing.PrintDocument()
                crReportDocument.PrintOptions.PrinterName = printDocument.PrinterSettings.PrinterName

                '//Start the printing process.  Provide details of the print job
                '//using the arguments.
                crReportDocument.PrintToPrinter(1, True, 0, 0)

                '//Let the user know that the print job is completed
                MessageBox.Show("Report Printed.", "")

            End Try

    You can also download the attached source code with crystal report.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook


Popular Posts of the Week

    Optimum Creative