Libreria C# per QR Code

Genera QR Code con C#

Gli sviluppatori C# possono usare QRCoder, una popolare libreria .NET, per generare QR code in applicazioni ASP.NET, WPF, MAUI e console. Nessuna dipendenza esterna richiesta.

Installazione

Installa QRCoder tramite NuGet Package Manager.

NuGet
dotnet add package QRCoder
Package Manager
Install-Package QRCoder

Genera QR Code con QRCoder

Esempi di codice usando la libreria QRCoder in C#.

Basic QR Code with QRCoder

using QRCoder;

var qrGenerator = new QRCodeGenerator();
var qrData = qrGenerator.CreateQrCode("https://qrcode.fun",
    QRCodeGenerator.ECCLevel.Q);

// PNG output
var qrCode = new PngByteQRCode(qrData);
byte[] pngBytes = qrCode.GetGraphic(20);
File.WriteAllBytes("qrcode.png", pngBytes);

SVG Output

using QRCoder;

var qrGenerator = new QRCodeGenerator();
var qrData = qrGenerator.CreateQrCode("https://qrcode.fun",
    QRCodeGenerator.ECCLevel.Q);

var svgQrCode = new SvgQRCode(qrData);
string svgString = svgQrCode.GetGraphic(20,
    "#1A2B3C", "#FFFFFF");
File.WriteAllText("qrcode.svg", svgString);

ASP.NET Core Endpoint

app.MapGet("/qr", (string data) =>
{
    var qrGenerator = new QRCodeGenerator();
    var qrData = qrGenerator.CreateQrCode(data,
        QRCodeGenerator.ECCLevel.Q);
    var qrCode = new PngByteQRCode(qrData);
    byte[] png = qrCode.GetGraphic(20);

    return Results.File(png, "image/png");
});
QRCode.fun API

Genera QR Code tramite API in C#

Chiama l'API QRCode.fun da C# usando HttpClient per QR code stilizzati.

Integrazione API C#
using System.Net.Http.Json;

var client = new HttpClient();
var payload = new {
    data = "https://qrcode.fun",
    width = 300,
    height = 300,
    type = "png",
    margin = 10,
    dotsOptions = new { color = "#1A2B3C", type = "rounded" },
    cornersSquareOptions = new { color = "#8564C3", type = "extra-rounded" },
    backgroundOptions = new { color = "#FFFFFF" }
};

var response = await client.PostAsJsonAsync(
    "https://qrcode.fun/api/generate-qr-styled", payload);
var result = await response.Content.ReadFromJsonAsync<JsonElement>();
Console.WriteLine(result.GetProperty("data").GetString()?[..50]);

Anteprima QR Code Live

Prova a generare un QR code con C# adesso.

Anteprima QR

Libreria Nativa vs API

Confronta l'uso di QRCoder con l'API QRCode.fun.

FunzionalitàQRCoderQRCode.fun API
Complessità di configurazioneInstallazione NuGetSingola richiesta HTTP tramite HttpClient
PersonalizzazioneColori, loghi, forme (ArtQRCode)Stile completo: colori, forme, loghi
Supporto offlineRichiede internet
ManutenzioneAggiornamento NuGetSempre aggiornato
Formati di outputPNG, SVG, PDF, ASCIIPNG, SVG

Casi d'Uso C# per QR Code

Scenari comuni per QR code nelle applicazioni .NET.

API Web ASP.NET

Genera QR code nelle API ASP.NET Core per biglietti, fatture, token di autenticazione e pagine prodotto.

App Desktop WPF e MAUI

Crea applicazioni desktop con generazione QR code per etichette, biglietti da visita e tracciamento risorse.

Azure Functions

Distribuisci la generazione QR come Azure Functions serverless attivate da richieste HTTP o messaggi in coda.

Report e PDF

Incorpora QR code in report PDF e documenti usando QuestPDF o iTextSharp per pagamenti e tracciamento.

Approfondimento sull'Ecosistema QR Code in C#

QR code enterprise in .NET per web, desktop, mobile e cloud.

ASP.NET Core e DI

Servizio QRCoder con scope. Caching con IMemoryCache/Redis. Minimal API Results.Bytes.

MAUI e Desktop

Cross-platform Windows/macOS/Android/iOS. QRCoder su tutte le piattaforme. WPF BitmapByteQRCode.

Azure Serverless

Azure Functions con trigger HTTP/Queue. Cold start inferiori a 500ms. Caching edge con Azure CDN.

Domande Frequenti

Domande comuni sulla generazione di QR code con C#.

QRCoder è una libreria .NET open-source per la generazione di QR code. Supporta formati di output multipli tra cui PNG, SVG, PDF e ASCII art, senza dipendenze esterne.

Esplora le Librerie QR Code per Altri Linguaggi

Trova guide per la generazione di QR code ed esempi di codice per il tuo linguaggio di programmazione preferito.

Inizia a generare QR code con C#

Usa il nostro generatore gratuito o integra l'API nelle tue applicazioni .NET.