2017-06-02 183 views

回答

0

有很多SDKs/API能够检测到&解码PDF中的QR条码。您还必须考虑如何输入PDF并将其拆分。

您没有指定您正在开发的平台/编程语言,因此我将列出几个不同的平台/编程语言。

如果你正在寻找一种用于检测QR条码一个开源的解决方案,那么你可以使用斑马线:

  • ZXing .NET口.NET和C#和相关的Windows平台

如果您正在寻找更完整的解决方案,您可以使用Commercial(非免费)SDK进行研究。就像一个免责声明,我为LEADTOOLS工作,我们有一个Barcode SDK

LEADTOOLS还能够将多页PDF作为条码SDK的一部分加载和拆分,因此您可以使用1 SDK来实现您想要的功能。下面是一个小的C#.NET方法,它将基于每个页面上的QR条码分割多页PDF:

static void SplitPDF(string filename) 
{ 
    BarcodeEngine barcodeEngine = new BarcodeEngine(); 
    List<int> PageNumbers = new List<int>(); 
    using (RasterCodecs codecs = new RasterCodecs()) 
    { 
     int totalPages = codecs.GetTotalPages(filename); 
     for (int page = 1; page <= totalPages; page++) 
     using (RasterImage image = codecs.Load(filename, page)) 
     { 
      BarcodeData barcodeData = barcodeEngine.Reader.ReadBarcode(image, LogicalRectangle.Empty, BarcodeSymbology.QR); 
      if (barcodeData != null) // QR Barcode found on this image 
       PageNumbers.Add(page); 
     } 
    } 

    int firstPage = 1; 
    PDFFile pdfFile = new PDFFile(filename); 
    //Loop through and split the PDF according to the barcodes 
    for(int i= 0; i < PageNumbers.Count; i++) 
    { 
     string outputFile = $"{Path.GetDirectoryName(filename)}\\{Path.GetFileNameWithoutExtension(filename)}_{i}.pdf"; 
     pdfFile.ExtractPages(firstPage, PageNumbers[i] - 1, outputFile); 
     firstPage = PageNumbers[i]; //set the first page to the next page 
    } 
    //split the rest of the PDF based on the last barcode 
    if (firstPage != 1) 
     pdfFile.ExtractPages(firstPage, -1, $"{Path.GetDirectoryName(filename)}\\{Path.GetFileNameWithoutExtension(filename)}_rest.pdf"); 
}