@PhilippHaenggi,
Thanks for the template file and sample code segment.
Please try our latest version of Aspose.BarCode for .NET v19.1.
Moreover, I could not compile your code segment as some method(s) and other objects/variables definitions/values are missing. I tested your scenario/ case a bit using the following sample code and your template PDF file with Aspose.PDF for .NET v19.2 and Aspose.BarCode for .NET v19.1, it works and I could not find any exception:
e.g
Sample code:
//open document
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document("e:\\test2\\Segment 002 von eokarte-defekt.pdf");
// traverse through individual pages of PDF file
for (int pageCount = 1; pageCount <= pdfDocument.Pages.Count; pageCount++)
{
// traverse through each image extracted from PDF pages
foreach (Aspose.Pdf.XImage xImage in pdfDocument.Pages[pageCount].Resources.Images)
{
using (MemoryStream imageStream = new MemoryStream())
{
//save output image
xImage.Save(imageStream, System.Drawing.Imaging.ImageFormat.Jpeg);
// set the stream position to the begining of Stream
imageStream.Position = 0;
// Instantiate BarCodeReader object
Aspose.BarCode.BarCodeRecognition.BarCodeReader barcodeReader = new Aspose.BarCode.BarCodeRecognition.BarCodeReader(imageStream, Aspose.BarCode.BarCodeRecognition.DecodeType.AllSupportedTypes);
//barcodeReader.QualitySettings.RecognitionMode = Aspose.BarCode.BarCodeRecognition.RecognitionMode.MaxQuality;
barcodeReader.QualitySettings = Aspose.BarCode.BarCodeRecognition.QualitySettings.HighQuality;
while (barcodeReader.Read())
{
// get BarCode text from BarCode image
string code = barcodeReader.GetCodeText();
// write the BarCode text to Console output
Console.WriteLine("BARCODE : " + code);
}
// close BarCodeReader object to release the Image file
barcodeReader.Close();
}
}
}
If you still find the issue, kindly do create a simple console demo (runnable) application (you may zip the project prior attaching here) using latest versions of Aspose.BarCode (especially) to reproduce the issue on our end, we will check it soon.