in

C1 Community

ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

Extremely Large Barcode Text

Last post 04-06-2006 2:04 PM by C1_BernardoC. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 04-04-2006 12:15 AM

    • aarone
    • Not Ranked
    • Joined on 04-04-2006
    • Posts 2

    Extremely Large Barcode Text

    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?

  • 04-04-2006 12:31 AM In reply to

    • aarone
    • Not Ranked
    • Joined on 04-04-2006
    • Posts 2

    Re: Extremely Large Barcode Text

    The correct barcode page should be as this attachment.
  • 04-06-2006 2:04 PM In reply to

    Re: Extremely Large Barcode Text

    This is an interesting problem. If you could send me a sample app, I would
    be glad to try it here.

    Without a sample app that I can run, only a couple of ideas come to my mind:

    1) I would try putting a C1BarCode control on a form and using that instead
    of creating one dynamically.

    2) Or I might set the size of the dynamic control explicitly, i.e

    Dim _barCodeDisplay As New C1.Win.C1BarCode.C1BarCode
    _barCodeDisplay.Size = new Size(300, 100)
    _barCodeDisplay.CodeType = C1.Win.C1BarCode.CodeTypeEnum.Code128

    3) Is there anything special about the machine where this does not work
    correctly? Does it have a printer driver installed?
Page 1 of 1 (3 items)
Contact ComponentOne: 1.800.858.2739 ©1987-2008 ComponentOne LLC All Rights Reserved.