Hello all! I am trying to set up my app to print with a custom paper size,
but it keeps failing with the following error:
PaperSize cannot be changed unless the Kind property is set to Custom.
On the line that reads:M_MiniLab el.DefaultPageS ettings.PaperSi ze.Height = 2000
I thought that I was setting the Kind to Custom in the row above. If anybody
has any input this would be greatly appreciated. Code below.
Thank You
Kevin
Imports System.Drawing. Printing
Public Class Form1
Private WithEvents M_MiniLabel As PrintDocument
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
M_MiniLabel = New PrintDocument
PageSetupDialog 1.Document = M_MiniLabel
PrintDialog.Sho wDialog()
M_MiniLabel.Def aultPageSetting s.PaperSize.Raw Kind = 0
MsgBox(M_MiniLa bel.DefaultPage Settings.PaperS ize.Kind.ToStri ng)
M_MiniLabel.Def aultPageSetting s.PaperSize.Hei ght = 2000
M_MiniLabel.Def aultPageSetting s.PaperSize.Wid th = 4000
PrintDialog.All owPrintToFile = False
M_MiniLabel.Pri nterSettings = PrintDialog.Pri nterSettings
M_MiniLabel.Ori ginAtMargins = True
M_MiniLabel.Pri nt()
End Sub
Private Sub M_MiniLabel_Pri ntPage(ByVal sender As Object, ByVal e As
System.Drawing. Printing.PrintP ageEventArgs) Handles M_MiniLabel.Pri ntPage
Dim font As New Drawing.Font("T imes New Roman", 48,
FontStyle.Regul ar, GraphicsUnit.Po int)
Dim format As New StringFormat
format.Alignmen t = StringAlignment .Near
Dim rec As New System.Drawing. RectangleF(2, 2, 4, 2)
e.Graphics.Smoo thingMode = Drawing2D.Smoot hingMode.HighQu ality
e.Graphics.Draw String("test", font, Brushes.Black, 1, 10, format)
e.HasMorePages = False
End Sub
End Class
but it keeps failing with the following error:
PaperSize cannot be changed unless the Kind property is set to Custom.
On the line that reads:M_MiniLab el.DefaultPageS ettings.PaperSi ze.Height = 2000
I thought that I was setting the Kind to Custom in the row above. If anybody
has any input this would be greatly appreciated. Code below.
Thank You
Kevin
Imports System.Drawing. Printing
Public Class Form1
Private WithEvents M_MiniLabel As PrintDocument
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
M_MiniLabel = New PrintDocument
PageSetupDialog 1.Document = M_MiniLabel
PrintDialog.Sho wDialog()
M_MiniLabel.Def aultPageSetting s.PaperSize.Raw Kind = 0
MsgBox(M_MiniLa bel.DefaultPage Settings.PaperS ize.Kind.ToStri ng)
M_MiniLabel.Def aultPageSetting s.PaperSize.Hei ght = 2000
M_MiniLabel.Def aultPageSetting s.PaperSize.Wid th = 4000
PrintDialog.All owPrintToFile = False
M_MiniLabel.Pri nterSettings = PrintDialog.Pri nterSettings
M_MiniLabel.Ori ginAtMargins = True
M_MiniLabel.Pri nt()
End Sub
Private Sub M_MiniLabel_Pri ntPage(ByVal sender As Object, ByVal e As
System.Drawing. Printing.PrintP ageEventArgs) Handles M_MiniLabel.Pri ntPage
Dim font As New Drawing.Font("T imes New Roman", 48,
FontStyle.Regul ar, GraphicsUnit.Po int)
Dim format As New StringFormat
format.Alignmen t = StringAlignment .Near
Dim rec As New System.Drawing. RectangleF(2, 2, 4, 2)
e.Graphics.Smoo thingMode = Drawing2D.Smoot hingMode.HighQu ality
e.Graphics.Draw String("test", font, Brushes.Black, 1, 10, format)
e.HasMorePages = False
End Sub
End Class