c# - Aspose pdf417识别

标签 c# pdf image-processing barcode aspose

我想使用 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 found:OBAQAQOB|0*6AJAFEHdbhDrh”。 有谁知道我做错了什么?

最佳答案

复制您的代码并仅在下面进行一处更改并获得“找到代码文本:OB|090547db800b6c47”输出。

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

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

附言。我是 Aspose 的开发人员布道师。

关于c# - Aspose pdf417识别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17473302/

相关文章:

java - Pdf Renderer API Android 来自 URL

python - 如何获得具有图像的 R、G 和 B 分量的大小为 n*3(其中 n 是图像的像素总数)的矩阵

c# - 如何从 sqlite 数据库检索 float 到 C# 文本框

iphone - 生成大型 PDF 文件缩略图导致 iPhone/iPad 崩溃

c# - 在 C# 中按下按钮时出现异常

php - 使用 PHP 获取 PDF 文件中的字段

c++ - 组合图像中的重叠组

html - CSS3 转换后捕获图像

c# - 有没有办法预测 `Marshal.GetExceptionForHR(code, pointers)` 会抛出 `AccessViolationException`

c# - 使用 linq 按父级对对象列表进行分组以输出子元素