Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VS2005 (VB) Printing-ima newbie

Status
Not open for further replies.

zarkon4

MIS
Dec 16, 2003
641
US
I keep looking at sample after sample after sample of printing in VB. I am totally confused. I am used to VB6
in which you give the x and y coordinates and print your data or image. I am looking to print a page that has a logo, title and various data within it using various fonts and sizes, I want to specify the position on the page. Can anyone point to somehwere where I can get a handle on printing? Or can someone explain it to me?
 
Never mind, I found some resources and samples that explain it better.
 
What might those sources be, if i may ask? I'm having the same problem.
Thanx.
 
Here is the module I have came up with from a sample I viewed online (I don't recall where though) but this will get you started. The following mindset really helps, I am an artist and I need to "paint" on a 'canvas' using a 'brush' and 'color' paint.

Hope this helps...

Private msItemNo As String
Public Sub PrintTag(strItem as String)

Dim MyTag As New PrintDocument
MyTag.DocumentName = "Shop Tag " & strItem
MyTag.DefaultPageSettings.Landscape = True

'set the module level variables
msItemNo = Trim(strItem)
msDesc = Trim(strDesc)
msMat = Trim(strMat)
msDwgDsh = Trim(strDwgDash)
msLoc = Replace(Trim(strLoc), "\", "")

'set the printdocument page handler overriding the default
AddHandler MyTag.PrintPage, AddressOf MyTagPageHandler

'print the tag
MyTag.Print()

End Sub

Private Sub MyTagPageHandler(ByVal sender As Object, ByVal e As PrintPageEventArgs)

'define the fonts to be used
Dim fntBarCode As New Font("Free 3 of 9 Extended", 72, FontStyle.Regular) ', GraphicsUnit.Inch)
Dim fntTagText As New Font("Times New Roman", 72, FontStyle.Bold) ', GraphicsUnit.Inch)
Dim fntLocText As New Font("Times New Roman", 10, FontStyle.Regular) ', GraphicsUnit.Inch)
Dim fntArrow As New Font("WingDings 3", 72, FontStyle.Bold) ', GraphicsUnit.Inch)
Dim newImage As System.Drawing.Image = System.Drawing.Image.FromFile("c:\Logos\LPLogo.bmp")


'create the canvas in which we paint the page
Dim canvas As Graphics = e.Graphics

'Change the unit of measure for the page
canvas.PageUnit = GraphicsUnit.Inch

'create our brush to do the painting
Dim brush = Brushes.Black

'
'DRAW ON THE CANVAS
'

'Barcode
canvas.DrawString("*" & msItemNo & "*", fntBarCode, brush, 0.83, 0.2)

'Arrow
canvas.DrawString("i", fntArrow, brush, 5, 0)
'description

'Item No
canvas.DrawString(msItemNo, fntTagText, brush, 0.83, 2.7)

'Logo
canvas.DrawImage(newImage, 2, 1)
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top