pls i have a barcode image creation program which needs to be scaled to paper. when it is sent to the printer directly through the printer object, the scanner is able to read the image but when it is sent into a canvas (like a bitmap object to be scaled into the desired paper size) before being sent to the printer, it doesnt read. pls send your response to email@removed.com. thanks.
this is the barcode printing funtion:
Public Function Code128_Print(ByVal Str As String,
ByVal Pricetag As String,
ByVal xOffset As Single,
ByVal yOffset As Single,
ByVal barHeight As Single,
ByVal BarWidth As Integer,
ByRef e As PrintPageEventArgs,
ByRef xShowPriceOnImageAt As showStringPositionOnImageAt,
ByRef xShowStringOnImageAt As showStringPositionOnImageAt) As Single
Dim Ret As String, X As Long, CurrChar As String, K As Long, Q As Long
Dim LineWidth As Integer
Dim barTop As Single = 20.0
Dim _pen As New Pen(Brushes.Black, 1)
If BarWidth < 1 Then BarWidth = 1
Ret = "11" & Replace(Code128_Str(Str), " ", "")
X = 14 * BarWidth
Do
CurrChar = Left(Ret, 2)
Ret = Mid(Ret, 3)
LineWidth = Val(Left(CurrChar, 1))
For K = 1 To LineWidth
For Q = 0 To BarWidth - 1
Graphics.DrawLine(_pen, X + Q + xOffset, yOffset + barTop, X + Q + xOffset, barHeight + yOffset)
Q = 0 To BarWidth - 1
e.Graphics.DrawLine(_pen, X + Q + xOffset, yOffset + barTop, X + Q + xOffset, barHeight + yOffset)
Next Q
X = X + BarWidth
Next K
X = X + (Val(Mid(CurrChar & "0", 2, 1)) * BarWidth)
Loop Until Len(Ret) = 0
X = X + (14 * BarWidth)
Return X
End Function
the mainclass form
Imports System.Drawing.Printing
Public Class Form1
Private oPrintDoc As New PrintDocument
Private oPrnPreviewer As New PrintPreviewControl
Private oprevwDialog As New PrintPreviewDialog
Private oPrnDialog As New PrintDialog
Private oBmp As Bitmap
Private Sub doPrint(ByVal sender As Object, ByVal e As PrintPageEventArgs)
Dim oBarCodePrinter As New itlBarcodePrinter
oBmp = oBarCodePrinter.Code128_Print(TextToPrint.Text, 100, 1, e)
PictureBox1.Image = oBmp
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
AddHandler oPrintDoc.PrintPage, AddressOf doPrint
End Sub
Private Sub PreviewBCode(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BeginGraphicPrint.Click
oprevwDialog.Document = oPrintDoc
oprevwDialog.ShowDialog()
End Sub
Private Sub PrintBCode(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If oPrnDialog.ShowDialog = DialogResult.OK Then
oPrintDoc.PrinterSettings.PrinterName = oPrnDialog.PrinterSettings.PrinterName
oPrintDoc.Print()
End If
End Sub
Private Sub DoneBtn_Click(sender As System.Object, e As System.EventArgs) Handles DoneBtn.Click
End Sub
End Class
please for more info, refer to
<\pre>