QRCode
I'm trying to generate a QRCode (in email , png file , any method is accepted), but I'm not able to get it working. I'm using Bonita Community 6.3.9.
importing QRCode connector fails. then I'm trying with the following groovy script
import com.google.zxing.qrcode.*
import com.google.zxing.qrcode.decoder.*
import com.google.zxing.client.j2se.*
import javax.imageio.ImageIO
import java.awt.image.BufferedImage
import java.awt.*
//fix zxing dependency
@Grapes(
@Grab(group='com.google.zxing', module='javase', version='2.2')
)
def QRCODE_IMAGE_HEIGHT = 300
def QRCODE_IMAGE_WIDTH = 300
//path where you want to save qrcode
def IMAGE_PATH = "C:/"
def hints = new HashMap()
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H)
def qrWriter = new QRCodeWriter()
//Add your data instead of http://www.google.com
def matrix = qrWriter.encode("http://www.google.com",
BarcodeFormat.QR_CODE,
QRCODE_IMAGE_WIDTH,
QRCODE_IMAGE_HEIGHT,
hints)
def image = MatrixToImageWriter.toBufferedImage(matrix)
//Draw the new image
def combined = new BufferedImage(QRCODE_IMAGE_HEIGHT, QRCODE_IMAGE_WIDTH, BufferedImage.TYPE_INT_ARGB)
def g = (Graphics2D)combined.getGraphics()
g.drawImage(image, 0, 0, null)
def imageFile = new File(IMAGE_PATH, "qrcode_logo2.png")
ImageIO.write(combined, "PNG", imageFile)
that gives the Runtime exception: could not find matching construct
try - Line 22 - def qrWriter = new QRCodeWriter) what is the ) doing there?
Comments
I apologize, cut and paste error. now fixed the script
not yet. The only way I'm able to generate a QRcode in a email is by a free on line generator like this: http://api.qrserver.com/v1/create-qr-code/?data=HelloWorld&size=100x100
thank you for the interesting link. but error on
Regards
thank you very much for your patience, again
I've found that http://stackoverflow.com/questions/9257038/how-to-create-qrcode-using-ja...
It's very simple , but I'm not able to get It working error : java.lang.NoSuchMethodError: com.google.zxing.Writer.encode(Ljava/lang/String;Lcom/google/zxing/BarcodeFormat;IILjava/util/Map;)Lcom/google/zxing/common/BitMatrix; I'm doing something wrong, but I don't know
I'm trying also to make use of this https://github.com/tyanhly/QRCode/blob/master/grails-app/services/grails...
but without success too
regards
thank you very much now it works Regards
- removed old JARs
- replaced with ones from the above link
- respect to your original code I've changed the path (desktop rather than C:\ ), because of a privilege exception.
try {
FileOutputStream fout = new FileOutputStream(new File("C:\\.....\\Desktop"));
fout.write(out.toByteArray());
fout.flush();
fout.close();
} catch (FileNotFoundException e) {
// Do Logging
} catch (IOException e) {
// Do Logging
}
good work Regards
hello, Im new in Bonita and I want to know how to use this jar. Where should I put those code to make QRcode.jar works?
Thanks before.
Regards
Sorry, I want to ask again.
Actually, it works when I run it with 'evaluate' button in connectors out box and set the necessary JARs manually! (as seen in pict below) 1
could it be automatically because I want to use it to generate qrcode based on user input? I've put it in LIB folder (C:\BonitaBPMCommunity-7.3.2\jre\lib).
Thanks in advance.
regards,
Delina
Comments
I'm not used to groovy but I see no try{} catch(){} blocks...
one which statement do you think you get this error message?
see here
regards