質問

I want to read the content of a pdf417 barcode contained in a pdf file using C#. I wrote the following code:

[...]
// 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");
[...]

I know that the content of the barcode is "OB|090547db800b6c47": the problem is that the output I obtain is "Codetext found: OBAQAQOB|0*6AJAFEHdbhDrh". Does anyone know what I'm doing wrong?

役に立ちましたか?

解決

Copied your code and did just one change below and got "Codetext found: OB|090547db800b6c47" output.

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

I used Aspose.BarCode for .NET version 5.5 in a .NET 4.5 project. Which version are you using?

PS. I am a Developer Evangelist at Aspose.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top