Skip to content

Whitespace on Right Side of UPCA #219

Open
@kyleherzog

Description

@kyleherzog

The barcode image generated for UPCA can result in whitespace on the right side of the image. I was noticing this with the following settings:

        using var barcode = new Barcode
        {
            IncludeLabel = false,
            Alignment = AlignmentPositions.Left,
            Width = 300,
            Height = 75,
            EncodedType = BarcodeStandard.Type.UpcA,
        };

I tried encoding the value "070640018420"

I think the root cause is that integer division is being done in the Generate_Image() method of BarcodeLib.cs to calculate bar width. In doing some testing, I found that it seems to be fixed by changing the following calculation
var iBarWidth = Width / EncodedValue.Length;
to
var iBarWidth = (float)Width / EncodedValue.Length;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions