Hi, everyone.
I'm facing 2 problem when print crystal report from vb.net 2010.
Problem 1: Printer will feed extra paper before printing.
Problem 2: The crystal report is printed in a very small size.
CR Runtime = version 13.0.2000.0
Printer Model = Thermal Printer
My sample code:
Private _ReportDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument
_ReportDocument.Load("C:\Report\Testing.rpt", CrystalDecisions.Shared.OpenReportMethod.OpenReportByDefault)
_ReportDocument.SetDatabaseLogon(DbUserId, DbPassword)
Dim DefPrintReportOptions as New CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions
Dim zPrinterName as string = "ThermalPrinter"
Dim tmpPrintDoc As New System.Drawing.Printing.PrintDocument()
tmpPrintDoc.PrinterSettings.PrinterName = zPrinterName
DefPrintReportOptions.PrinterName = zPrinterName
DefPrintReportOptions.PaperSize = tmpPrintDoc.DefaultPageSettings.PaperSize
DefPrintReportOptions.PaperSource = tmpPrintDoc.DefaultPageSettings.PaperSource
_ReportDocument.ReportClientDocument.PrintOutputController.PrintReport(DefPrintReportOptions)
I don't use _ReportDocument.PrintToPrinter(1, False, 0, 0) to print report because it take too long time to print out the crystal report.
Your help is very appreciated.
What I have tried:
My sample code:
Private _ReportDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument
_ReportDocument.Load("C:\Report\Testing.rpt", CrystalDecisions.Shared.OpenReportMethod.OpenReportByDefault)
_ReportDocument.SetDatabaseLogon(DbUserId, DbPassword)
Dim DefPrintReportOptions as New CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions
Dim zPrinterName as string = "ThermalPrinter"
Dim tmpPrintDoc As New System.Drawing.Printing.PrintDocument()
tmpPrintDoc.PrinterSettings.PrinterName = zPrinterName
DefPrintReportOptions.PrinterName = zPrinterName
DefPrintReportOptions.PaperSize = tmpPrintDoc.DefaultPageSettings.PaperSize
DefPrintReportOptions.PaperSource = tmpPrintDoc.DefaultPageSettings.PaperSource
_ReportDocument.ReportClientDocument.PrintOutputController.PrintReport(DefPrintReportOptions)