Sometimes, our vendors send us products with incorrect barcodes or without UPCs. We have a requirement such that every item in our warehouse must have a barcode for inventory control purposes. So when these barcode-less items arrive, we need to print out UPC labels for them. We have a thermal label printer, and we know that it can print out barcodes, so let’s figure out a way to have our application create these barcode labels automatically.
The printer you’ve probably seen before
This little thermal label printer is seemingly ubiquitous in the retail and warehouse worlds:
Everyone seems to have standardized on this little guy–you can rent one from UPS or FedEx to print shipping labels, PayPal can print to it, and so can Stamps.com and Endicia. They retail for nearly $400, but nobody pays that; you can pick up some battered beauties for about $70 on eBay. And the model hasn’t really changed much in over a decade, with the only major revision being the addition of USB support. There are some slight differences in the UPS and FedEx-supplied models because they install a custom firmware, but for our purposes, they’re all the same printer.
The native language of the printer isn’t PostScript or PCL but instead a proprietary language called EPL2 (most commonly just called EPL, without the “2″). It’s short for Eltron Printer Language. Eltron was the company that originally designed this model of printer, and Zebra bought them up a decade ago. Zebra has their own printer language–ZPL, or Zebra Printer Language–that’s similar to ZPL and is used on the TLP2844Z model, but the languages aren’t compatible with one another. Since there was already a lot of legacy code out there working with EPL, and since EPL itself isn’t broken, Zebra continues to offer printers that support EPL. This is the language that UPS WorldShip and FedEx Ship Manager use to print out UPS shipping labels from these devices.
It turns out that EPL is conceptually quite simple, and we can relatively easily add native support for it in our .NET applications. But first, let’s consider why we don’t just take the GDI route.
Why not print using PrintDocument and GDI+?
Zebra provides an advanced printer driver for the LP2844 that allows Windows to see it as any old GDI-based printer. If you open up a Word document, type some stuff into it, and print it to your LP2844, you’ll indeed get your document printed out as you expect. But there are a few disadvantages to this approach:
- The GDI conversion is much slower than when sending commands with EPL.
- The printer driver has a few bugs when it comes to determining the label size. If you’ve encountered a scenario where you specify landscape but it insists on printing in portrait mode or vice versa, then you’ve run into this problem.
- The fidelity of text is generally poor. The LP2844 only supports a resolution of 203dpi (actually, there’s a 300dpi version out there, but it’s pretty uncommon), so small text can come out blocky, jagged, and hard to read. This isn’t true for the printer’s native fonts, which are optimized for this resolution.
- GDI has no built-in support for rendering barcodes. Sure, you can write a barcode renderer yourself in GDI (I’ve done this before, but it’s not a trivial task), but why not save some time and use your printer’s built-in functionality?
Grabbing the EPL documentation and Zebra Firmware Downloader
One of the hardest parts of using EPL is simply finding the documentation for it. Zebra provides a very well-written manual, but it’s buried deep on their Web site: here’s a link to a mirrored copy of the EPL programming documentation. While you’re at it, download the Zebra Firmware Downloader, which will help you send your test EPL text files directly to the printer.
Learning about the EPL
An example is usually the easiest way to learn. Here’s the EPL commands necessary to generate the UPC label shown at the top of this blog post:
N q609 Q203,26 B26,26,0,UA0,2,2,152,B,"603679025109" A253,26,0,3,1,1,N,"SKU 6205518 MFG 6354" A253,56,0,3,1,1,N,"2XIST TROPICAL BEACH" A253,86,0,3,1,1,N,"STRIPE SQUARE CUT TRUNK" A253,116,0,3,1,1,N,"BRICK" A253,146,0,3,1,1,N,"X-LARGE" P1,1 |
EPL is one command per line. A command starts out with a command identifier, typically a letter, followed by a comma-separated list of parameters specific to that command. You can look up each of these commands in the EPL2 programming documentation. Here’s an English-language version of the commands in the above example.
0. Sending an initial newline guarantees that any previous borked
command is submitted.
1. [N] Clear the image buffer. This is an important step and
generally should be the first command in any EPL document;
who knows what state the previous job left the printer in.
2. [q] Set the label width to 609 dots (3 inch label x 203 dpi
= 609 dots wide).
3. [Q] Set the label height to 203 dots (1 inch label) with a 26
dot gap between the labels. (The printer will probably auto-
sense, but this doesn't hurt.)
4. [B] Draw a UPC-A barcode with value "603679025109" at
x = 26 dots (1/8 in), y = 26 dots (1/8 in) with a narrow bar
width of 2 dots and make it 152 dots (3/4 in) high. (The
origin of the label coordinate system is the top left corner
of the label.)
5. [A] Draw the text "SKU 6205518 MFG 6354" at
x = 253 dots (3/4 in), y = 26 dots (1/8 in) in
printer font "3", normal horizontal and vertical scaling,
and no fancy white-on-black effect.
(6 through 9 are similar to line 4.)
10. [P] Print one copy of one label. |
In a way, EPL is quite similar to GDI. You’ve got an image buffer in memory, you issue a batch of commands to doodle and write text and barcodes on that buffer, and then you release the buffer to the printer, telling it to print it.
When designing a label, I find that it’s essential to have a ruler and a calculator handy. You’ll be converting between dots and inches a lot as you design your label. If you find that you send a command (such as a barcode command) and nothing prints out, that usually means that the command was invalid or that some parameter was out of range (for example, the barcode height wasn’t tall enough).
It’d be nice if we could print out these EPL text files that we’ve created in Notepad without writing any code. The Zebra Firmware Downloader (which certainly has a scary name) can do this for us. Once you’ve installed the application, start it up and hunt for the “Auto Detect” button on the toolbar. Once it finds your printer, right-click it in the list, click Select Firmware File…, and browse to the text file containing your EPL commands. Then right-click the printer and choose Download to Selected. The printer will print out your test label. You can now easily be editing your EPL document in Notepad and keep choosing Download to Selected as you iterate through and refine your design.
Printing the label directly from C#
Now that we’ve got the EPL code written, we need to figure out a way for our application to send this file directly to the printer. The easiest way is to use the RawPrinterHelper sample class provided by Microsoft, but we’ll need to fix a bug in it first.
Here’s what a class that prints to the printer might look like:
using System; using System.Collections.Generic; using System.Text; using Skiviez.UndiesClient.Domain; using Skiviez.Commons.WinForms; using Skiviez.Commons.Core; using System.Globalization; namespace BlahBlahBlah { public class UpcLabel { private string upc; public UpcLabel(string upc) { if (upc== null) { throw new ArgumentNullException("upc"); } this.upc = upc; } public void Print(string printerName) { StringBuilder sb; if (printerName == null) { throw new ArgumentNullException("printerName"); } sb = new StringBuilder(); sb.AppendLine(); sb.AppendLine("N"); sb.AppendLine("q609"); sb.AppendLine("Q203,26"); sb.AppendLine(string.Format( CultureInfo.InvariantCulture, "B26,26,0,UA0,2,2,152,B,\"{0}\"", this.upc)); sb.AppendLine("P1,1"); RawPrinterHelper.SendStringToPrinter(printerName, sb.ToString()); } } } |
This is pretty straight forward. We’re just building our EPL document in a StringBuilder, and we could easily customize the document on the fly with some string.Format calls. Here’s how we might invoke this code:
UpcLabel label = new UpcLabel("603679025109"); label.Print("Zebra LP2844"); |
The string that we pass in in the Print function is just the name of the printer as it appears in the Printers list in the Windows control panel. You could pop up a PrintDialog here and ask the user for a printer, but I’ve just hard-coded the name.
The last piece of the puzzle is that RawPrinterHelper.SendStringToPrinter call. Well, it’s the exact same code copy and pasted from the Microsoft support article above. But there’s one bug that we need to fix. In the SendStringToPrinter method, there’s a line that looks like this:
dwCount = szString.Length; |
Change it to look like this:
dwCount = (szString.Length + 1) * Marshal.SystemMaxDBCSCharSize; |
(The main problem is that it wasn’t leaving room for the null character at the end of the unmanaged string, which can cause some mysterious problems with your last command not getting interpreted directly, depending on the length of the raw document. The SystemMaxDBCSCharSize nonsense is for versions of Windows where an ANSI codepage with double byte characters is loaded.)
Conclusions and Delusions
And there you have it! EPL is a fun and simple printer command language, and with a little bit of interop, we can send these commands directly from our C# application. Happy barcoding!


Hi, Thank you for this article. I am using an NP-2025 label printer and I have a problem sending the commands. When I use the SendStringToPrinter method and the string includes a command string (e.g. “0A” which is LineFeed) It prints the actual command instead of performing the LF task. I tried sending “LF” but still printing “LF”. Do you have an idea how to go about this?
This happened to me once with an EPSON TM-88III Receipt Printer. The trick is to remember that you need to send the actual ASCII character 0x0A; you’re sending either the character “0″ followed by the character “A” or sending the character “L” followed by the character “F”. Try sending “\r” instead.
Another way to do it is to use something like
string.Format(CultureInfo.InvariantCulture, "{0}", (char)0x0A)when building your command string. This way, you’ll be sure that you’re sending one actual character. You could similarly use theSendBytesToPrinter()method instead if that would make things clearer, sending something likebyte buffer = new byte[] { 0x0A }instead.Hope that makes sense–it can get real confusing. But I ran into the same problem when trying to send an ASCII escape character to the receipt printer; I had first sent the actual string “ESC” and the string “27″ instead of character 0x1B proper.
Thanks for the quick reply,
I’m so new to C# so I hope you pardon my ignorance. The string.format(CultureInfo…) seemed to work. So how do I use it to send a line command such as 1C21FF1C4301 (all in hex mode).
Or I use a function that accepts a memory stream that calls the SendBytesToPrinter method. I add string to the memory stream using WriteLine((char)0xA). If I send multiple commands can I do WriteLine((char)0x1B + (char)0×40 + “Test String”);
There’s a couple of ways you could do it. How you do it is partly preference and just what’s easier for you:
// Method 1: Append individual characters sb = new StringBuilder(); sb.Append((char)0x0A); sb.Append((char)0x40); sb.Append("Test String"); string command1 = sb.ToString();
// Method 2: Append char array directly sb = new StringBuilder(); sb.Append(new char[] { (char)0x1B, (char)0x40, 'T', 'e', 's', 't', ' ', 'S', 't', 'r', 'i', 'n', 'g' }); string command2 = sb.ToString();
// Method 3: Use string.format string command3 = string.Format( CultureInfo.InvariantCulture, "{0}{1}{2}", (char)0x1B, (char)0x40, "Test String");
// Method 4: Use bytes byte[] command4 = new byte[] { 0x1B, 0x40, (byte)'T' };
whew, finally got it working. A lot of thanks to you.
sir i m using c# want to copy text file into zebra printer for printing label ;
this is my code
string filePath1 = @”d:\sample1.txt”; string line1; if (File.Exists(filePath1)) { StreamReader file1 = null; try { file1 = new StreamReader(filePath1); while ((line1 = file1.ReadLine()) != null) { Console.WriteLine(line1); }
it open command prompt i want it directly fire print comman without visible to user
Reply please
Regards Neeraj
You’ll need to use code as described in the article to output the commands as a RAW document directly to the printer if you want to avoid having the console window pop up. (There are ways to hide it after a brief flash, but it’s not the approach that I would recommend.) See the Microsoft knowledge base article that I linked to in the blog post for some sample code.
Hi Nicholas,
I am using a Zebra 110XiIII Plus 300dpi printer with a USB interface and your code is working well with a ZPL file (Zebra Printing Language). Is there a possibility to read data from the printer. There are commands were the printer sends a reply, example reading the status of the printer.
btw. excelent article,
With kind regards,
Luc
Luc,
I’m not sure. I know that Win32 has a ReadPrinter function that you could P/Invoke into, but I have no idea how to use it because the need hasn’t hit me yet. Should be able to pass that function the same handle that RawPrinterHelper gets, though.
Good luck!
We use 2844′s heavily in our organization. We buy products from McKesson Technologies. At this point we are in a crunch because the 2844′s dont give us the mobility; however, the software we buy does not support anything expect the 2844.
How do we make the software recognize the QL220 or 440?
Or is there a battery pack that we can use with the 2844 on our cart for a couple hours?
Shaji,
I’m not sure. My understanding is that the 2844 is meant to be a desktop printer and would probably draw too much power in a mobile context. I’m not aware of any battery pack for it. A quick glance at Zebra’s site tell me that the QL220 and 440 do support EPL2, which is one of the most common Zebra printing languages and the one spoken by the 2844, so it’s likely that the software is sending EPL2 to the 2844s. So that’s one hurdle done with.
Now to get your software to print to the QL220, that’s something that I can’t answer. The software might be hardcoded to only look for the 2844 by USB product ID & vendor ID. Maybe it’s just going by the printer name alone. (Hey, hooking up a QL220 and renaming it is always worth a shot!) Or it might be sending EPL2 data blindly to whatever is attached to a certain port. You’ll have to contact the software vendor to get that straightened out.
Nicholas,
Thank you for the prompt response! That explains a whole lot.
Hi Nicholas,
I can’t seem to compile this line. Is it just me?
Looks like my backslashes got escaped out. Try
sb.AppendLine(string.Format( CultureInfo.InvariantCulture, “B26,26,0,UA0,2,2,152,B,\”{0}\”", this.upc));
Thanks Nicholas, that cleared things up. Any particular reason why Format() is used?
No particular reason–it’s a personal preference.
Hey,
Looked at your code and it helped me a lot to get things rolling, but i have a small issus when it comes to clearing the 2844 memory.
I start all my printing with “\nN” and end with “P1″ like the ref. says and it workes when i print the first page. The second gives me the first again etc.
I reinitialize all my variables etc. so that is not the problem. Any Idears?
/Toby
Yeah, I had that same problem, and the “\nN\n” fixed it. Make sure you’re sending that first newline, THEN “N\n”. The first newline basically finishes off any half-baked command that might still be sitting in the printer’s memory.
The only other thing I can think of is to check for that bug in RawPrinterHelper’s SendStringToPrinter() method, where it would chop off the last few characters of any string. But since you’re getting a label, that’s probably not the problem.
Sorry I can’t be of more help. Good luck!
Hey,
I tried your suggestion with “\nN\n” but it didn’t do much good. So I turned to resetting before I print.
So now I send “^@” before I begin printing and it works for one label then it causes trouble. So it’s not a good solution.
Can you think of anything else that could cause this issue? Do you have a simple c# solution that works for you that you can send me so I can try on my setup? In case the printer is faulty…
tnx
@Toby
Are you aware of the Zebra Firmware Downloader?
Do this:
N q609 Q203,26 A26,26,0,4,1,1,N,"SAVE 15% OFF YOUR NEXT ORDER OF $50" A26,62,0,4,1,1,N,"OR MORE REGULARLY-PRICED ITEMS!" A26,98,0,4,2,2,Y,"HOWDY" A400,98,0,4,1,1,N,"VALID THRU" A400,134,0,4,1,1,N,"01/01/2010" A26,170,0,3,1,1,N,"ENTER ABOVE CODE DURING CHECKOUT" P1,1
Start the Zebra Firmware Downloader and Tools > Auto-Detect your printer. (Unless it’s not USB, then futz around in the menus to get it to show up.)
Right-click your printer, select a “firmware” file, and point it to your text document.
Right-click again and choose Download To Selected. The printer should spit out your label. Try it again, and see if it works right.
The only other thing I can think of is maybe some weird double buffering status is enabled. Try resetting it with this document:
N q812 Q406,26 rN
Good luck!
Hey,
I tried the “Zebra Firmware Downloader” and it gave me the right result, but when printing from my application it all went south again.
So i tried your second tip and it helped. The printer must be set to use buffer as a default so by removing the buffer my problem was solved.
Now i have some more questions… Hope you are up for it.
Is there a way of batch print labels? Lets say i want to print 100 labels. Can i send all 100 at once or is it best todo 1 after another?
I tried to add a image to the printer with the “GM” command and it looks like it workes, but when using “GI” it returns “No graphics installed”.
ex: GM”LOGO”1253 “++,,,ììììÔ×ÏËÒÍÏÐËÓÎÉ×ÌÈÙËÈÎËÊÇÏËÊÆÐÌÉÆÝÉÅßÈÅßÈÄÑÏÇÄÑÏÇÄÑÏÇÄÒÅÅÄÇÄÒÅÇÈÃÑÅÄËÄÐÃÄÂÄÉÄÐÃÄÂÄÇÄÑÍÆÂÄâÂÃÄÆÂÇÙÄÆÂÅÙÄÆÂÇÙÄÅÃÆÚÄÅÂÇÐÉÃÆÂÇÏÊÃÆÂÇÎËÃÆÂÇÍÌÃÏËÂÍÃÛÎÄÍÄÅÐÅÊÉÓÇÆßìììììÿÿÿ”
do you have any hints or pointers when it comes to this issue?
Thanks
/Toby
@Toby
If you mean 100 copies of the same label, look at the parameters of the “P” command. I believe “P1,100″ would be what you want. That way, you only send the data to the printer once, and the printer loops through it 100 times. It’s an order of magnitude faster than doing a loop of 100 within your application.
I’ve never had a need to send graphics to a Zebra, so I’m afraid I have no experience in that subject. My only suggestions would be that (a) the file could be too big, (check out the M command), (b) it might not be in the proper 1-bit PCX format, or (c) it might be getting “baked” into the wrong encoding. I would play around with that in the Zebra Firmware Downloader, since if the Zebra acts anything like an Epson TM88-III, the graphics get stored in a separate location of non-volatile memory, so it persists across “N” commands and such.
Good luck!
Great post. Thanks very much. Does this method work only with 32 bit apps using Win32 api?
Is it possible to use this in a 64 bit app by using the 64 bit version of winspool.drv?
I cant find a native .NET method to print raw text to the Zebra. Does such a thing exist?
Hopefully we aren’t stuck with 32 bit app .
@Jason
Unless it was added to the framework, no such .NET method exists (indeed, the existing .NET printing methods are just P/Invoking under the hood, anyway). In the 64-bit world, everything written here should apply, unless documented otherwise in the MSDN. (Since I got the interop declarations from the P/Invoke Wiki, they may have a few sized-related issues when running in a 64-bit context, like an Int32 that should have been declared as an IntPtr. It “worked for me” so I haven’t reconciled the declarations against MSDN too closely.)
I see no reason why you’d be stuck with a 32-bit app.
Hi Nicholas,
thank you very much for this very helpful posting! I will recommend your blog to my colleagues.
Kind regards,
Magnus
Fantastic explanation which is more easier than anybody to understand
Thanks
Thanks for the help, works fine in Zebra GK40t on USB port.
sorry, GK420t
Hi, sorry 4 my english. I need send to TLP 2844 (zebra) by EPL2 command a graphic command without storage (GW Command). The Manual Say: Syntax GWp1,p2,p3,p4DATA¿ Parameters p1 = Horizontal start position (X) in dots. p2 = Ver ti cal start po si tion (Y) in dots. p3 = Width of graphic in bytes. Eight (8) dots = One (1) byte of data p4 = Length of graphic in dots (or print lines). DATA = Raw bi nary data with out graphic file for mat ting. Data must be in bytes. Mul ti - ply the width in bytes (p3) by the num - ber of print lines (p4) for the to tal amount of graphic data. The printer au - tomatically calculates the exact size of the data block based upon this for mula.
i have the function ” SendBytesToPrinter(string szPrinterName, IntPtr pBytes, Int32 dwCount)” but i dont know how to do to send the Bitmap throught de command.
I need some help, thanks for all.
Hi, I used the code (without fixing the bug related with dwCount = szString.Length; statement). When I printed first time, the code run very well and printed a label, but now suddenly, the program is not printing the label. Please let me know why it happens? Is it related with the statement dwCount = szString.Length;?
Please help me, i need the solution urgently.
Thanks,
I am trying to get my Mac to print using the Zebra LP2844…any advice? Having major difficulties.
Nicholas, thanks for this article! I’ve spent hours on the Zebra website and still couldn’t form a strategy for allowing my customers to design labels for Zebra printers that my application would then fill in the dymanic/variable content at runtime. Your article gave me a clear picture. I’ll be doing this in C++, but the principle is the same. I intend to allow my users to design labels in EPL or ZPL, incorporating tags that I define that my app can search and replace. They will then input the text into my app and let it rip. Everytime we need to print a label, the variables will be replaced and the labeler should print the content (barcodes, etc). Evidently this will work with RFID too. Thanks again!
hi, excuse me for ask but i have a problem, i write down your code int he namespace BlahBlahBlah and i’m using a virtual printer cute pdf, wehn send the string to print the cute pdf creates an empty file so i don’t know how to send the data to the printer, can you help me please? tnks a lot
good day Nicholas,
I am have been trying around to find whether card printer Zebra P300 i understands EPL or any how I can give commands from code. so far no luck. pls help. Zebra site says nothing…
Great blog, found it really informative. I am using the Zebra LP2844 myself to print my barcode labels and think it is a great printer. Would recommend it to anyone.
Keep up the good posts!
Thanks for the great article! It has made my life a lot easier and my dev for a project a LOT faster
Good afternoon,
How I can send image file for printing on the CARD?
Best regards,
Veasna
Hi Nicolas,
This was very simple and straight forward, it really helped.
Keep up the great work……
Regards,
PLEASE HELP ME! You article is awesome. I have everything working, except my 2844 just spits out a blank label. Please help, or I might find out what color the printer burns, quit my job, and jump off of a bridge. I have tried everything.
Nicholas, I have a situation involving a QSR kitchen video controller (ePic) which outputs an epson compatible file through a serial port. The output is in the form of an order ticket. I need to take that output, reformat it and send it to a Zebra printer as a label. The label would show order number and type on the first line followed by the item and associated modifiers which can wrap until the label is full. Some of what you discuss here would seem to be applicable. The challenge would be to capture and format the file from the ePic controller. I have some industrial computers running Windows CE 4.2 NET that might be usable as an interface.
Hi I have read your blog and have been trying to implement the method which your have published into my c# project using the EPL commands which i need for my application, but i have had no luck. When i have sent it to my Zebra LP 2844 printer nothing prints, not even a blank label is spooled, i have tried on both USB and parallel i have also installed the Zebra LP2844 driver. I have included the commands below but left out the variables, if you could give me any advice i would be very grateful. Thanks! P.S I am running Windows 7 Professional 32-bit and Visual Studio 2010 Ultimate
N N N Q1000,20+0 q800 S2 ZT B60,0,0,1,3,3,200,N,” ” A160,210,0,3,1,2,N,” ” A570,60,0,3,2,2,N,” ” A550,150,0,3,2,2,N,” ” A670,150,0,3,2,2,N,” ” A550,250,0,3,2,2,N,” ” A670,250,0,3,2,2,N,” ” A550,350,0,3,2,2,N,” ” A580,470,0,5,1,2,N,” ” A50,260,0,3,1,2,N,” ” A50,310,0,3,1,2,N,” ” A50,360,0,3,1,2,N,” ” A50,410,0,3,1,2,N,” ” A50,460,0,3,1,2,N,” ” A50,510,0,5,1,1,N,” ” A400,530,0,3,2,2,N,” ” A250,600,0,3,1,1,N,” ” A250,635,0,3,1,1,N,” ” A250,670,0,1,1,1,N,” ” A250,705,0,3,1,1,N,” ” A250,740,0,3,1,1,N,” ” A500,740,0,2,2,2,R,” ” A30,820,0,5,2,1,N,” ” A030,900,0,5,2,1,N,” ” A100,820,0,5,3,3,N,” ” A10,970,0,1,1,1,R,” ” P1
I have been printing labels in both EPL and ZPL format on linux. I am trying to get the same process to work for windows. I am using lpr -S ipaddress -P printername -o raw filename to send the file to the printer. It sends the file to the printer Zebra LP 2844 but prints the contents of the file instead of the barcode label. Any ideas?
Thank you. You said my life . Awesome engineer.
Do you know, how i can print cyrillic text in epl2?
Hi,
I need this same as in PHP. Please comebody help me out. Thank you in advance.
Hi Nicholas,
We are using a TLP2844 to print call number labels at our library. Last year I set up a little Word template to allow our librarians to bypass the clumsy software package they were using — and then automated the process with C#. It worked good enough until our network adminstrator installed Word 2010 last week. The page orientation is now all twisted around.
When I read your article I felt like Dante wandering in the wilderness meeting and meeting Virgil. I will have my administrator re-install Office 2007 until my backlog of projects clears up a bit and then write a form to display the label and print directly using the methods you outline. I understand that I will be using ZPL rather than EPL but your article gives me great confidence. Thanks for the posting.
Andy Helck Wilkinson Public Library Telluride, CO 81435
Nicholas,
Thanks for your blog post it has helped me out a lot. I was wondering if you had any insight on an issue I am having. I am printing UPS Shipping Labels with raw ZPL direct to a Zebra ZP 450 label printer using the above method and it works almost perfectly except it seems to cut off the Reference numbers at the very bottom of the label. If I look at my ZPL string I can see them trying to be printed. Any ideas?
Thanks so much in advance, Jeremie
Nicholas,
Disregard my post, I changed the label format from ZPL to EPL and that corrected the issue.
Thanks,
Jeremie
Nicholas,
So I thought I was out of the woods but it appears that my company also wants to print a Doc Label at the bottom of the UPS Shipping Label. I checked with UPS and it doesn’t appear that their web service supports sending back the EPL to create the doc label so I started trying to do it myself. The problem I run into is that after I go so far down the label the text I am telling it to print simply doesn’t.
For example,
Command: A12,1210,0,3,1,1,N,”ACCT#” will print at the very bottom of the shipping label.
But if I try A12,1250,0,3,1,1,N,”ACCT#” where 1250 is me trying to move this text to the doc label below the shipping label it never prints.
I checked the q and Q commands returned by UPS and I think they look ok.
q795 — 4 inches wide Q1600,24 — 8 inches long
The actual shipping label is only 4×6 which leaves the bottom 2 inches for the doc label, but when I try to print there the printer never seems to print. Any thoughts or ideas?
Thanks again in advance,
Jeremie
Hi,
My code doesn’t go beyond : if (OpenPrinter(szPrinterName.Normalize(), out hPrinter, IntPtr.Zero))
any clues?
Thanks,
Manish
Great post. Very helpful. Thanks alot =o)
Great tutorial, any idea if I can add a print queue using this method in case I want to print say 10 labels straight away?
Great Job, very nice…
Luis, you just need to insert all your string in a list. then use some algorithm to send the already built string to the printer.
Thanks, it helped a LOT!
Hi, i have a problem in printing 2D barcode with Data containing Line Feed. Please advice on writing the command to insert line feed in 2D barcode.
Pingback: Doctor Dolittle « Talking to yourself
very nice! How to print a image use GW command? could you give me a demo,please? Thanks!
Wow.. great and thanks!! Can you just tell me how can we send an image to Printer using c#?
Thanks!
Hi any one know how to detect when the printer is printing? I need the trigger when the printer is printing
thank you in advance for your help!
Hi any one know how to detect when the printer is printing? I need the trigger when the printer is printing
thank you in advance for your help! mario_tapiar (at)hotmail.com
Great Article … I was totally new to zebra programming & was having no clue how to send the command directly to Zebra printer. I was using Command execution option provided by zebra.
I am having Zebra TLP 2844-Z printer.
After reading this article I got the idea & searched the net & got some articles related to printing with C++ ..
It was a nice & well documented article. Thank you very much
Thanks. Hi all,
i have a ZPL printer s4M. may i know how to send image to printer via C# ZPL code.
TQ.
peijeng@crenergy.com.my pj8_8@hotmail.com
Will this work on a 64-bit platform, specifically Windows 7 and Windows 2008?
Some suggestion to print a Code 128 barcode to a fixed size? (EPL/EPL2) If the alphanumeric string of the upc is big, then the barcode is big and it printed out of margin. Some idea?
Thanks
Hi everyone,
i´ve got also the problem with sending an Image to my printer (GK420t)
the idea is to do it this way:
and the convert function:
public static byte[] ImageToBinary(string imagePath) { FileStream fileStream = new FileStream(imagePath, FileMode.Open, FileAccess.Read); byte[] buffer = new byte[fileStream.Length]; fileStream.Read(buffer, 0, (int)fileStream.Length); fileStream.Close(); return buffer; }
the problem is, the printer does nothing. not even a blank label comes out. so i think the printer doesn´t understand the converted image. the image itself has a size of 32x32dots.
Has anyone an idea, whats the problem in this code?
Thx
Hi Nicholas, Great Post. I have a issue printing in 2D Aztec barcode I am using this code with your code sb.AppendLine(string.Format( CultureInfo.InvariantCulture, “b26,26,A,\”{0}\”", this.upc)); but it prints nothing, i have also tried other barcode font none of 2d font is working. can you help me out?
Hi Nicholas, great article! It helped me a lot, thank you! By the way, it worked out on an ooold Genicom 6342 too. Flavio
Hi to all,
good article! Do you know if there’s a way to send a text with automatic justification?
Thanks.
Hi, I really appreciate this post. It’s a shame that after all the years of being on the market Zebra can’t do such a simple thing as to explain in few words how to print a label via their own product. It took me hours of fighting the obsolete drivers and no clear instructions to get nowhere.
Thank you very much! Radek
Hi, I am new to C# and web development. My question is how I can send a print on a printer that is installed at the client end. I have to do a web application that is supposed to create a ZPL code based on some database fields and the code is supposed to be printed on the clients printer. Any help will be appreciated. Thanks in advance!
Thx. This article help me a lot to implement a solution to generate the labels.
Excellent, thanks
Great article, Nicholas!
Would you have any idea why the first label I print using EPL prints out fine, but any following labels are garbage (basically solid black)?
Thanks!
Hi.
I have a problem, I have to insert an image into a text file for my Zebra lp2844 EPL to print, how can I get the jpeg into the coding for the image I need to print?
Hi, where i can get this librarys using Skiviez.UndiesClient.Domain; using Skiviez.Commons.WinForms; using Skiviez.Commons.Core;
Very good post, I am trying to print from a web application using EPL and printing directly on my LP2844 printer on my local machine, I have seen an activeX control, but that only works with 32 bit machine. I am looking for suggestions on how to print EPL file (from web app) to my LP2844 printer from my 64 bit machine
Will this work with CPCL instead of EPL2, too? What alterations are necessary, if any?
I have not used CPCL, but it looks like it should work the same way.
This doesn’t seem to work for my situation, using VS2003 / .NET 1.1
I copied the RawPrinterHelper, etc. from elsewhere (msdn), nevertheless many parts of that code are unrecognized by the compiler (MarshalAs, CharSet, ExactSpelling, Normalize, StringToCoTaskMemAnsi, FreeCoTaskMem, etc.)
Does anybody know something analagous I can use for my “retro” environment?
Thank you very much for this very clear, useful article Nicholas, it helped me with my work and for that I’m am grateful! Keep up the good work!,
KR,
C.