• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to send raw data to printer

 
sushmi shrestha
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I gotta need to print some pin codes on paper directly after generating pin code. Any references of APIs in java ?

I am looking into javax.print library
Any other better alternatives?

Please help me out.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope. The Print Service API is the extent of your options.
 
Joe Ess
Bartender
Pie
Posts: 9266
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your OS and printer supports it, you can access a printer like you would a file, like in this example from the old Java Programmer's FAQ:

 
sushmi shrestha
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankyou very much for helping.
I tried your code. Nothing got printed neither any errors.

I tried for the code below. The code also didn't work.



I am quite screwed up here. Neither I'm getting the expected output nor any errors are traced. I'm using network printer. Printer gets the document printed from other application but the code doesn't work leaving me no clue.

Waiting for helping hands.
 
Ritesh Agrawal
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Please refer to the following URL.

http://www.tek-tips.com/viewthread.cfm?qid=1126898&page=1

I tried your code and although it seems correct and same as the sample provided in the Java 6 API Docs, you need to wait for the Printing Job to be completed before closing the InputStream.

I added the code provided in the above URL, but it still didn't work for me. Thus, I added a Thread.sleep(20000); //sleep for 20 seconds to allow for Job to be completed, and then close the input stream.

Try this, hopefully it will work for you.
 
Albert Kam
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yupe, you'd have to wait.

I learned about it in the online Java Almanac 1.4 at http://www.exampledepot.com/egs/javax.print/WaitForDone.html?l=rel

Here's my exerpt :



Good Luck,
Albert Kam
[ October 31, 2008: Message edited by: Albert Kam ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic