Solved

Can I print at 300 dpi?

Posted on 2000-02-21
8
821 Views
Last Modified: 2012-08-13
Is there any way to print a graphic at a resolution better than 72 dpi?

I can get the resolution (72) for printJob but I can't find anything which will allow me to change the resolution.

Is the option only available in java 1.2 or 1.3?

AJY
0
Comment
Question by:youngs101497
  • 4
  • 2
  • 2
8 Comments
 
LVL 8

Expert Comment

by:diakov
Comment Utility
If your printer is postscript your actually 'partially' printing at a higher resolution.
Make an experiment and try to print a String with Font size of 3 points. If you printer is 300dpi the text will be still readable. The problem is then with lines, as they have default tickness and other settings set to match the Java 72dpi. You can try to play with the Java2D api to adjust these.

If you want to print Java 2 Swing components, be sure you disable the doublebuffering. This code would allow you do this:

  public static void disableDoubleBuffering(Component c) {
    RepaintManager currentManager = RepaintManager.currentManager(c);
    currentManager.setDoubleBufferingEnabled(false);
  }

  public static void enableDoubleBuffering(Component c) {
    RepaintManager currentManager = RepaintManager.currentManager(c);
    currentManager.setDoubleBufferingEnabled(true);
  }

Cheers,
  Nik
0
 

Author Comment

by:youngs101497
Comment Utility
Adjusted points to 100
0
 

Author Comment

by:youngs101497
Comment Utility
I found a great site which explained high resolution printing and also gave an example.

http://www.apl.jhu.edu/~hall/java/Swing-Tutorial/Swing-Tutorial-Printing.html

You may want to use this reference in answering future questions.
0
 
LVL 8

Expert Comment

by:diakov
Comment Utility
:-) I got the code snippet I posted just from there :-)

Take care,
  Nik
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 1

Accepted Solution

by:
gageot earned 100 total points
Comment Utility
All you have to do is set the thickness of lines in youre print method:

public int print (Graphics g, PageFormat aFormat, int aPage)
{
      float currentDPI = 72f ;
      float wantedDPI = 300f ;

      BasicStroke stroke = new BasicStroke (currentDPI / wantedDPI) ;
      ((Graphics2D) g).setStroke (stroke) ;

      // drawing job
}
0
 
LVL 8

Expert Comment

by:diakov
Comment Utility
to gageot :

Your suggestion is intriguing. Could you post a way to determine the dpi capability of the selected printer?

Without this feature, it is a wild guess, isn't it?

Cheers,
   Nik
0
 
LVL 1

Expert Comment

by:gageot
Comment Utility
Only JDK 1.3RC1 can give you the printing capabilities of the printer.
ie quality modes, resolution, media types, ...

Resolution can be found with PageAttribute.getPrinterResolution().

For JDK 1.2, I used the 300dpi value for both a 300dpi and a 1200dpi
printer and I was fine. Way better than with default value of 72dpi.
0
 
LVL 8

Expert Comment

by:diakov
Comment Utility
Thanks.

Nik.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will learn how to implement Singleton Design Pattern in Java.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now