Solved

Can I print at 300 dpi?

Posted on 2000-02-21
8
834 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
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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to execute a Python program and gather return output in Java 2 49
wild fly 8 startup error 2 43
spring maven example issues 3 44
DTD and JAVA versions 1 33
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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 about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

726 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