Back to Devexpress

BarCode.Module Property

officefileapi-devexpress-dot-barcodes-dot-barcode-b9a97c24.md

latest3.9 KB
Original Source

BarCode.Module Property

Gets or sets the width of the narrowest bar or space in the bar code.

Namespace : DevExpress.BarCodes

Assembly : DevExpress.Docs.v25.2.dll

NuGet Package : DevExpress.Document.Processor

Declaration

csharp
public double Module { get; set; }
vb
Public Property [Module] As Double

Property Value

TypeDescription
Double

A Double value which represents the width of the narrowest bar or space.

|

Remarks

The Module property cannot be set to a value less than or equal to 0.

Note that if the Module property is set to a very small value, a bar code image may be unreadable by a scanner.

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

csharp
using System;
using System.Text;
using DevExpress.BarCodes;
using DevExpress.Drawing;
using DevExpress.Drawing.Extensions;
//...

private void button1_Click(object sender, EventArgs e)
{
    this.pictureBox1.Image = null;

    BarCode barCode = new BarCode();
    barCode.Symbology = Symbology.QRCode;
    barCode.BackColor = Color.White;
    barCode.ForeColor = Color.Black;
    barCode.RotationAngle = 0;
    barCode.CodeBinaryData = Encoding.Default.GetBytes("https://www.devexpress.com/");
    barCode.Options.QRCode.CompactionMode = QRCodeCompactionMode.Byte;
    barCode.Options.QRCode.ErrorLevel = QRCodeErrorLevel.Q;
    barCode.Options.QRCode.ShowCodeText = true;
    barCode.DpiX = 72;
    barCode.DpiY = 72;
    barCode.Module = 2f;

    this.pictureBox1.Image = barCode.BarCodeImage.ConvertToGdiPlusImage();
}
vb
Imports System
Imports System.Text
Imports DevExpress.BarCodes
Imports DevExpress.Drawing
Imports DevExpress.Drawing.Extensions
'...

Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
    Me.pictureBox1.Image = Nothing

    Dim barCode As New BarCode()
    barCode.Symbology = Symbology.QRCode
    barCode.BackColor = Color.White
    barCode.ForeColor = Color.Black
    barCode.RotationAngle = 0
    barCode.CodeBinaryData = Encoding.Default.GetBytes("https://www.devexpress.com/")
    barCode.Options.QRCode.CompactionMode = QRCodeCompactionMode.Byte
    barCode.Options.QRCode.ErrorLevel = QRCodeErrorLevel.Q
    barCode.Options.QRCode.ShowCodeText = True
    barCode.DpiX = 72
    barCode.DpiY = 72
    barCode.Module = 2F

    Me.pictureBox1.Image = barCode.BarCodeImage.ConvertToGdiPlusImage()
End Sub

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Module property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

word-document-api-insert-inline-pictures/VB/InlinePictures/Program.vb#L43

vb
barCode.CodeBinaryData = Text.Encoding.Default.GetBytes(barCode.CodeText)
barCode.Module = 0.5
Dim docFooter As SubDocument = doc.Sections(0).BeginUpdateFooter()

See Also

BarCode Class

BarCode Members

DevExpress.BarCodes Namespace