Printing BufferedImage ?!?


How can I print a BufferedImage? I mean how can I send a BufferedImage to the printer? I heard something like printJob but I don't get it. Please help me about this. Thanks in advance.


It's printerJob, I would advise you to take a look at oracle documents which explain everything to do with setting the jobs, rendering with the Printable interface and opening the printer dialog.

Go through the document list and look at the examples and you should be able to then put something together. Also look at the class file and let us know if you have any problems.

Start with using the java.awt.print.* package as noted.


Class file:

Hope that helps :)

Excellent answer [I would like to add something to make the job easier, though.]

What you are looking for is the Desktop API. You can simply write the BufferedImage to a file (temporary, of course), and then use the Desktop API to send the file to the printer (read up on the Desktop API here: it's pretty easy to manipulate). Then, do away with the file, and your job is done.

This article has been dead for over six months: Start a new discussion instead
Start New Discussion
View similar articles that have also been tagged: