Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save aspose-com-gists/8849233aa668b11cbf43c1093352ec34 to your computer and use it in GitHub Desktop.

Select an option

Save aspose-com-gists/8849233aa668b11cbf43c1093352ec34 to your computer and use it in GitHub Desktop.
Generate Ean-13 Barcode in .NET
// Generate Ean-13 Barcode in .NET
// Read the full guide here: https://blog.aspose.com/barcode/generate-ean-13-barcode-in-dotnet/
using System;
using Aspose.BarCode.Generation;
using Aspose.BarCode;
namespace Ean13Demo
{
class Program
{
static void Main(string[] args)
{
// Initialize the barcode generator for EAN-13
var generator = new BarcodeGenerator(EncodeTypes.EAN13);
// Set the 12‑digit data; checksum will be added automatically
generator.CodeText = "590123412345";
// Ensure checksum calculation is enabled
generator.Parameters.Barcode.ChecksumMode = ChecksumMode.Auto;
// Optional: customize image appearance
generator.Parameters.Image.Width = 300;
generator.Parameters.Image.Height = 150;
generator.Parameters.Image.ForeColor = System.Drawing.Color.Black;
generator.Parameters.Image.BackColor = System.Drawing.Color.White;
// Save the barcode as a PNG file
generator.Save("ean13.png", BarCodeImageFormat.Png);
Console.WriteLine("EAN-13 barcode generated successfully.");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment