ASCII Hexadecimal Encoding?


  • Hi,

    I've reading the programming manual for Zebra ZPL2 commands (barcode printer). I'm trying to download a PNG graphic to the printer. The manual states that the image data must be in "ASCII hexadecimal encoding".  I've tried the code below without success.


    byte[] byteArray = File.ReadAllBytes(filePath);

    string imageHex = BitConverter.ToString(byteArray).Replace("-","");


    byte[] byteArray = File.ReadAllBytes(filePath);

    string asciiString = Encoding.ASCII.GetString(byteArray);

    byte[] byteArrayASCII =  Encoding.ASCII.GetBytes(asciiString);

    string imageHex = BitConverter.ToString(byteArrayASCII).Replace("-","");





    jueves, 08 de abril de 2010 19:41

Todas las respuestas

  • The format you probably need is:

    for (int i = 0; i < byteArray.Length; i++)

       imageHex +=byteArray[i].ToString("X2");

    In the old days, Zebras would not accept PNG, only GRF (basically a PCX format without headers) though ...


    jueves, 08 de abril de 2010 20:22
  • Hi and thank you both for your responses.

    I've tried both samples of code and both produce the same results, and it's the same hex as I've been producing. I don't know if this will help at all, but I'm able to use a Zebra program that can output a text file with the ASCII hexadecimal encoding.  I've noticed that the Zebra hex has alpha characters that are lower case (i and g). The hex that we are generating does not have any lower case characters.

    Hex sample from our code:


    Hex from Zebra app output file:





    jueves, 15 de abril de 2010 5:35
  • What does the zebra output look like if you do a Convert.FromBaase64String() and run that Byte[] into your hex generator of choice?
    jueves, 15 de abril de 2010 15:12
  • hex numbers only use letters a - f (or A - F) and digits 0 - 9, any other letter is most likely some command to the printer.

    The Zebra ZPL 2 manual used to be pretty complete, should have the info you require.


    jueves, 15 de abril de 2010 16:12
  • Thanks Cristian,

    The manual just states that if downloading PNG image, you must use DATA formatted as: ASCII hex or ZB64


    jueves, 15 de abril de 2010 18:05
  • If you have a look at this manual (starting at page 110), a description of the ZB64 format is given.


    jueves, 15 de abril de 2010 18:30
  • Hi Ron


    Where you ever able to download a PNG file to a Zebra printer in ASCII????



    viernes, 24 de septiembre de 2010 18:33
  • do you have finished your job?

    this problem trouble me, too

    domingo, 08 de mayo de 2011 12:50
  • To everyone still searching for an answer, I finally figured out how to do it, look at my post on stackoverflow!
    • Editado wShaw443 martes, 25 de marzo de 2014 1:53
    • Propuesto como respuesta charlievodka lunes, 21 de agosto de 2017 18:32
    martes, 11 de marzo de 2014 1:36