GdPicture.NET使用教程:读取PDF文档中的1D和2D码

使用GdPicture.NET(点击进入下载页)可以快速读取PDF文档中的1D和2D码,下面给出示例代码。

1 读取PDF文档中的1D码

   
      'Step1: Open the PDF
      Dim oGdPicturePDF As New GdPicture.GdPicturePDF
      If oGdPicturePDF.LoadFromFile("c:\test.pdf", False) = GdPictureStatus.OK Then
         'Step2: Convert the desired PDF page to GdPicture Image
         oGdPicturePDF.SelectPage(1)
         Dim ImageID As Integer = oGdPicturePDF.RenderPageToGdPictureImage(200, False)
         If ImageID <> 0 Then
            'Step3: Barcode recognition from GdPicture Image
            Dim oGdPictureImaging As New GdPicture.GdPictureImaging
            oGdPictureImaging.Barcode1DReaderDoScan(ImageID, Barcode1DReaderScanMode.BestQuality)
            oGdPictureImaging.ReleaseGdPictureImage(ImageID)
            For i As Integer = 1 To oGdPictureImaging.Barcode1DReaderGetBarcodeCount
               MsgBox("Barcode no: " + Str(i) + Chr(13) + _
                      "Barcode type: " + oGdPictureImaging.Barcode1DReaderGetBarcodeType(i).ToString + Chr(13) + _
                      "Barcode angle: " + Str(oGdPictureImaging.Barcode1DReaderGetBarcodeSkewAngle(i)) + Chr(13) + _
                      "Barcode value: " + oGdPictureImaging.Barcode1DReaderGetBarcodeValue(i))
            Next
            oGdPictureImaging.Barcode1DReaderClear()
            oGdPictureImaging.Dispose()
         End If
         oGdPicturePDF.CloseDocument()
      End If

2 读取PDF文档中的Datamatrix码

   
      'Step1: Open the PDF
      Dim oGdPicturePDF As New GdPicture.GdPicturePDF
      If oGdPicturePDF.LoadFromFile("c:\test.pdf", False) = GdPictureStatus.OK Then
         'Step2: Convert the desired PDF page to GdPicture Image
         oGdPicturePDF.SelectPage(1)
         Dim ImageID As Integer = oGdPicturePDF.RenderPageToGdPictureImage(200, False)
         If ImageID <> 0 Then
            'Step3: Barcode recognition from GdPicture Image
            Dim oGdPictureImaging As New GdPicture.GdPictureImaging
            oGdPictureImaging.BarcodeDataMatrixReaderDoScan(ImageID, BarcodeDataMatrixReaderScanMode.BestQuality)
            oGdPictureImaging.ReleaseGdPictureImage(ImageID)
            For i As Integer = 1 To oGdPictureImaging.BarcodeDataMatrixReaderGetBarcodeCount
               MsgBox("Barcode no: " + Str(i) + Chr(13) + _
                      "Barcode columns: " + oGdPictureImaging.BarcodeDataMatrixReaderGetBarcodeColumns(i).ToString + Chr(13) + _
                      "Barcode rows: " + Str(oGdPictureImaging.BarcodeDataMatrixReaderGetBarcodeRows(i)) + Chr(13) + _
                      "Barcode value: " + oGdPictureImaging.BarcodeDataMatrixReaderGetBarcodeValue(i))
            Next
            oGdPictureImaging.BarcodeDataMatrixReaderClear()
            oGdPictureImaging.Dispose()
         End If
         oGdPicturePDF.CloseDocument()
      End If

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值