I generated the QR code and I want to print the QR code directly from this method without javascript. I tried with javascript. It's not printing properly. I will get a base64 image in the result variable. Please help to find out the solution.
public ContentResult GeneratQRCode(string ID)
{
string result;
try
{
using (MemoryStream ms = new MemoryStream())
{
QRCodeGenerator qrGenerator = new QRCodeGenerator();
QRCodeGenerator.QRCode qrCode = qrGenerator.CreateQrCode(ID, QRCodeGenerator.ECCLevel.Q);
Bitmap bitMap = new Bitmap(40, 40);
using (bitMap = qrCode.GetGraphic(2))
{
bitMap.Save(ms, ImageFormat.Png);
PrintDocument pd = new PrintDocument();
result = "data:image/png;base64," + Convert.ToBase64String(ms.ToArray());
}
}
return Content(result);
}
catch (Exception ex)
{
result = "Exception";
return Content(result);
}
}