Printing to a Zebra LAN Printer
Posted
#1
(In Topic #1154)
Enthusiast

I was hoping someone could point me in the right direction
As you are all aware by now I am writing a EPoS application in Gambas (ive started working on the Back office application now) and I need to print some information to a Zebra Label Printer.
Below is the code I use for the Printer (this was crated by a Zebra program so I know it works as it works on my Windows PC)
Code
I8,A,001
Q280,024
q448
rN
S4
D7
ZT
JF
O
R0,0
f100
N
A181,40,2,4,1,1,N,"2002821"
A434,28,2,4,1,1,N,"F01"
A381,28,2,4,1,1,N,"1001/0052"
A436,134,2,4,2,2,N,"SEE THE ITEM "
A436,90,2,4,2,2,N,"FOR THE PRICE"
A396,50,2,4,1,1,N,"11/01/2020"
A443,245,2,4,1,1,N,"1234567890123456789012345"
A443,223,2,4,1,1,N,"1234567890123456789012345"
A443,201,2,4,1,1,N,"1234567890123456789012345"
A443,179,2,4,1,1,N,"1234567890123456789012345"
A443,157,2,4,1,1,N,"1234567890123456789012345"
P1
I need to print this to the LAN printer that is on 192.168.1.100 Port 9100.
so my question is how do I send data to the printer so it can print? (do I have to add a CUPS driver for it?) or can I send the data direct to the IP address / Port?
Any advice help etc is most welcomed as this was a pain to get working when I was in VB.net lol
Andy
Posted
Enthusiast

Posted
Enthusiast

sadams54 said
I have used cups to send printer data in my POS application. I am sure you can go direct to port but you are limiting yourself to particular printers that way. The problem with zebra (having worked with their stuff) is that they do not have any linux support.
The way my system is designed I don't print direct to the printer from my software I send data to a module and that does the work so I can have any shelf edge label printer on my system as long as I can make a module for it.
I try to use the usb or serial version of the zebra printers but when you're working in the middle of the shop requesting labels for a new install you are limited to what the customers have.
And yea I know just what you mean by Zebra not having any Linux support (oddly though the have Android support)
Also how would I print the port? I've never done that with Gambas (I assume I would need to open 192.168.1.100:9100 as output or something like that)
Posted
Regular

Maybe by using Socket Class of gb.net:AndyGable said
Also how would I print the port? I've never done that with Gambas (I assume I would need to open 192.168.1.100:9100 as output or something like that)
/comp/gb.net/socket - Gambas Documentation
Europaeus sum !
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Posted
Guru

Posted
Enthusiast

Or would it be better to talk direct to the printer?
Posted
Guru

Posted
Enthusiast

cogier said
Do you have any examples of how you used the gb.cairo?
Could I use that to print multiple labels across the page?
Posted
Regular

Here is a simple possible example:AndyGable said
Do you have any examples of how you used the gb.cairo?
Code (gambas)
- ' Specifies the graphic surface to be created for drawing on
- ' (second and third arguments are in millimeters):
- With Cairo
- ' Start drawing on the set surface:
- .Begin(png)
- ' Sets the background color of the entire graphic surface:
- .Source = .ColorPattern(Color.Yellow)
- .Paint
- ' Draws an arc:
- .LineWidth = 10.0
- .Source = .ColorPattern(Color.Blue) ' Sets the color of the drawing element:
- .Stroke
- ' Draws a full colored arc:
- .LineWidth = 10.0
- .Source = .ColorPattern(Color.Orange)
- .Fill
- ' Writes a text:
- .Source = .ColorPattern(Color.Red)
- .MoveTo(100, 200)
- .DrawText("Drawtext")
- .Fill
- .Source = .ColorPattern(Color.Green)
- .MoveTo(400, 300)
- .Text("Text")
- .Fill
- ' Draws 10x10 filled squares:
- .Rectangle(200 + x * 10.0, 500 + y * 10.0, 5, 5)
- .Source = .ColorPattern(Color.Violet)
- .Fill
- ' Two images are inserted:
- im2 = im2.Stretch(im2.W * 2, im2.H * 2) ' Doubles the size of the second image:
- .Source = Cairo.ImagePattern(im, 350, 600)
- .Paint ' Sets the image to the PNG surface
- .Source = .ImagePattern(im2, 60, 400)
- .Paint ' Sets the image to the PNG surface
- ' Finish the drawing:
- .End
- ' Save the surface contents as a PNG file
- ' (https://gambaswiki.org/wiki/comp/gb.cairo/cairosurface/save):
- png.Save("/tmp/file.png")
Europaeus sum !
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Posted
Guru

Do you have any examples of how you used the gb.cairo?
vuott's code is a good start. The code below is designed to create a PDF file with the words 'Hello world!' and saves it to the /tmp/ folder. The label size is 50 x 25mm (2" x 1")
Code (gambas)
Could I use that to print multiple labels across the page?
Simply loop through as many time as necessary.
1 guest and 0 members have just viewed this.



</IMG>