日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

itextpdf 二维码

發布時間:2023/12/14 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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 二维码的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。