Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 02-03-2005, 03:55 AM   #1 (permalink)
freesoft_2000
Code Monkey
 
Join Date: Oct 2004
Posts: 51
freesoft_2000 is on a distinguished road
Question Centering

Hi everyone,

I am trying to center a page number on the bottom center on a printed page but i am having some trouble doing it.

I am using the windows default page dialog where the user can select the desired page size(ie, a1,a2,a4) but i am unable to center the page number on the bottom center.

For now i am using hard-coded values but these values only work for the a4 paper format.

Code:
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) 
{
//other codes
//other codes

Font f = new Font("Arial", Font.PLAIN, 12);
graphics2D = (Graphics2D) graphics;
graphics2D.setFont(f);

graphics2D.drawString(("Page " + (pageIndex + 1)), 223, 643);

}
I know centering the page number involves the FontMetrics class but i can't seem to get it right. What i would like is for the user to select any page format using the windows page dialog and the page number is drawn on the bottom center of the page when it is printed

I hope someone can help me with this problem

Thank You

Yours Sincerely

Richard West
freesoft_2000 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 03:38 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting