This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/dotnet/barcodes/generation/write-1d-barcode-to-image.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Write a 1D barcode to an image

This guide shows how to generate a one-dimensional (1D) barcode and write it to an image.

Use this workflow when you need to:

  • Generate barcode labels for products or assets
  • Create machine-readable identifiers in automated pipelines
  • Export barcodes for print or digital distribution

Prepare the project

Register the SDK license before running barcode operations. For setup details, refer to the getting started with .NET SDK guide.

using GdPicture14;
LicenseManager licence = new LicenseManager();
licence.RegisterKEY(""); // Set your license key

Create the image canvas

Create a blank image to host the barcode:

using GdPictureImaging imaging = new GdPictureImaging();
// Create a new image canvas with specified dimensions and color depth
int imageId = imaging.CreateNewGdPictureImage(600, 300, 32, imaging.ARGBI(255, 255, 255, 255));

Generate the 1D barcode

Write the barcode value to the image:

// Generate 1D barcode with specified data and formatting parameters
imaging.Barcode1DWrite(imageId, GdPicture14.Barcode1DWriterType.Barcode1DWriterCode128,
"https://www.nutrient.io", 50, 50, 400, 100,
imaging.ARGBI(255, 0, 0, 0), BarcodeAlign.BarcodeAlignLeft, 0);

Save the output image

Export the barcode image as PNG:

// Save the generated barcode image as PNG format
imaging.SaveAsPNG(imageId, @"output_barcode_1d.png");

Supported barcode types

The SDK supports common 1D formats, including:

  • Code 128
  • Code 39
  • UPC-A and UPC-E
  • EAN-13 and EAN-8
  • Code 93
  • Interleaved 2 of 5

Conclusion

This workflow writes a 1D barcode to an image file that you can print, store, or pass to downstream systems.