1783535 - How to print a Crystal Report using PrintToPrinter() using .NET application?

SAP Knowledge Base Article - Public

1783535 - How to print a Crystal Report using PrintToPrinter() using .NET application?

Symptom

How to print a Crystal Report using PrintToPrinter() using .NET application?

Environment

  • Crystal Reports 2008
  • Crystal Reports for Visual Studio 2010

Resolution

   Following code can be used:    

        ReportDocument rpt = new ReportDocument();
        rpt.Load(Server.MapPath("Report6.rpt"));
        
        System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();
        CrystalDecisions.Shared.PrintLayoutSettings PrintLayout = new CrystalDecisions.Shared.PrintLayoutSettings();
        System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings();
        printerSettings.PrinterName = "PinterName";
        System.Drawing.Printing.PageSettings pSettings = new System.Drawing.Printing.PageSettings(printerSettings);
        rpt.PrintOptions.DissociatePageSizeAndPrinterPaperSize = true;
        rpt.PrintOptions.PrinterDuplex = PrinterDuplex.Simplex;
        System.Drawing.Printing.PageSettings pageSettings = new System.Drawing.Printing.PageSettings(printerSettings);
        rpt.PrintToPrinter(printerSettings, pSettings, false, PrintLayout);

Keywords

crvs2010 cr4vs2010 cr net sdk print to printer , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , How To

Product

Crystal Reports 2008 V1 ; SAP Crystal Reports, developer version for Microsoft Visual Studio