title: Print image in Zebra printer
body: <p>I've developed a system for generating an HTML tag and then converting it to a .PNG image.</p>
  
  <p>I need to print this image on the Zebra printer, but I still don't have a printer, I'm testing with the Zpl Printer application and with the online ZPL Viewer at <a href="http://labelary.com/viewer.html" rel="nofollow noreferrer">http://labelary.com/viewer.html</a>.</p>
  
  <p>My code is as follows: (C#)</p>
  
  <pre><code>var ipAddress = "127.0.0.1";
  var port = 9100;
  
  var bitmapImagePath = @"C:\Users\super\Desktop\Capturar.png";
  
  var bitmapDataFileSize = new FileInfo(bitmapImagePath).Length;
  
  var bitmapData = File.ReadAllBytes(bitmapImagePath);
  
  var hexadecimalString = BitConverter.ToString(bitmapData).Replace("-", string.Empty);
  
  var widthInBytes = Math.Ceiling(bitmapDataFileSize/8.0);
  
  var etiqueta = "^XA^FO0,0^GFA," + 
                 bitmapDataFileSize + "," +
                 bitmapDataFileSize + "," + 
                 widthInBytes + "," +
                 hexadecimalString + "^XZ";
  
  // Open connection
  var client = new System.Net.Sockets.TcpClient();
  client.Connect(ipAddress, port);
  
  // Write ZPL String to connection
  var writer = new StreamWriter(client.GetStream(), Encoding.UTF8);
  writer.Write(etiqueta);
  
  // Close Connection
  writer.Close();
  client.Close();
  
  return etiqueta;
  </code></pre>
  
  <p>The Zpl Printer displays the message that received a few bytes from the client, but doesn't display anything.</p>
  
  <p>I'm getting the ZPL return from my code and testing on the Labelary website and there it shows the label but in the wrong format.</p>
  
  <p>I would like to know what I'm doing wrong, how to fix the label size and why not show up in the ZPL Printer app.</p>
  
  <p>Note: the correct size is 3 x 14 cm.
  Here is an example image:</p>
  
  <p><img src="https://i.stack.imgur.com/o56Q5.jpg" alt="ExemploEtiqueta"></p>