The Source for Java Technology Collaboration

Home » java.net Forums » Java Desktop Technologies » Java 2D

Thread: Printing Resolution

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 2 - Last Post: May 25, 2006 2:55 PM by: diverdad
diverdad

Posts: 18
Printing Resolution
Posted: May 25, 2006 1:37 PM
  Click to reply to this thread Reply

How do I take advantage of the full resolution of the printer? When I do a default print using the printer service I seem to get the resolution of the window that I am printing, is there some way of getting the resolution of the printer not that of the display device? I have a Java2D graphics window, and have tried the following with no success:

Graphics2D graphics2D = (Graphics2D) graphics;

// Scale the printout to fit the pages.
double scalex = format.getImageableWidth() / getWidth();
double scaley = format.getImageableHeight() / getHeight();
double scale = Math.min(scalex, scaley);
// translate to the printable (0,0) location on the paper.
graphics2D.translate((int) format.getImageableX(),
(int) format.getImageableY());
graphics2D.scale(scale, scale);
// then paint the graphics 2D object.


I still get jagged lines on the printer device. The original window maybe displayed at 600x600.

Phil Race
Re: [JAVA2D] Printing Resolution
Posted: May 25, 2006 2:00 PM   in response to: diverdad
  Click to reply to this thread Reply

I suspect you are printing a double-buffered swing component window
using paint().
That paints to the swing back buffer which is unsurprisingly at screen
resolution
and then that is what you are sending to the printer.

Use Component.printAll() to print a Component, *not* Component.paint().

-phil.

java2d@javadesktop.org wrote:

>How do I take advantage of the full resolution of the printer? When I do a default print using the printer service I seem to get the resolution of the window that I am printing, is there some way of getting the resolution of the printer not that of the display device? I have a Java2D graphics window, and have tried the following with no success:
>
> Graphics2D graphics2D = (Graphics2D) graphics;
>
> // Scale the printout to fit the pages.
> double scalex = format.getImageableWidth() / getWidth();
> double scaley = format.getImageableHeight() / getHeight();
> double scale = Math.min(scalex, scaley);
> // translate to the printable (0,0) location on the paper.
> graphics2D.translate((int) format.getImageableX(),
> (int) format.getImageableY());
> graphics2D.scale(scale, scale);
> // then paint the graphics 2D object.
>
>
>I still get jagged lines on the printer device. The original window maybe displayed at 600x600.
>[Message sent by forum member 'diverdad' (diverdad)]
>
>http://forums.java.net/jive/thread.jspa?messageID=116274
>
>===========================================================================
>To unsubscribe, send email to listserv@java.sun.com and include in the body
>of the message "signoff JAVA2D-INTEREST". For general help, send email to
>listserv@java.sun.com and include in the body of the message "help".
>
>

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".


diverdad

Posts: 18
Re: Printing Resolution
Posted: May 25, 2006 2:55 PM   in response to: diverdad
  Click to reply to this thread Reply

Thanks I'll try that.




 XML java.net RSS