Need help with Zebra printer

Just starting out? Need help? Post your questions and find answers here.
leodh
Enthusiast
Enthusiast
Posts: 164
Joined: Sun Nov 06, 2005 6:07 am
Location: Perth Western Australia

Need help with Zebra printer

Post by leodh »

Hi All,

I am trying to write a small program that prints out barcode labels on a Zebra GK420t thermal printer.

It uses their ZPL II code to send instructions to the printer.

it uses ^XA to start and XZ to end transmission

Here is some code I found but I do not know how to translate it in to Purebasic.

Code: Select all

    Data1 = "^XA" & _
    "^FO89,20^A0N,25,18 ^FDWaranty void if removed^1,1^FS" & _
    "^FO93,45^A0N,24,17^FDGarantie Annule si enleve^1,1^FS" & _
    "^FO117,75^AB^FD" & SNum & "^1,1^FS" & _
    "^PQ3,0,1,Y^XZ"
    
    Open "LPT1:" For Output As #1
    Print #1, Data1
    Close #1
What is the easiest way to send this to the printer ( printer is USB001: )

Any help would be great.

Cheers
Leo
Last edited by leodh on Thu Nov 21, 2019 8:26 am, edited 1 time in total.
Regards
Leo
Marc56us
Addict
Addict
Posts: 1600
Joined: Sat Feb 08, 2014 3:26 pm

Re: Need help with Zebra printer

Post by Marc56us »

Code: Select all

Data1 = "^XA" & _
"^FO89,20^A0N,25,18 ^FDWaranty void if removed^1,1^FS" & _
"^FO93,45^A0N,24,17^FDGarantie Annule si enleve^1,1^FS" & _
"^FO117,75^AB^FD" & SNum & "^1,1^FS" & _
"^PQ3,0,1,Y^XZ"

Open "LPT1:" For Output As #1
Print #1, Data1
Close #1
What is the easiest way to send this to the printer ( printer is USB001: )
LPT1 means that the original program used a parallel port, but USB001: means that the printer is remapped with a USB cable // (// to USB)
So it is possible that it can be controlled with the Serial lib commands.
First you have to look in the options of the control panel at Serial level. If the printer appears on it, then just take the COM port number assigned to it.
leodh
Enthusiast
Enthusiast
Posts: 164
Joined: Sun Nov 06, 2005 6:07 am
Location: Perth Western Australia

Re: Need help with Zebra printer

Post by leodh »

@ Marc56us

Hi,

I have a laptop and there is no serial device listed in the Control Panel Device Manager.

From what I understand the serial open command only works with the COM device not USB.

Cheers
Leo
Regards
Leo
Marc56us
Addict
Addict
Posts: 1600
Joined: Sat Feb 08, 2014 3:26 pm

Re: Need help with Zebra printer

Post by Marc56us »

leodh wrote: I have a laptop and there is no serial device listed in the Control Panel Device Manager.
From what I understand the serial open command only works with the COM device not USB.
The serial port on modern Windows is virtual and only appears when a device used as such is connected and recognized (via driver).
This is the case, for example, for microcontroller cards (ie: Arduino) which often drive CNC machines (ie: 3D printer, Laser cutting)

USB stands for Universal Serial Bus, so it is always a serial protocol encapsuled and any programming language with serial functions can then be used (provided that the card supplier has provided a driver)

:wink:
ColBoy
Enthusiast
Enthusiast
Posts: 143
Joined: Fri Feb 13, 2004 2:37 pm
Location: Ottawa, Canada
Contact:

Re: Need help with Zebra printer

Post by ColBoy »

I have done this before on many barcode printers from Symbol, Intermec, Zebra and Sato, all connecting via USB. Many of these have used the regular Windows print driver, but I have also driven them directly using ZPL, EPL, etc. It's been a while. I'll try to dust off some code, to see what was done. I think for Symbol/Zebra there used to either be something in the driver, or you had to download a separate COM driver. I do have a Zebra ZQ510, which as well as wireless also has USB. I'll try to do some test when I get a chance, probably the weekend.

Colin
Colin
ColBoy
Enthusiast
Enthusiast
Posts: 143
Joined: Fri Feb 13, 2004 2:37 pm
Location: Ottawa, Canada
Contact:

Re: Need help with Zebra printer

Post by ColBoy »

Also found this. Printer name shouldn't matter as long as you use the name consistently
Colin
When I installed the printer, I renamed it to "ICS Label Printer". Here's how to change the options to allow pass-through ZPL commands:

Right-click on the "ICS Label Printer" and choose "Properties".
On the "General" tab, click on the "Printing Preferences..." button.
On the "Advanced Setup" tab, click on the "Other" button.
Make sure there is a check in the box labeled "Enable Passthrough Mode".
Make sure the "Start sequence:" is "${".
Make sure the "End sequence:" is "}$".
Click on the "Close" button.
Click on the "OK" button.
Click on the "OK" button.
In my code, I just have to add "${" to the beginning of my ZPL and "}$" to the end and print it as plain text. This is with the "Windows driver for ZDesigner LP 2844-Z printer Version 2.6.42 (Build 2382)". Works like a charm!
Colin
leodh
Enthusiast
Enthusiast
Posts: 164
Joined: Sun Nov 06, 2005 6:07 am
Location: Perth Western Australia

Re: Need help with Zebra printer

Post by leodh »

Hi Colboy,

Thanks for the reply, I have changed the printer prefs as you suggested. An old program I wrote now seems to communicate with the printer. It was written with PB Version 5.4 (32 Bit) with PRINT_LIB.

Can not seem to get PB Version 5.7 to talk to the printer, but will keep trying.

Thank again

Leo

PS, would like to see some of your code, it may help. Ta.
Regards
Leo
ColBoy
Enthusiast
Enthusiast
Posts: 143
Joined: Fri Feb 13, 2004 2:37 pm
Location: Ottawa, Canada
Contact:

Re: Need help with Zebra printer

Post by ColBoy »

Hi Leo

Glad you got something running. My code was written under VB.NET, but the same principals would apply. One of the other things to try is to install a Generic / Text Printer. That way, as long as the printer is set to ZPL mode, what you output should be converted into it's printed equivalent. Not tried this for ZPL, but used this method many moons ago, to print to a dot matrix at much greater speed, than using a manufactures Windows printer driver.

Colin
Colin
Post Reply