Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

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

Select an option

Save aspose-com-gists/56521ac3e1182585b1e22b5ad7d3ead2 to your computer and use it in GitHub Desktop.
Generate Upc Barcode in .NET
// Generate Upc Barcode in .NET
// Read the full guide here: https://blog.aspose.com/barcode/generate-upc-barcode-in-dotnet/
using System;
using Aspose.BarCode.Generation;
namespace UpcBarcodeDemo
{
class Program
{
static void Main()
{
// UPC‑A example (12 digits, includes checksum)
var upcAGenerator = new BarcodeGenerator(EncodeTypes.UpcA, "012345678905");
upcAGenerator.Parameters.ImageFormat = ImageFormat.Png;
upcAGenerator.Parameters.ImageResolution = 300;
upcAGenerator.Save("upc_a.png");
// UPC‑E example (8 digits, includes checksum)
var upcEGenerator = new BarcodeGenerator(EncodeTypes.UpcE, "01234565");
upcEGenerator.Parameters.ImageFormat = ImageFormat.Png;
upcEGenerator.Parameters.ImageResolution = 300;
upcEGenerator.Save("upc_e.png");
Console.WriteLine("UPC barcodes generated successfully.");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment