TyKonKet.BarcodeGenerator 2.1.0

dotnet add package TyKonKet.BarcodeGenerator --version 2.1.0
                    
NuGet\Install-Package TyKonKet.BarcodeGenerator -Version 2.1.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.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TyKonKet.BarcodeGenerator" Version="2.1.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.1.0
                    
#r "nuget: TyKonKet.BarcodeGenerator, 2.1.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.
#:package TyKonKet.BarcodeGenerator@2.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TyKonKet.BarcodeGenerator&version=2.1.0
                    
Install as a Cake Addin
#tool nuget:?package=TyKonKet.BarcodeGenerator&version=2.1.0
                    
Install as a Cake Tool

πŸ“Š BarcodeGenerator

NuGet NuGet Downloads Build Status codecov Benchmarks License: MIT

A compact, SkiaSharp-based .NET library for generating common 1D barcodes. Focused on reliability, correctness and a small API surface so it's easy to use from services and agent workflows.

Example:

using var barcode = new Barcode(opt => opt.Type = BarcodeTypes.Ean13);
string validated = barcode.Encode("123456789012");
barcode.Export("barcode.png");

πŸ“– Documentation

πŸ‘‰ Complete Documentation - Comprehensive guides, API reference, and examples


πŸš€ Supported Barcode Types

10 industry-standard formats for every use case:

Type Use Case Example
EAN-13 πŸ›’ Retail products, European standard 1234567890128
UPC-A πŸ‡ΊπŸ‡Έ North American retail, grocery 012345678905
UPC-E πŸ“¦ Compact retail, small packages 01234565
ISBN-13 πŸ“š Books and publications 9781234567897
EAN-8 πŸ“¦ Small packages, compact spaces 12345670
CODE-39 🏭 Industrial, automotive, defense ABC-123
CODE-93 πŸ“‹ Logistics, inventory management ABC123
CODE-128 πŸ“Š High-density alphanumeric encoding ABC123xyz
CODABAR πŸ₯ Libraries, blood banks, logistics A123456A
ITF πŸ“¦ Distribution, warehousing, cartons 12345678

Key points

  • Compact, easy-to-use API (fluent configuration)
  • Built-in validation helpers (see BarcodeValidator)
  • Export templating: use placeholders like {barcode}, {format} in file names
  • Cross-platform rendering using SkiaSharp

πŸ“¦ Installation

Choose your preferred installation method:

Package Manager Console:

Install-Package TyKonKet.BarcodeGenerator

CLI Command:

dotnet add package TyKonKet.BarcodeGenerator

🎯 Quick Start

Get up and running in 30 seconds:

1️⃣ Install

dotnet add package TyKonKet.BarcodeGenerator

2️⃣ Generate

using SkiaSharp;
using TyKonKet.BarcodeGenerator;

// Simple barcode generation
using var barcode = new Barcode(options => {
    options.Type = BarcodeTypes.Ean13;
    options.Height = 50;
    options.Scaling = 3;
});

string validatedCode = barcode.Encode("123456789012");
barcode.Export("my-barcode.png");

3️⃣ Customize

// Advanced styling with custom colors and fonts
using var styledBarcode = new Barcode(options => {
    options.Type = BarcodeTypes.Ean13;
    options.ForegroundColor = SKColors.DarkBlue;
    options.TextColor = SKColors.Red;           // πŸ†• Independent text color!
    options.BackgroundColor = SKColors.LightGray;
    options.UseTypeface("Arial", SKFontStyle.Bold);
    options.Margins = 10;
});

string result = styledBarcode.Encode("123456789012");
styledBarcode.Export("styled-barcode.png", SKEncodedImageFormat.Png, 100);

πŸ”₯ Pro Tip: Export Templating

// Dynamic file naming with placeholders
barcode.Export("output/{barcode}_{quality}.{format}", SKEncodedImageFormat.Png, 95);
// Creates: output/1234567890128_95.png

βœ… Validate Before Encoding

// NEW: Validate barcode data without encoding
var result = BarcodeValidator.Validate("123456789012", BarcodeTypes.Ean13);
if (result.IsValid)
{
    Console.WriteLine($"βœ“ Valid: {result.ValidatedBarcode}");
    // Output: βœ“ Valid: 1234567890128 (with check digit)
}
else
{
    Console.WriteLine($"βœ— Errors: {string.Join(", ", result.Errors)}");
    // Get suggestions for compatible barcode types (opt-in)
    var resultWithSuggestions = BarcodeValidator.Validate("ABC123", BarcodeTypes.Ean13, includeSuggestions: true);
    if (resultWithSuggestions.SuggestedTypes.Count > 0)
    {
        Console.WriteLine($"πŸ’‘ Try: {string.Join(", ", resultWithSuggestions.SuggestedTypes)}");
    }
}

πŸ’‘ Need more help? Check out our Getting Started Guide for step-by-step tutorials and examples.
πŸ“š Validation API: See the complete Validation API Documentation for detailed usage.


Common use cases

  • E-commerce product barcodes (EAN/UPC)
  • Inventory and asset tracking
  • Library ISBN generation
  • Label printing and batch export

πŸ“‹ Configuration Options

The BarcodeOptions class provides extensive customization capabilities:

Option Description Default
Type Barcode encoding type (EAN-13, UPC-A, ISBN-13, EAN-8, CODE-93, CODE-128) EAN-8
Height Height of barcode bars 30 pixels
Scaling Scale factor for the entire image 5x
Margins Spacing around the barcode 2 pixels
Colors Background, foreground, and text colors (independent control) White/Black
Text Rendering Show/hide text below barcode Enabled
Font Options Custom fonts, styles, and loading methods System default

πŸ“š Detailed Configuration: See our BarcodeOptions API Reference for complete documentation.


πŸ”§ Framework Compatibility

BarcodeGenerator supports multiple .NET framework versions for maximum compatibility:

Framework Version Target Scenario
.NET Standard 2.0 2.0+ Core compatibility for most scenarios
.NET Framework 4.6.2+ Legacy Windows applications
.NET 8.0 8.0+ Long-term support version
.NET 10.0 10.0+ Latest stable version

πŸ”„ Breaking Changes

Version 2.1.0

  • PolySharp Integration: The library now includes the PolySharp package to enhance compatibility. If you encounter any issues, please report them by opening an issue on our GitHub repository. For more details, visit the PolySharp GitHub repository.
  • API Rename: EncodesExtensions has been renamed to BarcodeTypeExtensions to better reflect its purpose. Update consuming code accordingly.
  • Framework requirement: .NET 6 support has been dropped in favor of the current net8.0/net10.0 targets; make sure callers move to those runtimes.

Version 2.0.0

  • Framework Requirement: No longer supports .NET Standard 1.3 (requires .NET Standard 2.0+).
  • API Changes: Redesigned for improved usability and customization.
  • SkiaSharp Update: Updated to SkiaSharp 3.116.1 for better performance.

πŸ“– Migration Guide: See our Getting Started documentation for updated API usage patterns.


πŸ—ΊοΈ Roadmap

βœ… Recently completed

  • CODE-39, CODE-128, CODABAR, ITF and UPC-E
  • Validation API: standalone validation without encoding (BarcodeValidator)
  • PolySharp integration to improve compatibility across target frameworks
  • Independent text color support (BarcodeOptions.TextColor) and rendering improvements

Have an idea? Start a discussion or vote on features!


🀝 Contributing

We welcome contributions from the community! πŸŽ‰

πŸ‘‰ Full Contributing Guide - Complete guide to contributing with setup, workflows, and guidelines

Quick Start:

Essential Checks:

  • Run tests: dotnet test --configuration Release
  • Check coverage: ./tools/run-coverage.sh
  • Follow our Code of Conduct

Every contribution matters - from typo fixes to new features! ✨


πŸ“„ License

This library is released under the MIT License. See the LICENSE file for details.


πŸ“š Explore Full Documentation | πŸš€ Getting Started Guide | πŸ”§ API Reference

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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.