This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Java in General and the fly likes Printing on PC / Network Printer Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Printing on PC / Network Printer" Watch "Printing on PC / Network Printer" New topic
Author

Printing on PC / Network Printer

Will Barbee
Ranch Hand

Joined: Oct 01, 2008
Posts: 41
I have a program which develops a set of weekly schedule data and displays it to the user.

I would like to print that same data to the PC printer as a report (once the user clicked an appropriate button).

Is there an example anywhere that shows how to set up the Java necessary to point to the PC printer and then send the data to it as String data or whatever?

I would have to manage headings and footings but that is a program part I understand.

Thanks.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32830
    
    4
I don't know; the only printing on paper I have ever seen has been in GUIs: try here in the Java Tutorials.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19232

With AWT's version of printing, it should be possible. The only problem is that you can't call printDialog() which sets up the properties. You will have to do that manually. You could try to use printDialog() in a test class to see what you need to setup manually. I know the PrintService is one of them.

You can get the printer (PrintService) using PrinterJob.lookupPrintServices() or some of the methods in javax.print.PrintServiceLookup.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Will Barbee
Ranch Hand

Joined: Oct 01, 2008
Posts: 41
Thanks for your responses.

With the tutorial and the hint, I should be OK.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19232

And should you run into more problems, this thread will be here
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Printing on PC / Network Printer
 
Similar Threads
java printing - printing a pdf
Printing
printout for reports
How do you print to the non default printer?
Printing API Question