簡體   English   中英

如何使用燒烤庫創建條形碼圖像而底部不包含文本

[英]How do I create barcode image without containing text at bottom using barbecue library

我想生成一個barcode.png文件,但是生成的文件中也包含條形碼編號,我不想要那個,我只想要沒有文本的圖像。

怎么做? 下面是我的代碼:

Barcode barcode3;
barcode3 = BarcodeFactory.createCode128("CODE128x1");
barcode3.setResolution(300);
BarcodeImageHandler.savePNG(barcode3, new File("Code128-1.png"));`

如果將null參數傳遞給Barcode類的setFont函數,則不會生成文本。 您的代碼如下所示

    Barcode barcode3;
    barcode3 = BarcodeFactory.createCode128("CODE128x1");
    barcode3.setFont(null);
    barcode3.setResolution(300);
    BarcodeImageHandler.savePNG(barcode3, new File("Code128-1.png"));

僅將其添加到您的代碼中:

barcode3.setDrawingText(false);

上面的方法將從條形碼中刪除文本。 完整的代碼

Barcode barcode3;
barcode3 = BarcodeFactory.createCode128("CODE128x1");
barcode3.setDrawingText(false);
barcode3.setResolution(300);
BarcodeImageHandler.savePNG(barcode3, new File("Code128-1.png"));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM