Skip to main content
All docs
V26.1
  • BarcodeGenerator.Export(Byte[], Stream, DXImageFormat) Method

    Exports a barcode image for the specified binary data to the provided stream in the given image format.

    Namespace: DevExpress.Docs.Barcode

    Assembly: DevExpress.Docs.Barcode.v26.1.dll

    Declaration

    public void Export(
        byte[] binaryData,
        Stream stream,
        DXImageFormat format
    )

    Parameters

    Name Type Description
    binaryData Byte[]

    The binary data to encode as a barcode.

    stream Stream

    The stream to which the barcode image will be written.

    Optional Parameters

    Name Type Default Description
    format DXImageFormat null

    (Optional) The image format for the exported barcode. If null, the default format (PNG) is used.

    Remarks

    The following code snippet encodes binary data to a QR code and exports it as a PNG image:

    using DevExpress.Docs;
    using DevExpress.Docs.Barcode;
    using DevExpress.Drawing;
    using System.Drawing;
    
    namespace ConsoleApp1;
    
    public class Program {
        public static async Task Main(string[] _) {
    
            // Configure QR code options.
            QRCodeOptions qrOptions = new QRCodeOptions {
                ErrorCorrectionLevel = QRCodeErrorCorrectionLevel.H,
                CompactionMode = QRCodeCompactionMode.Auto,
                IncludeQuietZone = false,
                Version = QRCodeVersion.Version10,
                ModuleSize = 40,
                BackColor = Color.LightGray,
                ShowText = false,
                Padding = new Padding(5),
                BorderWidth = 1,
                BorderColor = Color.Blue,
                Width = 500,
                Height = 500,
            };
    
            using BarcodeGenerator generator = new BarcodeGenerator(qrOptions);
    
            // Export binary data as a QR code in PNG format.
            using (FileStream pngStream = new FileStream(@"D:\barcode_symbology_qr_code.png", FileMode.Create, FileAccess.Write)) {
                byte[] data = { 0x48, 0x65, 0x6C, 0x6C, 0x6F };
                generator.Export(data, pngStream, DXImageFormat.Png);
            }
        }
    }
    
    See Also