I have an .NET Windows application that prints commands to Zebra printer using ZPL II or EPL2. Is there any way to print preview the data in a form before printing it directly from Zebra printer?
相关问题
- Generic Generics in Managed C++
- How to Debug/Register a Permanent WMI Event Which
- 'System.Threading.ThreadAbortException' in
- Bulk update SQL Server C#
- Should I use static function in c# where many call
I needed the ability to show the label in my Application. So I hooked up Fiddler and figured out what the communication was to get the image of the label.
I got it running in LinqPad. The HTTP stuff can be cleaned up a bit, but I thought I would post the code for others to use:
This has the following References:
and the following Uses:
NOTE: I could not find a way to communicate with a serial/non-IP Addressed printer. (Though that does not mean that there is not a way.)
The only way to preview the label is on the printer's web page.
If you go to the printer's directory listing
http://<printer IP>/dir
and click on the saved label (or create a new one) then you can click"Preview Label"
Have a look at the Labelary web service, which allows you to convert ZPL to an image programmatically.
Just build a URL containing the ZPL that you want to render, get the image back from the web server, and show the image to the user from within your application.
There's also a ZPL viewer lets you edit and view ZPL directly on a web page.
If you're ok with using a Chrome Plugin, please try Simon Binkert's Zpl Printer. This plugin is based on the Labelary Web Service linked in previous comments.
See also: https://stackoverflow.com/a/33066790/3196753
Note, although this plugin runs inside Google Chrome, it can work with any application on the computer capable of sending raw commands.
It can be configured to listen on localhost or dedicated IP address, so it can be used to emulate a ZPL printer on the PC and local network. If you need a local printer or printer share, you can set up a raw printer queue on the PC which points to it on hostname/ip and port and other desktop applications will be able to send ZPL to it.
Note, if you need to make it available to other computers on the network, make sure to change
127.0.0.1
in the Printer Settings to a valid LAN IP address.