【问题标题】:How do I create barcode image without containing text at bottom using barbecue library如何使用烧烤库创建条码图像而不在底部包含文本
【发布时间】:2015-07-24 22:11:20
【问题描述】:

我想生成一个barcode.png文件,但生成的文件也包含条形码编号,我不想要,我只想要没有文本的图像。

如何做到这一点? 以下是我的代码:-

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

【问题讨论】:

    标签: barcode barbecue


    【解决方案1】:

    如果您将 null 参数传递给 Barcode 类的 setFont 函数,则不会生成文本。您的代码如下所示

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

    【讨论】:

      【解决方案2】:

      仅将此添加到您的代码中:

      barcode3.setDrawingText(false);
      

      上述方法将从条形码中删除文本。完整代码

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

      【讨论】:

      • 请完整解释这个答案。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多