Question ssues with Printing to center of page

vbnetbeginner1

New member
Joined
Apr 15, 2012
Messages
1
Programming Experience
Beginner
IIssues with Printing to center of page
Please any great help on this will be appreciated.
I am trying to print to the center of page and to make the page portrait.
Here is the code I have now.




Dim ppagecounter As Int32 = 4
Public Sub printDoc_PrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim fontype As New Font("Tahoma", 12)

e.Graphics.DrawString("*section document", fontype, Brushes.Black, 100, 100)
ppagecounter= ppagecounter- 1
If ppagecounter= 0 Then
e.HasMorePages = False
Else
e.HasMorePages = True
End If
End Sub



Thanks!!!
 

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
How would you determine what the center of the page is?
How would you determine what the center of the string to be drawn is?

Once you know those two (extremely easy to google search), how would you go about determining what the left value should be given the two calculated values?
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,465
Location
Norway
Programming Experience
10+
I am trying to print to the center of page
A Simple way to do that is to use an instance of StringFormat class, set the two alignment properties, and pass it to DrawString method. Also pass the rectangle you want to center in, which would be e.MarginBounds here.
and to make the page portrait
Page settings is set before you print, with the PrintDocument.DefaultPageSettings, or dynamically during printing using the QueryPageSettings event where you set e.PageSettings. In both cases you set the Landscape property.
 
Top Bottom