C#
VB
C++
Represents the WCF Service contract for a barcode service.
[ServiceContractAttribute(Name="IBarcodeService", Namespace="http://Leadtools.Services.Barcode.ServiceContracts/2009/01")]
public interface IBarcodeService
Use the Read operation to search for barcodes within the specified area, or the Write operation to write linear, PDF417, MicroPDF417, Data Matrix, and QR barcode symbols over the image.
using Leadtools.Services;
using Leadtools.Services.Barcode.ServiceContracts;
using Leadtools.Services.Barcode.ServiceImplementations;
public void ReadExample()
{
BarcodeServiceClient client = new BarcodeServiceClient();
RawBinaryData sourceBinaryData = new RawBinaryData();
sourceBinaryData.Data = File.ReadAllBytes(Path.Combine(LEAD_VARS.ImagesDir, "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();
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}