How to send EPL2 command to Zebra LP2844 printer over USB using C #
I need to print labels and barcodes on a zebra print printer using C #. I've never used them before, but read and tried to figure out how to do it. And I found this code from http://support.microsoft.com/kb/322091 but it didn't work. From my tests, I can see that I was able to send data to the printer, but it is unresponsive and does not print. I am using buttons to send a command to the printer as in the kb article.
private void ConnectButton_Click(object sender, EventArgs e)
{
// Allow the user to select a printer.
string s = "B26,26,0,UA0,2,2,152,B,\"{0}\"";
PrintDialog pd = new PrintDialog();
pd.PrinterSettings = new PrinterSettings();
if (DialogResult.OK == pd.ShowDialog(this))
{
// Send a printer-specific to the printer.
RawPrintrHelper.SendStringToPrinter(pd.PrinterSettings.PrinterName,s);
MessageBox.Show("Data sent to printer.");
}
}
source to share
The following two blog posts written by Nikolai Piaseksky are an invaluable resource for anyone trying to print Zebra printers from .NET:
- Sending Raw EPL2 directly to Zebra LP2844 via C #
- Using EPL2 GW Command to Send Image to Zebra Thermal Printer
( his website seems to be dead right now, so the links go to the Wayback Machine )
I've been working with Zebra and EPL printers for over 10 years, about 6 of them with .NET.
When I started with Zebra / EPL and .NET, these two blog posts were all I needed to get it to work.
Regarding this:
And I found this code from http://support.microsoft.com/kb/322091 but it didn't work. From my tests, I can see that I was able to send data to the printer, but it is unresponsive and does not print.
This article has a bug in the code, the solution is explained at the bottom of the first blog post I linked.
source to share