JCoder.Label4Net 3.2603.1

dotnet add package JCoder.Label4Net --version 3.2603.1
                    
NuGet\Install-Package JCoder.Label4Net -Version 3.2603.1
                    
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="JCoder.Label4Net" Version="3.2603.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="JCoder.Label4Net" Version="3.2603.1" />
                    
Directory.Packages.props
<PackageReference Include="JCoder.Label4Net" />
                    
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 JCoder.Label4Net --version 3.2603.1
                    
#r "nuget: JCoder.Label4Net, 3.2603.1"
                    
#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 JCoder.Label4Net@3.2603.1
                    
#: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=JCoder.Label4Net&version=3.2603.1
                    
Install as a Cake Addin
#tool nuget:?package=JCoder.Label4Net&version=3.2603.1
                    
Install as a Cake Tool

JCoder.Label4Net

目录

[TOC]

一.架构说明

JCoder.Label4Net
语言 C#
协议 MIT
.Net框架 .Net Standard2.1; .Net Framework 4.7.2; .Net 6; .Net 8; .Net 10;
简述 A simple library for label.(一款用于标签处理的简易库)

1.1 引用类库

引用类库 版本
SkiaSharp 3.116.1
ZXing.Net 0.16.10
ZXing.Net.Bindings.SkiaSharp 0.16.21

1.2 相关类库

| 相关类库 | 说明 | | ---------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | | JCoder | The base library of JCoder Serial.(JCoder库系列的基础库。) |

获取方式

  1. 版本要求:>=2.0.0
  2. 以版本2.0.0为例

| 获取方式 | 描述 | | ------------------ | -------------------------------------------- | | Package Manager | Install-Package JCoder.Label4Net -Version 2.0.0 | | .Net CLI | dotnet add package JCoder.Label4Net --version 2.0.0 | | PackageReference | <PackageReference Include="JCoder.Label4Net" Version="2.0.0" /> | | Paket CLI | paket add JCoder.Label4Net --version 2.0.0 | | Script&Interactive | #r "nuget: JCoder.Label4Net, 2.0.0"| | Cake | // Install JCoder.Label4Net as a Cake Addin<br/>#addin nuget:?package=JCoder.Label4Net&version=2.0.0<br/><br/>// Install JCoder.Label4Net as a Cake Tool<br/>#tool nuget:?package=JCoder.Label4Net&version=2.0.0 |

三.使用说明

本库基于 SkiaSharp 与 ZXing.Net 提供标签设计与渲染功能,支持文本、二维码、条形码等元素的标签模板设计与图像生成。

3.1 主要类与接口

| 名称 | 类型 | 描述 | | ---------------------- | ------ | -------------------------------------------------------------------------------- | | Label | 类 | 标签对象,包含标签尺寸与元素集合。 | | LabelElement | 抽象类 | 标签元素基类,包含 ID、名称、坐标(Location)、尺寸(Size)。 | | LabelText | 类 | 标签文本元素,包含文本内容、字体、对齐方式等。 | | LabelQrCode | 类 | 标签二维码元素,包含内容值、尺寸等。 | | LabelBarcode | 类 | 标签条形码元素,包含内容值、条码格式。 | | LabelRenderer | 类 | 标签渲染器,将 Label 对象渲染为图片字节数组。 | | ILabelRenderer | 接口 | 标签渲染器接口,定义 GenerateImage / GenerateImage64 方法。 | | ILabelElement | 接口 | 标签元素接口。 | | BarcodeFormatType | 枚举 | 条码格式类型。 |

3.2 使用方法

  1. 创建标签并添加文本元素
using JCoder.Label4Net;
using System.Drawing;

// 创建标签,宽 400 x 高 300 像素
var _label = new Label
{
    Size = new Size(400, 300),
    ImageSize = new Size(800, 600),  // 输出图像放大2倍
};

// 添加文本元素
var _text = new LabelText
{
    Location = new Point(20, 20),
    Size = new Size(360, 40),
    Content = "Hello, Label!",
    FontSize = 18,
};
_label.Elements.Add(_text);
  1. 添加二维码元素
using JCoder.Label4Net;
using System.Drawing;

var _label = new Label { Size = new Size(400, 300) };

// 添加二维码元素
var _qr = new LabelQrCode
{
    Location = new Point(140, 80),
    Size = new Size(120, 120),
    Content = "https://www.example.com",
};
_label.Elements.Add(_qr);
  1. 添加条形码元素
using JCoder.Label4Net;
using System.Drawing;

var _label = new Label { Size = new Size(400, 200) };

// 添加条形码元素
var _barcode = new LabelBarcode
{
    Location = new Point(20, 60),
    Size = new Size(360, 80),
    Content = "123456789012",
    Format = BarcodeFormatType.CODE_128,
};
_label.Elements.Add(_barcode);
  1. 渲染标签为图片
using JCoder.Label4Net;

var _label = new Label { Size = new Size(400, 300) };
// ... 添加元素 ...

var _renderer = new LabelRenderer();

// 生成图片字节数组 (JPEG)
byte[] _imageBytes = _renderer.GenerateImage(_label);
File.WriteAllBytes(@"C:\Output\label.jpg", _imageBytes);

// 生成 Base64 字符串
string _base64 = _renderer.GenerateImage64(_label);
  1. 使用数据字典动态渲染
using JCoder.Label4Net;

var _label = new Label { Size = new Size(400, 300) };
// ... 添加包含占位符的元素 ...

// 传入数据字典替换标签中的变量
var _data = new Dictionary<string, string>
{
    ["Name"] = "Jack",
    ["OrderNo"] = "SO20260924001",
};

var _renderer = new LabelRenderer();
byte[] _image = _renderer.GenerateImage(_label, _data);
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.  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 netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
.NET Framework net472 is compatible.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen 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
3.2603.1 84 10/3/2026
3.2602.1 89 9/24/2026
2.3.2507.822 310 7/8/2025
2.2.2506.2616 268 6/26/2025
2.1.2308.1418 327 8/14/2023

Please contact Jackie by QQ 1378071853 or E-mail JackieLaw-dev@outlook.com;