Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Can I print at 300 dpi?

Posted on 2000-02-21
8
Medium Priority
?
873 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
Technology Partners: 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!

 
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
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…
Suggested Courses

596 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