Free Support Forum - aspose.com

Datamatrix doesnt read

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

Hi Micheal,


Thank you for contacting support.

I have worked with your sample and I am able to recognize the barcode using the similar code snippet as of yours. Please note that I have used the latest version ofAspose.BarCode for .NET (Latest Version) and Aspose.Pdf for .NET (Latest Version). The CodeText found from your provided sample is 75001|49602. I would request you to please get the latest versions of said components from Aspose download section and test it on your end.

Regarding the version of Aspose.BarCode that is deployed on the demo server. I will check back the version and will let you know here.