By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,183 Members | 1,212 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,183 IT Pros & Developers. It's quick & easy.

Printing With Custom Paper Size

P: n/a
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_MiniLabel.DefaultPageSettings.PaperSize.He ight = 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
Imports System.Drawing.Printing

Public Class Form1
Private WithEvents M_MiniLabel As PrintDocument
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
M_MiniLabel = New PrintDocument
PageSetupDialog1.Document = M_MiniLabel
M_MiniLabel.DefaultPageSettings.PaperSize.RawKind = 0
MsgBox(M_MiniLabel.DefaultPageSettings.PaperSize.K ind.ToString)
M_MiniLabel.DefaultPageSettings.PaperSize.Height = 2000
M_MiniLabel.DefaultPageSettings.PaperSize.Width = 4000
PrintDialog.AllowPrintToFile = False
M_MiniLabel.PrinterSettings = PrintDialog.PrinterSettings
M_MiniLabel.OriginAtMargins = True
End Sub

Private Sub M_MiniLabel_PrintPage(ByVal sender As Object, ByVal e As
System.Drawing.Printing.PrintPageEventArgs) Handles M_MiniLabel.PrintPage
Dim font As New Drawing.Font("Times New Roman", 48,
FontStyle.Regular, GraphicsUnit.Point)
Dim format As New StringFormat
format.Alignment = StringAlignment.Near
Dim rec As New System.Drawing.RectangleF(2, 2, 4, 2)
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
e.Graphics.DrawString("test", font, Brushes.Black, 1, 10, format)
e.HasMorePages = False
End Sub
End Class

Jun 26 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.