itextpdf 二维码
生活随笔
收集整理的這篇文章主要介紹了
itextpdf 二维码
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
itextpdf 二維碼
????????????????????
??????????????????????
***************
相關類與接口
??????????
BarcodeQRCode
public class BarcodeQRCode extends Barcode2D {ByteMatrix bm;Map<EncodeHintType, Object> hints;String code;******** 構造方法public BarcodeQRCode(String code, Map<EncodeHintType, Object> hints) {public BarcodeQRCode(String content) {public BarcodeQRCode() {******** 其他方法public void setCode(String code) {public void setHints(Map<EncodeHintType, Object> hints) {public void regenerate() {public String getCode() {public Rectangle getBarcodeSize() {public Map<EncodeHintType, Object> getHints() {public Rectangle getBarcodeSize(float moduleSize) {public Rectangle placeBarcode(PdfCanvas canvas, Color foreground) {public Rectangle placeBarcode(PdfCanvas canvas, Color foreground, float moduleSide) {public PdfFormXObject createFormXObject(Color foreground, PdfDocument document) {public PdfFormXObject createFormXObject(Color foreground, float moduleSize, PdfDocument document) {public Image createAwtImage(java.awt.Color foreground, java.awt.Color background) {private byte[] getBitMatrix() {????????????????
???????????????
***************
示例
??????????
public class Test4 {private static final String dest = "./qrcode/1.pdf";private static final String dest2 = "./qrcode/2.pdf";public static void fun() throws Exception{ //image生成二維碼,可調整二維碼寬度、高度,掃描二維碼會跳轉到百度首頁PdfDocument pdfDocument = new PdfDocument(new PdfWriter(dest));Document document = new Document(pdfDocument);BarcodeQRCode barcodeQRCode = new BarcodeQRCode();barcodeQRCode.setCode("http://www.baidu.com");Image image = new Image(barcodeQRCode.createFormXObject(pdfDocument));image.setWidth(200);image.setHeight(200);image.setFixedPosition(100,600);document.add(image);document.close();}public static void fun2() throws Exception{ //canvas繪制二維碼,掃描二維碼會跳轉到百度首頁PdfDocument pdfDocument = new PdfDocument(new PdfWriter(dest2));BarcodeQRCode barcodeQRCode = new BarcodeQRCode();barcodeQRCode.setCode("http://www.baidu.com");PdfFormXObject object = barcodeQRCode.createFormXObject(ColorConstants.BLACK,pdfDocument);float x = 100;float y = 750;float width = object.getWidth();float height = object.getHeight();PdfCanvas canvas = new PdfCanvas(pdfDocument.addNewPage());canvas.saveState();canvas.setFillColor(ColorConstants.WHITE);canvas.rectangle(x, y, width, height);canvas.fill();canvas.restoreState();canvas.addXObjectAt(object, x, y);pdfDocument.close();}public static void main(String[] args) throws Exception{fun();fun2();} }??????????????
image生成二維碼
????? ? ?? ?????
???????????????
canas繪制二維碼
????? ? ?? ?????
? ? ? ? ? ?
??????????????????
總結
以上是生活随笔為你收集整理的itextpdf 二维码的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MATLAB的图像显示函数imshow(
- 下一篇: 主机前置耳机孔没声音