barcodelib C# Library

repository·master·Indexed 21 days ago

https://github.com/barnhill/barcodelib

A C# library for generating barcode images from string data. It supports a wide range of symbologies including Code 128, Code 39, EAN-8, EAN-13, UPC-A, UPC-E, and others. The library utilizes the Barcode class and its Encode method to create images with customizable foreground and background colors, dimensions, and optional text labels.

Tokens
534
Snippets
2
Records
3
Agent score
24%

What's inside barcodelib

  1. Overview of supported barcode symbologies

    master

    barcodelib supports a wide range of barcode symbologies for generating barcode images from string data. Supported types include:

    • Code 128
    • Code 93
    • Code 39 (Extended / Full ASCII)
    • Code11
    • EAN-8
    • FIM (Facing Identification Mark)
    • UPC-A
    • UPC-E
    • Pharmacode
    • MSI
    • PostNet
    • Standard 2 of 5
    • ISBN
    • Codabar
    • Interleaved 2 of 5
    • ITF-14
    • Telepen
    • UPC Supplemental 2
    • JAN-13
    • EAN-13
    • UPC Supplemental 5
    • IATA2of5
  2. Generate a barcode image with Encode()

    master

    To generate a barcode image, use the Encode method on a Barcode instance. The method requires the following parameters:

    • Type: The symbology to use (e.g., Type.UpcA).
    • string: The data to be encoded.
    • SKColor: The foreground color (e.g., SKColors.Black).
    • SKColor: The background color (e.g., SKColors.White).
    • int: The width of the image.
    • int: The height of the image.

    You can also set the IncludeLabel property to true to include a text label with the barcode.

    var b = new Barcode();
    b.IncludeLabel = true;
    var img = b.Encode(Type.UpcA, "038000356216", SKColors.Black, SKColors.White, 290, 120);
  3. Use the Barcode class to generate barcodes

    master

    The core of the library is the Barcode class. You can instantiate it using three different constructors:

    1. Barcode(): Creates an empty instance. You must set the data and symbology via properties before encoding.
    2. Barcode(string): Creates an instance with the provided data string.
    3. Barcode(string, Type): Creates an instance with the provided data string and a specific symbology Type.

    If you use the parameterless constructor, ensure you specify the data and type before calling the Encode method.

    // Example of parameterless constructor usage
    var b = new Barcode();
    b.IncludeLabel = true;
    var img = b.Encode(Type.UpcA, "038000356216", SKColors.Black, SKColors.White, 290, 120);