473,978 Members | 9,936 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 4260
Not sure but the following may help you

'Set the page settings
Dim obPage As New PageSettings
obpage.PaperSiz e.Kind = 'PaperKind Enumeration value
'Assign theis object to the PrintDocument.D ocument 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.c om...
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_Cl ick(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles mnuMailLabel.Cl ick
Dim doc As PrintDocument = New PrintDocument
Dim printer As PrintDialog = New PrintDialog

printer.Documen t = doc
printer.Printer Settings.Printe rName = My.Settings.MPr inter
printer.Documen t.DefaultPageSe ttings.PaperSiz e = New
Printing.PaperS ize(Printing.Pa perKind.Custom, 350, 100)

AddHandler doc.PrintPage, AddressOf PrintPageHandle r
doc.Print()
End Sub

Private Sub PrintPageHandle r(ByVal sender As Object, ByVal e As
PrintPageEventA rgs)
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.T ext, 1) & " "
End If
PrintString = PrintString & txtLName.Text & vbCrLf &
txtAddress.Text & vbCrLf & txtCity.Text & ", " & txtState.Text & " " &
txtZip.Text

canvas.DrawStri ng(PrintString, _font, _brush, 0, 0)
End Sub
The line:
printer.Documen t.DefaultPageSe ttings.PaperSiz e = New
Printing.PaperS ize(Printing.Pa perKind.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.comwr ote:
>Not sure but the following may help you

'Set the page settings
Dim obPage As New PageSettings
obpage.PaperSi ze.Kind = 'PaperKind Enumeration value
'Assign theis object to the PrintDocument.D ocument 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
3483
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 type fonts. So I assume it's possible to send Font Type and the text to the printer, and the printer should digest and print faster. Still, barcode info needs to be sent as an image. When I print fifty copies of the same label it prints really...
2
3017
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 labels....due to slippage, soon you have the printout missing the label. So we are thinking that we have to use sheets of labels. HOWEVER, one job may need 15 labels, another may need 8, etc. Does anyone have a solution for how to set this up in...
3
6329
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 computer has drivers installed for this printer, and this printer is shared for the network. Question 1:
2
7203
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 taken from a MySQL DB, but it doesn't output the labels properly. As soon as it gets to the bottom of the page, it kinda spans the bottom two labels across the two pages. How do I tell it to print the whole last label on the second page? I had a look at...
6
2228
by: MJ | last post by:
Is it possible to print varying numbers of labels from Access?
6
8701
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 example anywhere that someone can point me to that is more flexible? And, I mean flexible in this regard:
2
2731
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 logo. My boss wants a solution where we simply "push" the Word or ODF file to the client's computer and it automatically prints on their printer. I actually think that is what our clients are hoping for as well. I've told him I am pretty darn...
11
2868
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 works fine. However I would like to print all the records from the query on to consecutive labels. Below is the code for this function but it doesn't work (surprise, surprise). I probably don't need the form in the code as it is looking at the...
5
2821
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 a print preview. But,when I print to the printer it disregards the number of labels to skip. I preview all the reports I've got and then have a little printer icon to click on if the user wants to actually print (my attempt at saving trees)....
0
10359
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10179
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11836
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11433
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11596
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10922
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8467
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
5163
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 we have to send another system
2
4748
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.