Printing to a Zebra LAN Printer

Post

Posted
Rating:
#1 (In Topic #1154)
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’
Hi Everyone

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
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Enthusiast
sadams54 is in the usergroup ‘Enthusiast’
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.
Online now: No Back to the top

Post

Posted
Rating:
#3
Enthusiast
AndyGable is in the usergroup ‘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)
Online now: No Back to the top

Post

Posted
Rating:
#4
Regular
vuott is in the usergroup ‘Regular’

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)
Maybe by using Socket Class of gb.net:
/comp/gb.net/socket - Gambas Documentation

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Guru
cogier is in the usergroup ‘Guru’
Have a look here https://supportcommuni…/000022631?language=en_US. I use a Zebra printer at work on Linux, but it is connected via USB. It works well for me. I create PDF files in Gambas and send them to the printer.
Online now: No Back to the top

Post

Posted
Rating:
#6
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’
 Does that mean I can still send the raw data to the printer driver like I can with the windows version?

Or would it be better to talk direct to the printer?
Online now: No Back to the top

Post

Posted
Rating:
#7
Avatar
Guru
cogier is in the usergroup ‘Guru’
I create a pdf using gb.cairo, then save the image to the /tmp/ folder. I Shell the lp command, see here,  with the file name, see below. Job done.

Code (gambas)

  1. Shell "lp /tmp/my.pdf" Wait

This produces labels like this: -

<IMG src="https://www.cogier.com/gambas/barcode5.png"> </IMG>
Online now: No Back to the top

Post

Posted
Rating:
#8
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’

cogier said

I create a pdf using gb.cairo, then save the image to the /tmp/ folder. I Shell the lp command, see here,  with the file name, see below. Job done.

Code (gambas)

  1. Shell "lp /tmp/my.pdf" Wait

This produces labels like this: -

<IMG src="https://www.cogier.com/gambas/barcode5.png"> </IMG>

Do you have any examples of how you used the gb.cairo?

Could I use that to print multiple labels across the page?
Online now: No Back to the top

Post

Posted
Rating:
#9
Regular
vuott is in the usergroup ‘Regular’

AndyGable said

Do you have any examples of how you used the gb.cairo?
Here is a simple possible example:

Code (gambas)

  1. Public Sub Button1_Click()
  2.  
  3.  Dim png As CairoSvgSurface
  4.  Dim x, y As Integer
  5.  Dim im, im2 As Image
  6.  
  7. ' Specifies the graphic surface to be created for drawing on
  8. ' (second and third arguments are in millimeters):
  9.  png = New CairoSvgSurface(Null, 210, 297)
  10.  
  11.  With Cairo
  12. ' Start drawing on the set surface:
  13.    .Begin(png)
  14. ' Sets the background color of the entire graphic surface:
  15.    .Source = .ColorPattern(Color.Yellow)
  16.    .Paint
  17. ' Draws an arc:
  18.    .LineWidth = 10.0
  19.    .Arc(300, 300, 100.0, 45.0 * (Pi / 180.0), 180.0 * (Pi / 180.0))
  20.    .Source = .ColorPattern(Color.Blue)    ' Sets the color of the drawing element:
  21.    .Stroke  
  22. ' Draws a full colored arc:
  23.    .LineWidth = 10.0
  24.    .ArcNegative(400, 300, 100.0, 45.0 * (Pi / 180.0), 180.0 * (Pi / 180.0))
  25.    .Source = .ColorPattern(Color.Orange)
  26.    .Fill
  27. ' Writes a text:
  28.    .Font.Size = 20
  29.    .Font.Name = "URW Palladio L"
  30.    .Source = .ColorPattern(Color.Red)
  31.    .MoveTo(100, 200)
  32.    .DrawText("Drawtext")
  33.    .Fill
  34.    .Source = .ColorPattern(Color.Green)
  35.    .MoveTo(400, 300)
  36.    .Font.Bold = True
  37.    .Text("Text")
  38.    .Fill
  39. ' Draws 10x10 filled squares:
  40.    For x = 0 To 9
  41.      For y = 0 To 9
  42.        .Rectangle(200 + x * 10.0, 500 + y * 10.0, 5, 5)
  43.      Next
  44.    Next
  45.   .Source = .ColorPattern(Color.Violet)
  46.   .Fill  
  47. ' Two images are inserted:
  48.   im = Image.Load("/usr/share/icons/breeze-dark/devices/64/battery.svg")
  49.   im2 = Image.Load("/usr/share/icons/breeze-dark/devices/64/media-optical-video.svg")
  50.   im2 = im2.Stretch(im2.W * 2, im2.H * 2)      ' Doubles the size of the second image:
  51.   .Source = Cairo.ImagePattern(im, 350, 600)
  52.   .Paint            ' Sets the image to the PNG surface
  53.   .Source = .ImagePattern(im2, 60, 400)
  54.   .Paint            ' Sets the image to the PNG surface
  55. ' Finish the drawing:
  56.   .End
  57.  
  58. ' Save the surface contents as a PNG file
  59. ' (https://gambaswiki.org/wiki/comp/gb.cairo/cairosurface/save):
  60.  png.Save("/tmp/file.png")
  61.  
  62.  End

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#10
Avatar
Guru
cogier is in the usergroup ‘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)

  1. '' Requires gb.cairo
  2.  
  3. Public Sub Form_Open()
  4.  
  5.   CreatePDF("Hello world!")
  6.  
  7.  
  8. Public Sub CreatePDF(sText As String)
  9.  
  10.   Dim pdf As CairoPdfSurface
  11.  
  12.   pdf = New CairoPdfSurface("/tmp/myprint.pdf", 50.8, 25.4)
  13.  
  14.   With Cairo
  15.     .Begin(pdf)
  16.     .Source = Cairo.ColorPattern(Color.White)
  17.     .Paint()
  18.     .Font.Name = "Ubuntu"
  19.     .Font.Size = 25
  20.     .Source = Cairo.ColorPattern(Color.Black)
  21.     .MoveTo(Centre(Cairo.TextExtents(sText).XAdvance), 40)
  22.     .Text(sText)
  23.     .Fill()
  24.     .End
  25.  
  26.   pdf.Finish
  27.  
  28.  
  29. Public Sub Centre(fPoints As Float) As Float
  30.  
  31.   Dim fWidth As Float = 50.8 / 25.4 * 72
  32.   Return (fWidth - fPoints) / 2
  33.  
  34.  

Could I use that to print multiple labels across the page?

Simply loop through

Code (gambas)

  1. Shell "lp /tmp/myprint.pdf" Wait
as many time as necessary.
Online now: No Back to the top
1 guest and 0 members have just viewed this.