Print PNG image to a TLP 2844

1,514 views
Skip to first unread message

JSimas

unread,
Sep 16, 2011, 5:54:14 AM9/16/11
to jZebra users
Hi.

I'm trying to print a QR Code png image to a zebra TLP 2844 using the
jzebra applet.

I already managed to use the applet to write text, or a normal barcode
using EPL2 sintax. However, the printer has no native command to print
qr code images, so my only choice is to send an image to the printer
(i already was able to print the qr code using the Windows Photo
Viewer print command)


This is my Java test case code:

File qrcodeFile = new File("...qrcode.png"); //Image with size
60x60px

PrintRaw pr= new PrintRaw();
pr.setCharset(Charset.defaultCharset());
pr.setPrintService(PrintServiceMatcher.findPrinter("zebra1"));
pr.clear();

pr.append(" \r\n");
pr.append("N\r\n"); //Clear printer buffer

//Simple text example - Working
//pr.append("A250,0,0,4,1,1,N,\"João Pedro 1 2 3 4 5\"\r\n");

//Simple bar code - Working
//pr.append("B50,800,0,3,3,7,200,B,\"998152-001\"\r\n");

//Write image, not working

InputStream is = new FileInputStream(qrcodeFile);
byte[] bimage = IOUtils.readFully(is, -1, false);

//System.out.println("Size: " + bimage.length);
pr.append("GW250, 0, 60, 60," + new String(bimage) + "\r\n");

pr.append("P1\r\n"); //End char
pr.append(" \r\n"); //Flush

pr.print();


An empty sticker is printed when i execute this code. I already tried
to change the png image to a greyscale bitmap, but still nothing was
printed. I'm stuck for several hours. Someone has any tip for me?

Thanks in advance

Best regards

João Simas

Tres Finocchiaro

unread,
Sep 16, 2011, 12:40:52 PM9/16/11
to jzebra...@googlegroups.com, jZebra users
Joao,

Image printing via image URL is not yet supported. I've had some progress with this but have not been completely successful. It is printer language specific, Zpl2 is the language I'm targeting currently.

-Tres

> --
> To unsubscribe from this group, send email to jzebra-users...@googlegroups.com
>
> http://code.google.com/p/jzebra

Tung Quan

unread,
May 26, 2013, 11:02:40 PM5/26/13
to jzebra...@googlegroups.com
Hi All,

I'm having the same problem. Trying to print images using raw EPL2 command from a LP 2844. Has anyone got this worked?

Tres Finocchiaro

unread,
May 28, 2013, 9:09:17 AM5/28/13
to jzebra...@googlegroups.com
Tung,

EPL2 has not yet been implemented in the appendImage() function.

For now, you should use another program to create the print file, and then append that raw file using jZebra.

-Tres

 
Notice there is no option for EPL2: 
switch (lang) {
   case CPCL:
       return "EG " + (int)(w/8) + " " + h + " 0 0 " + data;
   case ESCP:   
   case ESCP2:
       // n1 and n2 represent the image height in 2-byte format
       // example: the number "09" would be "0009"
       //          the number "10" would be "000A"
       //          the number "255" would be "00FF"
       //          the number "510" would be "FFFF"
       // Images larger than 510pixels must not be supporteds
       if (h > 510) {
           return " ESCP IMAGES TALLER THAN 510 PIXELS NOT SUPPORTED ";
       }
       int n1 = h > 255 ? h - 255 : 0;
       int n2 = h <= 255 ? h : 255;
       return (char) 27 + (char) 86 + (byte) n1 + (byte) n2 + new String(getBytes(hex), charset.name());
   case ZPLII:
       return "^GFA," + bytes + "," + bytes + "," + perRow + "," + data;
   default:
       return " ERROR CONVERTING JZEBRA IMAGE TO COMMANDS "; 
}


Tung Quan

unread,
Jun 3, 2013, 10:15:22 PM6/3/13
to jzebra...@googlegroups.com
Hi Tres,

Thank you so much for your hardwork. So sorry for the late reply. As far as I understand, I have to convert the image into raw data by myself and jZebra can have me deliver it to the printer, is that correct? If that is the case, how do I transfer raw data using jZebra?

Thanks,

Tres Finocchiaro

unread,
Jun 4, 2013, 1:03:47 AM6/4/13
to jzebra...@googlegroups.com
Tung,

 I have to convert the image into raw data by myself and jZebra can have me deliver it to the printer, is that correct?

Correct.

how do I transfer raw data using jZebra?

The safest way is to append all of your commands using a file or url using appendFile() function.

You can also append it in base64 using append64() function.

There's a chance you can append the image data using JavaScript too, so long as you NEVER use the \x00 hex (NUL) character.

-Tres

--
--
To unsubscribe from this group, send email to jzebra-users...@googlegroups.com
 
http://code.google.com/p/jzebra
 
---
You received this message because you are subscribed to the Google Groups "jZebra users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jzebra-users...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
- Tres.Fin...@gmail.com

Tung Quan

unread,
Jun 12, 2013, 6:49:05 AM6/12/13
to jzebra...@googlegroups.com
Hi Tres,

Sorry still struggling with this. Bear with me. I have managed to convert both the text and the image (in .jpeg) format to base 64 and transferred to the printer using .append64() function but nothing come out. How would you put this command:

G590,200,15,50,[bytedata]
P1

into base64? What I did was convert the first part "G590,200,15,50" into a base64 string, let's call it X. I then convert the image into another base64 string Y, convert "P1" into a base64 string Z. Now that I have 3 strings. I use

applet.append64(X+Y+Z);

but an error pop out from browser... Do you happen to have any working example with image using appendbase64() ? Thank you very much.


On Friday, 16 September 2011 17:54:14 UTC+8, JSimas wrote:

Tres Finocchiaro

unread,
Jun 12, 2013, 8:44:55 AM6/12/13
to jzebra...@googlegroups.com
Tung,

Here is an article on it:


If you are willing to sponsor this feature, email me directly, tres.fin...@gmail.com and we can discuss.

-Tres

--
--
To unsubscribe from this group, send email to jzebra-users...@googlegroups.com
 
http://code.google.com/p/jzebra
 
---
You received this message because you are subscribed to the Google Groups "jZebra users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jzebra-users...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Tres Finocchiaro

unread,
Sep 4, 2013, 10:48:31 PM9/4/13
to jZebra users
Sorry to bump an old email thread, but this PNG feature was sponsored and implemented in versions 1.5.3 and higher.

Feel free to try this out (1.5.6 linked).
Reply all
Reply to author
Forward
0 new messages