Leadtools.Services.Barcode.ServiceContracts Requires Document/Medical product license | Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
Read Method
See Also  Example
Leadtools.Services.Barcode.ServiceContracts Namespace > IBarcodeService Interface : Read Method



request
A DataContractAttribute containing the data that will be used for the Read operation.
request
A DataContractAttribute containing the data that will be used for the Read operation.
Searches for barcodes within the specified area.

Syntax

Visual Basic (Declaration) 
<OperationContractAttribute("Read")>
<FaultContractAttribute(DetailType=Leadtools.Services.Raster.FaultContracts.RasterFault, 
   Action="", 
   Name="", 
   Namespace="", 
   HasProtectionLevel=False)>
Overridable Function Read( _
   ByVal request As ReadRequest _
) As ReadResponse
Visual Basic (Usage)Copy Code
Dim instance As IBarcodeService
Dim request As ReadRequest
Dim value As ReadResponse
 
value = instance.Read(request)
C# 
[OperationContractAttribute("Read")]
[FaultContractAttribute(DetailType=Leadtools.Services.Raster.FaultContracts.RasterFault, 
   Action="", 
   Name="", 
   Namespace="", 
   HasProtectionLevel=false)]
virtual ReadResponse Read( 
   ReadRequest request
)
C++/CLI 
[OperationContractAttribute("Read")]
[FaultContractAttribute(DetailType=Leadtools.Services.Raster.FaultContracts.RasterFault, 
   Action="", 
   Name="", 
   Namespace="", 
   HasProtectionLevel=false)]
virtual ReadResponse Read( 
   ReadRequest request
) 

Parameters

request
A DataContractAttribute containing the data that will be used for the Read operation.

Return Value

A DataContractAttribute containing a list of BarcodeData found in the specified image.

Example

Visual BasicCopy Code
Public Sub ReadExample()
   Dim client As BarcodeServiceClient = New BarcodeServiceClient()
   Dim sourceBinaryData As RawBinaryData = New RawBinaryData()
   sourceBinaryData.Data = File.ReadAllBytes(LeadtoolsExamples.Common.ImagesPath.Path & "barcode2.tif")

   Dim searchRectangle As LeadRectangle = New LeadRectangle()
   searchRectangle.X = 0
   searchRectangle.Y = 0
   searchRectangle.Width = 0
   searchRectangle.Height = 0

   Dim bar1d As Barcode1d = New Barcode1d()

   bar1d.Direction = BarcodeDirectionFlags.LeftToRight
   bar1d.ErrorCheck = True
   bar1d.Granularity = 9
   bar1d.MaximumLength = 3
   bar1d.MinimumLength = 1
   bar1d.WhiteLines = 3
   bar1d.OutShowText = True
   bar1d.StandardFlags = Barcode1dStandardFlags.Barcode1dNormal

   Dim barPDF As BarcodeReadPdf = New BarcodeReadPdf()
   barPDF.Direction = BarcodeDirectionFlags.LeftToRight

   Dim barColor As BarcodeColor = New BarcodeColor()
   barColor.BarColor = "Black"
   barColor.SpaceColor = "White"

   Dim options As ReadOptions = New ReadOptions()

   Dim barcode1d4State As ReadBarcode1d4State = New ReadBarcode1d4State()
   barcode1d4State.Flags = ReadBarcode1d4StateFlags.AustralianPost
   options.Add(barcode1d4State)

   Dim barcode1dStandard As ReadBarcode1dStandard = New ReadBarcode1dStandard()
   barcode1dStandard.Flags = ReadBarcodeStandardFlags.All
   options.Add(barcode1dStandard)

   Dim barcode2DQr As ReadBarcode2DQr = New ReadBarcode2DQr()
   barcode2DQr.Flags = ReadBarcode2DQrFlags.QrCode
   options.Add(barcode2DQr)

   Dim barcode2DPdf417 As ReadBarcode2DPdf417 = New ReadBarcode2DPdf417()
   barcode2DPdf417.Flags = ReadBarcode2DPdf417Flags.Pdf417
   options.Add(barcode2DPdf417)

   Dim barcode2DMicroPdf417 As ReadBarcode2DMicroPdf417 = New ReadBarcode2DMicroPdf417()
   barcode2DMicroPdf417.Flags = ReadBarcode2DMicroPdf417Flags.MicroPdf417
   options.Add(barcode2DMicroPdf417)

   Dim request As ReadRequest = New ReadRequest()

   request.Code1d = bar1d
   request.CodeColor = barColor
   request.CodePdf = barPDF
   request.MultipleMaxCount = 0
   request.Options = options
   request.ReadFlags = BarcodeReadFlags.BlockSearch Or BarcodeReadFlags.Markers
   request.SearchRectangle = searchRectangle
   request.Source = sourceBinaryData
   request.TypeFlags = BarcodeMajorTypeFlags.Barcodes1d Or BarcodeMajorTypeFlags.Barcodes2dRead Or BarcodeMajorTypeFlags.BarcodesQrRead
   request.Unit = BarcodeUnit.ScanlinesPerPixels


   Dim response As ReadResponse = client.Read(request)

   If Not response.Barcodes Is Nothing Then
      Dim barcodeMsg As String = String.Format("Total Bar Code Symbols Found = {0}", response.Barcodes.Count)
      Console.WriteLine(barcodeMsg)

      Dim i As Integer = 0
      For Each data As BarcodeData In response.Barcodes
         i += 1
         barcodeMsg = String.Format("No. {0}" & Constants.vbLf & "Type {1}" & Constants.vbLf & "Units {2}" & Constants.vbLf & "PosX {3}" & Constants.vbLf & "PosY {4}" & Constants.vbLf & "Width {5}" & Constants.vbLf & "Height {6}" & Constants.vbLf & "Group {7}" & Constants.vbLf & "Duplicate Index {8}" & Constants.vbLf, i, data.Type.ToString(), data.Unit.ToString(), data.Location.X.ToString(), data.Location.Y.ToString(), data.Location.Width.ToString(), data.Location.Height.ToString(), data.Group.ToString(), data.IndexDuplicate.ToString())

         Console.WriteLine(barcodeMsg)
      Next data
   End If

   client.Close()
End Sub
C#Copy Code
public void ReadExample() 

   BarcodeServiceClient client = new BarcodeServiceClient(); 
   RawBinaryData sourceBinaryData = new RawBinaryData(); 
   sourceBinaryData.Data = File.ReadAllBytes(LeadtoolsExamples.Common.ImagesPath.Path + "barcode2.tif"); 
 
   LeadRectangle searchRectangle = new LeadRectangle(); 
   searchRectangle.X = 0; 
   searchRectangle.Y = 0; 
   searchRectangle.Width = 0; 
   searchRectangle.Height = 0; 
 
   Barcode1d bar1d = new Barcode1d(); 
 
   bar1d.Direction = BarcodeDirectionFlags.LeftToRight; 
   bar1d.ErrorCheck = true; 
   bar1d.Granularity = 9; 
   bar1d.MaximumLength = 3; 
   bar1d.MinimumLength = 1; 
   bar1d.WhiteLines = 3; 
   bar1d.OutShowText = true; 
   bar1d.StandardFlags = Barcode1dStandardFlags.Barcode1dNormal; 
 
   BarcodeReadPdf barPDF = new BarcodeReadPdf(); 
   barPDF.Direction = BarcodeDirectionFlags.LeftToRight; 
 
   BarcodeColor barColor = new BarcodeColor(); 
   barColor.BarColor = "Black"; 
   barColor.SpaceColor = "White"; 
 
   ReadOptions options = new ReadOptions(); 
 
   ReadBarcode1d4State barcode1d4State = new ReadBarcode1d4State(); 
   barcode1d4State.Flags = ReadBarcode1d4StateFlags.AustralianPost; 
   options.Add(barcode1d4State); 
 
   ReadBarcode1dStandard barcode1dStandard = new ReadBarcode1dStandard(); 
   barcode1dStandard.Flags = ReadBarcodeStandardFlags.All; 
   options.Add(barcode1dStandard); 
 
   ReadBarcode2DQr barcode2DQr = new ReadBarcode2DQr(); 
   barcode2DQr.Flags = ReadBarcode2DQrFlags.QrCode; 
   options.Add(barcode2DQr); 
 
   ReadBarcode2DPdf417 barcode2DPdf417 = new ReadBarcode2DPdf417(); 
   barcode2DPdf417.Flags = ReadBarcode2DPdf417Flags.Pdf417; 
   options.Add(barcode2DPdf417); 
 
   ReadBarcode2DMicroPdf417 barcode2DMicroPdf417 = new ReadBarcode2DMicroPdf417(); 
   barcode2DMicroPdf417.Flags = ReadBarcode2DMicroPdf417Flags.MicroPdf417; 
   options.Add(barcode2DMicroPdf417); 
 
   ReadRequest request = new ReadRequest(); 
 
   request.Code1d = bar1d; 
   request.CodeColor = barColor; 
   request.CodePdf = barPDF; 
   request.MultipleMaxCount = 0; 
   request.Options = options; 
   request.ReadFlags = BarcodeReadFlags.BlockSearch | BarcodeReadFlags.Markers; 
   request.SearchRectangle = searchRectangle; 
   request.Source = sourceBinaryData; 
   request.TypeFlags = BarcodeMajorTypeFlags.Barcodes1d | BarcodeMajorTypeFlags.Barcodes2dRead | BarcodeMajorTypeFlags.BarcodesQrRead; 
   request.Unit = BarcodeUnit.ScanlinesPerPixels; 
 
 
   ReadResponse response = client.Read(request); 
 
   if (response.Barcodes != null) 
   { 
      string barcodeMsg = string.Format("Total Bar Code Symbols Found = {0}", response.Barcodes.Count); 
      Console.WriteLine(barcodeMsg); 
 
      int i = 0; 
      foreach (BarcodeData data in response.Barcodes) 
      { 
         i++; 
         barcodeMsg = string.Format("No. {0}\nType {1}\nUnits {2}\nPosX {3}\nPosY {4}\nWidth {5}\nHeight {6}\nGroup {7}\nDuplicate Index {8}\n", 
            i, 
            data.Type.ToString(), 
            data.Unit.ToString(), 
            data.Location.X.ToString(), 
            data.Location.Y.ToString(), 
            data.Location.Width.ToString(), 
            data.Location.Height.ToString(), 
            data.Group.ToString(), 
            data.IndexDuplicate.ToString()); 
 
         Console.WriteLine(barcodeMsg); 
      } 
   } 
 
   client.Close(); 
}

Remarks

This operation supports all image formats currently supported by LEADTOOLS.

Use this operation to recognize barcode data.

To determine whether a barcode element is duplicated, use the Leadtools.Services.Barcode.DataContracts.BarcodeData.IsDuplicated property.

If the barcode is duplicated, get it by calling the Leadtools.Services.Barcode.DataContracts.BarcodeData.DuplicatedIndex property.

When Leadtools.Services.Barcode.DataContracts.ReadRequest.ReadFlags is set to Leadtools.Services.Barcode.DataContracts.BarcodeReadFlags.UseColors, then this operation will use the Leadtools.Services.Barcode.DataContracts.ReadRequest.CodeColor property. Otherwise the operation will ignore it and use the default colors (black for bars and white for spaces).

The Leadtools.Services.Barcode.DataContracts.BarcodeReadFlags.UseColors enumeration value does not apply to 1 bit per pixel images.

The Leadtools.Services.Barcode.DataContracts.BarcodeReadFlags.UseColors flag is used with all barcode types.

The BarcodeReadFlags.ReturnCheck flag is used only for reading linear barcodes.

The smallest Data Matrix symbol size is 40 pixels by 40 pixels.

It can be read by setting Leadtools.Services.Barcode.DataContracts.ReadBarcode2DDataMatrix.Flags to Leadtools.Services.Barcode.DataContracts.ReadBarcode2DDataMatrix.Small since this enables the reading of Data Matrix symbols that are between 20 to 40 pixels in size.

Linear barcodes are not supported in UNICODE text.

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also

Applications developed with LEADTOOLS WCF components require runtime licenses. Server licensing is required for applications on a server. For more information, refer to: Imaging Pro/Document/Medical Features