wood burning stoves 2.0*
The moose likes Java in General and the fly likes Want to print a file using java program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Want to print a file using java program" Watch "Want to print a file using java program" New topic
Author

Want to print a file using java program

Nithin Madathil
Greenhorn

Joined: Aug 26, 2006
Posts: 11
Hi
I am looking to invoke the windows print dialog using a java program and pass a file to print when I click on the print button on the print box. Can anyone help me with a piece of code regarding this?

Nithin
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
Does your printer (or printer driver) know how to handle the file format? Otherwise, you'll have to implement printing yourself.

An introduction to printing can be found with http://java.sun.com/javase/6/docs/technotes/guides/jps/spec/jpsTitle.fm.html


Ping & DNS - updated with new look and Ping home screen widget
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36486
    
  16
Or, maybe this tutorial and this one.
Ryan Beckett
Ranch Hand

Joined: Feb 22, 2009
Posts: 192
I've done that, its easy.
Nithin Madathil
Greenhorn

Joined: Aug 26, 2006
Posts: 11
Yes my printer knows the format of print data.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19543
    
  16

But first check out java.awt.Desktop - it has a built-in print method that can print many file formats for you.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Nithin Madathil
Greenhorn

Joined: Aug 26, 2006
Posts: 11
I was trying to use SDK 1.2 Printing API Tutorial. I have invoked the print dialog but how can get a file to printer.
Ryan Beckett
Ranch Hand

Joined: Feb 22, 2009
Posts: 192



Print to local printer using FileOutputStream
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Want to print a file using java program
 
Similar Threads
how to print in java
bundling jre with an app/ print problem
File IO
Checking Printable Characters
Print a document using java API