• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Print raw bytes to thermal printer

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And what does service.getSupportedDocFlavors() return? Is DocFlavor.BYTE_ARRAY.AUTOSENSE one of them?
 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic