Here a short sample to detect & read 1D barcodes from PDF:
- Code: Select all
'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
And now a sample to read Datamatrix barcodes from PDF:
- Code: Select all
'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
