SAP Knowledge Base Article - Public

2154929 - WPF .NET Windows Application using CrystalReportsViewer1.ViewerCore.PrintReport() does not print the report

Symptom

How to display the print dialog box in crystal reports viewer for visual studio 2013 in a wpf application?

Environment

Crystal Reports viewer for Visual Studio 2013

Reproducing the Issue

Create a simple WPF application in VS 2013.

Following code duplicates the issue:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using CrystalDecisions.CrystalReports.Engine;

namespace CrystalReportDemo
{
    using SAPBusinessObjects.WPF.Viewer;

    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        ReportDocument reportDocument = new ReportDemo();
        public MainWindow()
        {
            InitializeComponent();
            this.WindowState = WindowState.Normal;
            CrystalReportsViewer1.ViewerCore.ReportSource = reportDocument;
            CrystalReportsViewer1.ViewerCore.PrintReport();

        }
    }
}

Resolution

This issue has been escalated to development for a fix which is expected to be in Service Pack 14.

As a work around use the Engine to load the report first:

e.g.

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportDemo = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

            ReportDemo.Load(@"D:\Atest\Sandeep\CrystalReportDemo\CrystalReportDemo\ReportDemo.rpt");
            CrystalReportsViewer1.ViewerCore.ReportSource = ReportDemo;
            CrystalReportsViewer1.ViewerCore.PrintReport();
        }

Keywords

ViewerCore.PrintReport, Crystal Reports for Visual Studio, WPF, PrintReport , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Bug Filed

Product

SAP Crystal Reports, developer version for Microsoft Visual Studio