TyKonKet.BarcodeGenerator 2.0.0

dotnet add package TyKonKet.BarcodeGenerator --version 2.0.0
                    
NuGet\Install-Package TyKonKet.BarcodeGenerator -Version 2.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TyKonKet.BarcodeGenerator" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TyKonKet.BarcodeGenerator" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="TyKonKet.BarcodeGenerator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TyKonKet.BarcodeGenerator --version 2.0.0
                    
#r "nuget: TyKonKet.BarcodeGenerator, 2.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=TyKonKet.BarcodeGenerator&version=2.0.0
                    
Install TyKonKet.BarcodeGenerator as a Cake Addin
#tool nuget:?package=TyKonKet.BarcodeGenerator&version=2.0.0
                    
Install TyKonKet.BarcodeGenerator as a Cake Tool

Barcode Generator

NuGet NuGet

Barcode generator based on SkiaSharp library, supports the following encoders:

  • EAN-13
  • UPC-A
  • ISBN
  • EAN-8
  • CODE93

Table of Contents

Installation

BarcodeGenerator is available as a convenient NuGet package.
To install the package, use one of the following commands:

PM> Install-Package TyKonKet.BarcodeGenerator
nuget install TyKonKet.BarcodeGenerator

Usage

You can generate all the barcodes using the Barcode class. The Barcode class has a constructor that accepts an Action<BarcodeOptions> delegate to set the barcode options. The BarcodeOptions class has the following properties:

  • Encode: Specifies the encoding type (e.g., Encodes.Code93).
  • Height: Sets the height of the barcode.
  • Scale: Sets the scale of the barcode.
  • Margins: Sets the margins around the barcode.
  • BackgroundColor: Sets the background color of the barcode.
  • Color: Sets the color of the barcode.
  • Font: Sets the font for the barcode text.
  • FontStyle: Sets the font style for the barcode text.
  • DrawText: Specifies whether to draw text below the barcode.

Getting Started

Here is an example of how to generate a barcode using the Barcode class:

using SkiaSharp;
using TyKonKet.BarcodeGenerator;

internal static class Example
{
    private static void CreateBarcodeImage()
    {
        // Set up the barcode generator with specific options
        using var barcodeGenerator = new Barcode(options =>
        {
            // Set the type of barcode to Code93
            options.Type = BarcodeTypes.Code93;
            // Set the height of the barcode
            options.Height = 30;
            // Set the scaling factor for the barcode
            options.Scaling = 10;
            // Set the margins around the barcode
            options.Margins = 2;
            // Set the background color of the barcode to transparent
            options.BackgroundColor = SKColors.Transparent;
            // Set the foreground color of the barcode to black
            options.ForegroundColor = SKColors.Black;
            // Enable rendering of text below the barcode
            options.RenderText = true;
            // Use the specified font family and style for the text
            options.UseTypeface("Arial", SKFontStyle.Normal);
        });

        // Encode the barcode with the specified string
        barcodeGenerator.Encode("THE-BARCODE");

        // Export the barcode image to a file
        // The file path can include the following keywords:
        // - {barcode}: The barcode string.
        // - {format}: The image format (e.g., png, jpg).
        // - {quality}: The image quality (1-100).
        barcodeGenerator.Export("path/{barcode}_{quality}.{format}", SKEncodedImageFormat.Png, 100);
    }
}

Breaking Changes

  • Starting with version 2.0.0, the library is no longer compatible with .NET Standard 1.3 since it uses SkiaSharp 3.116.1, which requires .NET Standard 2.0.
  • Starting with version 2.0.0, the API has been changed to be more user-friendly and to allow more customization. Follow the examples in the README.md file to see how to use the new API.

Roadmap

  • Update the README.md documentation
  • Add support for CODE39 and CODE128 encoders
  • Add support for more barcode types
  • Add an API to validate the barcode
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0 694 1/18/2025
1.0.3 4,408 1/3/2022
1.0.2 312 12/29/2021
1.0.1 320 12/28/2021
1.0.0 376 11/18/2021