Image printing with zebra printer using zpl command
<p>I am trying to print image on zebra printer(LP-2844-Z) using zpl language. In ZPL documentaion it says you have to convert image into ASCII HexaDecimal. Then by using GF command you can print image.
I tried below code to get image and convert it into hexa decimal</p>
<pre><code>URL oracle = new URL(urlString);
URLConnection yc = oracle.openConnection();
BufferedImage bufferedImage = ImageIO.read(yc.getInputStream());
int rowsData = bufferedImage.getWidth()/8;
System.out.println(rowsData);
byte[] pixel = ((DataBufferByte)bufferedImage.getRaster().getDataBuffer()).getData();
System.out.println(pixel.length);
System.out.println(Hex.encodeHex(pixel, false));
</code></pre>
<p>And then I tried to print this data using zebra printer but it is not printing correct image. I tried another code to get image bytes and converted it into hexa decimal</p>
<pre><code>URL oracle = new URL(urlString);
URLConnection yc = oracle.openConnection();
InputStream inputStream = yc.getInputStream();
byte[] imageData = IOUtils.toByteArray(inputStream);
System.out.println(Hex.encodeHex(pixel, false));
</code></pre>
<p>Still I am not able to print correct image. I follow following URL <a href="http://labelary.com/viewer.html" rel="nofollow noreferrer">(http://labelary.com/viewer.html)</a> and tried to see code when we upload image. What I found that after uploading image, the base64 generated by zebra viewer is totally different which I generated using above code. I go through several post on stackoverflow but still I am not able to solve out this problem.</p>
<p>I know where I am doing mistake but I don't know how to solve it. Actually I am not able to generate ASCII Hex Base64 code for given image. This is my thought.</p>
<p>Any help is appriciated.</p>
<p>Thanks,</p>