Aspose Bar Code 19.7.0.0
var bc = new Aspose.BarCode.Generation.BarCodeGenerator(Aspose.BarCode.Generation.EncodeTypes.Code128);
// setup bar code image parameters
bc.AutoSizeMode = Aspose.BarCode.Generation.AutoSizeMode.Interpolation;
bc.Margins.Top.Millimeters = 0;
bc.Margins.Bottom.Millimeters = 0;
bc.Margins.Left.Millimeters = 0;
bc.Margins.Right.Millimeters = 0;
bc.BarCodeWidth.Millimeters = 25;
bc.BarCodeHeight.Millimeters = 4;
bc.CodeText = clssentry.SerialNumber;
bc.CodeTextStyle.Location = CodeLocation.None;
bc.CaptionBelow.Visible = true;
bc.CaptionBelow.Text = clssentry.SerialNumber.ToString();
bc.CaptionBelow.Alignment = StringAlignment.Center;
bc.CaptionBelow.Font.Size.Point = 8;
bc.CaptionBelow.Space.Millimeters = .25F;
bc.Resolution = 200;
Bitmap bmp = bc.GenerateBarCodeImage();
builder.InsertImage(bmp);
Example output bar height is 4cm and image looks fine
image.png (360 Bytes)
Aspose Bar Code 19.11.0.0
var bc = new Aspose.BarCode.Generation.BarcodeGenerator(Aspose.BarCode.Generation.EncodeTypes.Code128);
// setup bar code image parameters
bc.Parameters.Barcode.AutoSizeMode = Aspose.BarCode.Generation.AutoSizeMode.Interpolation;
bc.Parameters.Barcode.Padding.Top.Millimeters = 0;
bc.Parameters.Barcode.Padding.Bottom.Millimeters = 0;
bc.Parameters.Barcode.Padding.Left.Millimeters = 0;
bc.Parameters.Barcode.Padding.Right.Millimeters = 0;
bc.Parameters.Barcode.BarCodeWidth.Millimeters = 25;
bc.Parameters.Barcode.BarCodeHeight.Millimeters = 4;
bc.CodeText = clssentry.SerialNumber;
bc.Parameters.Barcode.CodeTextParameters.Location = Aspose.BarCode.Generation.CodeLocation.None;
bc.Parameters.CaptionBelow.Visible = true;
bc.Parameters.CaptionBelow.Text = clssentry.SerialNumber.ToString();
bc.Parameters.CaptionBelow.Alignment = Aspose.BarCode.Generation.TextAlignment.Center;
bc.Parameters.CaptionBelow.Font.Size.Point = 8;
bc.Parameters.CaptionBelow.Padding.Top.Millimeters = 0.25F;
bc.Parameters.Resolution = 200;
Bitmap bmp = bc.GenerateBarCodeImage();
builder.InsertImage(bmp);
Example output bar height is 4cm and image doesn’t appear
image.png (262 Bytes)
Example output bar height is changed to 8cm and image appears but bar code height is much smaller
image.png (716 Bytes)