Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QRCode' does not contain a definition for 'GetGraphic' and no accessible extension method 'GetGraphic' accepting a first argument of type 'QRCode' could be found #441

Open
ANKUSH-032 opened this issue Jan 10, 2023 · 1 comment

Comments

@ANKUSH-032
Copy link

I am trying to generate QRCode in .Net 6 but get a error Tell me where is my code wrong

QRCodeGenerator qrCodeGenerator = new();
string data = "Name : " + employeeSalaryGetDetails.Name + "\n DOB : " + employeeSalaryGetDetails.DayofBirth.ToString() + "\n Email Address : " + employeeSalaryGetDetails.EmailId.ToString();
QRCodeData qrCodeData = qrCodeGenerator.CreateQrCode(data, QRCodeGenerator.ECCLevel.Q);
QRCode qrCoder = new();
qrCoder.Equals(qrCodeData);
Image rqCodeImage = qrCoder.GetGraphic(20);

            var bytes = ImageToByteArray(rqCodeImage);
            return File(bytes, "image/tmp");
@Benjlet
Copy link

Benjlet commented Apr 1, 2023

Ankush,

The syntax on the frontpage of this GitHub might be for an older version - the below code works fine for me in .NET 6, referencing QRCoder v1.4.3:

string data = "Your data here";
string path = @"image/example.png"

QRCodeData qrCodeData = QRCoder.QRCodeGenerator.GenerateQrCode(data, QRCoder.QRCodeGenerator.ECCLevel.Q);
BitmapByteQRCode qrCode = new QRCoder.BitmapByteQRCode(qrCodeData);
byte[] bytes = qrCode.GetGraphic(50);

File.WriteAllBytes(path, bytes);

There are of course much nicer ways of writing this but illustrates it is still working on the latest.

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants