Print Report directly to Printer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • danishce
    New Member
    • Apr 2007
    • 31

    Print Report directly to Printer

    Hi,
    I want to print crystal report directly to printer using vb.net application without any dialog box. how can i achieve this?

    CrystalReportVi ewer1.ReportSou rce = System.Environm ent.CurrentDire ctory & "\MiniStatement .rpt"
    'CrystalReportV iewer1.Show()
    CrystalReportVi ewer1.PrintRepo rt()

    Thanks:
    Danish Majid
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    Please search the site, there are a few examples of this.

    Comment

    • danishce
      New Member
      • Apr 2007
      • 31

      #3
      I search the site but the examples here are for printing the text file to printer and i unable to find any query to print crystal report directly to printer.
      Any help?

      Comment

      • Motoma
        Recognized Expert Specialist
        • Jan 2007
        • 3236

        #4
        Originally posted by danishce
        I search the site but the examples here are for printing the text file to printer and i unable to find any query to print crystal report directly to printer.
        Any help?
        Most Crystal Reports Reports have a PrintToPrinter member to call.

        Comment

        • sudhaMurugesan
          New Member
          • May 2007
          • 94

          #5
          Hi Danishce,
          You can try PrinttoPrinter Method.
          write this code in any button click event

          Code:
           /* Print the report. Set the no. of copies, collate (false or true), startPageN and endPageN . set startPageN and endPageN parameters to 0 to print all pages.*/
                                  reportobject.PrintToPrinter(1, true, 0, 0);
          Before that bind the report to the report object.

          Comment

          • danishce
            New Member
            • Apr 2007
            • 31

            #6
            Thanks all for helping me but still i can not find PrinttoPrinter method in the crystalreportvi ewer dropdownlist inside my vb.net application.can you guide me step-by-step how to do this?
            Report name =rptStatement.r pt
            Crystal Report Control Name=CrystalRep ortViewer1
            Crystal Report Version=9.2.0.4 48
            Visual Studio .NET 2003=vb.net

            //Code
            CrystalReportVi ewer1.ReportSou rce = "rptStatement.r pt"
            CrystalReportVi ewer1.PrintRepo rt()

            but when i use CrystalReportVi ewer1.PrinttoPr inter() method it does not appear in properties & gives error.

            Please help me what i missed here?
            Thanks

            Comment

            • danishce
              New Member
              • Apr 2007
              • 31

              #7
              using the code below the PrinttoPrinter method appears
              Dim obj As New CrystalDecision s.CrystalReport s.Engine.Report Document
              obj.PrintToPrin ter(1, True, 0, 0)
              but gives the following error :
              error=D:\rptSta tement.rpt Cannot find custom tool 'CrystalDecisio ns.VSDesigner.C odeGen.ReportCo deGenerator' on this system.

              and also how can i set the name and location of report?

              Comment

              • Motoma
                Recognized Expert Specialist
                • Jan 2007
                • 3236

                #8
                Originally posted by danishce
                using the code below the PrinttoPrinter method appears
                Dim obj As New CrystalDecision s.CrystalReport s.Engine.Report Document
                obj.PrintToPrin ter(1, True, 0, 0)
                but gives the following error :
                error=D:\rptSta tement.rpt Cannot find custom tool 'CrystalDecisio ns.VSDesigner.C odeGen.ReportCo deGenerator' on this system.

                and also how can i set the name and location of report?
                Take a look at this link for a demonstration on report printing.

                Comment

                • danishce
                  New Member
                  • Apr 2007
                  • 31

                  #9
                  MyReport.PrintT oPrinter(1,Fals e,0,0)
                  In the above code, how i create report object named MyReport because when i create object the report name does not appear.Report name is "RptStatement.r pt"
                  dim MyReport as new RptStatement
                  it gives the error.
                  Please help me out on how i create report object or can i miss any referenece to report?

                  Comment

                  • 1q2w3e4r5t6y7u8i
                    New Member
                    • May 2007
                    • 19

                    #10
                    Just Write

                    Dim cr as new crystalreport1
                    cr.printtoprint er(1,false,1,1)


                    That's all Cheers

                    Comment

                    • danishce
                      New Member
                      • Apr 2007
                      • 31

                      #11
                      Thanks All for helping me out,I have finally succeeded using following code:
                      Dim obj As New CrystalDecision s.CrystalReport s.Engine.Report Document
                      Dim m_rptname As String
                      m_rptname = System.Environm ent.CurrentDire ctory & "\MiniStatement .rpt"
                      obj.Load(m_rptn ame)
                      obj.PrintToPrin ter(1, True, 0, 0)

                      Comment

                      • Motoma
                        Recognized Expert Specialist
                        • Jan 2007
                        • 3236

                        #12
                        Originally posted by danishce
                        Thanks All for helping me out,I have finally succeeded using following code:
                        Dim obj As New CrystalDecision s.CrystalReport s.Engine.Report Document
                        Dim m_rptname As String
                        m_rptname = System.Environm ent.CurrentDire ctory & "\MiniStatement .rpt"
                        obj.Load(m_rptn ame)
                        obj.PrintToPrin ter(1, True, 0, 0)
                        I am glad you have found a solution to your problem. Come back any time you have a question.

                        Comment

                        • 1q2w3e4r5t6y7u8i
                          New Member
                          • May 2007
                          • 19

                          #13
                          Hi,

                          Good to hear about your sucess
                          But I didn't get sucess in my problem
                          My problem is to export the report in .txt format in vb.net 2003 environment
                          this project is pending from about 1yr
                          Please help me

                          Regards
                          Aatish

                          Comment

                          Working...