Android Question Has anyone successfully printed an image on a thermal printer from NVRam?

Dman

Active Member
Licensed User
Longtime User
I have spent days and days reading every piece of ESC/POS documentation I can find and to tell the truth, I honestly think I am dumber now than when I started.

I have saved the image to the printer and can print it using the utilities software that came with the printer but for the life of me I cannot get this to print from my application. Text is fine but this image thing is killing me.

I have tried this line of code (FS p n m) where my image is in slot 1 of my printer:

B4X:
PrintBuffer = PrintBuffer & Chr(28) & Chr(112) & "1" & "0"

and gotten nothing. I have tried every variation that I can think of. I am not sure if I have to define the image first or what.

Also I have seen that the above command is becoming obsolete and it is being replaced with GS(L GS8L which screws me up even more. I am totally lost on that one.

Does anyone that has successfully been able to print like this have any guidance?
 

Daestrum

Expert
Licensed User
Longtime User
I could only suggest trying the following, as looking at the ESC/POS commands, it looks like you are sending the wrong ones.
the n and m values required are 0x01 and 0x00, you are sending 0x31 and 0x30

change
B4X:
PrintBuffer = PrintBuffer & Chr(28) & Chr(112) & "1" & "0"

to
B4X:
PrintBuffer = PrintBuffer & Chr(28) & Chr(112) & chr(1) & chr(0)

I may be wrong, as it's the first time I have seen anything to do with an ESC/POS printer. :)
 
Upvote 0

Dman

Active Member
Licensed User
Longtime User
Thanks, that is one of the many combinations that I have tried to no avail.....

I tried it again just in case though but still no good.
 
Upvote 0

RandomCoder

Well-Known Member
Licensed User
Longtime User
A long time ago I needed to write an application to print labels on a Zebra thermal printer because we were upgrading the PC's and the software for the printer was unsupported. I remember that I did it by first capturing what was being sent to the printer. I then worked out which were the variable fields and then created my app.
Maybe this is something you could try? Once you have the right codes the job is made much more simple.

Kind Regards,
RandomCoder
 
Upvote 0

Dman

Active Member
Licensed User
Longtime User
I can find where a lot of people say that it is easy to print an image from nvram and even the code they use to print but I haven't had any luck. There is a command set to define the image but I am not sure if it is needed when printing an image that is stored on the printer.
 
Upvote 0

RandomCoder

Well-Known Member
Licensed User
Longtime User
Can you upload the manual or provide a link to it so that we can check which op codes you need to be using?
 
Upvote 0

RandomCoder

Well-Known Member
Licensed User
Longtime User
I believe that the reason you are getting no print output is because you first need to define the image using "fs q" before issuing the print image command. The example is shown on page 196. Also note that there is a warning on the previous page "If the NV bit image exceeds one line of print area, the printer does not print it."
I also wonder if it might be easier to program a Macro and then just issue an Execute Macro command but I've not got that far in the manual yet :)
 
Upvote 0

RandomCoder

Well-Known Member
Licensed User
Longtime User
Well I can quite understand why you're lost, me too!
But I have found two other resources that may be useful, this first one use's the same command as you have already tried but stores the values in a file and just sends the file to the printer (might be worth a shot?) http://www.experts-exchange.com/Programming/Editors_IDEs/Q_22418070.html#a18695354
And this other link provides an additional resource/manual for the Epson TM range of printers and provides a detailed approach using c# http://nicholas.piasecki.name/blog/...tm-t88iii-receipt-printer-using-c-and-escpos/
But as you have the PC software and that prints what you want, then I'd be inclined on just setting it to print to a file and then interrogate the contents of the file to see what is sent. You could even save this file and use it in your own app.
 
Upvote 0

Dman

Active Member
Licensed User
Longtime User
Well, I couldn't make heads or tails from that but it did give me an idea. I changed my google search from "print image" to print logo and viola! I found it. I actually printed an image from my printers ram. Once I get it printing the correct image, I will post the code I used.

Thanks a million!
 
Upvote 0

RandomCoder

Well-Known Member
Licensed User
Longtime User
@Dman mighty glad you got it sorted. I know how frustrating it is to have something that should be relatively simple made so bloody difficult. :confused:
 
Upvote 0

Dman

Active Member
Licensed User
Longtime User
Finally. I have racked my brain and racked my brain and finally figured it out thanks to a small detail I noticed in one of your links.

Here is the code to print the image in slot one. I finally figured out that the key code is the slot address.

This code will print the image in slot 1 (address 00)
B4X:
 PrintBuffer = PrintBuffer & Chr(29) & Chr(40) & Chr(76) & Chr(6)& Chr(0)& Chr(48)& Chr(69) & Chr(48) _
     & Chr(48) & Chr(1)& Chr(1)

And this code will print the image in slot 2 (address 01)
B4X:
PrintBuffer = PrintBuffer & Chr(29) & Chr(40) & Chr(76) & Chr(6)& Chr(0)& Chr(48)& Chr(69) & Chr(48) _
     & Chr(49) & Chr(1)& Chr(1)

Thank you for all your help. This has been an experience but I am a happy camper now. :)
 
Upvote 0

RandomCoder

Well-Known Member
Licensed User
Longtime User
Well done :D
I couldn't work out what the key code was used for. Fancy calling it something like that, wouldn't slot or card address have been much more appropriate! Glad you got it working.
 
Upvote 0

Dman

Active Member
Licensed User
Longtime User
Thanks again for the help. I have figured out what everything is in the command line except for the pL and pH. I have read what the official definition for it is but I haven't been able to translate it into redneck so I can understand it. :)
 
Upvote 0

RandomCoder

Well-Known Member
Licensed User
Longtime User
As I understand, these two values are defining how many bytes follow after the pH parameter.
In your case...
GS ( L pL pH m fn kc1 kc2 x y
So pL=6 (i.e a byte for each value after pH), its letting the printer know how many bytes to expect to read in.
The value pH will normally be zero unless you intend to send image data in which case each time pL exceeds 256 bytes pH will need to be incremented.
Hope that makes some sense.
 
Upvote 0

Dman

Active Member
Licensed User
Longtime User
That makes a little sense. I'm not sure how to figure what pL should be or how you know how many bytes you need.
 
Upvote 0

RandomCoder

Well-Known Member
Licensed User
Longtime User
It looks like each parameter consumes 1 byte which is why pL is 6 in the example above i.e. 1 byte for each of the letters after pH (m gn kc1 kc2 x and y)
The function you are now using is defined by the parameters sent after the GS ( L and so the printer uses pL and pH to know how many bytes to read in.
Maybe another example will help?
To delete all NV graphics data is
GS ( L pL pH m fn d1 d2 d3
And so pL is 5 for this function (bold parameters). pH is always going to be 0 until more than 256 bytes of data is being sent.
 
Upvote 0

picenainformatica

Active Member
Licensed User
Longtime User
send to printer:

B4X:
dim B(4) as byte
b(0)=28
b(1)=112
b(2)=1
b(3)=48

if you want to use a string convert to Bytes in UTF8
 
Upvote 0
Top