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
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));
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
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));
Still I am not able to print correct image. I follow following URL (http://labelary.com/viewer.html) 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.
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.
Any help is appriciated.
Thanks,