Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to do fast draft print in dotmatrix printers using Java?

Status
Not open for further replies.

Gireeshnemath

Technical User
Mar 18, 2003
8
0
0
IN
Hi all,
I am doing an inventory software using Java. While printing receipts and bills, I need to get printout in draft mode in dotmatrix printer inorder to get faster and cheaper print out. (just like plain old DOS mode printing) Is there any such provision in Java? If anybody know, pls help..

Thanking you all in advance,
Gireesh.
 
I didn't test it, so perhaps this is completely nonesense:

Print to System.out, and redirect it to the printer.
On my System this would be:
Code:
java DotPrinter | lpr
On a more dos-like System:
Code:
java DotPrinter > LPR
java DotPrinter > PRN
Perhaps specifying the printer as Outputstream in the program itself is possible too?



seeking a job as java-programmer in Berlin:
 
Ya. It works. But I need to print from the application itself...

Thanx n regds,
Gireesh
 
Depending on the printer, you can just open a socket to the printer if it is networked, and dump the data down the pipe to it.
For example, this works on an HP 8100 using the jetdirect port :

Code:
Socket s = new Socket("printer_1", 9100);
OutputStream os = s.getOutputStream();
os.write("Hello World".getBytes());
os.flush();
os.close();
s.close();

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top