Hello,
I’m trying to read all barcode Code93Extended in a PDF.
My method works fine with a lot of PDF but I Have a problem with 2 files.
Calling “barcodeReader.Read()” stucks, Method doesn’t return. My application hangs on this method.
I set Timeout (in milliseconds) but doesn’t work.
I use Aspose.Barcode 5.0 (I can’t upgrade it).
Help me please. Thanks!
Private Function GetBarcodePDF() As List(Of String)
Dim listCodes = New List(Of String)
Try
’ Set Licence…
' bind the pdf document
Dim pdfExtractor As Aspose.Pdf.Facades.PdfExtractor = New Aspose.Pdf.Facades.PdfExtractor()
pdfExtractor.BindPdf("c:\Temp\file.pdf")
' set page range for image extraction
pdfExtractor.StartPage = 0
pdfExtractor.EndPage = 1
' extract the images
pdfExtractor.ExtractImage()
' save images to stream in a loop
Do While pdfExtractor.HasNextImage()
' save image to stream
Dim imageStream As MemoryStream = New MemoryStream()
pdfExtractor.GetNextImage(imageStream)
imageStream.Position = 0
' recognize the barcode from the image stream above
dim barcodeReader = New Aspose.BarCodeRecognition.BarCodeReader(imageStream, BarCodeReadType.Code93Extended)
barcodeReader.Timeout = 2500
Do While barcodeReader.Read()
listCodes.Add(barcodeReader.GetCodeText)
Loop
' close the reader
barcodeReader.Close()
Loop
GetBarcodePDF = listCodes
Catch ex As Exception
m_exception = ex.Message
End Try
End Function