473,493 Members | 2,274 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Printing With Custom Paper Size

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
Kevin
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
PrintDialog.ShowDialog()
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
M_MiniLabel.Print()
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
0 4611

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
10381
by: gb | last post by:
Hi All, Ive created a popup page using 'var openWindow = window.open("new","pop")' And added content using openWindow.document.write(" "); statements. But now I would like to be able to print...
6
1169
by: Rand | last post by:
Hello anyone, Situation: I want to print 1 or x mailing continuous form labels 1" X 3.5" then change to a different name and print again. Everything works fine except for problem below. ...
3
31779
by: D Witherspoon | last post by:
No matter what I do the default paper size is always either A3 or 11 by 8.5 .. Here is the code. Dim dlg As DialogResult pd.DocumentName = "Weld Image" Dim pkPaperSize As New...
2
2523
by: Sukh | last post by:
Hi I am stuck with a problem Can anyone help me out from this... I am printing a report on pre-printed continue paper using dot-matrix printer using vb.net. Data is printing on all the...
9
2875
by: Sukh | last post by:
Hello anyone, I am printing a pre-printed continue paper on dot-matrix printer using vb.net winform. For printing I am creating custom size paper and selecting the same for printing. Everything...
10
54888
by: gigi24 | last post by:
I have set up a custom paper size on a Windows XP SP2 machine. I have followed all of the directions that I can find. It does appear in the print server properties, but when I go to the advanced...
6
12407
by: Brewtzaff | last post by:
Hello, I have a little problem to print my reports on custom sized paper. I got a db containing clubmembers, a query which selects only the needed infos to print out my membershipcards. My...
1
9904
by: Anne DeBlois | last post by:
Hi, I want to programatically set the paper size of a print document. I created a class that inherits PrintDocument, so I can print some database records on 8" x 10" paper. I added this line...
2
9928
by: Brad Pears | last post by:
I have a vb.net 2005 application and am using the print preview screen. This screen has a printer icon on it that the user can use to print the document currently being viewed. It uses the default...
0
7119
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6989
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6873
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7367
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4889
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
644
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.