I'm writing java code that uses Zxing to create a QR code on printed conference badges that contain attendee information to be used for lead retrieval.
I've been able to create a QR code and have been able to scan it successfully on most phones. A few phones were not able to scan the QR code so we wanted to make it a bit larger but we still need it to fit on the badge without conflicting with other elements.
When generating the QR code Zxing does not seem to be respecting the size that I'm passing in. If I use sizes of 100-105 I get the same size QR code. If I use 106 the size of the finished QR code is doubled. For the life of me I can't figure out what I'm doing wrong.
Here is the code... Does anyone have any suggestions?
<SNIP>
String filePath = System.getProperty("catalina.base") +
System.getProperty("file.separator") +
"webapps" + System.getProperty("file.separator") +
"craps" + System.getProperty("file.separator") +
"tmp";
File qrDir = new File(filePath);
File qrFile = File.createTempFile("CrapsBC", ".png", qrDir);
OutputStream os = new FileOutputStream(qrFile);
Hashtable hintMap = new Hashtable();
hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
String content = "Some user information.";
String size = 106;
QRCodeWriter qrCodeWriter = new QRCodeWriter();
BitMatrix bitMatrix = qrCodeWriter.encode(content, BarcodeFormat.QR_CODE, size, size, hintMap);
MatrixToImageWriter.writeToStream(bitMatrix, "png", os);
os.flush();
os.close();
// Add the QR code to the PDF
Image image = Image.getInstance(qrFile.getAbsolutePath());
template.addImage(image, size, 0, 0, size, 170, 60); // (image, image_width, 0, 0, image_height, x, y)
// Make sure to delete the QR code file.
qrFile.delete();
</SNIP>