Skip to main content
All docs
V24.1

BarCode.Save(Stream, DXImageFormat) Method

Saves the barcode image to a stream in the specified format.

Namespace: DevExpress.BarCodes

Assembly: DevExpress.Docs.v24.1.dll

NuGet Package: DevExpress.Document.Processor

Declaration

public void Save(
    Stream stream,
    DXImageFormat format
)

Parameters

Name Type Description
stream Stream

The output stream.

format DXImageFormat

An enumeration member that specifies the image format.

Remarks

Use the Save method overloads to export a barcode to an image file. Static properties of the DXImageFormat class allow you to specify an output image format. To save a barcode as a vector image, pass the ImageFormat.Emf parameter to the method.

The example below shows how to create a QR code and save it as an image.

using DevExpress.BarCodes;
using DevExpress.Drawing;
//...

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.DpiX = 72;
barCode.DpiY = 72;
barCode.Module = 2f;

using (FileStream stream = new FileStream("BarCodeImage.png", FileMode.Create))
{
    barCode.Save(stream, DXImageFormat.Png);
}
See Also