Aspose pdf417 recognition

本文关键字:recognition pdf417 Aspose | 更新日期: 2023-09-27 18:21:14

我想使用C#读取pdf文件中包含的pdf417条形码的内容。我写了以下代码:

[...]
// bind the pdf document
Aspose.Pdf.Facades.PdfExtractor pdfExtractor = new Aspose.Pdf.Facades.PdfExtractor();
pdfExtractor.BindPdf(ImageFullPath);
pdfExtractor.StartPage = 1;
pdfExtractor.EndPage = 1;
// extract the images
pdfExtractor.ExtractImage();
//save images to stream in a loop
while (pdfExtractor.HasNextImage())
{
     // save image to stream
     MemoryStream imageStream = new MemoryStream();
     pdfExtractor.GetNextImage(imageStream);
     imageStream.Position = 0;
     // recognize the barcode from the image stream above
     System.Drawing.Image img = Image.FromStream(imageStream);
     Aspose.BarCodeRecognition.BarCodeReader barcodeReader = new Aspose.BarCodeRecognition.BarCodeReader(imageStream, BarCodeReadType.Pdf417);
     while (barcodeReader.Read())
     {
         Console.WriteLine("Codetext found: " + barcodeReader.GetCodeBytes());
     }
     // close the reader
     barcodeReader.Close();
 }
 Console.WriteLine("Done");
[...]

我知道条形码的内容是"OB|090547db800b6c47":问题是我获得的输出是"找到的Codetext:OBAQAQOB|0*6AJAFEHdbhDrh"。有人知道我做错了什么吗?

Aspose pdf417 recognition

复制您的代码,只做了下面的一个更改,得到了"Codetextfound:OB|090547db800b6c47"输出。

Console.WriteLine("Codetext found: " + barcodeReader.GetCodeText());

我在.NET 4.5项目中使用了.NET 5.5版本的Aspose.BarCode。您正在使用哪个版本?

PS。我是Aspose的开发人员福音传道者。