4
我想使用C#閱讀PDF文件中包含的pdf417條形碼的內容。我寫了下面的代碼:Aspose pdf417 recognition
[...]
// 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」:問題是我得到的輸出是「代碼文本發現:OBAQAQOB | 0 * 6AJAFEHdbhDrh」。 有誰知道我在做什麼錯?
您可能想要提供說明此問題的示例PDF。 – mkl
它是這樣的:http://www.filedropper.com/sample_16 –