我需要按照一些技术规范创建一个qrcode,例如: qrcode符号version()、模块()、模块宽度()、ECC级别()和字符集()。我必须使用itextpdf库,我所获得的必须成为和awt.Image。
我试图同时使用BarcodeQRCode.和QRCode。使用QRCode I设置符号版本、模块、模块宽度和ECC级别。然后使用BarcodeQRCode设置字符集,然后我可以获得一个awt.Image。
问题是我不能将QRCode传递给BarcodeQRCode。您知道如何解决这个问题并使用这个库获得完整的qrcode/映像吗?
这是我的密码:
StringBuffer sb = new StringBuffer ();
sb.append ( QRCODE_IDENTIFICATIVO );
// other lines with the content of qrcode
QRCode qrCode = new QRCode ();
qrCode.setVersion ( versione );
qrCode.at ( modulesWidth, modulesHeight );
qrCode.setMatrixWidth ( modulesWidth );
qrCode.setECLevel ( ErrorCorrectionLevel.M );
Map<EncodeHintType, Object> qrParam = new HashMap<EncodeHintType, Object> ();
qrParam.put ( EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M );
qrParam.put ( EncodeHintType.CHARACTER_SET, "UTF-8" );
BarcodeQRCode qrcode = new BarcodeQRCode ( sb.toString (), (int) mmToPt ( 30f ), (int) mmToPt ( 30f ), qrParam );
return qrcode.createAwtImage ( Color.BLACK, Color.WHITE );谢谢
发布于 2018-12-18 09:24:55
我知道如何解决这个问题。版本4是有33个模块(或模块width=33)的版本。因此,在初始化barQRcode时,第二个和第三个参数设置模块数量,因此,版本和模块宽度也会设置。而EncodeHintType提供了有关字符和纠错的信息。通过这种方式,无需使用QRcode就可以使用所有信息。它是:
StringBuffer sb = new StringBuffer ();
sb.append ( QRCODE_IDENTIFICATIVO );
// other lines with the content of qrcode
Map<EncodeHintType, Object> qrParam = new HashMap<EncodeHintType, Object> ();
qrParam.put ( EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M );
qrParam.put ( EncodeHintType.CHARACTER_SET, "UTF-8" );
BarcodeQRCode qrcode = new BarcodeQRCode ( sb.toString (), 33, 33, qrParam );
return qrcode.createAwtImage ( Color.BLACK, Color.WHITE );https://stackoverflow.com/questions/53782305
复制相似问题