Hi everyone.
I have a utility which uses a PrintDocument class to create a sheet of barcodes.
For some reason though, the barcode text is incredibly large and not in the correct location.
To create the barcode I use the following code:
Private Function GetBarcode(byval Barcode as string) As Image
Dim
_barCodeDisplay As New C1.Win.C1BarCode.C1BarCode
_barCodeDisplay.CodeType = C1.Win.C1BarCode.CodeTypeEnum.Code128
_barCodeDisplay.ShowText = True
_barCodeDisplay.Font = New Font("Verdana", 9)
_barCodeDisplay.Text = Barcode
Return _barCodeDisplay.Image
End
Function
Then to print the barcodes i use the following code:
Private
Sub printBarcodePage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
e.Graphics.PageUnit = GraphicsUnit.Document
Dim _yPos As Double = 0
Dim _leftMargin As Double = e.MarginBounds.Left
Dim _topMargin As Double = e.MarginBounds.Top
For _line As Integer = 0 To c_BarcodesPerPage - 1
_yPos = _topMargin + (_line * c_imageHeight)
Try
For i As Integer = 0 To 2
Dim _image As Image = GetBarcode(m_barcode.Barcode(m_barcodeIndex))
Dim _imageWidthInMM As Integer = c_imageHeightInMM * _image.Width / _image.Height
Dim _x As Integer = CInt(i * c_imageWidth + _leftMargin + (c_imageWidth - _imageWidthInMM - c_columnWidth) / 2)
Dim _y As Integer = CInt(_yPos)
Dim _yUn As Double = _topMargin + (_line * c_imageHeight)
e.Graphics.DrawImage(_image, _x, _y, _imageWidthInMM, CInt(c_imageHeightInMM))
Next
Catch ex As Exception
MessageBox.Show("Error Printing Barcodes: - " & ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
e.HasMorePages = False
Exit Sub
End Try
m_barcodeIndex += 1
Next
m_pageIndex += 1
e.HasMorePages = m_pageIndex <= UpDown_PageCount.Value
End Sub
I've included the results as an attachment.
It works fine on most machines, but on one release machine it's rendered incorrect.
Any ideas?