【问题标题】:Read barcode from PDF file从 PDF 文件读取条形码
【发布时间】:2014-08-10 23:57:18
【问题描述】:

是否有任何 Java API 可以在打开的文件(扫描的 PDF)中找到条形码,然后从条形码中检索数据? 或者我应该如何解决这个问题?

【问题讨论】:

  • 将每个页面转换为图像。在图像上运行某种图像识别算法来定位潜在的条形码。隔离潜在的条码并通过条码识别/解码库运行。
  • 谢谢。你知道任何可以为我隔离条形码的 Java 库吗?

标签: java barcode


【解决方案1】:

如果您在 Windows 上运行,ClearImage Barcode SDK 有一个 Java API。它可以从 PDF 或图像中读取和解码条形码,并将解码后的数据提供给您。

一些示例代码:

public static void testDataMatrix () {
  try { 
       String filename  = "1.png ";
       CiServer objCi = new CiServer();
       Ci = objCi.getICiServer();

       ICiDataMatrix reader = Ci.CreateDataMatrix(); // read DataMatrix Barcode
       reader.getImage().Open(filename, 1);
       int n = reader.Find(0); // find all the barcodes in the doc
       for (i = 1; i <= n; i++) {
          ICiBarcode Bc = reader.getBarcodes().getItem(i); // getItem is 1-based
          System.out.println("Barcode " + i + " has Text: " + Bc.getText());
       }
   } catch (Exception ex) {System.out.println(ex.getMessage());}
 }

另一个需要考虑的是Accusoft 的Barcode Xpress,它也有一个Java API。

免责声明:我过去曾为 Inlite 做过一些工作。

【讨论】:

    猜你喜欢
    • 2012-01-27
    • 2011-03-31
    • 1970-01-01
    • 2019-12-29
    • 1970-01-01
    • 1970-01-01
    • 2015-07-08
    • 1970-01-01
    • 2021-10-27
    相关资源
    最近更新 更多