2017-06-02 23 views

答えて

0

&は、PDF内のQRバーコードをデコードすることができるSDK/APIが多数あります。また、PDFの入力方法と分割方法も考慮する必要があります。

開発するプラットフォーム/プログラミング言語を指定していないため、いくつかのプラットフォーム/プログラミング言語を示します。

あなたはQRバーコードを検出するためのオープンソースソリューションを探しているなら、あなたはZXingを使用することができます。

  • ZXing .NET .NETやC#への移植、および関連するWindowsプラットフォーム

の場合より完全なソリューションを探している場合は、商用(非フリー)SDKを使用して調べることができます。免責条項と同様に、私はLEADTOOLSのために働き、私たちはBarcode SDKを持っています。

LEADTOOLSは、複数ページのPDFをBarcode SDKの一部として読み込んで分割する機能も備えています。したがって、1 SDKを使用して目的を達成することができます。次に、各ページにあるQRバーコードに基づいて複数ページのPDFを分割する小さなC#.NETメソッドを示します。

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"); 
} 
関連する問題