Skip to content

Instantly share code, notes, and snippets.

@mevsungur
Created June 9, 2021 08:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mevsungur/ea23baa7bc5dc77045a512a835397c4c to your computer and use it in GitHub Desktop.
Save mevsungur/ea23baa7bc5dc77045a512a835397c4c to your computer and use it in GitHub Desktop.
QR code generator with zxing
public static BufferedImage createQr(String text, Integer length) throws UnsupportedEncodingException, WriterException {
MultiFormatWriter writer = new MultiFormatWriter();
text = new String(text.getBytes("UTF-8"),"UTF-8");
BitMatrix matrix = writer.encode( text,
BarcodeFormat.QR_CODE, length, length);
BufferedImage bufferedImage = MatrixToImageWriter.toBufferedImage(matrix);
return bufferedImage;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment