0
votes

Is there any way to use the images stored in a Zebra printer in the following code:

Dim g As Graphics = e.Graphics
    Dim bc As New BarcodeProfessional
    Dim br As Brush = New SolidBrush(Drawing.Color.Black)

    Dim blackPen As New Pen(Color.Black, 5)

    e.Graphics.DrawArc(blackPen, 10, 10, 70, 50, 130, 100)
    g.DrawString("UPC", Arial_6_bold, br, 210, 15)

the above prints an arc, and a "UPC" text, now can I print here also an image stored in the Zebra printer?

I have found that I can send ZPL code to the printer in this way:

    Dim ipAddress As String = "10.3.14.59"
Dim port As Integer = 9100

Dim ZPLString As String = _
"^XA" & _
      "^FO50,50" & _
      "^A0N,50,50" & _
      "^FDHello, World!^FS" & _
      "^XZ"

Try
      'Open Connection
      Dim client As New System.Net.Sockets.TcpClient
      client.Connect(ipAddress, port)

      'Write ZPL String to Connection
      Dim writer As New System.IO.StreamWriter(client.GetStream())
      writer.Write(ZPLString)
      writer.Flush()

      'Close Connection
      writer.Close()
      client.Close()

Catch ex As Exception

      'Catch Exception Here

End Try

But I don't know how to put together both codes, any idea?

2

2 Answers

3
votes

If the graphic will be static and doesn't change based on user input or etc., you could just create a .grf out of it. I guess the easiest way to do that would be to export the image as a bitmap, open in paint, save as a .pcx file, and then open it in ZTools to convert to a hex .grf file. Then you can send the graphic to the printer along with your other ZPL code.

For examples on how to do this, I'll refer you to the ZPL programming guide, available at http://www.servopack.de/support/zebra/ZPLbasics.pdf

You'll find an example that explains creating and printing .grf files on page 36, and an example of sending both .grf and text to a label on page 63.

3
votes

It sounds like your image is already stored to the printer. If so, its file name (as stored on the printer) should be something like 'E:MYFILE.GRF'. You can use the ZPL command ^XG to recall stored graphics. So, by sending the following ZPL, the graphic should print after the text 'Hello, World!":

  "^XA" & _
  "^FO50,50" & _
  "^A0N,50,50" & _
  "^FDHello, World!^FS" & _
  "^XGE:MYFILE.GRF,1,1^FS" & _
  "^XZ"

In case your image isn't already stored, you can store a GRF file through the ~DY command, but it is far easier to download objects through Zebra Setup Utilities: http://www.zebra.com/us/en/products-services/software/manage-software/zebra-setup-utility.html.

Source: https://support.zebra.com/cpws/docs/zpl/zpl_manual.pdf.