PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
VS 2010 Extra Margin upon printing-VBForums
Results 1 to 4 of 4

Thread: Extra Margin upon printing

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,133

    Extra Margin upon printing

    Hello
    I am using the following code. When i preview the PrintDocument the "test" is drawn at 50,50, but when i print the document its printing using some extra margin ( i think its printing at 100,100)

    vb Code:
    1. Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
    2.         e.Graphics.DrawString("Test", Me.Font, Brushes.Black, 50, 50)
    3.     End Sub
    4.  
    5.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    6.         Me.PrintDialog1.Document = Me.PrintDocument1
    7.  
    8.         If Me.PrintDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
    9.             Me.PrintDocument1.PrinterSettings = Me.PrintDialog1.PrinterSettings
    10.             Me.PrintDocument1.Print()
    11.  
    12.         End If
    13.     End Sub
    14.  
    15.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    16.         Me.PageSetupDialog1.Document = Me.PrintDocument1
    17.         If Me.PageSetupDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
    18.             Me.PrintDialog1.PrinterSettings = Me.PageSetupDialog1.PrinterSettings
    19.             Me.PrintDocument1.DefaultPageSettings = Me.PageSetupDialog1.PageSettings
    20.         End If
    21.     End Sub

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    22,461

    Re: Extra Margin upon printing

    You need to set the e.DefaultPrintSettings Margins and OriginAtMargins properties

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,133

    Re: Extra Margin upon printing

    I didn't find e.DefaultPrintSettings property in PrintDocument_PrintPage Event

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    22,461

    Re: Extra Margin upon printing

    Quote Originally Posted by aashish_9601 View Post
    I didn't find e.DefaultPrintSettings property in PrintDocument_PrintPage Event
    Sorry. It's the PrintDocument' DefaultPageSettings

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width