Skip to main content

BarCode.AutoSize Property

Allows you to create an image in a size that fits all the specified bar code options.

Namespace: DevExpress.BarCodes

Assembly: DevExpress.Docs.v24.1.dll

NuGet Package: DevExpress.Document.Processor


public bool AutoSize { get; set; }

Property Value

Type Description

true, to create an image unrestricted to the specified size; otherwise, false.


If the AutoSize is set to true, the BarCode.ImageWidth and BarCode.ImageHeight are not taken into account when an image is generated. You can get the image in a size that satisfies all the specified options.

If you set the AutoSize to false, the image will be clipped to the specified size. In this situation, you have to adjust the options which affect the image size (BarCode.Dpi, BarCode.TopCaption, BarCode.BottomCaption etc.) manually to achieve the desired size.

The code sample below creates a QR code and displays it in a PictureBox.

using DevExpress.BarCodes;
this.pictureBox1.Image = null;

BarCode barCode = new BarCode();
barCode.Symbology = Symbology.QRCode;
barCode.CodeText = "";
barCode.BackColor = Color.White;
barCode.ForeColor = Color.Black;
barCode.RotationAngle = 0;
barCode.CodeBinaryData = Encoding.Default.GetBytes(barCode.CodeText);
barCode.Options.QRCode.CompactionMode = QRCodeCompactionMode.Byte;
barCode.Options.QRCode.ErrorLevel = QRCodeErrorLevel.Q;
barCode.Options.QRCode.ShowCodeText = false;
barCode.AutoSize = true;

this.pictureBox1.Image = barCode.BarCodeImage;
pictureBox1.Size = pictureBox1.Image.Size;
See Also