New to Telerik UI for WinForms? Download free 30-day trial

Export to Image

RadBarcode supports export to image functionality.

You can export the RadBarcode content by using one of the following overloads of the ExportToImage method:

  • ExportToImage() - Exports the barcode with the current dimentions of the control. ExportToImage(int width, int height) Layouts the barcode using the provided dimentions and exports it to an image.

  • ExportToImage(Stream stream, Size size) - Layouts the barcode using the provided size and exports it to the specified stream.

  • ExportToImage(string filePath, Size size) - Layouts the barcode using the provided size and exports it to the specified file location.

  • ExportToImage(Stream stream, Size size, ImageFormat imageFormat) - Layouts the barcode using the provided size and exports it to the specified stream in the specified image format.

  • ExportToImage(string filePath, Size size, ImageFormat imageFormat) - Layouts the barcode using the provided size and exports it to the specified file location in the specified image format.

Export to Image


using (SaveFileDialog saveFileDialog = new SaveFileDialog())
{
    saveFileDialog.Filter = "Png (*.png)|*.png";
    saveFileDialog.FileName = "QRCode";
    if (saveFileDialog.ShowDialog() == DialogResult.OK)
    {
        Image img = this.radBarcode1.ExportToImage();
        img.Save(saveFileDialog.FileName, System.Drawing.Imaging.ImageFormat.Png);
    }
}

Using saveFileDialog As SaveFileDialog = New SaveFileDialog()
    saveFileDialog.Filter = "Png (*.png)|*.png"
    saveFileDialog.FileName = "QRCode"
    If saveFileDialog.ShowDialog() = DialogResult.OK Then
        Dim img As Image = Me.radBarcode1.ExportToImage()
        img.Save(saveFileDialog.FileName, System.Drawing.Imaging.ImageFormat.Png)
    End If
End Using
End Sub

Figure 1: Exported Barcode

WinForms RadBarcode Exported Barcode

If you need to export the barcode data to a document, you can use a RadDocument and insert the exported image into it. Afterwards, you can use the RadRichTextEditor 's export functionality.

In this article