cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal Reports Viewer and Zebra Printer

Former Member
0 Kudos

Hi,

We have a legacy system that we've upgraded from VB6 / Crystal Reports 8.5 to .NET / Crystal Reports 14.1.1.1036.  We have a report which has historically been printed out of a Zebra 105SL Printer.

In the new system, we can get the report to print directly to the Zebra, and it functions perfectly.

Our problem is with the Crystal Reports Viewer.  We can preview the report fine, but when we print from the viewer itself, the actual print job appears momentarily in the Zebra's print queue, but nothing comes out of the printer.  Here's the code:

public void ShowReportViewerForZebra(ReportDocument report)

{          

  var printerSettings = new PrinterSettings();

  printerSettings.PrinterName = "ZDesigner 105SL 203DPI";

  var pageSettings = new PageSettings();

  report.PrintOptions.CopyTo(printerSettings, pageSettings);

  var viewer = new ReportsViewer();   // <= WPF window which contains CrystalReportsViewer

  viewer.CrystalReportsViewer.ViewerCore.ReportSource = report;

  viewer.Show();

}

I've already conceived of a workaround, wherein we use the Crystal Reports Viewer to preview the report, and create a separate print button.  My concern is the overall stability of this solution.  If we can't print to Zebra from the CrystalReportsViewer now, who knows if in subsequent releases we'll lose the ability to print *anything* to the Zebra Printer.

Here's the research I've done, thus far:

1.) Confirmed we have the latest version of the drivers: https://www.zebra.com/us/en/support-downloads/industrial/105sl.html#mainpartabscontainer=drivers

2.) Reviewed the following threads: http://scn.sap.com/thread/3244122, http://scn.sap.com/thread/3215010, http://scn.sap.com/thread/3607455

3.) Lastly, it appears that Zebra themselves is essentially saying that Crystal Reports *not* is a "close fit" solution for printing to Zebra =>  https://km.zebra.com/kb/index?page=content&id=SO6545

The legacy system printed to our Zebra fine for 12+ years... but if CR and Zebra no longer work (well) together, then such is life.  What was nice about the CR solution is that is allowed us to preview our output.

ALSO: if not Zebra, will you guide us to some alternative solutions for printing labels from a .NET desktop application?

Thanks for your help,

Aleks

EDIT: just fixed Item #2 to specify that Crystal Reports is *not* a close fit for Zebra

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

The settings you are making for the report object will not be transferred to the viewer. E.g.; the two are quite independent. Your best option will be to add your own print button and then use your print code there. I have some basic steps on adding a button to the win viewer, but not WPF viewer - not sure if these will work for you:


How to add a customized print button to the Crystal Reports viewer control in Visual Studio .NET 2008 Windows application instead of using existing print button?

Resolution

Customized print button cna be added to the Crystal Reports Viewer by using ToolStrip.

Please refer to the following code to add a customized print button to the Crystal Reports Viewer control:

--------------------------------------------------------------------------------------------------------------------------------------------------

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using CrystalDecisions.CrystalReports.Engine;

using CrystalDecisions.Shared;

using System.Drawing.Printing;

namespace WindowsFormsApplication1

{

    public partial class Form1 : Form

    {

        CrystalReport1 cr;

        public Form1()

        {

            InitializeComponent();

        }

        private void Form1_Load(object sender, EventArgs e)

        {

            ToolStrip ts;

            ts = (ToolStrip)crystalReportViewer1 .Controls[3];

            ToolStripButton printbutton = new ToolStripButton();

            printbutton.Image = ts.Items[1].Image;

            ts.Items.Remove(ts.Items[1]);

            ts.Items.Insert(1, printbutton);

            ts.Items[1].Click += new EventHandler(this.CaptureEvent);                  

            cr = new CrystalReport1();

            this.crystalReportViewer1.ReportSource = cr;

                         

        }

        private void CaptureEvent(Object Sender, EventArgs e)

        {

            try

            {        // Create a Print Dialog                

                PrintDialog printDialog1 = new PrintDialog();

                // Create a Print Document

                PrintDocument pd = new PrintDocument();

                printDialog1.Document = pd;

                printDialog1.ShowNetwork = true;

                printDialog1.AllowSomePages = true;

                DialogResult result = printDialog1.ShowDialog();

                if (result == DialogResult.OK)

                {

                    MessageBox.Show("Print button has been selected !!!");

                    PrintReport(printDialog1.PrinterSettings.PrinterName);

                }

                else if (result == DialogResult.Cancel)

                {

                    MessageBox.Show("Cancel button has been selected !!!");

                }

            }

            catch (Exception ex)

            {

                MessageBox.Show(ex.Message);

            }

         }

        private void PrintReport(string printerName)

        {

            // Select the printer.

            cr.PrintOptions.PrinterName = printerName;

            /* Print the report. Set the startPageN and endPageN

             parameters to 0 to print all pages.*/

            cr.PrintToPrinter(1, false, 0, 0);

        }                          

    }

}

- Ludek

Senior Support Engineer AGS Product Support, Global Support Center Canada

Follow us on Twitter

Former Member
0 Kudos

Yep: adding an external print button appears to be the most direct route.  Thanks for the response, Ludek.


Regards,

Aleks

Answers (1)

Answers (1)

former_member292966
Active Contributor
0 Kudos

Hi Aleksandr,

I've used Zebra printers in the past and have quite often ran into issues printing labels with Crystal.  They are a good printer and expensive and when things don't work then it's hard to deal with.

An alternative printer are the label printers from Dymo.  They are a lot less expensive and I have never had an issue setting it up and working with Crystal Reports.

I haven't used it with the viewer but I haven't had any issues with the .NET applications I've written either.

Good luck,

Brian