IRONSOFTWAREHOME

How to create 2D barcodes

Curtis Chau
Curtis Chau
Updated: August 2, 2026

IronBarcode enables you to generate all major 2D barcode formats including QR Code, Aztec, DataMatrix, MaxiCode, PDF417, and the new rMQR format with simple C# code. Simply pass the desired encoding type to the CreateBarcode method and export as an image. With support for over 30 barcode formats, IronBarcode provides a comprehensive solution for all your barcode generation needs.

When storing detailed information in a small space, 2D barcodes are the definitive industry solution. They hold thousands of characters while remaining readable even when torn, scratched, or marked. Because they can be scanned from any angle and don't require perfect alignment, these barcodes are ideal for fast-paced logistics and mobile scanning applications. Built-in error correction ensures your data remains accessible even in challenging conditions.

The main challenge is selecting the correct format for your specific needs. You might need Aztec Code's borderless compact design for mobile ticketing, DataMatrix's industrial precision for tiny electronic components, or PDF417's massive offline storage capacity for driver's licenses and ID cards. With IronBarcode, you can generate all these formats reliably and efficiently.

In this guide, we'll cover how to generate critical 2D formats like QR Code, MaxiCode, and the new rMQR, along with their everyday use cases.


Quickstart: Generate Your First 2D Barcode

Use IronBarcode's simple API to create a QR Code from a string and save it as a PNG image. Get started immediately - supply the data, choose the encoding and size, and write your image file.

  1. 1Install IronBarcode with NuGet Package Manager

    PM > Install-Package BarCode

  2. 2Copy and run this code snippet.

    IronBarCode.BarcodeWriter.CreateBarcode("Hello World", BarcodeEncoding.QRCode, 250, 250).SaveAsPng("myQRCode.png");
    C#
  3. 3Deploy to test on your live environment

    Start using IronBarcode in your project today with a free trial
    arrow pointer

What are 2D barcodes and when should I use them?

Two-dimensional barcodes like 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 hold only a few numbers or letters, 2D codes can store massive amounts of data - including web links, ID details, or entire files - without requiring a database connection.

This robust design makes 2D barcodes incredibly durable. Built-in error correction allows scanning even when barcodes are scratched, torn, or marked, where typical barcodes would fail. This makes 2D barcodes ideal for harsh environments or mobile scanning where perfect conditions aren't guaranteed. For more information on fine-tuning error correction, see our error correction guide.

Let's explore all 2D barcode formats supported by IronBarcode, demonstrate how to create them, and discuss their common uses. Each format has unique characteristics suited to specific applications.

How do I create an Aztec barcode for mobile ticketing?

Aztec Code is a high-density 2D matrix recognized by its square bullseye pattern at the center. Unlike other formats, Aztec codes are space-efficient and store data in a compact square format.

Aztec code's unique advantage is that it requires no quiet zone, unlike other barcodes. It's commonly used for mobile ticketing like electronic boarding passes and healthcare patient wristbands. Airlines and transit systems prefer this format for its compact size and excellent readability on smartphone screens.

Code

IronBarcode makes generating Aztec codes simple: pass BarcodeEncoding.Aztec as the second parameter when calling the CreateBarcode method, then export the result as an image. You can further customize the appearance using IronBarcode's styling options.

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");

Output

Aztec barcode example showing the characteristic bullseye pattern

How do I create a DataMatrix barcode for industrial part marking?

Data Matrix is a compact 2D matrix recognized by the L-shaped finder pattern on its perimeter. This format excels where space is limited and durability is critical.

Data Matrix's unique strength is extreme durability and ability to scale down to microscopic sizes for direct part marking (DPM). It's commonly used for industrial tracking on surgical instruments, electronic components, and aerospace parts where space is severely limited. The format's compact size and high data density are perfect for creating barcodes from various data types including serial numbers and batch codes.

Code

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

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");

Output

DataMatrix barcode example displaying the L-shaped finder pattern

How do I create a MaxiCode barcode for shipping labels?

MaxiCode is a fixed-size 2D matrix recognized by its circular bullseye pattern surrounded by a hexagonal grid. This unique design was engineered specifically for high-speed scanning on conveyor belts.

MaxiCode's unique aspect is its constant 1-inch physical size regardless of stored data, optimizing it for high-speed conveyor belt reading. It's commonly used in logistics and supply chain management, specifically on UPS shipping labels for automated package sorting and routing. The fixed size ensures consistent scanning performance regardless of data payload.

Code

IronBarcode makes generating MaxiCode simple: pass BarcodeEncoding.MaxiCode as the second parameter when calling the CreateBarcode method, then export it as an image. For more examples, check our barcode quickstart guide.

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");

Output

MaxiCode barcode example with hexagonal pattern and circular bullseye

How do I create a PDF417 barcode for ID cards?

PDF417 is a stacked linear barcode recognized by its wide, rectangular appearance resembling digital static. This format encodes significantly more data than other 2D formats, making it ideal for storing detailed information.

PDF417's unique capability is serving as a portable data file, storing large amounts of data like photos, names, and biometric records without requiring database connections. It's commonly used for government identification like driver's licenses and printed airline boarding passes. The format supports both text and binary data encoding.

Code

IronBarcode makes generating PDF417 simple: pass BarcodeEncoding.PDF417 as the second parameter when calling the CreateBarcode method, then export it as an image. You can also save barcodes in various image formats including PNG, JPEG, and more.

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");

Output

PDF417 barcode example showing stacked linear pattern

How do I create a QR Code for marketing campaigns?

A QR Code is a high-density 2D matrix recognized by three distinctive square finder patterns in its corners. As the most widely recognized 2D barcode format, QR codes have become ubiquitous in consumer applications.

QR Code's unique advantage is universal consumer accessibility - it's the only 2D symbology natively supported by virtually all modern smartphone camera apps without additional software. It's commonly used for marketing and public engagement, linking to websites and digital menus, and facilitating mobile payments. For advanced QR code generation, explore our QR code creation examples.

Code

IronBarcode makes generating QR codes simple: pass BarcodeEncoding.QRCode as the second parameter when calling the CreateBarcode method, then export it as an image. You can also customize QR code styles by adding logos and changing colors.

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");

Output

QR Code example with three corner finder patterns

How do I create a Micro QR Code for small electronics?

A Micro QR Code is a miniaturized 2D matrix recognized by its single square finder pattern in the top-left corner. This format was designed specifically for applications where space is extremely limited.

Due to its miniaturized size, character limits apply. The largest version (M4) holds a maximum of 21 alphanumeric characters or 35 numbers. Carefully plan your data encoding strategy when using Micro QR codes.

Code

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

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");

Output

Micro QR Code example with single finder pattern

What happens if my data exceeds Micro QR capacity?

IronBarcode throws an error if the input string exceeds 35 numeric digits or 21 alphanumeric characters. This built-in validation helps prevent runtime errors in production environments.

Error message displayed when Micro QR Code data capacity is exceeded

How do I create an rMQR Code for narrow spaces?

Rectangular Micro QR Code (rMQR) is a specialized 2D matrix recognized by its elongated, strip-like shape and single finder pattern in the top-left corner. This innovative format addresses a specific gap in barcode technology.

Due to its rectangular design, it stretches horizontally to increase capacity without increasing vertical footprint. The largest version (R17x139) contains up to 219 alphanumeric characters or 361 numbers - significantly more capable than MicroQRCode while maintaining a slim profile.

Code

IronBarcode makes generating RMQRCode simple: pass BarcodeEncoding.RMQRCode as the second parameter when calling the CreateBarcode method, then export it as an image. For a comprehensive overview of all IronBarcode features, visit our API reference.

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");

Output

rMQR Code example showing rectangular format

What happens if my data exceeds rMQR capacity?

IronBarcode throws an error if the input string exceeds 361 numeric digits or 219 alphanumeric characters. This validation ensures your barcodes remain scannable and compliant with the rMQR specification.

Error message shown when rMQR Code capacity limit is exceeded

Which 2D barcode format should I choose?

NameFormatCommon UsageRestrictions & Pitfalls
Aztec CodeMatrix (Center-Out)
Square grid with central "bullseye" finder. No quiet zone required.
Mobile boarding passes (Apple Wallet), train tickets, and healthcare wristbands.
  • Center Damage: Relies on center finder; bullseye damage causes total failure.
  • Screen Glare: Reflective phone screens can blind standard scanners.
Data MatrixMatrix (L-Pattern)
Square or rectangular with solid "L" border on two sides.
Electronics components, surgical instruments, and Direct Part Marking (DPM) on metal.
  • Quiet Zone: Requires 1-module white border; edge graphics cause failures.
  • Contrast: Shiny metal (DPM) requires specialized lighting to read.
MaxiCodeFixed Size Matrix
Exactly 1x1 inch. Hexagonal dots with central circular bullseye.
UPS Shipping labels and high-speed conveyor belt sorting.
  • Fixed Size: Cannot shrink below 1 inch tall.
  • Printer Quality: Low-resolution thermal printers distort hexagons.
PDF417Stacked Linear
Wide rectangle resembling digital static. High capacity.
Driver's Licenses (AAMVA), ID cards, and paper boarding passes.
  • Truncation: Handheld scanners often miss left/right edges.
  • Size Growth: Physical size increases significantly with more data.
QR CodeMatrix
Square with three distinctive corner finder patterns.
Consumer marketing, payments, restaurant menus, Wi-Fi pairing.
  • Quiet Zone: Requires large white margin (4 modules wide).
  • Density: Long URLs without shortening create unfocusable "static".
Micro QRMiniature 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.
  • Scanner Support: Not supported by all smartphone camera apps.
rMQRRectangular Matrix
Long, narrow strip bridging Micro QR and standard QR.
Test tubes, cables, thin bezels, narrow product edges.
  • New Format: Growing support but not universal on legacy scanners.
  • Aspect Ratio: Designed strictly for narrow spaces.

Frequently Asked Questions

What are 2D barcodes and when should I use them?

2D barcodes, like QR Codes and Data Matrix, use a grid of squares or dots to store information horizontally and vertically. These codes can store large amounts of data, such as URLs and ID details, and are highly durable due to built-in error correction. They're ideal for environments where barcodes may be scratched or damaged, or where quick scanning is necessary.

How do I create a QR Code using IronBarcode?

To create a QR Code using IronBarcode, use the `CreateBarcode` method, passing `BarcodeEncoding.QRCode` as a parameter, and export the barcode as an image with methods like `SaveAsJpeg`. IronBarcode allows you to customize the QR code by adding logos and changing colors.

Can IronBarcode generate Aztec barcodes for mobile ticketing?

Yes, IronBarcode can generate Aztec barcodes. By using the `BarcodeEncoding.Aztec` parameter in the `CreateBarcode` method, you can create this compact, space-efficient barcode, which is ideal for applications like mobile ticketing and electronic boarding passes.

What is the advantage of using Data Matrix barcodes with IronBarcode?

Data Matrix barcodes are extremely durable and can be scaled to microscopic sizes, making them ideal for industrial applications and direct part marking on electronic components. IronBarcode simplifies their creation with easy-to-use methods and options for customizing appearance.

How can I create a MaxiCode barcode with IronBarcode for logistics purposes?

To create a MaxiCode barcode with IronBarcode, pass `BarcodeEncoding.MaxiCode` to the `CreateBarcode` method. MaxiCode barcodes are optimized for high-speed scanning on logistics conveyor belts and have a fixed size, which is advantageous for automated sorting and routing.

Is IronBarcode capable of creating PDF417 barcodes for ID cards?

Yes, IronBarcode can create PDF417 barcodes, which are perfect for storing large amounts of data such as text and biometric records. Use `BarcodeEncoding.PDF417` in the `CreateBarcode` method, and export the result in various image formats for use on ID cards and licenses.

Can I generate Micro QR Codes using IronBarcode?

IronBarcode supports the generation of Micro QR Codes, which are designed for applications with limited space. Use `BarcodeEncoding.MicroQRCode` when calling `CreateBarcode`, but ensure your data doesn't exceed the character limits specific to Micro QR Codes.

What happens if my data exceeds the capacity of an rMQR Code when using IronBarcode?

IronBarcode will throw an error if the input string for an rMQR Code exceeds 361 numeric digits or 219 alphanumeric characters, ensuring your barcodes remain scannable and compliant with specifications.

How do I choose the right 2D barcode format with IronBarcode?

Choosing the right 2D barcode with IronBarcode involves understanding each format's strengths. Aztec is great for mobile screens, DataMatrix for industrial marking, QR for consumer use, and so on. IronBarcode supports all these, offering customization for specific needs.

What makes 2D barcodes generated by IronBarcode reliable?

IronBarcode equips 2D barcodes with built-in error correction, maintaining data accessibility even if the barcode is damaged. This feature, alongside the capacity to store large amounts of data, makes them reliable for fast-paced and mobile scanning environments.

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 2,422,100Version:2026.9just released

Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package BarCode
nuget.org/packages/BarCode/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronBarCode"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

  1. Download and unzip IronBarCode to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronBarCode.dll"

Licenses from $999

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required