Print margins not working

  • Thread starter Thread starter scrawnyguns
  • Start date Start date
S

scrawnyguns

There's probably something easy I'm missing here.

When I run a print operation in my program (Microsoft VB.Net Form) I
have some code that sets the print margins so that it leaves a nice
gap, however, these gaps do not work. No matter what I set the margins
to, the printer (HP Color Laserjet) always prints the same (top left
corner with about a 5mm gap).

Please Help.

Here's my code (the landscape bit works by the way):

Private Sub MenuPrint_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MenuPrint.Click
Dim result As DialogResult

PrintDialog1.AllowSomePages = True
PrintDialog1.ShowHelp = True
PrintDialog1.Document = PrintDocument1
result = PrintDialog1.ShowDialog()
If (result = DialogResult.OK ) Then
CaptureScreen()
With PrintDocument1
With .DefaultPageSettings
.Landscape = True
.Margins.Left = 100
.Margins.Top = 100
.Margins.Right = 100
.Margins.Bottom = 100
End With
.Print()
End With
End If
End Sub

Cheers.
 
It's quite common to mix up the role of
PrinterSettings.DefaultPageSettings and
PrintDocument.DefaultPageSettings.


You have to copy each setting of

..PrinterSettings.DefaultPageSettings

over

PrintDocument.DefaultPageSettings

or set directly the last one.

-tom



(e-mail address removed) ha scritto:
 
Back
Top