> Hi everyone,
>
[quoted text clipped - 19 lines]
>
> graphics2D.drawString(("Page " + (pageIndex + 1)), 223, 643);
A slightly less hard-coded way would be:
graphics2D.drawString(("Page " + (pageIndex + 1)),
pageFormat.getWidth() / 2 - 50,
pageFormat.getHeight() - 200);
(See also the javadoc of java.awt.print.PageFormat)
> }
>
[quoted text clipped - 4 lines]
>
> I hope someone can help me with this problem

Signature
"Thomas:Fritsch$ops:de".replace(':','.').replace('$','@')
Birkemose - 03 Feb 2005 21:06 GMT
"Thomas Fritsch" wrote...
> A slightly less hard-coded way would be:
> graphics2D.drawString(("Page " + (pageIndex + 1)),
> pageFormat.getWidth() / 2 - 50,
> pageFormat.getHeight() - 200);
> (See also the javadoc of java.awt.print.PageFormat)
I personally would not advertice this as good programming practice.....
opinions might differ
You need to find the size of your printing area, make sure you dont get
fooled by margins..
To get the size of a text, this snippet will do, based on a graphics context
Code stripped down for clarity
public Point textSize( String S, Graphics Graph ) {
Graphics2D Graph2D;
TextLayout Layout;
Graph2D = ( Graphics2D )Graph;
Layout = new TextLayout( S, Graph.getFont( ),
Graph2D.getFontRenderContext( ) );
return( new Point( ( int )Layout.getBounds( ).getWidth( ), (
int )Layout.getBounds( ).getHeight( ) ) );
}
Regards
LB