Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Centering any font on page

Status
Not open for further replies.

sjulian

Programmer
Aug 15, 2000
56
US
I am using the following code to print a string on the center of a page. However, it comes out somewhat off center to the right. (I have encountered other problems when using the textwidth property)
The code is as follows:
With Printer
.Font = "Arial"
.FontBold = True
.FontSize = 14
strTemp = aryHeadingItems(0)
FieldWidth = TextWidth(strTemp)
FieldHeight = TextHeight(strTemp)
.CurrentX = ((LeftBoundry + RightBoundry)*.5) - (FieldWidth * .5)
.CurrentY = FieldHeight
Printer.Print strTemp


Thanks!
 
Hi sjulian

Try this

dblWidth = Printer.TextWidth(strTemp) / 2
dblHeight = Printer.TextHeight(strTemp) / 2
Printer.CurrentX = Printer.ScaleWidth / 2 - dblWidth
Printer.CurrentY = Printer.ScaleHeight / 2 - dblHeight
Printer.Print strTemp
Printer.EndDoc

Jon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top