• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

how to send raw data to printer

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nope. The Print Service API is the extent of your options.
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
All of the following truths are shameless lies. But what about this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic