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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ScaleMode

Status
Not open for further replies.

sunila7

Technical User
Joined
Apr 11, 2001
Messages
1,087
Location
US
Hi,

Iam trying to print a card through the printer object. The card is approx 3.5 inch long. Now the problem is that if I try to Print a long Text(Which comes up from DB, as entered by the user), part of the text is not printed on the card. The Font iam using is Arial and size is 20.

Now i want to reduce the size of the font till it fits into this paper size.

This is the code Iam trying to use
P.DrawMode = 13
P.FontSize = 20
For i = 20 To 8 Step -2
If P.TextWidth(C.PoolName) >= P.Width Then
P.FontSize = i
Else
Exit For
End If
Next

but somehow a Fontsize of 18 prints the Text in the card, though P.TextWidth(C.PoolName) shows no of Twips to be 12000 and No of Twips possible in the card(accroding to the length) is 4944

How is it possible....

Thanks for help

Sunil
 

I may not describe this right but here goes.

The printer object seems to hold the initial setting given to it until you send an EndDoc to it, then you can once again set it to a different value. My suggestion would be to try to use the TextWidth of the form or a picture box to do your TextWidth test until you reach a value that will fit. Then set the fontsize of the printer object.

I Hope this helps, Good Luck

 
Hi,

Thanks for the response.

Actually the data that is being printed is not being displayed on a form, it is directly sent to the printer, when a command button is pressed. data is fetched from the DB on the click and sent to the printer...

So i cannot set it on the form and then send to printer


Sunil
 

You do not need to set it on the form you just need to use the form. Give this a try...

[tt]
Private Sub Command1_Click()

Dim MyString As String

MyString = "This is a test"

Me.Font.Size = 20
Me.FontName = "Arial"

MsgBox Me.TextWidth(MyString)

Me.Font.Size = 8

MsgBox Me.TextWidth(MyString)

End Sub


[/tt]
 

Hi,

y does this return 2 different value for the same text C.PoolName.

frmname.TextWidth(C.PoolName) = 3765
P.TextWidth(C.PoolName) =15595

Thanks

Sunil
 
Hi,

The text Iam trying to print seems to fit, when I try to use the form that is no of twips for printer is 4944 and no of twips for the text
frmname.TextWidth(C.PoolName) is 3765 for Arial size 20. but when actually it is printed out, it doesnt fit, any ideas.

Thanks
Sunil
 

Scale modes must be different for each so...

[tt]
Me.ScaleMode = Printer.ScaleMode
[/tt]

Good Luck
 
Hi,

The problem with my code was that i was not setting the font type before setting the font size.....

Thanks for ur help vb5prgmr..

Sunil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top