Print human readable text below barcode

Questions, comments and suggestions concerning VintaSoft Barcode .NET SDK.

Moderator: Alex

Post Reply
distrivers
Posts: 2
Joined: Mon Dec 03, 2018 12:35 pm

Print human readable text below barcode

Post by distrivers »

Hi,

I'm using the Barcode sdk in my .net (C# Winforms) application.

I would like to add human readable text below the barcode (with the same value as the barcode itself) but so far I am failing to do so.

I have been reading the documentation and to my best knowledge the text below the barcode 'should' be shown by default, but in my case it is not.
I tried the PrintableValue (default is the value if I'm not mistaken)
ValueVisible is set to true (also default)

What am I missing here?

This is the part that 'generates' the barcode.

Code: Select all

        public static Image DrawBarcode(BarcodeType barcode, string value, float resolution, float width,
                 float height, UnitOfMeasure units)
        {
            // create the barcode writer
            BarcodeWriter writer = new BarcodeWriter();

            // set barcode writer settings
            writer.Settings.Barcode = barcode;
            writer.Settings.Value = value;
            writer.Settings.Resolution = resolution;
            writer.Settings.PixelFormat = BarcodeImagePixelFormat.Bgr24;
            writer.Settings.ValueVisible = true;
            writer.Settings.ValueAutoLetterSpacing = true;
            

            // return barcode image
            return writer.GetBarcodeAsBitmap(width, height, UnitOfMeasure.Centimeters);
        }
And it is called here.

Code: Select all

            string barcode = "13245";
            using (Image barcodeImage = DrawBarcode(BarcodeType.Code128, barcode, 250, 7, 2,
                               UnitOfMeasure.Centimeters))
            {

                Point locean = new Point(20, 225);
                e.Graphics.DrawImage(barcodeImage, locean);

            }
The barcode itself is generated, but not the text below.

Thanks in advance,

Peter
Alex
Site Admin
Posts: 2305
Joined: Thu Jul 10, 2008 2:21 pm

Re: Print human readable text below barcode

Post by Alex »

Hi Peter,

The BarcodeWriter.GetBarcodeAsBitmap(Double,Double,UnitOfMeasure) method generates a barcode image without the barcode text, i.e. method ignores the WriterSettings.ValueVisible property:
https://www.vintasoft.com/docs/vsbarcod ... sure).html

You can get a barcode image with text by 2 ways.

WAY 1: Use the BarcodeWriter.GetBarcodeAsBitmap() method.

WAY 2: Get a temporary barcode image using the BarcodeWriter.GetBarcodeAsBitmap(Double,Double,UnitOfMeasure) method, draw temporary barcode image with text on the result barcode image.

Best regards, Alexander
distrivers
Posts: 2
Joined: Mon Dec 03, 2018 12:35 pm

Re: Print human readable text below barcode

Post by distrivers »

Thanks Alexander for your quick reply.

If I go for 'way 1'.
How can I set the width of the barcode (so that it will fit our label)?

Because I leave out that parameter now.
Alex
Site Admin
Posts: 2305
Joined: Thu Jul 10, 2008 2:21 pm

Re: Print human readable text below barcode

Post by Alex »

distrivers wrote: Mon Dec 03, 2018 3:14 pm If I go for 'way 1'.
How can I set the width of the barcode (so that it will fit our label)?

Because I leave out that parameter now.
In this case you need to scale the image but this may decrease the barcode image quality.

Best regards, Alexander
Post Reply