none
ASCII Hexadecimal Encoding?

    Pregunta

  • 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("-","");

    or

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

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

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

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

     

    thanks,

    Ron

     

    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 ...

    Cristian.

    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:

    89504E470D0A1A0A0000000D4948445200000096000000960100000000147A4C4F000000097048597300000F6100000F6101A83FA7690000000467414D410000B18E7CFB5193000000206348524D00007A25000080830000F9FF000080E9000075300000EA6000003A980000176F925FC5460000054B49

    Hex from Zebra app output file:

    iV01gUFH03gUF807gUF807gUFC07gUFC07PF0EH03gFC07OF83801gGFC07NFE07807CgFC07NFC0F01FCF7XFC07NFC3E03FCF3XFC07LFCF83E07F8E3XFC07LF8F07C0HF8E3BWFC07KFE1F0FC0HF0C73WFC07KFE1E0FC1HF1847WFC07KFC3E1FC1FE2H0XFC07JFDC3E1FC1FEH03XFC07JF1C3E1FC1FCH07XFC07IFE3C7E1FC1F8H0YFC07IFC787E0FC0F801YFC07IFC787E0FE0F807YFC07HF98787F07E0380gFC07FE38F83F03FH0F9g

     

    thanks,

    Ron

    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?
    jon.stromer.galley
    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.

    Cristian.

    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

    Ron

    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.

    Cristian.

    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????

     

    Roland

    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!

    http://stackoverflow.com/questions/8818688/printing-images-png-to-a-network-zebra-printer-zpl-z64-b64/22623274#22623274
    • Editado wShaw443 martes, 25 de marzo de 2014 1:53
    martes, 11 de marzo de 2014 1:36