• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to print a file

 
helen sol
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i can display the content of a file,but i want print
it to the printer,how i can invoke? i can deal with it
in c language ,but i don't know about how to deal with
it in java . please help!!
 
anandh
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to supply an object that implements the printable interface and then start the print job.
Check the API details for PrinterJob..
for more, http://www.apl.jhu.edu/~hall/java/Swing-Tutorial/Swing-Tutorial-Printing.html
 
helen sol
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i only print the content of the text file to EPSON1600k, i may invoke cprintf(...) method in c language,whether i can directly
invoke some methods in java.
 
anandh
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think Java has any "command" as such. Maybe you could look into redirecting the stdout to PRN..but that's a very wild guess and I myself won't trust it.
Why don't you just use the API and right objects/methods?
This question has been discussed already on Javaranch.. take a look: http://www.javaranch.com/ubb/Forum45/HTML/000165.html
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!