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 Want to print a file using java program Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply 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: 35252
    
    7
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


Android appsImageJ pluginsJava web charts
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32708
    
    4
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: 19216

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
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://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Want to print a file using java program
 
Similar Threads
Checking Printable Characters
File IO
Print a document using java API
how to print in java
bundling jre with an app/ print problem