1,105,177 Community Members

Printing BufferedImage ?!?

Member Avatar
uurcnyldrm
Light Poster
26 posts since Jan 2012
Reputation Points: -3 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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.

Member Avatar
StephNicolaou
Posting Whiz in Training
204 posts since Nov 2007
Reputation Points: 32 [?]
Q&As Helped to Solve: 18 [?]
Skill Endorsements: 0 [?]
 
2
 

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.

Oracle:
http://docs.oracle.com/javase/tutorial/2d/printing/printable.html

http://docs.oracle.com/javase/tutorial/2d/printing/dialog.html

Class file:
http://docs.oracle.com/javase/1.4.2/docs/api/java/awt/print/PrinterJob.html

Hope that helps :)

Member Avatar
dantinkakkar
Junior Poster
174 posts since Aug 2011
Reputation Points: 19 [?]
Q&As Helped to Solve: 22 [?]
Skill Endorsements: 4 [?]
 
0
 

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: http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/desktop_api/ it's pretty easy to manipulate). Then, do away with the file, and your job is done.

Member Avatar
dantinkakkar
Junior Poster
174 posts since Aug 2011
Reputation Points: 19 [?]
Q&As Helped to Solve: 22 [?]
Skill Endorsements: 4 [?]
 
0
 

Add to the previous post:

http://www.daniweb.com/software-development/java/code/413537

Check this out. :)

( Desktop API Example, and if you're confused about the writing-to-file part; just use the ImageIO.write(params) function :) )

Member Avatar
dongiulio
Newbie Poster
1 post since Jul 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

http://www.daniweb.com/software-development/java/code/413537

Check this out. :)

The article seems to be missing ATM, It would have been interesting to see it, could you please repost it?

thanks a lot.

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