Solved

Can I print at 300 dpi?

Posted on 2000-02-21
8
840 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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 100 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

Industry Leaders: 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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

707 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