|
-
Mar 27th, 2009, 02:43 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Increase Height of Printed Text
I'm in the process of making a barcode printing program for my job.
The barcode is printed by printing text using font "WASP 39 LC". I have it automatically determining the correct font size of the text so that it will stretch from the left edge to the right edge, but the barcode isn't very wide (or tall), It's only about a centimeter tall (when printing a 9-digit number).
I'd like to increase the height of the text without increasing the width also.
Does anyone have any ideas about how I could accomplish this? I thought maybe printing the text to a picturebox, increasing the height of that, and painting it on the barcode, but I can't seem to figure out how to do that.
Any input is immensely appreciated!
Code:
Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
e.PageSettings.PaperSize.Height = 250 'Height(inch) * 100
e.PageSettings.PaperSize.Width = 400 'Width(inch) * 100
sAcctCode = txtAcctCode.Text
sAcctName = txtAcctName.Text
sValue = "*" & txtBarcode.Text & "*"
Dim f As Font
Dim p As Point
Dim siz As Integer
f = New Font("Times New Roman", 20, FontStyle.Regular)
p.X = (e.PageSettings.PaperSize.Width / 2) - (e.Graphics.MeasureString("FILEFOLDERS ONLY", f).Width / 2)
p.Y = e.PageSettings.PaperSize.Height - e.Graphics.MeasureString("(FILEFOLDERS ONLY)", f).Height
e.Graphics.DrawString("(FILEFOLDERS ONLY)", f, Brushes.Black, p)
siz = 1
f = New Font("WASP 39 LC", siz, FontStyle.Regular)
Do Until e.Graphics.MeasureString(sValue, f).Width >= e.PageSettings.PaperSize.Width
siz = siz + 1
f = New Font("WASP 39 LC", siz, FontStyle.Regular)
Loop
siz = siz - 3
p.X = (e.PageSettings.PaperSize.Width / 2) - (e.Graphics.MeasureString(sValue, f).Width / 2)
p.Y = p.Y - (e.Graphics.MeasureString(sValue, f).Height) - 20
e.Graphics.DrawString(sValue, f, Brushes.Black, p)
siz = 12
f = New Font("Times New Roman", siz, FontStyle.Bold)
If e.Graphics.MeasureString(sAcctName, f).Width > e.PageSettings.PaperSize.Width Then
Do Until e.Graphics.MeasureString(sAcctName, f).Width < e.PageSettings.PaperSize.Width
siz = siz - 1
f = New Font("Times New Roman", siz, FontStyle.Bold)
Loop
End If
Dim pic As New PictureBox 'Draw barcode & Increase height
siz = siz - 3
p.Y = p.Y - e.Graphics.MeasureString(sAcctName, f).Height
p.X = p.X + 5
e.Graphics.DrawString(sAcctName, f, Brushes.Black, p)
siz = 12
f = New Font("Times New Roman", siz, FontStyle.Bold)
If e.Graphics.MeasureString(sAcctCode, f).Width > e.PageSettings.PaperSize.Width Then
Do Until e.Graphics.MeasureString(sAcctCode, f).Width < e.PageSettings.PaperSize.Width
siz = siz - 1
f = New Font("Times New Roman", siz, FontStyle.Bold)
Loop
End If
siz = siz - 3
p.Y = p.Y - e.Graphics.MeasureString(sAcctCode, f).Height
e.Graphics.DrawString(sAcctCode, f, Brushes.Black, p)
siz = 14
f = New Font("Times New Roman", siz, FontStyle.Bold)
p.Y = 10
p.X = 5
e.Graphics.DrawString("Retrievex", f, Brushes.Black, p)
p.X = e.PageSettings.PaperSize.Width - e.Graphics.MeasureString("888-869-2767", f).Width - 10
e.Graphics.DrawString("888-869-2767", f, Brushes.Black, p)
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|