Testimonials


First of all, let me compliment you on your Barcode.NET Library. We evaluated a number of products to use in our application, and yours was our favorite.

Dan Konigsberg
CampMinder, LLC





VintaSoftBarcode.NET SDK - FAQ

General questions:

 

Redistribution:

 

Sales:

 

Programming:

 

Images:

 

 

For what purpose can I use the VintaSoftBarcode.NET SDK?

The SDK allows to read and write 1D, postal and 2D barcodes in digital images and image resources of PDF files.

 

 

From which parts does the library consist?

The library contains:

  • Vintasoft.Barcode.dll/Vintasoft.Wpf.Barcode.dll file - a 100% managed .NET class library
  • Documentation in CHM format (Documentation\Vintasoft.Barcode.chm file)
  • Demo applications (.exe files in Bin\vX.X\ folder)
  • Examples for MS Visual Basic .NET, MS Visual C#, ASP.NET (files in the /Examples folder)
  • Test images with barcodes (files in the /Images folder)

 

 

In which programming languages can I use the VintaSoftBarcode.NET SDK?

With the Single Developer license or Site license you can use library in:

  • Microsoft Visual Studio .NET : Visual Basic, Visual C#, Visual C++, Visual J#
  • Borland Delphi 8.0, Borland C# Builder, Borland C++ BuilderX
  • any other languages which are compatible with .NET Framework.

With the Server license you can use library in:

  • Intranet / internet applications on a server-side (ASP.NET or PHP)

 

 

What restrictions does the unregistered version contain?

Unregistered version has following restrictions:

  • nag screen is shown before start of each barcode reading process in Vintasoft.Barcode.dll/Vintasoft.Wpf.Barcode.dll from Bin/X.X/ folder
  • barcode value is replaced by the "*DEMO*" string for QR Code, GS1 Databar and IntelligentMail barcodes
  • some symbols from the read barcode are replaced by '*' in Vintasoft.Barcode.dll/Vintasoft.Wpf.Barcode.dll from Bin/X.X/NoNagScreen/ folder
  • barcodes can be read only from the first page of PDF document
  • watermark is added in a random way to any generated barcode

 

 

I have problems. What should I do?

Answers to the majority of questions can be found in the documentation or this web site. Please write to our support team to get more help.

 

 

What files do I need to include in the setup package of my program?

You need include only one file: Vintasoft.Barcode.dll/Vintasoft.Wpf.Barcode.dll. This file must be placed in the same folder as the assembly that references it. Make sure that the version you distribute is the version your assembly was compiled with.

 

 

Can I re-distribute the Vintasoft.Barcode.dll or Vintasoft.Wpf.Barcode.dll file with my application without royalties?

Yes, this library is royalty free. You pay only for registration one time.
Only Vintasoft.Barcode.dll/Vintasoft.Wpf.Barcode.dll file can be re-distributed with your application. Site license has no limitations in re-distribution. Single Developer license has limitation in re-distribution. Server license is not royalty free. Please read the license agreement for more info.

 

 

What to do when my Single developer license application redistribution count is about to exceed 100 copies in a year?

If you own Single developer license you must contact Sales in an event your application redistribution count is about to exceed 100 copies in current year. You'll be provided with an opportunity to upgrade your Single developer license to Site license with 30% discount or to buy additional Single developer license.

 

 

What is the difference between Single developer license and Site license?

  • Single developer license must be used in software development by only one programmer whose name is indicated in the license data.
  • Site license must be used in software development by any programmer who works for a company which name is indicated in the license data.
  • Single developer license may be used in software development on any PC located at any physical address.
  • Site license may be used in software development on any PC located at single physical address (at only one office).
  • Single developer license permits a royalty free distribution of an application which integrates the SDK redistributable assemblies up to 100 copies in a year.
  • Site license permits an unlimited royalty free distribution of an application which integrates the SDK redistributable assemblies.

 

 

May I upgrade my existing Standard edition license to equivalent Standard + WPF edition license?

Yes, please contact Sales and you'll be provided with an opportunity to buy the equivalent Standard + WPF edition license with 70% discount.

 

 

Is there a difference in deploying my application on a desktop PC or on a server?

Yes, there is. Please read the "Deploying" section in this product documentation to understand the difference.

Terms: Desktop PC - Windows XP, Vista, 7 OS installed. Server - Windows Server 2000, 2003, 2008 OS installed.

 

 

How can I maximize barcode reading speed?

Here are some tips which will allow you to maximize the barcode reading speed:

  • Recognize only necessary barcode types (see Settings.ScanBarcodeTypes property). This can increase barcode reading speed up to 2 times.
  • Recognize barcodes only in necessary directions (see Settings.ScanDirection property). This can increase barcode reading speed up to 20%.
  • Find and use optimal threshold values for your color images (see Settings.Threshold property), do not use authomatic threshold mode (see Settings.ThresholdMode property) if this isn't necessary. This can increase barcode reading speed up to 10%.
  • Set the ExpectedBarcodes Property if number of barcodes is known.
  • Use only black-white images with barcodes in your system (if possible). This can increase barcode reading speed up to 20%.
  • Disable RemovePeas feature if you barcode image has good quality. This can increase barcode reading speed up to 5%.
  • Don't use ScanDirection.Angle45and135 property if you don't have for recognition low and wide bars barcodes rotated to 30-60 degrees. This can increase barcode reading speed up to 30%.
  • Disable Settings.SearchDistortedDataMatrixBarcodes feature if your DataMatrix barcodes have no dimensional distortion. This can increase DataMatrix barcode reading speed up to 50%.

 

 

How can I get the most stable barcode recognition system?

Here is a list of steps which should help you to gain an understanding on how to create the most stable barcode recognition system for your specific set of barcodes:

  • Make a collection of test images with your specific barcodes (at least 10 images).
    If you acquire images from scanner - make collection of test images with different brightness and contrast.
  • Read barcodes from test images with different Threshold and calculate minimal and average value of the ReadingQuality property
  • Choose the parameters which gave max average value of ReadingQuality property
  • Recommended min average value of ReadingQuality is 0,75 - this should allow you to get the most stable barcode recognition system.

We do not recommend to process barcode images (via deskew, despeckle, etc) before you run barcode reading process because this can dramatically decrease barcode proportions and as result the quality of recognition.

 

 

Are there any recommendations for 1D barcodes creation?

Code 39 and Code 128 are the most stable linear barcodes for damage and distortion.
The most compact barcode is Code 128 (both numeric and symbol data).

Recommendations for barcode creation to be successfully read further:

  • Create 1D barcodes with cell size (single-wide bar) not less than 2 pixels
  • The more barcode height, the more reading quality
  • Use the padding for barcodes with size not less than 4 cell size
  • Use optional checksum for barcodes without default checksum (Code 39, Interleaved 2of5, Standard 2of5). This will help you to avoid mistakes in barcode recognition from poor quality images.

 

 

Are there any recommendations for 2D barcode creation?

Data Matrix is the most stable 2D barcode for damage and distortion. Aztec and Data Matrix are the most compact barcodes. After come QR Code and PDF417.
All 2D barcodes can contain text and binary data, and can restore up to 30% of damaged data using Reed-Solomon error correction algorithm.

Recommendations for barcode creation to be successfully read further:

  • Create Aztec, QR Code and Data Matrix barcodes with cell size not less than 3 pixels
  • Create PDF417 barcode with cell size not less than 2 pixels
  • Use the padding for PDF417 and Data Matrix barcodes with size not less than 2 cell size
  • Use the padding for QR Code barcode with size not less than 4 cell size

 

 

Does the library support multithreading?

Yes, multithreading is supported since version 5.0. Main algorithm can be scaled to N threads.

 


 

How can I recognize barcode in color image with poor quality?

There are two ways:

  • You should use the Automatic Recognition mode (see ReaderSettings.AutomaticRecognition).
  • You should use the Iteration mode (see ThresholdMode.Iterations). Here is a simple example that demonstrates how to detect barcodes in a color image with "difficult-to-locate" threshold:

[VB.NET]
Private Shared Sub ScanWithIterations(ByVal fileName As String, _
                                      ByVal barcodes As BarcodeType, _
                                      ByVal expectedBarcodes As Integer, _
                                      ByVal iterationCount As Integer, _
                                      ByVal minThreshold As Integer, _
                                      ByVal maxThreshold As Integer)
    Dim barcodeImage As Image = Image.FromFile(fileName)
    Dim reader As New BarcodeReader()
    reader.Settings.ScanBarcodeTypes = barcodes
    reader.Settings.ExpectedBarcodes = expectedBarcodes
    reader.Settings.ThresholdMode = ThresholdMode.Iterations
    reader.Settings.ThresholdIterations = iterationCount
    reader.Settings.ThresholdMin = minThreshold
    reader.Settings.ThresholdMax = maxThreshold
    ' read barcodes
    Dim barcodesInfo As IBarcodeInfo() = reader.readBarcodes(barcodeImage)
    If barcodesInfo.Length = 0 Then
        Console.WriteLine("No barcodes found.")
    Else
        For i As Integer = 0 To barcodesInfo.Length - 1
            Dim inf As IBarcodeInfo = barcodesInfo(i)
            Console.WriteLine(String.Format("[{0}] {1} (Threshold: {2})", inf.BarcodeType, _
                                                                inf.Value, inf.Threshold))
        Next
    End If
    barcodeImage.Dispose()
End Sub

Private Shared Sub TestScanWithIterationsCode128orDataMatrix(ByVal fileName As String)
    ' find one Code 128 or DataMatrix barcode from 400 to 600 _
                                                           threshold (10 iterations)
    ScanWithIterations(fileName, BarcodeType.Code128 Or BarcodeType.DataMatrix, _
                                                               1, 10, 400, 600)
End Sub

[C#]
static void ScanWithIterations(string fileName, BarcodeType barcodes, int expectedBarcodes, 
    int iterationCount, int minThreshold, int maxThreshold)
{
    Image barcodeImage = Image.FromFile(fileName);
    BarcodeReader reader = new BarcodeReader();
    reader.Settings.ScanBarcodeTypes = barcodes;
    reader.Settings.ExpectedBarcodes = expectedBarcodes;
    reader.Settings.ThresholdMode = ThresholdMode.Iterations;
    reader.Settings.ThresholdIterations = iterationCount;
    reader.Settings.ThresholdMin = minThreshold;
    reader.Settings.ThresholdMax = maxThreshold;
    // read barcodes
    IBarcodeInfo[] barcodesInfo = reader.ReadBarcodes(barcodeImage);
    if (barcodesInfo.Length == 0)
    {
        Console.WriteLine("No barcodes found.");
    }
    else
    {
        for (int i = 0; i < barcodesInfo.Length; i++)
        {
            IBarcodeInfo inf = barcodesInfo[i];
            Console.WriteLine(string.Format("[{0}] {1} (Threshold: {2})", 
                                                        inf.BarcodeType, 
                                                        inf.Value, inf.Threshold));
        }
    }
    barcodeImage.Dispose();
}

static void TestScanWithIterationsCode128orDataMatrix(string fileName)
{
    // find one Code 128 or DataMatrix barcode from 400 to 600 
                                                          threshold (10 iterations)
    ScanWithIterations(fileName, BarcodeType.Code128 | BarcodeType.DataMatrix, 
                                                             1, 10, 400, 600);
}
    

 

 

How can I read barcodes from multipage TIFF file?

Here is a simple code:

[VB.NET]
Private Shared Sub ReadBarcodesFromMiltipageTiffFile(ByVal fileName As String, _
                                                     ByVal barcodes As BarcodeType)
    ' open tiff image
    Dim tiffImage As Image = Image.FromFile(fileName)
    Dim index As Guid = tiffImage.FrameDimensionsList(0)
    Dim dimension As New FrameDimension(index)
    Dim pageCount As Integer = tiffImage.GetFrameCount(dimension)
    ' create reader
    Dim reader As New BarcodeReader()
    reader.Settings.ScanBarcodeTypes = barcodes
    ' read barcodes from all pages
    For i As Integer = 0 To pageCount - 1
        ' selects a page
        tiffImage.SelectActiveFrame(dimension, i)
        ' read barcodes from page i
        Dim barcodesInfo As IBarcodeInfo() = reader.readBarcodes(tiffImage)
        ' write information
        Console.WriteLine(String.Format("Page {0}: ", i))
        If barcodesInfo.Length = 0 Then
            Console.WriteLine("No barcodes found.")
        Else
            For j As Integer = 0 To barcodesInfo.Length - 1
                Console.WriteLine(String.Format("[{0}] {1}", _
                                  barcodesInfo(j).BarcodeType, barcodesInfo(j).Value))
            Next
        End If
    Next
    ' free resources
    tiffImage.Dispose()
End Sub

[C#]
static void ReadBarcodesFromMiltipageTiffFile(string fileName, BarcodeType barcodes)
{
    // open tiff image
    Image tiffImage = Image.FromFile(fileName);
    Guid index = tiffImage.FrameDimensionsList[0];
    FrameDimension dimension = new FrameDimension(index);
    int pageCount = tiffImage.GetFrameCount(dimension);
    // create reader
    BarcodeReader reader = new BarcodeReader();
    reader.Settings.ScanBarcodeTypes = barcodes;
    // read barcodes from all pages
    for (int i = 0; i < pageCount; i++)
    {
        // selects a page
        tiffImage.SelectActiveFrame(dimension, i);
        // read barcodes from page i
        IBarcodeInfo[] barcodesInfo = reader.ReadBarcodes(tiffImage);
        // write information
        Console.WriteLine(string.Format("Page {0}: ", i));
        if (barcodesInfo.Length == 0)
        {
            Console.WriteLine("No barcodes found.");
        }
        else
        {
            for (int j = 0; j < barcodesInfo.Length; j++)
                Console.WriteLine(string.Format("[{0}] {1}", 
                                  barcodesInfo[j].BarcodeType, 
                                  barcodesInfo[j].Value));
        }
    }
    // free resources
    tiffImage.Dispose();
}

 

 

How can I read barcodes from PDF document?

Here is a simple code:

[VB.NET]
Private Shared Sub ReadBarcodesFromPdfDocument(ByVal fileName As String, _
                                               ByVal barcodes As BarcodeType)
    ' open PDF document
    Dim pdfImageViewer As New PdfImageViewer(fileName)
    ' create reader
    Dim reader As New BarcodeReader()
    reader.Settings.ScanBarcodeTypes = barcodes
    ' read barcodes from all pages
    For i As Integer = 0 To pdfImageViewer.PageCount - 1
        ' get all images names from page i
        Dim imageNames As String() = pdfImageViewer.GetImageNames(i)
        ' foreach images in page i
        For k As Integer = 0 To imageNames.Length - 1
            Console.WriteLine(String.Format("Page {0}, image {1}: ", i, _
                                                        imageNames(k)))
            Dim barcodeImage As Image
            ' get image with name imageNames[k]
            Try
                barcodeImage = pdfImageViewer.GetImage(i, imageNames(k))
            Catch e As Exception
                ' not supported image format
                Console.WriteLine(e.Message)
                Continue For
            End Try
            ' read barcodes 
            Dim barcodesInfo As IBarcodeInfo() = reader.readBarcodes(barcodeImage)
            ' write information
            If barcodesInfo.Length = 0 Then
                Console.WriteLine("No barcodes found.")
            Else
                For j As Integer = 0 To barcodesInfo.Length - 1
                    Console.WriteLine(String.Format("[{0}] {1}", _
                                      barcodesInfo(j).BarcodeType, _
                                      barcodesInfo(j).Value))
                Next
            End If
        Next
    Next
    ' free resources
    pdfImageViewer.Dispose()
End Sub

[C#]
static void ReadBarcodesFromPdfDocument(string fileName, BarcodeType barcodes)
{
    // open PDF document
    PdfImageViewer pdfImageViewer = new PdfImageViewer(fileName);
    // create reader
    BarcodeReader reader = new BarcodeReader();
    reader.Settings.ScanBarcodeTypes = barcodes;
    // read barcodes from all pages
    for (int i = 0; i < pdfImageViewer.PageCount; i++)
    {
        // get all images names from page i
        string[] imageNames = pdfImageViewer.GetImageNames(i);
        // foreach images in page i
        for (int k = 0; k < imageNames.Length; k++)
        {
            Console.WriteLine(string.Format("Page {0}, image {1}: ", i, 
                                                       imageNames[k]));
            Image barcodeImage;
            // get image with name imageNames[k]
            try
            {
                barcodeImage = pdfImageViewer.GetImage(i, imageNames[k]);
            }
            catch(Exception e)
            {
                // not supported image format
                Console.WriteLine(e.Message);
                continue;
            }
            // read barcodes 
            IBarcodeInfo[] barcodesInfo = reader.ReadBarcodes(barcodeImage);
            // write information
            if (barcodesInfo.Length == 0)
            {
                Console.WriteLine("No barcodes found.");
            }
            else
            {
                for (int j = 0; j < barcodesInfo.Length; j++)
                    Console.WriteLine(string.Format("[{0}] {1}", 
                                      barcodesInfo[j].BarcodeType, 
                                      barcodesInfo[j].Value));
            }
        }
    }
    // free resources
    pdfImageViewer.Dispose();
}

 

 

How can I read vector form barcode from PDF document?

Here is a simple code:

[C#]
// Important: You need Vintasoft.Barcode.dll, 
//                     Vintasoft.Imaging.dll, 
//                     Vintasoft.Pdf.dll assemblies 
//                     to run this code.
static void ReadBarcodesFromVectorPDFDocument(string pdfFilename)
{
    ImageCollection pdfPages = new ImageCollection();
    pdfPages.Add(pdfFilename);
    // set RenderingSettings if needed
    pdfPages.SetRenderingSettings(new RenderingSettings(new Resolution(200, 200)));
    // foreach pages
    foreach (VintasoftImage image in pdfPages)
    {
        // get page Image
        Image pageImage = image.GetAsBitmap();
        // read barcodes
        ReadBarcodesFromImage(pageImage);
        // free resources
        pageImage.Dispose();
    }
    // free resources
    pdfPages.ClearAndDisposeItems();
}

static void ReadBarcodesFromImage(Image barcodeImage)
{
    // create barcode reader
    BarcodeReader reader = new BarcodeReader();

    // Code 39, Code128 and DatMatrix barcodes are extracted
    reader.Settings.ScanBarcodeTypes =
        BarcodeType.Code39 |
        BarcodeType.Code128 |
        BarcodeType.DataMatrix;

    // only horizontal barcodes are extracted
    reader.Settings.ScanDirection = ScanDirection.LeftToRight | 
                                    ScanDirection.RightToLeft;

    // read barcodes from image
    IBarcodeInfo[] infos = reader.ReadBarcodes(barcodeImage);

    Console.WriteLine(string.Format("Recognition time {0} ms.",
                      reader.RecognizeTime.TotalMilliseconds));

    if (infos.Length == 0)
    {
        Console.WriteLine("No barcodes found.");
    }
    else
    {
        Console.WriteLine(string.Format("{0} barcodes found:", infos.Length));
        Console.WriteLine();
        for (int i = 0; i < infos.Length; i++)
        {
            IBarcodeInfo info = infos[i];
            Console.WriteLine(string.Format("[{0}:{1}]", i, info.BarcodeType));
            Console.WriteLine(string.Format("Value:      {0}", info.Value));
            Console.WriteLine(string.Format("Confidence: {0}%", 
                                             Math.Round(info.Confidence)));
            Console.WriteLine(string.Format("Threshold:  {0}", info.Threshold));
            Console.WriteLine(string.Format("Region:     {0}", info.Region));
            Console.WriteLine();
        }
    }
} 

 

 

How can I write vector form barcode into PDF document?

Here is a simple code:

[VB.NET]
' Important: You need Vintasoft.Barcode.dll, 
'                     Vintasoft.Imaging.dll, 
'                     Vintasoft.Pdf.dll assemblies 
'                     to run this code.
Private Shared Sub MarkPDF(ByVal pdfFilename As String)
    ' create barcodeWriter
    Dim barcodeWriter As New BarcodeWriter()
    ' using DataMatrix 2D barcode
    barcodeWriter.Settings.Barcode = BarcodeType.DataMatrix
    ' barcode padding
    Dim padding As Single = 5

    ' open PDF document
    Dim document As New PdfDocument(pdfFilename)
    ' foreach pages
    For i As Integer = 0 To document.Pages.Count - 1
        Dim page As PdfPage = document.Pages(i)
        ' barcode value - page number
        barcodeWriter.Settings.Value = (i + 1).ToString()
        ' write barcode graphics path
        Dim barcodePath As GraphicsPath = barcodeWriter.GetBarcodeAsGraphicsPath()
        ' translate barcode to right-bottom page corner
        Using m As New Matrix()
            Dim barcodeWidth As Single = barcodePath.GetBounds().Width
            m.Translate(page.MediaBox.Right - barcodeWidth - padding, padding)
            barcodePath.Transform(m)
        End Using
        ' fill barcode path
        Using g As PdfGraphics = page.GetGraphics()
            Dim brush As New PdfBrush(Color.Black)
            g.FillPath(brush, barcodePath)
        End Using
        barcodePath.Dispose()
    Next

    ' saving document
    Dim resultFileName As String = Path.GetFileNameWithoutExtension(pdfFilename) & _
                                                                     "_marked.pdf"
    document.Save(Path.Combine(Path.GetDirectoryName(pdfFilename), resultFileName))
    ' free resources
    document.Dispose()
End Sub

[C#]
// Important: You need Vintasoft.Barcode.dll, 
//                     Vintasoft.Imaging.dll, 
//                     Vintasoft.Pdf.dll assemblies 
//                     to run this code.
static void MarkPDF(string pdfFilename)
{
    // create barcodeWriter
    BarcodeWriter barcodeWriter = new BarcodeWriter();
    // using DataMatrix 2D barcode
    barcodeWriter.Settings.Barcode = BarcodeType.DataMatrix;
    // barcode padding
    float padding = 5;

    // open PDF document
    PdfDocument document = new PdfDocument(pdfFilename);
    // foreach pages
    for (int i = 0; i < document.Pages.Count; i++)
    {
        PdfPage page = document.Pages[i];
        // barcode value - page number
        barcodeWriter.Settings.Value = (i + 1).ToString();
        // write barcode graphics path
        GraphicsPath barcodePath = barcodeWriter.GetBarcodeAsGraphicsPath();
        // translate barcode to right-bottom page corner
        using (Matrix m = new Matrix())
        {
            float barcodeWidth = barcodePath.GetBounds().Width;
            m.Translate(page.MediaBox.Right - barcodeWidth - padding, padding);
            barcodePath.Transform(m);
        }
        // fill barcode path
        using (PdfGraphics g = page.GetGraphics())
        {
            PdfBrush brush = new PdfBrush(Color.Black);
            g.FillPath(brush, barcodePath);
        }
        barcodePath.Dispose();
    }

    // saving document
    string resultFileName = Path.GetFileNameWithoutExtension(pdfFilename) + 
                                                             "_marked.pdf";
    document.Save(Path.Combine(Path.GetDirectoryName(pdfFilename), resultFileName));
    // free resources
    document.Dispose();
}

 

 

How can I use my checksum in barcode (in reader and writer)?

You must use ReaderSettings.VerifyBarcodeMethod property to validate correctness of barcode(check checksum). Here is a simple code which illustrate how to create and read Code 39 barcode with cheksum at base 1000:

[VB.NET]
' Generate checksum at base 1000.
Private Shared Function GenerateChecksum(ByVal value As String) As String
    Dim checkSum As Integer = 0
    For i As Integer = 0 To value.Length - 1
        checkSum += CByte(AscW(value(i))) * i
        checkSum = checkSum Mod 1000
    Next
    'result - [000..999]
    Return checkSum.ToString().PadLeft(3, "0"c)
End Function

' Testing Checksum in barcode value.
Private Shared Function TestChecksum(ByVal barcodeValue As String) As Boolean
    Dim value As String = barcodeValue.Substring(0, barcodeValue.Length - 3)
    Dim readChecksum As String = barcodeValue.Substring(barcodeValue.Length - 3)
    Return readChecksum = GenerateChecksum(value)
End Function

' Verify barcode method.
Private Shared Sub VerifyBarcodeMethod(ByVal reader As BarcodeReader, _
                                       ByVal barcodeInfo As IBarcodeInfo)
    If TestChecksum(barcodeInfo.Value) Then
        barcodeInfo.Confidence = 100
    Else
        barcodeInfo.Confidence = 0
    End If
End Sub

Private Shared Sub TestCode39Barcode(ByVal value As String)
    ' create writer
    Dim writer As New BarcodeWriter()
    writer.Settings.Barcode = BarcodeType.Code39

    ' create reader
    Dim reader As New BarcodeReader()
    reader.Settings.ScanBarcodeTypes = BarcodeType.Code39
    reader.Settings.MinConfidence = 100
    reader.Settings.AutomaticRecognition = True
    reader.Settings.ExpectedBarcodes = 1

    ' write barcode without checksum
    writer.Settings.Value = value
    Dim barcodeNoChecksumImage As Image = writer.GetBarcodeAsBitmap()

    ' write barcode with checksum
    writer.Settings.Value = value & GenerateChecksum(value)
    Dim barcodeWithMyChecksumImage As Image = writer.GetBarcodeAsBitmap()

    'set VerifyBarcodeMethod
    reader.Settings.VerifyBarcodeMethod = AddressOf VerifyBarcodeMethod

    Dim infos As IBarcodeInfo()

    'read barcodes from barcode image without checksum
    'no barcodes found
    infos = reader.readBarcodes(barcodeNoChecksumImage)
    Console.WriteLine("Scan (NoChecksum):")
    For i As Integer = 0 To infos.Length - 1
        Console.WriteLine(infos(i).Value)
    Next

    'read barcodes from barcode image with checksum
    'found one barcode
    infos = reader.readBarcodes(barcodeWithMyChecksumImage)
    Console.WriteLine("Scan (MyChecksum):")
    For i As Integer = 0 To infos.Length - 1
        Console.WriteLine(infos(i).Value)
    Next
End Sub

[C#]
// Generate checksum at base 1000.
static string GenerateChecksum(string value)
{
    int checkSum = 0;
    for (int i = 0; i < value.Length; i++)
    {
        checkSum += ((byte)value[i]) * i;
        checkSum %= 1000;
    }
    //result - [000..999]
    return checkSum.ToString().PadLeft(3, '0');
}

// Testing Checksum in barcode value.
static bool TestChecksum(string barcodeValue)
{
    string value = barcodeValue.Substring(0, barcodeValue.Length - 3);
    string readChecksum = barcodeValue.Substring(barcodeValue.Length - 3);
    return readChecksum == GenerateChecksum(value);
}

// Verify barcode method.
static void VerifyBarcodeMethod(BarcodeReader reader, IBarcodeInfo barcodeInfo)
{
    if (TestChecksum(barcodeInfo.Value))
        barcodeInfo.Confidence = 100;
    else
        barcodeInfo.Confidence = 0;
}

static void TestCode39Barcode(string value)
{
    // create writer
    BarcodeWriter writer = new BarcodeWriter();
    writer.Settings.Barcode = BarcodeType.Code39;

    // create reader
    BarcodeReader reader = new BarcodeReader();
    reader.Settings.ScanBarcodeTypes = BarcodeType.Code39;
    reader.Settings.MinConfidence = 100;
    reader.Settings.AutomaticRecognition = true;
    reader.Settings.ExpectedBarcodes = 1;

    // write barcode without checksum
    writer.Settings.Value = value;
    Image barcodeNoChecksumImage = writer.GetBarcodeAsBitmap();

    // write barcode with checksum
    writer.Settings.Value = value + GenerateChecksum(value);
    Image barcodeWithMyChecksumImage = writer.GetBarcodeAsBitmap();

    //set VerifyBarcodeMethod
    reader.Settings.VerifyBarcodeMethod = VerifyBarcodeMethod;

    IBarcodeInfo[] infos;

    //read barcodes from barcode image without checksum
    //no barcodes found
    infos = reader.ReadBarcodes(barcodeNoChecksumImage);
    Console.WriteLine("Scan (NoChecksum):");
    for (int i = 0; i < infos.Length; i++)
        Console.WriteLine(infos[i].Value);

    //read barcodes from barcode image with checksum
    //found one barcode
    infos = reader.ReadBarcodes(barcodeWithMyChecksumImage);
    Console.WriteLine("Scan (MyChecksum):");
    for (int i = 0; i < infos.Length; i++)
        Console.WriteLine(infos[i].Value);
}

 

 

How can I draw a barcode with specified size and resolution?

[VB.NET]
Private Shared Function DrawBarcode(ByVal barcode As BarcodeType, _
                                    ByVal value As String, _
                                    ByVal resolution As Single, _ 
ByVal width As Single, ByVal height As Single, ByVal units As UnitOfMeasure) As Image
    Dim writer As New BarcodeWriter()
    writer.Settings.Barcode = barcode
    writer.Settings.Value = value
    writer.Settings.Resolution = resolution
    writer.Settings.SetWidth(width, units)
    writer.Settings.SetHeight(height, units)
    Return writer.GetBarcodeAsBitmap()
End Function

Private Shared Sub TestDrawBarcode(ByVal fileName As String)
    ' Draw barcode 6x2 cm in 600 DPI
    Dim barcodeImage As Image = DrawBarcode(BarcodeType.Code128, "TESTBARCODE", _
                                          600, 6, 2, UnitOfMeasure.Centimeters)
    barcodeImage.Save(fileName)
    barcodeImage.Dispose()
End Sub

[C#]
static Image DrawBarcode(BarcodeType barcode, string value, float resolution, 
                                                            float width, 
                                                            float height, 
                                                            UnitOfMeasure units)
{
    BarcodeWriter writer = new BarcodeWriter();            
    writer.Settings.Barcode = barcode;
    writer.Settings.Value = value;
    writer.Settings.Resolution = resolution;
    writer.Settings.SetWidth(width, units);
    writer.Settings.SetHeight(height, units);
    return writer.GetBarcodeAsBitmap();
}

static void TestDrawBarcode(string fileName)
{
    // Draw barcode 6x2 cm in 600 DPI
    Image barcodeImage = DrawBarcode(BarcodeType.Code128, "TESTBARCODE", 
                                  600, 6, 2, UnitOfMeasure.Centimeters);
    barcodeImage.Save(fileName);
    barcodeImage.Dispose();
}

 

 

What compressions and color spaces of PDF image resources are supported by this .NET barcode reader?

Supported compressions:

  • ZIP
  • JPEG (DeviceGray, DeviceRGB)
  • CCITT3
  • CCITT4
  • LZW
  • Run Length

Supported color spaces:

  • DeviceGray
  • DeviceRGB
  • DeviceCMYK
  • Indexed