List of usage examples for com.itextpdf.text.pdf.qrcode ErrorCorrectionLevel L
ErrorCorrectionLevel L
To view the source code for com.itextpdf.text.pdf.qrcode ErrorCorrectionLevel L.
Click Source Link
From source file:com.mui.certificate.core.HalalCertification.java
License:Apache License
private ByteMatrix generateQRCode(String data) throws Exception { QRCode qrcode = new QRCode(); qrcode.setMode(Mode.BYTE);/*from ww w .ja va2s .c o m*/ Encoder.encode(data, ErrorCorrectionLevel.L, qrcode); ByteMatrix matrix = qrcode.getMatrix(); return matrix; }
From source file:se.billes.pdf.renderer.model.QRCode.java
License:Open Source License
@SuppressWarnings("unchecked") public void onRender(PdfContentByte cb) throws PdfRenderException { float[] positions = new BlockFactory().getBoundsInPs(this); try {/*w w w .java 2s .c o m*/ @SuppressWarnings("rawtypes") Hashtable hintMap = new Hashtable(); hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L); PdfDocument req = getPage().getPdfDocument(); QRCodeWriter qrCodeWriter = new QRCodeWriter(); BitMatrix byteMatrix = qrCodeWriter.encode(getText(), BarcodeFormat.QR_CODE, (int) (positions[2]), (int) (positions[3]), hintMap); int matrixWidth = byteMatrix.getWidth(); int matrixHeight = byteMatrix.getHeight(); float pageHeight = req.getSize()[1]; float top = getPosition()[1]; if (getPage().getPdfDocument().getCutmarks() != null) { pageHeight += SizeFactory.CUT_MARK * 2; top += SizeFactory.CUT_MARK; } cb.setColorFill(getBaseColor()); float pageHeightInPs = SizeFactory.millimetersToPostscriptPoints(pageHeight); float topInPs = SizeFactory.millimetersToPostscriptPoints(top); for (int i = byteMatrix.getTopLeftOnBit()[0]; i < matrixWidth; i++) { for (int j = byteMatrix.getTopLeftOnBit()[0]; j < matrixHeight; j++) { if (byteMatrix.get(i, j)) { cb.rectangle(positions[0] + (i - byteMatrix.getTopLeftOnBit()[0]), pageHeightInPs - ((topInPs + 1) + (j - byteMatrix.getTopLeftOnBit()[0])), 1, 1); } } } cb.fill(); cb.setColorFill(new ColorFactory().getBlack()); } catch (Exception e) { } }