Printing to a Zebra Printer

Can anyone share how to print to a Zebra printer via USB?

I am trying to print either a PNG or a PDF file with no luck (and no error codes either!!).

I have the Zebra connected to my Mac via USB, and when I use another app it works just fine, I just cannot get any output from my own app.

Thanks in advance.

My code is:

Dim picFile As FolderItem
picFile = GetOpenFolderItem("")

If picFile <> Nil Then

Dim pic As Picture
pic = Picture.Open(picFile)
ImageWell1.Image = pic

// 4x6 inches @ 72dpi = 288x432 pixels
Dim g As Graphics
g = OpenPrinterDialog
If g <> Nil Then
g.DrawPicture(pic,0,0,288,432,0,0,pic.width,pic.height)
//g.DrawPicture(pic,0,0)
End If

Else

MsgBox(“No image found”)

End If

[quote=151197:@brad timinski]Can anyone share how to print to a Zebra printer via USB?

I am trying to print either a PNG or a PDF file with no luck (and no error codes either!!).

I have the Zebra connected to my Mac via USB, and when I use another app it works just fine, I just cannot get any output from my own app.

Thanks in advance.

My code is:

Dim picFile As FolderItem
picFile = GetOpenFolderItem("")

If picFile <> Nil Then

Dim pic As Picture
pic = Picture.Open(picFile)
ImageWell1.Image = pic

// 4x6 inches @ 72dpi = 288x432 pixels
Dim g As Graphics
g = OpenPrinterDialog
If g <> Nil Then
g.DrawPicture(pic,0,0,288,432,0,0,pic.width,pic.height)
//g.DrawPicture(pic,0,0)
End If

Else

MsgBox(“No image found”)

End If[/quote]

Are you able to print from a standard application such as TextEdit ?

If not seems this could be a solution using a browser :
http://qzindustries.com/download
Their Wiki indicates how to set up the zebra printer as a raw printer. That maybe the issue :
http://qzindustries.com/TutorialRawOSX

First of all, don’t use 72 dpi. Thermal printers are typically 200, 300 or 400 dpi and sending another resolution is a great way to get headaches.

Secondly don’t rely on the printers to rotate for you if you need that. Use a plugin or write some xojo code to rotate it in your app.

Thirdly (maybe this should have been first), check the printer config. There are modes for these printers where they will only accept ZPL (Zebra Printing Language). You’ll need to disable that option unless you want to learn The ZPL protocol.

Also make sure that, if this is Windows, there is not an OS driver that is adding to your problems.

I have had good and bad luck using Windows drivers. I have NOT done any Zebra or similar projects in XOJO so I don’t have any specific tips that might help.

If your formatting is complex with lots of graphics then maybe a Windows driver makes sense and you treat your output like any other Windows printer. It seems that getting the printer to print is the easy part when using the Windows driver. The real trick is to get the form length right because Windows seems to want to feed 11 inches of paper as a default and sometimes the label printer will attempt to comply by feeding lots of blank labels.

If your formatting is simple then then ZPL and raw output (so the Windows driver does not get involved) might work fine and be much more predictable.

These things are always an “adventure”.

My first product back in 1987 was a printer driver that let PCs output accented characters and new fonts on standard dot matrix printers which, at the time, were rather crude. I quickly dropped, because of the amount of support requests. Printers are probably the worst peripherals to address.

An opinion shared by a friend of mine who developed most of Windows 3.2 printer drivers.

That was a while ago, but still today, printers remain the most finicky of peripherals…

Thanks everyone for your help!

I am still not having any luck. I did the CUPS thing, and tried printing directly in EPL language and ZPL language.

I need to get this working in a Mac OS X environment (not Windows).

The Zebra is connected directly to my Mac via USB, and it prints fine whenever I print from a browser and ‘some’ OSX apps, but it doesn’t want to work when I print from the Xojo app I build (using the drawPicture function).

I am stuck! Funny thing is that I can do this in PHP I have written, but no joy with Xojo.

[quote=151552:@brad timinski]Thanks everyone for your help!

I am still not having any luck. I did the CUPS thing, and tried printing directly in EPL language and ZPL language.

I need to get this working in a Mac OS X environment (not Windows).

The Zebra is connected directly to my Mac via USB, and it prints fine whenever I print from a browser and ‘some’ OSX apps, but it doesn’t want to work when I print from the Xojo app I build (using the drawPicture function).

I am stuck! Funny thing is that I can do this in PHP I have written, but no joy with Xojo.[/quote]

I asked you if it printed from TextEdit precisely to try to find out which standard apps do. That could be an indication as what kind of printing is used.

Which browser ? Safari ? With any plugin or just as it comes ? Which are these ‘some’ apps ? Specialized ones or standard ones ?

You say you can do it in php. Is it run on the Mac or on a host ? If run on the Mac, how do you send output to the printer ?

Good questions.

This is all on a Mac OS X puter running latest Yosemite:
TextWrangler (printing a few lines of text) - ejects a blank label
TextEdit (printing a few lines of text) - ejects a blank label
OSX Mail (printing a short email) -prints all
OSX Mail (printing a longer email) - prints only the last ~ 20 lines
Zend Studio PHP Editor (printing a script’s source code) - prints all
Chrome (no plugins, printing a PDF) - prints all
Safari (no plugins, printing a PDF) -prints all
Xojo Desktop (no plugins, printing thesource code I pasted in at the top message) - prints only the last few lines

In my Xojo app, I have adjusted the printer resolution to 203 dpi.
The printer is a Zebra 2348 PLUS using EPL2 mode.
When I say PHP, it is ultimately printing from the Chrome or Safari browser, but the PDF is composed and sent to the browser with PHP code.
Also, as Michel B suggested, I did set up the printer via CUPS as a RAW printer, and when I print to it I can see the printer window telling me it is ‘sending data to the printer’ and then the window closes with no error messages, but then nada, not even a blank page or page eject.

I have been all over the 'net looking for Zebra printing codes, EPL codes, printer strings, etc., and trying to glean any tricks I can, but still no joy.

I am ultimately trying to print shipping labels from Fedex and the like. I want to move away from our browser/PHP solution to a desktop app (using Xojo) but printing seems to be the sticking point and has consumed two days so far. I so want Xojo to work!!

Thanks again for your time and suggestions.

[quote=151575:@brad timinski]Good questions.

This is all on a Mac OS X puter running latest Yosemite:
TextWrangler (printing a few lines of text) - ejects a blank label
TextEdit (printing a few lines of text) - ejects a blank label
OSX Mail (printing a short email) -prints all
OSX Mail (printing a longer email) - prints only the last ~ 20 lines
Zend Studio PHP Editor (printing a script’s source code) - prints all
Chrome (no plugins, printing a PDF) - prints all
Safari (no plugins, printing a PDF) -prints all
Xojo Desktop (no plugins, printing thesource code I pasted in at the top message) - prints only the last few lines

In my Xojo app, I have adjusted the printer resolution to 203 dpi.
The printer is a Zebra 2348 PLUS using EPL2 mode.
When I say PHP, it is ultimately printing from the Chrome or Safari browser, but the PDF is composed and sent to the browser with PHP code.
Also, as Michel B suggested, I did set up the printer via CUPS as a RAW printer, and when I print to it I can see the printer window telling me it is ‘sending data to the printer’ and then the window closes with no error messages, but then nada, not even a blank page or page eject.

I have been all over the 'net looking for Zebra printing codes, EPL codes, printer strings, etc., and trying to glean any tricks I can, but still no joy.

I am ultimately trying to print shipping labels from Fedex and the like. I want to move away from our browser/PHP solution to a desktop app (using Xojo) but printing seems to be the sticking point and has consumed two days so far. I so want Xojo to work!!

Thanks again for your time and suggestions.[/quote]

Have you tried to send a form feed character &u000C through the raw printer to see if that ejects a page ? It is very possible that the driver actually does not communicate with the printer.

Just a hunch, but since browsers seem to print fine, what about trying to print through an HTMLViewer ?

Good suggestion, I will give the HTMLViewer a try over the weekend. Thanks.

If you are using the FedEx API tell them to send you EPL and send that RAW to the printer and you will get labels. This also works for the Endicia and UPS APIs.

I will try this. Thanks!

To send RAW to the printer,I assume I build a string variable with the EPL raw code in it, then use the g.DrawString command to send it to the printer?

Sorry I am pretty new to Xojo and not yet up to speed on the printing tools available.

When using a graphics object you need the proper driver and the printer has to have enough memory to render it. That is sometimes questionable in that model (I have two of them in my warehouse).

When using RAW it is often easiest to create your EPL and send it to the printer using a plain text driver.

To tell the truth I would just write the EPL to a temporary text file then cat it to the printer on either Linux or OSX.

If your printer has enough memory I would stick to the graphics methods for printing since it is the least work route.

No, that won’t work. DrawString is a graphics command. You’d get the text of the raw code printed, not the results of the raw code. Go with temp file and cat on *nix environments. On Windows, you can do it with a few declares.

Side note: I print to zebra printers on Windows, where the drivers take care of everything and you can use the graphics methods. But I like the idea of getting raw EPL from FedEx/UPS. Thanks for the tip!

As an aside, why do I keep having a “Pearls Before Swine” experience and read the title of this thread: “Zeeba Printa”?

I don’t have any Macs available to me at the moment to test this but you should be able to get away with using TextOutputStream printing directly to the spooler like below.

[code] Dim sEPLdata As String
sEPLdata = “Populate your data here.”

Dim f As FolderItem = “/dev/lp0”
If f <> Nil Then
Try
Dim t As TextOutputStream = TextOutputStream.Create(f)
t.Write(ConvertEncoding(sEPLdata, Encodings.WindowsANSI))
t = Nil
Catch e As IOException
MsgBox(“Time to try something else.”)
End Try
End If[/code]

Bob.

Appreciate the help. That looks like what I needed.

I will test today or tomorrow to see how it goes.

Thanks!