I was trying to export QR code as image inside C: folder. I'm using C# on visual studio and devExpress to create the QR code. I've already created the QR code but I don't know how to export it. Is there a way to do it? Hadn't tried much because I didn't find a lot. Thank you!
Asked
Active
Viewed 1,336 times
-2
-
The following may be helpful: https://stackoverflow.com/questions/69206917/how-to-generate-pdf-one-page-one-row-from-datatable-using-itextsharp/69218085#69218085 – Tu deschizi eu inchid Sep 25 '21 at 15:13
-
Please provide enough code so others can better understand or reproduce the problem. – Community Oct 03 '21 at 12:50
-
Please check the devexpress documentation, https://docs.devexpress.com/XtraReports/DevExpress.XtraReports.UI.XtraReport.ExportToImage.overloads and https://docs.devexpress.com/XtraReports/2581/detailed-guide-to-devexpress-reporting/store-and-distribute-reports/export-reports/export-to-image – Mdyahiya Oct 12 '21 at 03:46
2 Answers
2
If you wish to generate barcodes using our WinForms BarCodeControl, use the BarCodeControl.ExportToImage(Stream, ImageFormat, Int32) method to export barcode as an image to a stream. after that convert a stream to byte array
or a Base64
string.
If you prefer non-visual Barcode Generation API library to create barcodes, use the BarCode.Save(Stream, ImageFormat) method to save the barcode image to a stream in the specified format.Then, convert a stream to a byte array or a Base64 string.

MD. RAKIB HASAN
- 3,670
- 4
- 22
- 35
-
The last part, when it says 'convert a stream to a byte array or a Base64 string', what does it mean? – Leonardo Vitale Sep 25 '21 at 10:50
-
0
This code belokngs to vb. Net and I'm not using devexpress Add Zxing.net nuget package. Maybe this code can help you or someone
Imports System.Data Imports ZXing.Common Imports ZXing Imports ZXing.QrCode Public Class Form1
Private options As QrCodeEncodingOptions
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
options = New QrCodeEncodingOptions With {
.DisableECI = True,
.CharacterSet = "UTF-8",
.Width = 50,
.Height = 50
}
Dim writer = New BarcodeWriter()
writer.Format = BarcodeFormat.QR_CODE
writer.Options = options
writer.Options.PureBarcode = True
End Sub
Private Sub btn_GenerateQRCode_Click(sender As Object, e As EventArgs) Handles btn_GenerateQRCode.Click
If String.IsNullOrWhiteSpace(TextBox1.Text) OrElse String.IsNullOrEmpty(TextBox1.Text) Then
PictureBox1.Image = Nothing
MessageBox.Show("Text not found", "Oops!", MessageBoxButtons.OK, MessageBoxIcon.[Error])
Else
Dim qr = New ZXing.BarcodeWriter()
qr.Options = options
qr.Format = ZXing.BarcodeFormat.QR_CODE
Dim result = New Bitmap(qr.Write(TextBox1.Text.Trim()))
PictureBox1.Image = result
TextBox1.Clear()
End If
End Sub
Private Sub btn_DecodeQRCode_Click(sender As Object, e As EventArgs) Handles btn_DecodeQRCode.Click
Try
Dim bitmap As Bitmap = New Bitmap(PictureBox1.Image)
Dim reader As BarcodeReader = New BarcodeReader With {
.AutoRotate = True,
.TryInverted = True
}
Dim result As Result = reader.Decode(bitmap)
Dim decoded As String = result.ToString().Trim()
TextBox1.Text = decoded
Catch ex As Exception
MessageBox.Show("Image not found", "Oops!", MessageBoxButtons.OK, MessageBoxIcon.[Error])
End Try
End Sub
Private Sub btn_BrowseQRImage_Click(sender As Object, e As EventArgs) Handles btn_BrowseQRImage.Click
Dim open As OpenFileDialog = New OpenFileDialog()
If open.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
Dim qr = New ZXing.BarcodeWriter()
qr.Options = options
qr.Format = ZXing.BarcodeFormat.QR_CODE
PictureBox1.ImageLocation = open.FileName
End If
End Sub
Private Sub btnExportQRCodetoFolder_Click(sender As Object, e As EventArgs) Handles btnExportQRCodetoFolder.Click
If PictureBox1.Image Is Nothing Then
MessageBox.Show("Image not found", "Oops!", MessageBoxButtons.OK, MessageBoxIcon.[Error])
Else
Dim save As SaveFileDialog = New SaveFileDialog()
'save.CreatePrompt = True
'save.OverwritePrompt = True
'save.FileName = "MyQR"
save.Filter = "PNG|*.png|JPEG|*.jpg|BMP|*.bmp|GIF|*.gif"
If save.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
PictureBox1.Image.Save(save.FileName)
save.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
End If
End If
End Sub
End Class

Prabahar
- 26
- 2