Hello
Which version of Aspose.Barcode recognition is used here:
http://www.aspose.com/demos/.net-components/aspose.barcode/vb.net/barcode-reader/read-from-pdf.aspx
The PDF I have reads the Datamatrix on the Website but not in my code.
I'm using Aspose.Barcode 4.7.0.0 and have have the same problem with the newst version
_
Public
Shared Sub stproc_ReadDataMatrixeFromPDF(ByVal inputFile As String, ByRef DataMatrix As String)
Try
' set the license for Aspose.BarCode for .NET and Aspose.Pdf.Kit for .NET components
Dim licenceBarCodeRecognition As Aspose.BarCodeRecognition.License = New Aspose.BarCodeRecognition.License()
licenceBarCodeRecognition.SetLicense(
"D:\Data\DigiDocs\Assemblies\Production\dllWord\Aspose.Total.lic")
Dim licensePdfKit As Aspose.Pdf.Kit.License = New Aspose.Pdf.Kit.License()
licensePdfKit.SetLicense(
"D:\Data\DigiDocs\Assemblies\Production\dllWord\Aspose.Total.lic")
' bind the pdf document
Dim pdfExtractor As Aspose.Pdf.Kit.PdfExtractor = New Aspose.Pdf.Kit.PdfExtractor()
pdfExtractor.BindPdf(inputFile)
' set page range for image extraction
pdfExtractor.StartPage = 1
pdfExtractor.EndPage = 1
' extract the images
Console.WriteLine(
"Extracting images.....")
pdfExtractor.ExtractImage()
' save images to stream in a loop
Do While pdfExtractor.HasNextImage()
Console.WriteLine(
"Getting next image....")
' save image to stream
Dim imageStream As MemoryStream = New MemoryStream()
pdfExtractor.GetNextImage(imageStream)
imageStream.Position = 0
Console.WriteLine(
"Recognizing barcode....")
' recognize the barcode from the image stream above
Dim reader As BarCodeReader = New BarCodeReader(imageStream, BarCodeReadType.DataMatrix)
Dim barcodes As String
barcodes =
“”
’ call Read() method in a loop
Do While reader.Read()
barcodes = barcodes &
"," & reader.GetCodeText().ToString()
Loop
Using connection As New SqlConnection(“context connection=true”)
connection.Open()
Dim command As New SqlCommand("SELECT '" & barcodes & "' AS BarcodesCommanSeperated", connection)
SqlContext.Pipe.ExecuteAndSend(command)
End Using
DataMatrix = barcodes
reader.Close()
reader.Dispose()
barcodes =
Nothing
Loop
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
End Sub