• Post Reply Bookmark Topic Watch Topic
  • New Topic

Want to print a file using java program  RSS feed

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 56838
173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or, maybe this tutorial and this one.
 
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've done that, its easy.
 
Nithin Madathil
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes my printer knows the format of print data.
 
Sheriff
Posts: 21182
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But first check out java.awt.Desktop - it has a built-in print method that can print many file formats for you.
 
Nithin Madathil
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Print to local printer using FileOutputStream
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!