bardecode.com
barcode reading software
  • Home
  • Download
  • Purchase
  • SDK Licensing
  • Pricing
    • Windows SDK Price List
    • Windows SDK with PDF Extension Price List
    • Linux SDK Price List
    • Linux SDK with PDF Extension Price List
    • PDF Extension For Windows Price List
    • Multi-Platform Toolkit for .NET Price List
    • BardecodeFiler Desktop Only Price List
    • BardecodeFiler Windows Service Price List
    • DOS Command Prompt Barcode Tool Price List
    • Terms and Conditions
    • Refund Policy
  • Products
    • Softek Barcode Reader Toolkit for Windows
    • Softek Barcode Reader Toolkit for Linux
    • BardecodeFiler Desktop App
    • BardecodeFiler Windows Service
    • Windows DOS Command Prompt Tool
    • Multi-platform barcode reader toolkit for .NET
    • Aquaforest’s Autobahn DX
  • Knowledge Base
    • Documentation
    • Specifications
  • News
  • Contact
    • About Us
    • Terms and Conditions
    • Resellers
    • Links
Select Page ...

News

How to scan a barcode from a .Net stream

admin September 26, 2021 Knowledge Base, Software Development Kits

You can read a barcode from a stream (TIF/JPG or PDF) in C# using the following function to convert the stream into a byte array:


private static byte[] StreamToByteArray(Stream input)
{
   byte[] buffer = new byte[16 * 1024];
   using (MemoryStream ms = new MemoryStream())
   {
      int read;
      while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
      {
         ms.Write(buffer, 0, read);
      }
      return ms.ToArray();
   }
}

…and then if ‘s’ is your stream scan for the barcode with code similar to:

SoftekBarcodeNet.BarcodeReader barcode = new SoftekBarcodeNet.BarcodeReader();
byte[] data = StreamToByteArray(s);
int nBarCodes = barcode.ScanBarCodeFromByteArray(data);
etc etc

← How to migrate from BardecodeFiler Desktop to BardecodeFiler Service
Softek Barcode Reader Toolkit with Docker and .Net →
admin

  • Copyright © 2023 Softek Software Ltd. All Rights Reserved