How to create 2D barcodes

When it comes to storing detailed information in a small space, 2D barcodes are the definitive industry solution. They are incredibly robust, holding thousands of characters while remaining readable even when torn, scratched, or marked up. Furthermore, because they can be scanned from any angle and don't require perfect alignment, these barcodes are the ideal choice for fast-paced logistics and mobile scanning applications where efficiency is key.

The main challenge is simply picking the correct format for your specific needs. You might need the borderless compact design of Aztec Code for mobile ticketing, the industrial precision of Data Matrix for tiny electronic components, or the massive offline storage capacity of PDF417 for driver's licenses and ID cards. With IronBarcode, you can confidently generate all these formats, knowing your process is simplified and reliable.

In this how-to guide, we will cover how to generate the most critical 2D formats, such as QR Code, MaxiCode, and the new rMQR, as well as their everyday use cases with IronBarcode.

Get started with IronBarcode

Start using IronBarcode in your project today with a free trial.

First Step:
green arrow pointer


Create 2D barcodes

Two-dimensional barcodes, such as QR Codes, use a grid of squares or dots to store information both horizontally and vertically. In contrast, linear one-dimensional barcodes use a single row of lines to store data. While standard barcodes are limited to a few numbers or letters, 2D codes can hold a massive amount of data, such as web links, ID details, or entire files, without requiring a database connection.

This robust design also makes 2D barcodes incredibly durable. Thanks to built-in error correction, they can still be scanned even if they get scratched, torn, or marked, where a typical barcode would often get misinterpreted by the scanner. This makes 2D barcodes the best choice for harsh environments or mobile scanning where you can't guarantee perfect conditions. For more information on how to fine-tune error correction, please refer to here.

Let's go through all the 2D barcode formats supported by IronBarcode and showcase how straightforward it is to create them, as well as their common uses.

Aztec

Aztec Code is a high-density 2D matrix commonly recognized by its square bullseye pattern in the center of the symbol.

The unique aspect of the Aztec code is that it doesn't require a quiet zone, unlike other barcodes. Most commonly used for mobile ticketing, such as electronic boarding passes and healthcare patient wristbands.

Code

IronBarcode makes generating Aztec codes straightforward: we pass BarcodeEncoding.Aztec as the second parameter when calling the Create method, then export the result as an image.

:path=/static-assets/barcode/content-code-examples/how-to/create-aztec-barcode.cs
using IronBarCode;

// Create the Aztec barcode
GeneratedBarcode AztecCode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.Aztec);

// Display the value below the barcode
AztecCode.AddBarcodeValueTextBelowBarcode();

// Save as a JPG file
AztecCode.SaveAsJpeg("aztec-sample.jpg");
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Output

Aztec Example Output

DataMatrix

Data Matrix is a compact 2D matrix commonly recognized by the L-shaped finder pattern on its perimeter.

The unique aspect of Data Matrix is its extreme durability and ability to scale down to microscopic sizes for direct part marking (DPM). Most commonly used for industrial tracking, such as on surgical instruments, electronic components, and aerospace parts, where space is severely limited.

Code

IronBarcode makes generating DataMatrix codes straightforward: we pass BarcodeEncoding.DataMatrix as the second parameter when calling the Create method, then export the result as an image.

:path=/static-assets/barcode/content-code-examples/how-to/create-datamatrix-barcode.cs
using IronBarCode;

// Create the DataMatrix barcode
GeneratedBarcode DataMatrix = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.DataMatrix);

// Display the value below the barcode
DataMatrix.AddBarcodeValueTextBelowBarcode();

// Save as a JPG file
DataMatrix.SaveAsJpeg("dataMatrix-sample.jpg");
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Output

DataMatrix Example Output

MaxiCode

MaxiCode is a fixed-size 2D matrix commonly recognized by its circular bullseye pattern surrounded by a hexagonal grid.

The unique aspect of MaxiCode is that it maintains a constant 1-inch physical size regardless of the data it stores, making it optimized for reading on high-speed conveyor belts. Most commonly used for logistics and supply chain management, specifically on UPS shipping labels for automated package sorting and routing.

Code

IronBarcode makes generating MaxiCode straightforward: we pass BarcodeEncoding.MaxiCode as the second parameter when calling the Create method, then export it as an image.

:path=/static-assets/barcode/content-code-examples/how-to/create-maxicode-barcode.cs
using IronBarCode;

// Create the MaxiCode barcode
GeneratedBarcode MaxiCode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.MaxiCode);

// Display the value below the barcode
MaxiCode.AddBarcodeValueTextBelowBarcode();

// Save as a JPG file
MaxiCode.SaveAsJpeg("maxiCode-sample.jpg");
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Output

MaxiCode Example Output

PDF417

PDF417 is a stacked linear barcode commonly recognized by its wide, rectangular appearance that resembles a block of digital static.

The unique aspect of PDF417 is its ability to serve as a portable data file, allowing it to store large amounts of comprehensive data, such as photos, names, and biometric records, without requiring a database connection. Most commonly used for government identification, such as the back of driver's licenses, and printed airline boarding passes.

Code

IronBarcode makes generating PDF417 straightforward: we pass BarcodeEncoding.PDF417 as the second parameter when calling the Create method, then export it as an image.

:path=/static-assets/barcode/content-code-examples/how-to/create-pdf417-barcode.cs
using IronBarCode;

// Create PDF417 barcode
GeneratedBarcode PDF417code = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.PDF417);

// Display the value below the barcode
PDF417code.AddBarcodeValueTextBelowBarcode();

// Save as a JPG file
PDF417code.SaveAsJpeg("pdf417-sample.jpg");
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Output

PDF417 Example Output

QRCode

A QR Code is a high-density 2D matrix commonly recognized by the three distinctive square finder patterns located in its corners.

The unique aspect of the QR Code is its universal consumer accessibility, as it is the only 2D symbology natively supported by virtually all modern smartphone camera apps without requiring additional software. Most commonly used for marketing and public engagement, such as linking to websites and digital restaurant menus, and for facilitating mobile payments.

Code

IronBarcode makes generating QR codes straightforward: we passBarcodeEncoding.QRCodeas the second parameter when calling theCreatemethod, then export it as an image.

:path=/static-assets/barcode/content-code-examples/how-to/create-QRCode.cs
using IronBarCode;

// Create QR Code
GeneratedBarcode QRcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.QRCode);

// Display the value below the barcode
QRcode.AddBarcodeValueTextBelowBarcode();

// Save as a JPG file
QRcode.SaveAsJpeg("QRcode.jpg");
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Output

QRCode Example Output

MicroQRCode

A Micro QR Code is a miniaturized 2D matrix commonly recognized by its single-square finder pattern in the top-left corner.

The unique aspect of the Micro QR Code is its ability to fit into extremely tight spaces by reducing overhead, requiring only a two-module quiet zone compared to the standard four, while sacrificing data capacity for physical compactness. Most commonly used for marking small electronic components, printed circuit boards (PCBs), and industrial parts where a standard QR Code is physically too large to fit.

Due to its miniaturized size, there's a limit to how many characters you can fit. The largest version (M4) can only contain a maximum of 21 alphanumeric characters or 35 numbers.

Code

IronBarcode makes generating MicroQRCode straightforward: we pass BarcodeEncoding.MicroQRCode as the second parameter when calling the Create method, then export it as an image.

:path=/static-assets/barcode/content-code-examples/how-to/create-microQR.cs
using IronBarCode;

// Create a Micro QR Code
GeneratedBarcode microQRcode = BarcodeWriter.CreateBarcode("IRON-1234", BarcodeEncoding.MicroQRCode);

// Display the value below the barcode
microQRcode.AddBarcodeValueTextBelowBarcode();

// Save to file as Jpeg
microQRcode.SaveAsJpeg("microQRCode.jpg");
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Output

MicroQR Code Example Output

Troubleshooting

As you can see, IronBarcode throws an error if the input string provided is more than 35 numeric digits or 21 alphanumeric characters.

MicroQR Code Exception

RMQRCode

Rectangular Micro QR Code (rMQR) is a specialized 2D matrix commonly recognized by its elongated, strip-like shape and a single finder pattern in the top-left corner.

The unique aspect of rMQR is its ability to fit into long, narrow spaces where a square code physically cannot, such as the thin edge of a bezel or a curved surface. It bridges the gap between the tiny footprint of Micro QR and the high capacity of a standard QR Code, requiring only a two-module quiet zone. Most commonly used for marking cables, test tubes, medical vials, and thin electronic components where height is severely restricted.

Due to its rectangular design, it can stretch horizontally to increase capacity without increasing its vertical footprint. The largest version (R17x139) can contain up to 219 alphanumeric characters or 361 numbers.

Code

IronBarcode makes generating RMQRCode straightforward: we pass BarcodeEncoding.RMQRCode as the second parameter when calling the Create method, then export it as an image.

:path=/static-assets/barcode/content-code-examples/how-to/create-rmQRcode.cs
using IronBarCode;

// Create a  RmQR Code
GeneratedBarcode rMqrCode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.RMQRCode);

// Display the value below the barcode
rMqrCode.AddBarcodeValueTextBelowBarcode();

// Save to file as Jpeg
rMqrCode.SaveAsJpeg("rmQRcode.jpg");
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Output

rmQRcode Example Output

Troubleshooting

As you can see, IronBarcode throws an error if the input string provided is more than 361 numeric digits or 219 alphanumeric characters.

rmQR Exception

Overview of Different 2D Barcode Types

Name Format Common Usage Restrictions & Pitfalls
Aztec Code Matrix (Center-Out)
Square grid with a central "bullseye" finder. No quiet zone required.
Mobile boarding passes (Apple Wallet), train tickets, and healthcare wristbands.
  • Center Damage: Relies entirely on the center finder; if the "bullseye" is scratched or distorted, the code fails.
  • Screen Glare: Highly reflective phone screens can blind standard scanners without optimized illumination.
Data Matrix Matrix (L-Pattern)
Square or Rectangular. Defined by a solid "L" border on two sides.
Electronics components, surgical instruments, and Direct Part Marking (DPM) on metal.
  • Quiet Zone: Strictly requires a 1-module white border. Graphics touching the edge will cause read failures.
  • Contrast: Low contrast on shiny metal (DPM) often requires specialized lighting to read.
MaxiCode Fixed Size Matrix
Exactly 1x1 inch. Hexagonal dots with a central circular bullseye.
UPS Shipping labels and high-speed conveyor belt sorting.
  • Fixed Size: Cannot be shrunk to fit small items; must remain 1 inch tall.
  • Printer Quality: Low-resolution thermal printers often distort the hexagons, creating "aliasing" errors.
PDF417 Stacked Linear
Wide rectangle resembling digital static. High capacity (can hold files).
Driver's Licenses (AAMVA), ID cards, and paper boarding passes.
  • Truncation: The code is wide; handheld scanners often miss the left/right edges ("Start/Stop" patterns).
  • Size Growth: The physical size grows significantly as you add more data.
QR Code Matrix
Square with three distinctive corner finder patterns.
Consumer marketing, payments, restaurant menus, Wi-Fi pairing.
  • Quiet Zone: Requires a large white margin (4 modules wide) to function.
  • Density: Encoding long URLs without a shortener creates dense "static" that phone cameras struggle to focus on.
Micro QR Miniature Matrix
Tiny square with only one corner finder pattern.
Printed Circuit Boards (PCBs), small electrical components.
  • Capacity Limit: Max ~35 numeric or 21 alphanumeric characters. Cannot hold full URLs.
  • Scanner Support: Not natively supported by all standard smartphone camera apps.
rMQR Rectangular Matrix
Long, narrow strip. Bridges the gap between Micro QR and standard QR.
Test tubes, cables, thin bezels, narrow product edges.
  • New Format: Support is growing, but not yet universal on all legacy scanners.
  • Aspect Ratio: Strictly designed for narrow spaces; not intended for general use.

Frequently Asked Questions

What are 2D barcodes?

2D barcodes, also known as two-dimensional barcodes, are matrix codes that can store data in two dimensions, allowing them to hold more information than traditional 1D barcodes.

How can I create 2D barcodes in C#?

You can create 2D barcodes in C# using IronBarcode, which provides easy-to-follow code examples and instructions for generating barcodes in various formats.

What types of 2D barcodes can be generated with IronBarcode?

IronBarcode supports the generation of several 2D barcode formats, including QR codes, Data Matrix, and PDF417.

Do I need any special software to use IronBarcode?

No special software is required. IronBarcode is a .NET library that can be easily integrated into your existing C# applications.

Is it possible to customize the appearance of 2D barcodes?

Yes, with IronBarcode, you can customize the appearance of 2D barcodes, including colors, size, and embedded logos.

Can IronBarcode read barcodes as well as create them?

Yes, IronBarcode can both create and read a wide variety of barcode formats, making it a versatile tool for barcode applications.

What are some common applications of 2D barcodes?

2D barcodes are commonly used in applications such as inventory management, ticketing, and mobile payments due to their ability to store more information than 1D barcodes.

How do I get started with IronBarcode?

To get started with IronBarcode, you can download the library from the Iron Software website and follow the step-by-step instructions and code examples provided in the documentation.

Are there any licensing requirements for using IronBarcode?

Yes, IronBarcode requires a valid license for commercial use, which can be obtained from the Iron Software website.

Can I integrate IronBarcode with other .NET applications?

Absolutely, IronBarcode is designed to seamlessly integrate with other .NET applications, allowing for easy implementation and usage.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...

Read More
Ready to Get Started?
Nuget Downloads 1,964,769 | Version: 2025.11 just released