• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Print raw bytes to thermal printer

 
Tobia Scapin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What DocFlavor are you using? How are you creating the SimpleDoc? How are you looking up the PrintService?
 
Tobia Scapin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get the printerservice with a loop on this array (checking the service name):


And i print with this:
 
Rob Spoor
Sheriff
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And what does service.getSupportedDocFlavors() return? Is DocFlavor.BYTE_ARRAY.AUTOSENSE one of them?
 
Roldan Baldo
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic