【问题标题】:How to insert barcode in PDF using PDFBox 2.0.13?如何使用 PDFBox 2.0.13 在 PDF 中插入条形码?
【发布时间】:2019-02-12 09:25:14
【问题描述】:

我正在尝试使用 PDFBox2.0.13 在 PDF 中插入条形码。我尝试为此使用 BufferedImage,如 How to add Code128 Barcode image to existing pdf using pdfbox(1.8.12) with barcode4j library? 但这使用“new PDPixelMap(doc, bim)”这个 PDPixelMap 在 2.0.x 中已弃用。 我的问题是我们如何在不使用 PDPixelMap 的情况下使用 PDFBox2.0.13 中可用的 API(可能替换 PDPixelMap)在 PDF 中插入条形码?如果提供代码 sn-p 那就太好了。

【问题讨论】:

    标签: java pdf-generation pdfbox


    【解决方案1】:

    像这样使用LosslessFactory

    PDImageXObject img = LosslessFactory.createFromImage(doc, bim);
    contentStream.drawImage(img, x, y);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-12
      • 1970-01-01
      • 2016-06-28
      相关资源
      最近更新 更多