View Qrcode on screen in web application

Asked

Viewed 27 times

0

I have this code that generates the Qrcode of the Zxing library:

private static byte[] getQRCodeImage(String text, int width, int height) throws WriterException, IOException {
  QRCodeWriter qrCodeWriter = new QRCodeWriter();
  BitMatrix bitMatrix = qrCodeWriter.encode(text, BarcodeFormat.QR_CODE, width, height);

  ByteArrayOutputStream pngOutputStream = new ByteArrayOutputStream();
  MatrixToImageWriter.writeToStream(bitMatrix, "PNG", pngOutputStream);
  byte[] pngData = pngOutputStream.toByteArray();
  return pngData;
}

It is returning an array of bytes.

I’m making a web application.

How do I display this array as an image on the screen?

  • Your application is developed in Java and runs in the browser or is a web server?

  • JSF + Primefaces

  • There is some relevant information at this link. I will then write a reply quoting them.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.