Author
Print raw bytes to thermal printer
Tobia Scapin
Greenhorn
Joined: Mar 19, 2010
Posts: 5
posted May 27, 2010 02:41:18
0
Hello everyone,
I have to write a simple applet to print a byte array to a thermal printer (raw textual stream, it is a ESCPOS printer).
I can not understand how to open a RAW stream to the printer, i tried to create a SimpleDoc object and send it to the PrintService but i can not find the correct flavor. Maybe a need a StreamInput object to write, but how to get it from my printer?
Thanks.
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
What DocFlavor are you using? How are you creating the SimpleDoc ? How are you looking up the PrintService ?
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Tobia Scapin
Greenhorn
Joined: Mar 19, 2010
Posts: 5
posted May 27, 2010 04:38:20
0
I get the printerservice with a loop on this array (checking the service name):
And i print with this:
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
And what does service.getSupportedDocFlavors() return? Is DocFlavor.BYTE_ARRAY.AUTOSENSE one of them?
Roldan Baldo
Ranch Hand
Joined: Aug 11, 2009
Posts: 99
Hi, sorry for reviving this old thread, but I've got a similar problem with this, and to avoid double posting.
I also have problem in printing, I use
but the printer print some code/text like
%!PS-Adobe-3.0
%%BoundingBox: 17 19 595 773
%%Pages: 1
.....
%%BegingFeature: *InputSlot Upper
2 dict up /PageSize [612 792] put dup /ImagingBox null put setpagedevice
%%EndFeature
....
%%EndSetup
%%Page: 1 1
%%BeginPageSetup
%%EndPageSetup
%%BeginDocument: nondsc
Hello World
%%EndDocument
%%EOF
I just wanted to print the "Hello World", how will I eliminate the unwanted text in the output? is there something in my code?
My printer is ESC/POS
Model P06-P
My platform: Mac OS 10.8.2
Any help would be much appreciated. Thanks.
subject: Print raw bytes to thermal printer