Mab.PipelineFramework.BarcodeGenerator
1.0.0
dotnet add package Mab.PipelineFramework.BarcodeGenerator --version 1.0.0
NuGet\Install-Package Mab.PipelineFramework.BarcodeGenerator -Version 1.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="Mab.PipelineFramework.BarcodeGenerator" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Mab.PipelineFramework.BarcodeGenerator" Version="1.0.0" />
<PackageReference Include="Mab.PipelineFramework.BarcodeGenerator" />
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 Mab.PipelineFramework.BarcodeGenerator --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Mab.PipelineFramework.BarcodeGenerator, 1.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.
#:package Mab.PipelineFramework.BarcodeGenerator@1.0.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=Mab.PipelineFramework.BarcodeGenerator&version=1.0.0
#tool nuget:?package=Mab.PipelineFramework.BarcodeGenerator&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
PipelineFramework.BarcodeGenerator
High-quality barcode and QR code generator for .NET with extensive customization options.
Installation
dotnet add package Mab.PipelineFramework.BarcodeGenerator
Features
- QR Codes: Full customization with logo embedding, colors, gradients, custom shapes
- 1D Barcodes: Code128, Code39, EAN-13, EAN-8, UPC-A, UPC-E, ITF, Codabar
- 2D Barcodes: QR Code, Data Matrix, PDF417, Aztec
- Multiple Output Formats: PNG, JPEG, SVG, WebP, BMP, GIF
- Fluent Builder API: Intuitive, chainable configuration
- Result Pattern: Rich error handling without exceptions
- DI Integration: Full dependency injection support
- High Performance: Optimized for speed and memory efficiency
Quick Start
Simple QR Code
using PipelineFramework.BarcodeGenerator;
using PipelineFramework.BarcodeGenerator.Builders;
// Using fluent builder (recommended)
var qrCode = QRCodeBuilder.Create("https://example.com")
.WithSize(300)
.WithHighErrorCorrection()
.Build();
// Save to file
qrCode.Save("qrcode.png");
// Or get as data URL for HTML
var dataUrl = qrCode.ToDataUrl();
// <img src="{dataUrl}" />
QR Code with Logo
var qrCode = QRCodeBuilder.Create("https://mycompany.com")
.WithSize(400)
.WithLogo(File.ReadAllBytes("logo.png"), sizeRatio: 0.25)
.WithLogoBackground(BarcodeColor.White, cornerRadius: 8)
.WithColors("#1E3A8A", "#FFFFFF") // Navy on white
.WithRoundedModules()
.Build();
Styled QR Code with Gradient
var qrCode = QRCodeBuilder.Create("https://example.com")
.WithSize(400)
.WithGradient("#6366F1", "#EC4899", GradientDirection.Diagonal)
.WithCircularModules()
.WithHighErrorCorrection()
.AsPng()
.Build();
WiFi QR Code
var wifiQR = QRCodeBuilder.Create()
.WithWiFi("MyNetwork", "MyPassword123", "WPA2")
.WithSize(300)
.Build();
vCard QR Code
var contactQR = QRCodeBuilder.Create()
.WithVCard(
name: "John Doe",
phone: "+1-555-123-4567",
email: "john@example.com",
organization: "Acme Inc")
.WithSize(300)
.Build();
1D Barcodes
// Code 128 (most versatile)
var code128 = BarcodeBuilder.Code128("ABC-12345")
.WithSize(300, 100)
.ShowText()
.Build();
// EAN-13 (retail)
var ean13 = BarcodeBuilder.EAN13("5901234123457")
.WithSize(200, 80)
.Build();
// UPC-A
var upca = BarcodeBuilder.UPCA("012345678905")
.WithColors("#000000", "#FFFFFF")
.Build();
Dependency Injection
// Program.cs
builder.Services.AddBarcodeGenerator();
// In your service
public class InvoiceService
{
private readonly IBarcodeGenerator _generator;
public InvoiceService(IBarcodeGenerator generator)
{
_generator = generator;
}
public async Task<byte[]> CreateInvoiceBarcodeAsync(string invoiceId)
{
var result = await _generator.GenerateQRCodeAsync(
$"INV:{invoiceId}",
new QRCodeOptions
{
Width = 200,
Height = 200,
ErrorCorrectionLevel = ErrorCorrectionLevel.Medium
});
return result.GetDataOrThrow();
}
}
Result Handling
var result = generator.GenerateQRCode("https://example.com");
// Check success
if (result.IsSuccess)
{
// Access data
byte[] bytes = result.Data;
await result.SaveAsync("output.png");
string base64 = result.ToBase64();
string dataUrl = result.ToDataUrl();
}
else
{
// Handle error
Console.WriteLine($"Error: {result.Error.Message}");
Console.WriteLine($"Code: {result.Error.Code}");
}
// Functional approach
result
.OnSuccess((data, metadata) =>
{
Console.WriteLine($"Generated {metadata.Width}x{metadata.Height} image");
Console.WriteLine($"Size: {metadata.SizeBytes} bytes");
Console.WriteLine($"Time: {metadata.GenerationTime.TotalMilliseconds}ms");
})
.OnFailure(error =>
{
Console.WriteLine($"Failed: {error}");
});
// Pattern matching
var message = result.Match(
onSuccess: (data, meta) => $"Success: {meta.SizeBytes} bytes",
onFailure: error => $"Error: {error.Message}"
);
Output Formats
// PNG (default, lossless, supports transparency)
var png = QRCodeBuilder.Create(content).AsPng().Build();
// SVG (vector, scalable, perfect for web)
var svg = QRCodeBuilder.Create(content).AsSvg().BuildSvgString();
// JPEG (smaller file size, no transparency)
var jpeg = QRCodeBuilder.Create(content).AsJpeg().Build();
// WebP (modern, excellent compression)
var webp = QRCodeBuilder.Create(content).AsWebP().Build();
// Data URL (for HTML img src)
var dataUrl = QRCodeBuilder.Create(content).BuildDataUrl();
Validation
var generator = new BarcodeGenerator();
// Validate before generating
var validation = generator.Validate("123456789012", BarcodeType.EAN13);
if (validation.IsValid)
{
Console.WriteLine($"Encoding mode: {validation.DetectedEncodingMode}");
Console.WriteLine($"Capacity usage: {validation.EstimatedCapacityUsage}%");
Console.WriteLine($"Recommended QR version: {validation.RecommendedQRVersion}");
}
else
{
foreach (var error in validation.Errors)
Console.WriteLine($"Error: {error}");
}
Customization Options
QR Code Options
| Option | Description | Default |
|---|---|---|
Width, Height |
Image dimensions in pixels | 300x300 |
Margin |
Quiet zone in pixels | 10 |
ErrorCorrectionLevel |
L (7%), M (15%), Q (25%), H (30%) | Medium |
ForegroundColor |
Module color | Black |
BackgroundColor |
Background color | White |
ModuleShape |
Square, RoundedSquare, Circle, Diamond | Square |
LogoData |
Logo image bytes | null |
LogoSizeRatio |
Logo size relative to QR (0.0-0.3) | 0.2 |
UseGradient |
Enable gradient coloring | false |
Barcode Options
| Option | Description | Default |
|---|---|---|
BarcodeType |
Code128, EAN13, UPCA, etc. | Code128 |
Width, Height |
Image dimensions | 300x100 |
ShowText |
Display text below barcode | true |
DisplayText |
Custom display text | null |
FontFamily |
Text font | Arial |
FontSize |
Text size in points | 12 |
Supported Barcode Types
2D Codes
- QR Code - URLs, text, vCards, WiFi configs
- Data Matrix - Industrial, healthcare
- PDF417 - ID cards, shipping
- Aztec - Tickets, boarding passes
1D Codes
- Code 128 - Full ASCII, shipping
- Code 39 - Alphanumeric, automotive
- Code 93 - Compact alphanumeric
- EAN-13 - Retail worldwide
- EAN-8 - Small retail packages
- UPC-A - North American retail
- UPC-E - Small packages
- ITF - Warehousing
- Codabar - Libraries, shipping
Related Packages
- Mab.PipelineFramework.BarcodeGenerator.Abstractions: Interfaces only (for library authors)
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Mab.PipelineFramework.BarcodeGenerator.Abstractions (>= 1.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
- QRCoder (>= 1.6.0)
- SixLabors.ImageSharp (>= 3.1.8)
- SixLabors.ImageSharp.Drawing (>= 2.1.6)
- ZXing.Net (>= 0.16.9)
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 |
|---|---|---|
| 1.0.0 | 280 | 12/12/2025 |