Net.Codecrete.QrCodeGenerator 2.0.6 (original) (raw)

QR Code Generator for .NET

Open-source library for generating QR codes from text strings and byte arrays.

The library is built for .NET Standard 2.0 and therefore runs on most modern .NET platforms (.NET Core, .NET Framework, Mono etc.) including .NET 6 on all platforms.

It is mostly a translation of project Nayuki's Java version of the QR code generator. The project provides implementations for many more programming languages, and the Project Nayuki web site has additional information about the implementation.

Features

Core features:

Manual parameters:

Optional advanced features:

Getting started

  1. Create a new Visual Studio project for .NET Core 3.1 (or higher) (File > New > Project... / Visual C# > .NET Core > Console App (.NET Core))
  2. Add the library via NuGet:
    Either via Project > Manage NuGet Packages... / Browse / search for qrcodegenerator / Install
    Or by running a command in the Package Manager Console
Install-Package Net.Codecrete.QrCodeGenerator -Version 2.0.6
  1. Add the code from the example below
  2. Run it

API Documention

See API Documentation

Examples

Simple operation

using Net.Codecrete.QrCodeGenerator;

namespace Examples
{
    class SimpleOperation
    {
        static void Main()
        {
            var qr = QrCode.EncodeText("Hello, world!", QrCode.Ecc.Medium);
            string svg = qr.ToSvgString(4);
            File.WriteAllText("hello-world-qr.svg", svg, Encoding.UTF8);
        }
    }
}

Manual operation

using Net.Codecrete.QrCodeGenerator;

namespace Examples
{
    class ManualOperation
    {
        static void Main()
        {
            var segments = QrSegment.MakeSegments("3141592653589793238462643383");
            var qr = QrCode.EncodeSegments(segments, QrCode.Ecc.High, 5, 5, 2, false);
            for (int y = 0; y < qr.Size; y++)
            {
                for (int x = 0; x < qr.Size; x++)
                {
                    ... paint qr.GetModule(x,y) ...
                }
            }
        }
    }
}

Requirements

QR Code Generator for .NET requires a .NET implementation compatible with .NET Standard 2.0 or higher, i.e. any of:

Raster Images / Bitmaps

Starting with .NET 6, System.Drawing is only supported on Windows operating system and thus cannot be used for multi-platform libraries like this one. Therefore, ToBitmap() has been removed and three options are now offered in the form of method extensions.

To use it:

Imaging library Recommendation NuGet dependencies Extension file
System.Drawing For Windows only projects System.Drawing.Common QrCodeBitmapExtensions.cs
SkiaSharp For macOS, Linux, iOS, Android and multi-platform projects SkiaSharp and SkiaSharp.NativeAssets.Linux (for Linux only) QrCodeBitmapExtensions.cs
ImageSharp Currently in beta state SixLabors.ImageSharp.Drawing QrCodeBitmapExtensions.cs

Using these extension methods, generating PNG images is straight-forward:

using Net.Codecrete.QrCodeGenerator;

namespace Examples
{
    class PngImage
    {
        static void Main()
        {
            var qr = QrCode.EncodeText("Hello, world!", QrCode.Ecc.Medium);
            qr.SaveAsPng("hello-world-qr.png", 10, 3);
        }
    }
}

Examples

Several example projects are provided:

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 was computed. 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 was computed. 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 was computed. 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.

NuGet packages (15)

Showing the top 5 NuGet packages that depend on Net.Codecrete.QrCodeGenerator:

Package Downloads
Codecrete.SwissQRBill.Core Generates the new QR bills for invoicing in Switzerland. The Swiss QR bill library: - is a minimal, platform-independent library supporting PDF and SVG (see homge page for PNG and EMF), - parses the invoice data embedded in the QR code, - generates payment slips (105mm by 210mm), A4 sheets or QR codes, - is multilingual: German, French, Italian, English, Romansh, - validates the invoice data and provides detailed validation information, - adds and retrieves structured bill information (according to Swico S1), - is easy to use and comes with many examples, - is small and fast, - is free – even for commecial use (MIT License), - is built for .NET Standard 2.0 and runs on all modern .NET platforms. See home page https://github.com/manuelbl/SwissQRBill.NET for examples and other library versions. 501.8K
Aiursoft.WebTools A tool for web development. 68.4K
NineDigit.eKasa eKasa PPEKK solution by Nine Digit, s.r.o. 35.7K
LeadSoft.Common.Library LeadSoft® Common utilities methods and classes. 28.6K
PinguApps.Blazor.QRCode A Blazor component for generating QR codes. This component encodes specified data into a QR code image, which can be customized in terms of size, colors, and error correction level. The QR code is generated as an SVG for optimal scalability and clarity. 16.6K

GitHub repositories (9)

Showing the top 9 popular GitHub repositories that depend on Net.Codecrete.QrCodeGenerator:

Repository Stars
BeyondDimension/SteamTools 🛠「Watt Toolkit」是一个开源跨平台的多功能 Steam 工具箱。 22.3K
LagrangeDev/Lagrange.Core An Implementation of NTQQ Protocol, with Pure C#, Derived from Konata.Core 2.6K
CHKZL/DDTV 可对阿B进行直播多窗口观看、开播提醒、自动录制、合并、转码的跨平台工具 1.4K
ClassIsland/ClassIsland 一款适用于班级多媒体屏幕的课表信息显示工具,可以一目了然地显示各种信息。 1.0K
neozhu/visitormanagement helps in managing visitors visiting the institutions for various reasons. It allows visitors to check-in digitally to eliminate the tedious registeration and other paperwork. Additionally, it also keeps a track of every individual inside the campus and their timings. Institutions has guards who enter their detail in some notebooks to keep a log which are practically impossible to reconcile. It is really unpleasent and hectic for visitor to stand at the gate and give details about the visit. To ease the process of registeration, Entry-In, Entry-Out, time tracking and logging the history, this VMS can be of great use!! 372
YSGStudyHards/DotNetExercises ⚔【DotNetGuide专栏C#/.NET/.NET Core编程技巧练习集】C#/.NET/.NET Core编程常用语法、算法、技巧、中间件、类库、工作业务实操练习集,配套详细的文章教程讲解,助你快速掌握C#/.NET/.NET Core中各种编程常用语法、算法、技巧、中间件、类库、工作业务实操等等。 318
CervantesSec/cervantes Cervantes is an open-source, collaborative platform designed specifically for pentesters and red teams. It serves as a comprehensive management tool, streamlining the organization of projects, clients, vulnerabilities, and reports in a single, centralized location. 301
neozhu/cleanaspire CleanAspire is a cloud-native template powered by Aspire for cloud environments with scalability and offline support. Using .NET 9 Minimal APIs and Blazor WebAssembly, it provides a lightweight, fast foundation for building Progressive Web Applications (PWA) optimized for the cloud. 168
aiguoli/SimpleList Manage your onedrive files on WinUI3 powered app 109
Version Downloads Last updated
2.0.6 113,679 12/7/2024
2.0.5 493,920 3/23/2024
2.0.4 610,959 10/13/2023
2.0.3 702,722 7/4/2022
2.0.2 1,110 7/4/2022
2.0.1 349,619 12/10/2021
2.0.0 329,658 11/14/2021
2.0.0-rc.1 7,558 8/24/2021
1.6.1 250,810 10/19/2020
1.6.0 24,674 7/5/2020
1.5.0 123,329 10/20/2019
1.4.1 12,101 2/20/2019
1.4.0 2,164 2/10/2019

New in releases 2.0.x:
- Fully compatible with .NET 6 (no longer depends on System.Drawing)
- Separate ToBitmap() implementations for System.Drawing, SkiaSharp and ImageSharp
- Documentation included into NuGet package
- QR code as geometric path suitable for SVG and XAML
- Very compact SVGs
- BMP bitmap generation
- Fix for SVG generation with Norwegian locale
- Enable trimming for .NET 6
- Fix for `IndexOutOfRangeException`