Search Results for

    Show / Hide Table of Contents

    Class QRCodeWriter

    A class allowing for advanced control on the generation of QR type barcodes.

    QRCodeWriter gives the developer access to set QR code error correction levels, and to add logo images to QR codes.

    Generated Barcodes can be exported as Images, Bitmaps, Files and Streams.

    Inheritance
    System.Object
    QRCodeWriter
    Namespace: IronBarCode
    Assembly: IronBarCode.dll
    Syntax
    public static class QRCodeWriter : Object

    QRCodeWriter generates QR codes with QR-specific options in C#, including version, error correction, and an embedded logo. Both members are static, so call QRCodeWriter.CreateQrCode(...) and a GeneratedBarcode comes back, ready to save as an image, stamp onto a PDF, or export as a data URL.

    CreateQrCode encodes a string, byte[], or Stream and accepts a size, a QRCodeWriter.QrErrorCorrectionLevel, and a qrVersion. The error-correction argument is what lets a code survive print wear or a partial cover, so raise it for labels that take physical handling. CreateQrCodeWithLogo does the same but also takes a QRCodeLogo, placing a brand mark in the center of the symbol and building in the extra correction a logo needs. For non-QR symbologies, or for a plain QR code without these options, use BarcodeWriter.CreateBarcode with BarcodeEncoding.QRCode instead. Because both methods return the same GeneratedBarcode, the choice of output format is made afterward and is independent of how the code was encoded.

    using IronBarCode;
    
    QRCodeWriter.CreateQrCode("https://ironsoftware.com", 500, QRCodeWriter.QrErrorCorrectionLevel.High)
        .SaveAsPng("qr.png");

    The create 2D barcodes how-to generates a QR code, and the custom QR code example applies version, error correction, and a logo.

    Methods

    CreateQrCode(Byte[], Int32, QRCodeWriter.QrErrorCorrectionLevel, Int32)

    Renders a QR code.

    Overload methods and methods of the created GeneratedBarcode object allow for barcode sizes and colors to be customized. Logos & Branding may also be added using the CreateQrCodeWithLogo method.

    Declaration
    public static GeneratedBarcode CreateQrCode(byte[] binaryData, int size = 500, QRCodeWriter.QrErrorCorrectionLevel errorCorrection, int qrVersion = 0)
    Parameters
    Type Name Description
    System.Byte[] binaryData

    The value of the QR code as a byte array.

    System.Int32 size

    The width and height of the QR code in pixels.

    QRCodeWriter.QrErrorCorrectionLevel errorCorrection

    The error correction level of the QR code.

    System.Int32 qrVersion

    The symbol version of the QR Code. The default value 0 will automatically assign an appropriate QR version for your data (highly recommended).

    Returns
    Type Description
    GeneratedBarcode

    A GeneratedBarcode object for the QR code which can be manipulated, annotated and saved to a System.Drawing.Image, an object, image file, PDF, MediaURL or data stream.

    CreateQrCode(Stream, Int32, QRCodeWriter.QrErrorCorrectionLevel, Int32)

    Renders a QR code.

    Overload methods and methods of the created GeneratedBarcode object allow for barcode sizes and colors to be customized. Logos & Branding may also be added using the CreateQrCodeWithLogo method.

    Declaration
    public static GeneratedBarcode CreateQrCode(Stream binaryDataStream, int size = 500, QRCodeWriter.QrErrorCorrectionLevel errorCorrection, int qrVersion = 0)
    Parameters
    Type Name Description
    System.IO.Stream binaryDataStream

    The value of the QR code as a stream.

    System.Int32 size

    The width and height of the QR code in pixels.

    QRCodeWriter.QrErrorCorrectionLevel errorCorrection

    The error correction level of the QR code.

    System.Int32 qrVersion

    The symbol version of the QR Code. The default value 0 will automatically assign an appropriate QR version for your data (highly recommended).

    Returns
    Type Description
    GeneratedBarcode

    A GeneratedBarcode object for the QR code which can be manipulated, annotated and saved to a System.Drawing.Image, an object, image file, PDF, MediaURL or data stream.

    CreateQrCode(String, Int32, QRCodeWriter.QrErrorCorrectionLevel, Int32)

    Renders a QR code from a String of data. UTF-8 fully supported.

    Overload methods and methods of the created GeneratedBarcode object allow for barcode sizes and colors to be customized. Logos / Branding may also be added.

    Declaration
    public static GeneratedBarcode CreateQrCode(string value, int size = 500, QRCodeWriter.QrErrorCorrectionLevel errorCorrection, int qrVersion = 0)
    Parameters
    Type Name Description
    System.String value

    The value of the QR code as a string. Also suitable for URLS.

    System.Int32 size

    The width and height of the QR code in pixels.

    QRCodeWriter.QrErrorCorrectionLevel errorCorrection

    The error correction level of the QR code.

    System.Int32 qrVersion

    The symbol version of the QR Code. The default value 0 will automatically assign an appropriate QR version for your data (highly recommended).

    Returns
    Type Description
    GeneratedBarcode

    A GeneratedBarcode object for the QR code which can be manipulated, annotated and saved to a System.Drawing.Image, an object, image file, PDF, MediaURL or data stream.

    CreateQrCodeWithLogo(Byte[], QRCodeLogo, Int32, Int32)

    Renders a QR code of given dimensions with a logo image at its center.

    Declaration
    public static GeneratedBarcode CreateQrCodeWithLogo(byte[] binaryData, QRCodeLogo qrCodeLogo, int size = 500, int qrVersion = 0)
    Parameters
    Type Name Description
    System.Byte[] binaryData

    The value of the QR code as a byte array.

    QRCodeLogo qrCodeLogo

    A QRCodeLogo class instance representing your desired logo image settings.

    System.Int32 size

    The width and height of the QR code in pixels.

    System.Int32 qrVersion

    The symbol version of the QR Code. The default value 0 will automatically assign an appropriate QR version for your data (highly recommended).

    Returns
    Type Description
    GeneratedBarcode

    A GeneratedBarcode object for the QR code which can be manipulated, annotated and saved to a System.Drawing.Image, an object, image file, PDF, MediaURL or data stream.

    CreateQrCodeWithLogo(Stream, QRCodeLogo, Int32, Int32)

    Renders a QR code of given dimensions with a logo image at its center.

    Declaration
    public static GeneratedBarcode CreateQrCodeWithLogo(Stream binaryDataStream, QRCodeLogo qrCodeLogo, int size = 500, int qrVersion = 0)
    Parameters
    Type Name Description
    System.IO.Stream binaryDataStream

    The value of the QR code as a stream.

    QRCodeLogo qrCodeLogo

    A QRCodeLogo class instance representing your desired logo image settings.

    System.Int32 size

    The width and height of the QR code in pixels.

    System.Int32 qrVersion

    The symbol version of the QR Code. The default value 0 will automatically assign an appropriate QR version for your data (highly recommended).

    Returns
    Type Description
    GeneratedBarcode

    A GeneratedBarcode object for the QR code which can be manipulated, annotated and saved to a System.Drawing.Image, an object, image file, PDF, MediaURL or data stream.

    CreateQrCodeWithLogo(String, QRCodeLogo, Int32, Int32)

    Renders a QR code of given dimensions with a logo image at its center.

    Declaration
    public static GeneratedBarcode CreateQrCodeWithLogo(string value, QRCodeLogo qrCodeLogo, int size = 500, int qrVersion = 0)
    Parameters
    Type Name Description
    System.String value

    The value of the QR code as a string. Also suitable for URLS.

    QRCodeLogo qrCodeLogo

    A QRCodeLogo class instance representing your desired logo image settings.

    System.Int32 size

    The width and height of the QR code in pixels.

    System.Int32 qrVersion

    The symbol version of the QR Code. The default value 0 will automatically assign an appropriate QR version for your data (highly recommended).

    Returns
    Type Description
    GeneratedBarcode

    A GeneratedBarcode object for the QR code which can be manipulated, annotated and saved to a System.Drawing.Image, an object, image file, PDF, MediaURL or data stream.

    ☀
    ☾
    Downloads
    • Download with Nuget
    • Start for Free
    In This Article
    Back to top
    Install with Nuget