Printer Journal

How to Print Barcode Labels in C#: A Practical Guide for Developers

2026-04-28

If you're building a warehouse tool, a POS system, or even a small shipping app, sooner or later you'll need to print barcode labels in C#. And that's where things get confusing—because printing isn't just about code. It's about barcodes, label size, printers, and communication protocols all working together.


This guide keeps it simple. No fluff—just what you actually need to get barcode label printing working in a real application.

What “Printing Barcode Labels in C#” Really Means

When developers look up how to print barcode labels with C#, they're typically trying to fix one of these common issues:


·  Generate barcodes (Code128, QR, etc.)

·  Print labels like 4×6 shipping labels or product tags

·  Connect to a thermal barcode printer 

·  Control layout, DPI, and positioning


So the task is actually a combination of:


  1. Barcode generation 

  2. Label layout 

  3. Printer communication 

Step 1: Generate Barcodes in C#

Before printing, you need a barcode image.

Popular Libraries

·  ZXing.Net (free, widely used)

·  BarcodeLib (simple, lightweight)

·  Commercial SDKs (more features, better support)

Example: Generate a Code128 Barcode

using ZXing;
using System.Drawing;

var writer = new BarcodeWriter
{
    Format = BarcodeFormat.CODE_128
};

Bitmap barcode = writer.Write("123456789");
barcode.Save("barcode.png");

This creates a basic barcode image you can later print on a label.

Step 2: Print Barcode Labels Using Windows Printing

The simplest way to print barcode labels in C# is using the built-in .NET PrintDocument class.

Basic Example

using System.Drawing;
using System.Drawing.Printing;

PrintDocument pd = new PrintDocument();

pd.PrintPage += (sender, e) =>
{
    Image img = Image.FromFile("barcode.png");
    e.Graphics.DrawImage(img, 10, 10, 200, 80);
};

pd.Print();

When This Works Best

·  Standard printers

·  Simple label printing

·  Small-scale applications


But here's the catch: This method is not ideal for thermal barcode printers (like shipping label printers).

Step 3: Use Printer Command Languages (ZPL / TSPL)

If you're working with barcode label printers (Zebra, TSC, etc.), you'll get better results using printer commands instead of images.

Why This Matters

Thermal printers don't “render” like normal printers. They expect commands like:

· ZPL (Zebra Programming Language) 

· TSPL (TSC Printer Language) 

Example: Print a Barcode with ZPL in C#

using System.IO;

string zpl = @"^XA
^FO50,50
^BCN,100,Y,N,N
^FD123456789^FS
^XZ";

File.WriteAllText(@"\\PrinterName\Share", zpl);

This sends raw instructions directly to the printer.

Benefits

·  Faster printing

·  Sharper barcode output

·  Better control over label layout


This is the preferred method for:

·  shipping label printing 

·  warehouse barcode systems 

·  inventory tracking solutions 

Step 4: Handle Label Size and DPI Correctly

A common issue developers face:

“Why does my barcode look stretched or blurry?”

Usually, it's because of label size or DPI mismatch.

Key Things to Check

·  Printer resolution (203 dpi vs 300 dpi)

·  Label size (e.g., 4×6 inches)

·  Scaling in code


For example:


·  4×6 label at 203 dpi → 812 × 1218 pixels

·  4×6 label at 300 dpi → 1200 × 1800 pixels


If you ignore this, scanning problems will happen.

Step 5: Choose the Right Approach

There are three common ways to print barcode labels in C#:

Method

Best For

Limitation

PrintDocument

Simple apps

Not ideal for thermal printers

Image printing

Basic labels

Lower performance

ZPL / TSPL commands

Professional systems

Requires learning printer language

 

Real-World Use Cases

1. E-commerce Shipping Labels

· Print 4×6 shipping labels 

· Use ZPL for speed and consistency

2. Inventory and Warehouse Systems

· Generate SKU and pallet labels

· Use barcode printing with C# backend systems

3. Retail Product Labeling

· Print price tags and QR labels

· Combine barcode generation + layout control

Common Mistakes to Avoid

❌ Using image printing for thermal printers

→ Leads to slow speed and poor quality

❌ Ignoring DPI differences

→ Causes unreadable barcodes

❌ Hardcoding label sizes

→ Breaks when switching printers

❌ Not testing with real scanners

→ “Looks fine” doesn't mean it scans fine

Useful Keywords (What Developers Also Search)

If you're researching this topic, you'll also see queries like:


· C# barcode printing example 

· print label using ZPL C# 

· thermal printer C# SDK 

· how to generate barcode in C# 

· barcode label printing for warehouse systems 


These all point to the same core goal:


building a reliable barcode printing workflow in C#.

Final Thoughts

Printing barcode labels in C# isn't just about writing code—it's about understanding how printers actually work.

If you're building a quick tool, start with PrintDocument.


If you're building something serious—like a shipping system or inventory platform—go straight to ZPL or TSPL commands.


That one decision will save you hours of debugging later.

FAQs About Barcode Printing in C#

Can I print barcode labels without a special printer?

Yes, but results may vary. Standard printers can print barcodes, but thermal barcode printers are more reliable for scanning.

Which barcode format should I use?

· Code128 → general use

· QR code → more data

· EAN/UPC → retail

Do I need a barcode SDK?

Not always. Libraries like ZXing.Net are enough for most cases.

Is ZPL better than image printing?

For thermal printers, yes. It's faster, cleaner, and designed for label printing.