Skip to content

This is rest api for generate the QR-Code which is developed by Grails-3.x.

Notifications You must be signed in to change notification settings

mindexpert7546/qr-code-generator

Repository files navigation

Cheat Sheet

QR-Code Generator API :


  1. Create the New Restful Application
  2. Dependency :
   compile 'com.google.zxing:core:3.4.1'
   compile 'com.google.zxing:javase:3.4.1'
ref link : https://mvnrepository.com/artifact/com.google.zxing/core/3.4.1
  1. Create the service for the generationg the qr code :

  2. Crete the controller to call the service to use it for creating the qr code

  3. Make sure URLMapping is working fine

Complete ref : https://medium.com/nerd-for-tech/how-to-generate-qr-code-in-java-spring-boot-134adb81f10d

Screenshot :

Screenshot (24)

How to run :

make sure you hava install

| Grails Version: 3.2.6
| Groovy Version: 2.4.7
| JVM Version: 1.8.0_181

Clone this api in you local system

git clone https://github.com/mindexpert7546/qr-code-generator.git

Go to the qr folder

cd qr-code-generator

for running

grails run-app

To test this api by postman

http://localhost:8080/qrgen

Above is the url of this api

Now for final result : After url put / here the text will be converted into the qr

Explain :

Supposed you enter :

http://localhost:8080/qrgen/mindexpert

In above url mindexpert will be converted into the qr.

Some importent step :

  1. Crete the object of QRCodeWriter (e.g - QRCodeWriter qrCodeWriter = new QRCodeWriter())

  2. Use qrCodeWriter to generate the qr code and store to the BitMatrix in from of 2D array (e.g- BitMatrix bitMatrix = qrCodeWriter.encode(text, BarcodeFormat.QR_CODE, width, height))

  3. Crete the object of ByteArrayOutputStream to stor the qr code in form of byte (e.g- ByteArrayOutputStream pngOutputStream = new ByteArrayOutputStream())

  4. Now the time to build complete qr code and store to the byte output Stream (e.g - MatrixToImageWriter.writeToStream(bitMatrix, "PNG", pngOutputStream,config))

We have successfuly build the application to generate the qr code in form of the png format