Apache Velocity PDF QR Layout issue

Experience Log #3
Resolved
#Java Template QR code Generate
Created
2025-12-02T04:20:15.980Z
Last Updated
2025-12-02T04:20:14.959Z

Description

For Java generate QR code a html ready code for the template com.google.zxing.qrcode.QRCodeWriter generate the qr sizing issue code exmaple: String urlQrCodeBase64 = qrCodeService.generateQRCodePngBase64("context", 150); <img src=\"data:image/png;base64," + urlQrCodeBase64 + "\" style=\"width: 150px; height: 150px;\" /> butthe context leght is more the size will be shrink

Solution

Map<EncodeHintType, Object> hints = new HashMap<>(); hints.put(EncodeHintType.MARGIN, 1); // Use 0 margin for maximum QR code size BitMatrix bitMatrix = qrCodeWriter.encode(context, BarcodeFormat.QR_CODE, size, size, hints); using MARGIN to scale the qr size to fits the container

Apache Velocity PDF QR Layout issue - Keith's Portfolio