Skip to main content
All docs
V26.1
  • BarcodeGenerator.Export(String, Encoding, Stream) Method

    Exports a barcode image for the supplied text to a stream using the specified encoding.

    Namespace: DevExpress.Docs.Barcode

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

    Declaration

    public void Export(
        string text,
        Encoding encoding,
        Stream stream
    )

    Parameters

    Name Type Description
    text String

    The text to encode as a barcode.

    encoding Encoding

    The encoding to use for the text.

    stream Stream

    The stream to which the barcode image will be written.

    Remarks

    The following code snippet encodes string 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 QR code as PNG image.
            using (FileStream pngStream = new FileStream(@"D:\barcode_symbology_qr_code.png", FileMode.Create, FileAccess.Write)) {
                generator.Export("https://example.com", Encoding.UTF8, pngStream);
            }
        }
    }
    
    See Also