java 生成二维码

// 二维码
String codeInfo = JSON.toJSONString(vo);
codeInfo = AESUtil.aesEncrypt(codeInfo, CodeConstants.AES_TOKEN);
Image image = Image.getInstance(
QRCodeUtils.imageToBytes(QRCodeUtils.createImage(codeInfo, null, false, 300), "png"));

放在pdf中使用 cell填充:
`
PdfPTable pdfPTable2 = null;
pdfPTable2 = new PdfPTable(new float[] { 40,60 });
pdfPTable2.setWidthPercentage(100);
pdfPTable2.setHorizontalAlignment(Element.ALIGN_CENTER);
PdfPCell pdfPCell = new PdfPCell();
pdfPCell = new PdfPCell(image, true);
pdfPCell.setHorizontalAlignment(Element.ALIGN_LEFT);
pdfPCell.setVerticalAlignment(Element.ALIGN_CENTER);
pdfPCell.setBorderWidthTop(0);
pdfPCell.setBorderWidthRight(0);
pdfPCell.setBorderWidthBottom(0);
pdfPCell.setBorderWidthLeft(0);
pdfPCell.setRowspan(5);
pdfPTable2.addCell(pdfPCell);`
posted on 2023-10-30 14:38 HeavenTang 阅读(294) 评论(0) 收藏 举报
浙公网安备 33010602011771号