473,508 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help printing labels...

In my VB2005 Windows Forms program I want to be able to click a button
and have my Dot Matrix printer print one 15/16 x 3 1/2 address label
from continuous forms.

I'm trying to use a PrintDocument, but don't know how to set up the
page size to be only one label.
Jul 17 '06 #1
2 4203
Not sure but the following may help you

'Set the page settings
Dim obPage As New PageSettings
obpage.PaperSize.Kind = 'PaperKind Enumeration value
'Assign theis object to the PrintDocument.Document member

You may set it to custom size (it is a value in the enum) and then set it to
the required size
hth,
Samuel

"Kevin" <ke****@cfl.rr.comwrote in message
news:70********************************@4ax.com...
In my VB2005 Windows Forms program I want to be able to click a button
and have my Dot Matrix printer print one 15/16 x 3 1/2 address label
from continuous forms.

I'm trying to use a PrintDocument, but don't know how to set up the
page size to be only one label.

Jul 17 '06 #2
Thanks for the reply Samuel, but after more searching, I finally found
someone else's code I used as an example.
Private Sub mnuMailLabel_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles mnuMailLabel.Click
Dim doc As PrintDocument = New PrintDocument
Dim printer As PrintDialog = New PrintDialog

printer.Document = doc
printer.PrinterSettings.PrinterName = My.Settings.MPrinter
printer.Document.DefaultPageSettings.PaperSize = New
Printing.PaperSize(Printing.PaperKind.Custom, 350, 100)

AddHandler doc.PrintPage, AddressOf PrintPageHandler
doc.Print()
End Sub

Private Sub PrintPageHandler(ByVal sender As Object, ByVal e As
PrintPageEventArgs)
Dim canvas As Graphics = e.Graphics
Dim _font As Font = New Font("Tahoma", 10)
Dim _brush = Brushes.Black
Dim PrintString As String

PrintString = txtFName.Text & " "
If Trim(txtMI.Text) <"" Then
PrintString = PrintString & VB.Left(txtMI.Text, 1) & " "
End If
PrintString = PrintString & txtLName.Text & vbCrLf &
txtAddress.Text & vbCrLf & txtCity.Text & ", " & txtState.Text & " " &
txtZip.Text

canvas.DrawString(PrintString, _font, _brush, 0, 0)
End Sub
The line:
printer.Document.DefaultPageSettings.PaperSize = New
Printing.PaperSize(Printing.PaperKind.Custom, 350, 100)

was what I couldn't quite figure out how to do. This code works fine
in my program.


On Mon, 17 Jul 2006 18:44:33 +0100, "Samuel Shulman"
<sa************@ntlworld.comwrote:
>Not sure but the following may help you

'Set the page settings
Dim obPage As New PageSettings
obpage.PaperSize.Kind = 'PaperKind Enumeration value
'Assign theis object to the PrintDocument.Document member

You may set it to custom size (it is a value in the enum) and then set it to
the required size
hth,
Samuel

"Kevin" <ke****@cfl.rr.comwrote in message
news:70********************************@4ax.com.. .
>In my VB2005 Windows Forms program I want to be able to click a button
and have my Dot Matrix printer print one 15/16 x 3 1/2 address label
from continuous forms.

I'm trying to use a PrintDocument, but don't know how to set up the
page size to be only one label.
Jul 17 '06 #3

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

Similar topics

2
3434
by: qumpus | last post by:
My program right now generates USPS style shipping label using System.Drawing.Graphics. It works fine except that the printer prints really slowly. I want to make my program take advantage of true...
2
2984
by: DBQueen | last post by:
I have a database which will be printing out labels for SMALL test tubes (1/4" high). We have yet to find a reasonably-priced printer (labelwriter) which can effectively print this on ROLLS of...
3
6271
by: Mika M | last post by:
Hi all! I have made an application for printing simple barcode labels using PrintDocument object, and it's working fine. Barcode printer that I use is attached to the computer, and this...
2
7141
by: LordMerlin | last post by:
Hi I'm trying to write a label printing routine, but I'm not being too sucsessful. I'm hoping maybe someone who's used FPDF b4 can help me out? Basically, I want to print labels from a data...
6
2203
by: MJ | last post by:
Is it possible to print varying numbers of labels from Access?
6
8607
by: Ron | last post by:
Hi, I know Access allows for easy construction of a report setup to print labels from a table/query, etc. I've done that one. It works pretty well for what I need. However, is there an...
2
2700
by: Matt | last post by:
We have clients asking that we provide an easy way to print envelops from within our web applications. These envelopes need to be pretty advanced, and need to include a bar code and maybe even a...
11
2791
by: fieldling | last post by:
I have a query which I view through a form. Due to problems with the label wizard printing to a dot-matrix printer I have some code to print out a single label when a command button is clicked. This...
5
2789
by: Ron | last post by:
Hi All, I've got a report that prints mailing labels. It utilizes a routine that asks the number of labels to skip, the number of each label to print, and then prints. It works really well on...
0
7224
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
7380
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7494
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...
0
5626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3192
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
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1553
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.