views:

440

answers:

3

Hi,

I'm working on a project where we need to use a Zebra Printer for barcode labels. We're using C#, and we're doing OK on the printing side of things, sending raw ZPL strings to the printer (using winspool.drv).

However, we also need to read from the printer, and no luck there.

We need to get the status from the printer, which is the output to the ZPL command "~HS", so we can tell how many labels are in memory waiting to be printed. The EnumJobs() from winspool.drv only has jobs on the windows spool, and once they're sent to the printer, they're gone from that list. But that doesn't mean the label has been printed, since the printer has a peel sensor and only prints one label at a time, and we're obviously interested in sending batches of labels to the printer.

I've tried something like (using the winspool.drv calls):

OpenPrinter(szPrinterName, out hPrinter, IntPtr.Zero);
WritePrinter(hPrinter, pBytes, dwCount, out dwWritten); // send the string "~HS"
ReadPrinter(hPrinter, data, buff, out pcRead);

But I get nothing on the ReadPrinter call. I don't even know if this is the right way of going at it.

Anyone out there tackled this before?

Thanks.

+1  A: 

About 15 years ago I wrote software to print throught Zebra printers.

At the time we communicated with the printer over RS-232 (? standard serial comms), which worked well, all information came back from the printer in a timely and accurate fashion.

Recently I'd to work with Epson tally printers, and found the windows printer drivers clumsy and inefficient. I dropped down a level and communicated directly with the printer through GDI, and everything worked to my satisification.

I say take out the middle man, if you drop down a level and communicate with the printer directly, rather than communicating through windows printer drivers, you'll have more success.

Hope this helps,

Binary Worrier
A: 

hey dude can u tell me how you comunicate directly with the printer? i can't send commands to the zebra printer in my application, can u spare any idea? tnks

Ax Perez Parra Castro
-1 this doesnt answer the question.
mizipzor
+1  A: 

Hi pmoreira,

I'm facing the same problem. Did you already manage anything on this subject?

Ax Perez Parra Castro, this is how I did it:

-get the RawPrinterHelper class from here http://support.microsoft.com/kb/322091

-my printer (zebra 2030) doesn't support ZPL, so as far as I know the only way is to send unicode to it

-I made a list of characters I need e.g.

string enq = Convert.ToChar(5).ToString();
string esc = Convert.ToChar(27).ToString();
string nul = Convert.ToChar(0).ToString();
string rs = Convert.ToChar(30).ToString();
string lf = Convert.ToChar(10).ToString();
string cr = Convert.ToChar(13).ToString();

(get those int values from en.wikipedia.org/wiki/ASCII)

-compose the command - e.g. sb.Append(esc + enq + Convert.ToChar(7).ToString()); (from the printer manual, the command < ESC>< ENQ><7> should get the firmware version)

-send the command RawPrinterHelper.SendStringToPrinter(printerName, sb.ToString()); (printerName in my case is "Zebra TTP 2030")

bfi