彩票走势图

使用Aspose.BarCode 和 Aspose.Words从Word文档中识别条码

原创|其它|编辑:郝浩|2012-10-23 10:34:23.000|阅读 352 次

概述:在本文中,我们将使用Aspose.BarCode 和 Aspose.Words这两个控件实现从Word文档中识别条码。

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

在本文中,我们将使用Aspose.BarCodeAspose.Words这两个控件实现从Word文档中识别条码。步骤如下:

1、使用Aspose.Words for .NET从文档中提取图像

2 、以流的形式保存提取的图像

3 、将图像以流的形式传递到Aspose.BarCode for .NET中

4 、从图像中读取条码

[C#]

// Load the word document
Document wordDocument = new Document("Invitation.doc");
// get all the shapes
NodeCollection shapes = wordDocument.GetChildNodes(NodeType.Shape, true, false);
// loop through all the shapes
foreach (Shape shape in shapes)
{
    // check if it has an image
    if (shape.HasImage)
    {
        // save the image in memory stream
        MemoryStream imgStream = new MemoryStream();
        shape.ImageData.Save(imgStream);

        // recognize the barcode from the image stream above
        BarCodeReader reader = new BarCodeReader(new Bitmap(imgStream), BarCodeReadType.Code39Standard);
        while(reader.Read())
        {
            Console.WriteLine("Codetext found: " + reader.GetCodeText());
        }
        // close the reader
        reader.Close();
    }

[VB.NET]

' Load the word document
Dim wordDocument As Document = New Document("Invitation.doc")
' get all the shapes
Dim shapes As NodeCollection = wordDocument.GetChildNodes(NodeType.Shape, True, False)
' loop through all the shapes
For Each shape As Shape In shapes
   ' check if it has an image
   If shape.HasImage Then
      ' save the image in memory stream
      Dim imgStream As MemoryStream = New MemoryStream()
      shape.ImageData.Save(imgStream)

      ' recognize the barcode from the image stream above
      Dim reader As BarCodeReader = New BarCodeReader(New Bitmap(imgStream), BarCodeReadType.Code39Standard)
      Do While reader.Read()
         Console.WriteLine("Codetext found: " & reader.GetCodeText())
      Loop
      ' close the reader
      reader.Close()
   End If
Next shape

标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@pclwef.cn

文章转载自:慧都控件网

为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP