473,372 Members | 1,089 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

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 4185
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
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
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
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
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
by: MJ | last post by:
Is it possible to print varying numbers of labels from Access?
6
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
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
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
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.