• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Printing a BufferedImage

Joel Cochran
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a class that extends JPanel and implements Printable. The paintComponent() method of this class creates an image which I can print, but with some problems:
1: The print quality if very poor. I have researched the PrintQuality class, but I cannot get it to work, I think becuase it is a protected class, so here is what I've tried:

But I get the following error:

SketchPane.java:589: cannot resolve symbol
symbol : constructor PrintQuality (javax.print.attribute.standard.PrintQuality
location: class javax.print.attribute.standard.PrintQuality
new PrintQuality( PrintQuality.HIGH ) )

2: I changed the PrintDialog to the Copnvenience method
The PrintQuality is shown under the Appearance tab but is input inhibited.

3: The Job Name is listed as Java Printing. I want to change the job name, so before the printDialog I have

But the Job Name still shows as Java Printing.

4: Finally, it is my understanding that the x,y coordinates are supposed to start at the inside of the left and top margins (as indicated here) but when I perform a print the image is cut off on the top and left by the width of the margin.

5: This class extends JPanel, and the image is slightly smaller than the JPanel (which has a gray background), so when I implement printable with the following method

I get part of the JPanel background on the printout. Is there no way I can simply print the BufferedImage of the graphic?

Printing is going to be a huge part of this project, so if anyone has any suggestions or good references I'd sure appreciate it!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic