Getting Started with BarCode Reader SDK

  • Home
  • /
  • Getting Started with BarCode Reader SDK

To view the documentation for the SDK go to Start > All Programs > Bytescout BarCode Reader SDK and click the “Documentation” link.

The SDK comes with lot of ready-to-use source code examples for Visual Basic, C#, ASP.NET, VB6, VBScript, classic ASP.

To find source code samples, please go to “My Documents” folder, “ByteScout Samples” and “BarCode Reader SDK”. Do not hesitate to copy and paste code snippets from samples right into your application!

The First Application

To help you get the most out of your evaluation, here is the quick guide to write your first application to decode barcode from an image.

  • run Visual Studio and create New Project.
  • add reference to BarCode Reader SDK using Project | Add Reference. In the Add Reference dialog select “Bytescout BarCode Reader SDK” and click OK.
  • copy-and-paste the following code:

Visual Basic:

Imports <span data-scayt_word="System.IO" data-scaytid="2">System.IO</span>

Imports <span data-scayt_word="Bytescout.BarCodeReader" data-scaytid="4">Bytescout.BarCodeReader</span>

Module <span data-scayt_word="Module1" data-scaytid="40">Module1</span>

Sub Main()
Dim pat As String = "<span data-scayt_word="BarcodePhoto.jpg" data-scaytid="6">BarcodePhoto.jpg</span>"
<span data-scayt_word="Console.WriteLine" data-scaytid="8">Console.WriteLine</span>("Reading barcode(s) from image {0}", <span data-scayt_word="Path.GetFullPath" data-scaytid="14">Path.GetFullPath</span>(pat))

Dim <span data-scayt_word="bc" data-scaytid="41">bc</span> As New Reader()
Dim barcodes As <span data-scayt_word="FoundBarcode" data-scaytid="43">FoundBarcode</span>() = <span data-scayt_word="bc.ReadFrom" data-scaytid="16">bc.ReadFrom</span>(pat)

Dim i As Integer
For i = 0 To <span data-scayt_word="barcodes.Length" data-scaytid="18">barcodes.Length</span> - 1
<span data-scayt_word="Console.WriteLine" data-scaytid="9">Console.WriteLine</span>("Found barcode with type '{0}' and value '{1}'", barcodes(i).Type, barcodes(i).Value)
Next

<span data-scayt_word="Console.WriteLine" data-scaytid="10">Console.WriteLine</span>("Press any key to exit..")
<span data-scayt_word="Console.ReadKey" data-scaytid="19">Console.ReadKey</span>()
End Sub

End Module

C#:

using System;
using <span data-scayt_word="System.Collections.Generic" data-scaytid="21">System.Collections.Generic</span>;
using <span data-scayt_word="System.Text" data-scaytid="22">System.Text</span>;
using <span data-scayt_word="System.IO" data-scaytid="3">System.IO</span>;

using <span data-scayt_word="Bytescout.BarCodeReader" data-scaytid="5">Bytescout.BarCodeReader</span>;

<span data-scayt_word="namespace" data-scaytid="46">namespace</span> <span data-scayt_word="SimpleTestSharp" data-scaytid="47">SimpleTestSharp</span>
{
class Program
{
<span data-scayt_word="const" data-scaytid="48">const</span> string path = "<span data-scayt_word="BarcodePhoto.jpg" data-scaytid="7">BarcodePhoto.jpg</span>";

static void Main(string[] <span data-scayt_word="args" data-scaytid="49">args</span>)
{
<span data-scayt_word="Console.WriteLine" data-scaytid="11">Console.WriteLine</span>("Reading barcode(s) from image {0}", <span data-scayt_word="Path.GetFullPath" data-scaytid="15">Path.GetFullPath</span>(path));

Reader <span data-scayt_word="bc" data-scaytid="42">bc</span> = new Reader();
<span data-scayt_word="FoundBarcode" data-scaytid="44">FoundBarcode</span>[] barcodes = <span data-scayt_word="bc.ReadFrom" data-scaytid="17">bc.ReadFrom</span>(path);

<span data-scayt_word="foreach" data-scaytid="50">foreach</span> (<span data-scayt_word="FoundBarcode" data-scaytid="45">FoundBarcode</span> barcode in barcodes)
<span data-scayt_word="Console.WriteLine" data-scaytid="12">Console.WriteLine</span>("Found barcode with type '{0}' and value '{1}'", <span data-scayt_word="barcode.Type" data-scaytid="23">barcode.Type</span>, <span data-scayt_word="barcode.Value" data-scaytid="24">barcode.Value</span>);

<span data-scayt_word="Console.WriteLine" data-scaytid="13">Console.WriteLine</span>("Press any key to exit..");
<span data-scayt_word="Console.ReadKey" data-scaytid="20">Console.ReadKey</span>();
}
}
}
  • press F5 to compile and run your first application!

The application reads the image and displays the decoded barcode value.

More Samples

For more source code samples on reading barcodes, explore “ByteScout Samples / BarCode Reader SDK ” folder in “My Documents” or see the tutorials below.

Evaluation version adds a reminder text into the output value each time you read a barcode from image.

You are welcome to purchase a license for the SDK at purchase page.

We provide 30-Day Unconditional Money Back Guarantee for the SDK!

Have a Question?

Contact us at support@bytescout.com or use the online contact form at https://bytescout.com/support/index.php?_m=tickets&_a=submit&step=1&departmentid=2

Thanks again for evaluating BarCode Reader SDK!

Tutorials: