Search code examples
vb.netcrystal-reportsreport

Crystal report printing to wrong printer


I'm troubleshooting an issue with a VB.NET app that I inherited.

The following lines execute print operation:

Me.rptShippingLabel1.PrintOptions.PrinterName = "LabelPrinter"
Me.rptShippingLabel1.PrintOptions.PaperOrientation =   CrystalDecisions.Shared.PaperOrientation.Landscape
Me.rptShippingLabel1.PrintToPrinter(Me.txtLabelQty.Text, False, 1, 1)

There is a Zebra ZDesign TLP2844 connected to workstations via direct USB and named LabelPrinter. However, despite target printer being specified in the code, that Zebra must be set as default printer in Windows, otherwise the job would go to any other printer set as default.
What's even more frustrating is that on some computers, with exactly the same configuration jobs go to correct printer but I can't identify controllable pattern. Any suggestions why might that be?

Reports in question are disassociated from printer in Design>Page Settings.


Solution

  • Look into your report. In page settings see if report is optimized for display. If yes, uncheck it. If report is optimized for displaying only, PrinterOptions enumeration is being discarded. You could still assign to Printer name property in older framework but not anymore.