Code128 barcode width help


Firstly, this is a great .NET component.

I need to change the width of a code128 barcode when it gets printed.
The data in the barcode is say BZ0123456789D
When this prints it is about 8cm wide.
Can I reduce this down to about 4 - 5cm
What settings do I use?

Is it determined by the barcode height?

Is there any documentation on all the settings in BarcodeSettings of the DLL

I'm using VB.Net in VS2013

Thanks in advanced.



RichardHVince wrote Jul 12, 2014 at 12:36 PM

Just an addition to my previous comment about adjusting the width of a printed barcode. I have the following code that I think should print 5 different barcodes one below the other. But it only prints 1 barcode at the x,y coordinates of the last one. Can anyone help me work out why it is only printing 1 barcode?

Imports Spire.Barcode
Imports System.Drawing.Printing

Public Class Form1
Public settings As BarcodeSettings
Private WithEvents MultiPage_PrintDocument As PrintDocument

Private Sub MultiPage_PrintDocument_QueryPageSettings(ByVal sender As Object, ByVal e As System.Drawing.Printing.QueryPageSettingsEventArgs) Handles MultiPage_PrintDocument.QueryPageSettings

    ' Print in landscape.
    e.PageSettings.Landscape = True

End Sub

Private Sub MultiPage_PrintDocument_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles MultiPage_PrintDocument.PrintPage

    Dim YPos As Integer = 10
    Dim Barcodenumber As Int64 = 9876543210
    Dim BarcodeData As String = ""
    Dim BarcodeType As String = "Code128"
    Dim barcode As Image

    settings = New BarcodeSettings
    settings.Type = CType(System.Enum.Parse(GetType(BarCodeType), BarcodeType), BarCodeType)
    settings.ShowText = False
    settings.ShowTopText = False
    settings.BarHeight = 8
    settings.ImageWidth = 30
    settings.AutoResize = False
    settings.X = 0.2
    settings.XYRatio = 0.2

    BarcodeData = "BZ0123456789D"

    Dim generator As New BarCodeGenerator(settings)

    For coounter As Integer = 1 To 5
        BarcodeData = "BZ" + Barcodenumber.ToString + "D"
        settings.Data = BarcodeData
        barcode = generator.GenerateImage()
        e.Graphics.DrawImage(barcode, 10, YPos)
        Barcodenumber += 1
        YPos = YPos + 50
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    MultiPage_PrintDocument = New PrintDocument
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
End Sub
End Class