File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Print raw bytes to thermal printer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Print raw bytes to thermal printer" Watch "Print raw bytes to thermal printer" New topic
Author

Print raw bytes to thermal printer

Tobia Scapin
Greenhorn

Joined: Mar 19, 2010
Posts: 5
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: 19693
    
  20

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 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Tobia Scapin
Greenhorn

Joined: Mar 19, 2010
Posts: 5
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: 19693
    
  20

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Print raw bytes to thermal printer