Skip to content

jvan100/CSBarcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CSBarcode - A pure C# barcode generation library

CSBarcode is a lightweight, pure C# library for generating barcodes, with current support for QR code generation.

It provides an easy-to-use API for creating high-quality QR code images, including support for generating specialist payloads and Japanese Kanji characters.

Installation

You can add CSBarcode to your project by installing the NuGet package:

dotnet add package CSBarcode

Usage

You can easily generate a QR code and save it as an image:

using CSBarcode;

QRCode qr = QRGenerator.Generate("Message to encode", errorCorrectionLevel: ErrorCorrectionLevel.Medium);
qr.Save("/path/to/folder/qr.png", pixelsPerModule: 10);

Payload Generators

CSBarcode provides helpful utility methods to create special QR code messages for various use cases:

Generate a WiFi message

string wifiMessage = QRGenerator.GenerateWiFiMessage(
    SSID: "SSID", 
    password: "password", 
    encryption: WiFiEncryption.WPA, 
    isHiddenNetwork: false
);

Generate an Email message

string emailMessage = QRGenerator.GenerateEmailMessage(
    email: "[email protected]", 
    subject: "Email subject", 
    body: "Email body"
);

Generate an SMS message

string smsMessage = QRGenerator.GenerateSMSMessage(
    phoneNumber: "Phone number", 
    message: "SMS message"
);

Generate a Calendar Event message

string eventMessage = QRGenerator.GenerateCalendarEventMessage(
    title: "Event title", 
    description: "Event description", 
    location: "Event location", 
    startDateTime: new DateTime(2024, 12, 25), 
    endDateTime: new DateTime(2025, 12, 25)
);

Example

Example code to generate a link to a YouTube video:

QRCode qr = QRGenerator.Generate("https://www.youtube.com/watch?v=dQw4w9WgXcQ", errorCorrectionLevel: ErrorCorrectionLevel.Medium);
qr.Save("./example-qr.png", pixelsPerModule: 10);

Output

Example QR Code

About

A pure C# barcode generation library

Resources

License

Stars

Watchers

Forks

Packages

No packages published