Skip to main content

[JAVA2D] printing java 2D

1 reply [Last post]
Anonymous

I am writing a program that performs different types of image manipulation. I have set up my image canvas class (which is where the images are displayed) to print using the printerable interface, but it doesn't work well at all. The java print dialog that comes up seems to not work properly, and it always prints the same portion of the image no matter what I change the settings to be. Does anybody know how I may be able get my program to print according to the settings given in the print dialog. I want to first and foremost be able to compress the image to be able to print entirely on one page. Any help or info on the functionality of the java print classes or how to fix my problem would be much appreciated. Thank you.

And if any code excerpts for what im using to print awould be helpful, pleae let me know and I will post them.

*****************************************************************************

David Braun-Friedman

Programador de Telecomunicaciones

Departamento de Electr�nica y Comunicaciones

Email (CEIT): dbraun-friedman@ceit.es

Email (Fuera): dbra5506@postoffice.uri.edu

Tlfno: 943 212 800 Extensi�n: 289

M�vil: 628527739

Centro de Estudios e Investigaciones T�cnicas C.E.I.T.

Paseo Manuel de Lardizabal, 15
20018 San Sebastian

*****************************************************************************

===========================================================================
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".
[att1.html]
[image001.jpg]

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Phil Race

Braun-Friedman, David wrote:
> The java print dialog that comes up seems to not work properly,

Too little information to comment there.

> I want to first and foremost be able to compress the image to be able
to print

entirely on one page.

This is a fairly simple matter and there's more than one way
to do it, so here's just one approach
In the Printable :
1) Find the size of your image (image.getWidth() &getHeight())
2) Query the imageable area of the PageFormat
3) Use these two values to calculate a scale so that the image will fit
in the imageable area.
4) Scale the printer graphics (Graphics2D.scale()) accordingly
5) call drawimage.

http://java.sun.com/products/java-media/2D/forDevelopers/sdk12print.html

Has a tutorial on some of the printing classes.

This includes explanaation of imageable area and has some code showing
how to scale to fit.

-Phil.

===========================================================================
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".