?
Solved

Can I print at 300 dpi?

Posted on 2000-02-21
8
Medium Priority
?
856 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 8

Expert Comment

by:diakov
ID: 2545332
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
ID: 2548531
Adjusted points to 100
0
 

Author Comment

by:youngs101497
ID: 2571460
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
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
LVL 8

Expert Comment

by:diakov
ID: 2571728
:-) I got the code snippet I posted just from there :-)

Take care,
  Nik
0
 
LVL 1

Accepted Solution

by:
gageot earned 300 total points
ID: 2575665
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
ID: 2575933
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
ID: 2576000
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
ID: 2576213
Thanks.

Nik.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn different types of Android Layout and some basics of an Android App.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Suggested Courses
Course of the Month13 days, 23 hours left to enroll

800 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