Barcoding Cases

Correcting the Sample Code


Menu Expand/Collapse Menu

It is not very convenient to print a text file every time a label is needed. We want to send a batch of EPL commands to the label printer programatically. Sample code for sending raw EPL commands to a label printer is easily found via a google search.


For example:
How to Send Raw Data to a Printer Using the Win32 API from Visual Basic

When the exact same commands that worked via a text file are sent using the sample code, the print queue shows that they arrive but nothing prints.


To see what's happening, switch to line mode & run the sample code again. You will see what arrives at the label printer, garbage.


To fix the code, I did some more Google searching & found this link.
Send Raw Data to a Printer (Bypass Printer Driver) Using the Win32 API from Visual Basic

If you look closely, there's a tiny, odd difference in the sample code. Towards the bottom of the sample code is the following:

lReturn = WritePrinter(lhPrinter, ByVal sWrittenData, Len(sWrittenData), lpcWritten)

By placing "ByVal" in the call to WritePrinter, the EPL is sent directly to the label printer without jumbling. In line mode, the commands print out correctly. In page mode, the label prints correctly.

 

Granted the Zebra LP 2844 is just one of many label printers & there are a few command languages as well. Print drivers will display different options from print preferences. Sending commands to a label printer can use the generic code (with correction) which you can find from the links above. Note also that a search will find links for .Net versions of sample code. Look at the testing tactics as a generic approach to solving the nothing-prints scenario.