Sorry, but it still does not work
I am converting the PDF to bitmap via spire.pdf and then try to read from the bmp-object. The bitmap looks fine if I take a peak via "bmp.save("temp.bmp") ". Here is my code... Any ideas what could be wrong? Thanks a lot, Oliver
''' <summary>
''' Prüft, ob die Datei Barcodes enthält und gibt sie aus
''' </summary>
''' <param name="dateiname"></param>
''' <remarks></remarks>
Public Shared Function PrüfeBarcodeSpire(ByVal dateiname As String) As String
Dim result As String = "Lesevorgang fehlerhaft"
'-- Read PDF into byte array
Dim bData As Byte()
Dim br As IO.BinaryReader = New IO.BinaryReader(System.IO.File.OpenRead(dateiname))
bData = br.ReadBytes(br.BaseStream.Length)
br.Close()
br.Dispose()
'-- empty list for images
Dim images As New List(Of System.Drawing.Bitmap)
'-- open pdf from byte array
Dim pdf As New Spire.Pdf.PdfDocument
pdf.LoadFromBytes(bData)
If pdf.Pages.Count = 0 Then
pdf.Close()
pdf.Dispose()
result = "Datei enthält keine Seiten"
Return result
End If
Dim anzahlPages As Integer = pdf.Pages.Count
'-- convert pdf to bitmap
For i As Integer = 0 To anzahlPages - 1
images.Add(pdf.SaveAsImage(i, Spire.Pdf.Graphics.PdfImageType.Bitmap, 600, 600))
Next
pdf.Close()
pdf.Dispose()
Dim barcodes(0) As String
Dim scan As String = String.Empty
'-- scan bitmap for barcodes
For Each bild As System.Drawing.Bitmap In images
scan = Spire.Barcode.BarcodeScanner.ScanOne(bild)
If Not String.IsNullOrEmpty(scan) Then
barcodes(0) = scan
Dim gl7code As Etikett.Barcode = FindeGL7Barcode(barcodes)
If gl7code IsNot Nothing Then
result = "GL7-Code: " & gl7code.ScanWert
Else
result = "Kein gültiger GL7-Code gefunden"
End If
Else
result = "1. Seite enthält keinen Barcode"
End If
Next
Return result
End Function