Results 1 to 3 of 3

Thread: ssues with Printing to center of page

  1. #1
    vbnetbeginner1 is offline VB.NET Forum Newbie
    .NET Framework
    .NET 2.0
    Join Date
    Apr 2012
    Posts
    1
    Reputation
    0

    ssues with Printing to center of page

    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!!!

  2. #2
    JuggaloBrotha's Avatar
    JuggaloBrotha is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Jun 2004
    Location
    Lansing, MI; USA
    Posts
    4,321
    Reputation
    959
    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?
    Currently using: VS 2010 Ultimate on Win7 Ultimate x64.


  3. #3
    JohnH's Avatar
    JohnH is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    14,177
    Reputation
    2368
    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.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Harvest time tracking