• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

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: 42974
76
  • 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: 61777
193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or, maybe this tutorial and this one.
 
Ranch Hand
Posts: 194
  • 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: 21466
97
Chrome Eclipse IDE Java Spring Ubuntu VI Editor 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: 194
  • 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!