officefileapi-devexpress-dot-barcodes-dot-barcode-cc84405e.md
Allows you to create an image in a size that fits all the specified bar code options.
Namespace : DevExpress.BarCodes
Assembly : DevExpress.Docs.v25.2.dll
NuGet Package : DevExpress.Document.Processor
public bool AutoSize { get; set; }
Public Property AutoSize As Boolean
| Type | Description |
|---|---|
| Boolean |
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 = "https://www.devexpress.com/";
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;
Imports DevExpress.BarCodes
'...
Me.pictureBox1.Image = Nothing
Dim barCode As New BarCode()
barCode.Symbology = Symbology.QRCode
barCode.CodeText = "http:/www.devexpress.com"
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
Me.pictureBox1.Image = barCode.BarCodeImage
pictureBox1.Size = pictureBox1.Image.Size
See Also