C# PDF417 Barcode Generator Library

Integration & Developer Guide for PDF-417 2D barcode image generation in C#

Generate 2d barcode PDF-417 images in Visual C# .NET with complete sample C# source code


In this C# tutorial, you will learn how to create PDF-417 2d barcodes in .NET ASP.NET, Windows applications.

  • Easy to encode international text, special characters (such as non-printable chars) in PDF 417
  • Customizable properties for PDF417 color setting, image width and height settings
  • Support compact (Truncated) PDF417 for smaller printing area
  • Support Macro PDF417 to store large data message into mutliple PDF417 barcodes
  • Support .NET Standard 2.0, .NET Core 8, 7, 6, 5 and .NET Framework 4.x, 3.x, 2.x
  • Build-in controller for ASP.NET web app and WinForms on .NET Framework

How to create 2d PDF417 barcodes using C#

  1. Download .NET PDF-417 Barcode Generator Suite
  2. Install C# library to create PDF417 barcodes in .NET projects
  3. Step by Step Tutorial










PDF-417, also known as Portable Data File 417, PDF 417, PDF417 Truncated, is a stacked linear barcode symbol format used in a variety of applications.

C# PDF-417 Generator is one of the functions in OnBarcode's C# Barcode Generation Controls, which supports generating & printing PDF-417, QR Code, Code 128 and 20+ other linear & 2D bar codes for C# applications.





Quick to Create PDF-417 in C#

Top
Using OnBarcode Barcode Generator for C# library, you can easily generate PDF-417 barcodes in your ASP.NET, MVC, WinForms, WPF .NET apps.

  1. Create a new PDF417 object
  2. Set PDF-417 data message
  3. Generate and print PDF-417 to an image file
PDF417 barcode = new PDF417();
barcode.Data = "PDF417";
barcode.drawBarcode("C://Output//pdf417-sample.png");





PDF417 Barcode Data Characters Encoding using C#

Top

PDF417 Valid character set

PDF417 barcode supports encoding the following character sets

  1. Full ASCII (128 characters)

  2. Extended ASCII. Values 128-255 in accordance with ISO 8859-1

  3. Up to 811 800 different character sets or data interpretations

  4. Various function codewords for control purposes





PDF417 data encoding mode

PDF417 format supports the following compact modes

  • Text Compaction mode permits all printable ASCII characters to be encoded, i.e. values 32 - 126 inclusive in accordance with ISO/IEC 646 (IRV), as well as selected control characters.

  • Byte Compaction mode permits all 256 possible 8-bit byte values to be encoded. This includes all ASCII characters value 0 to 127 inclusive and provides for international character set support.

  • Numeric Compaction mode permits efficient encoding of numeric data strings.


Using PDF417 barcode generator C# library, you can set the data encoding mode through property DataMode. You can also set DataMode to auto value, and the barcode library will choose the right encode mode for you.

barcode.DataMode = PDF417DataMode.Auto;




PDF417 maximum data length

Maximum possible number of characters a PDF417 barcode (at error correction level 0).

  • Text Compaction mode: 1,850 characters

  • Byte Compaction mode: 1,108 characters

  • Numeric Compaction mode: 2,710 characters




How to encode text in PDF-417 using C#?

Top
In the following section, we will explain how to create PDF-417 2d barcode with various text encoded in C# ASP.NET, MVC, Windows application.
  • ASCII table characters (plain text)
  • Unicode text
  • Binary data
  • GS1 System business message
  • Data in ECI mode




Generate PDF-417 with ASCII text encode

PDF-417 symbol supports all 128 ASCII characters encoding. ASCII table includes 128 characters. 95 of them are printable characters, and 33 of them are control characters, which do not have graphical label, and they are non-printing characters.

It is easy to create PDF-417 barcode with printable ASCII chars.

PDF417 barcode = new PDF417();
barcode.Data = "PDF417";


To print PDF-417 with non-printing chars, you cannot pass the characters to "Data" property directly. You should pass the ASCII value of the non-printing char in three digits. You can find all ASCII char values here : ASCII table
  • Convert the non-printable characters to string in '~ddd' format. Here 'ddd' is the ASCII value in 3 digits. For example, char 'carriage return' ascii value is 13, so the string will be '~013'.
  • Enable ProcessTilde to true. When the property is true, the barcode library will understand how to process the special text format '~ddd'.
PDF417 barcode = new PDF417();

// Encode non-printable character '[CR]' between 'a' and 'b'.
barcode.Data = "a~013bc";
barcode.ProcessTilde = true;

barcode.drawBarcode("C://Output//csharp-pdf417-non-print.png");




Generate PDF-417 with Unicode text encode

Encoding Unicode text is a common feature in most 2d barcode symbols. Using OnBarcode C# Barcode Generator library, you can use multiple methods to generate PDF-417 in C# application.

Here we will show you a quick way to create PDF417 with Unicode text encode in C# class.
  1. Initialize a PDF417 object
  2. Enable EncodeUnicodeText to true. With this property enabled, the barcode generator library will know the value in "Data" property is Unicode text string.
  3. Set the Unicode text string to property Data
PDF417 barcode = new PDF417();
barcode.EncodeUnicodeText = true;
barcode.Data = "unicode text here";
barcode.drawBarcode("C://Output//pdf417-unicode-sample.png");


There are more methods to create 2d barcode (including PDF-417) with Unicode text string using C# Barcode Generator library. You can find the details here: How to create 2d barcode with Unicode text string encode using C#?




Other data formats in PDF417 : binary data, ECI mode

Creating barcode with binary data and ECI mode are also common functions in 2d barcode symbologies. To know how to create PDF-417 barcode with binary data, ECI data mode, please view the detailed C# sample source code below :




PDF417 2D Barcode Dimension Width and Height Settings in C#?

Top
In C# PDF417 barcode generator, you can use the following barcode dimension size settings:

  • UOM: Unit of measure. You can choose PIXEL, CM or INCH.

  • X: Width of the bar module. The mimumum bar width is defined by the application specification

  • XtoYRatio: Bar width vs bar height ratio. Default value is 0.3333333f

  • RowCount: 3 to 90. Number of rows

  • ColumnCount: 1 to 30. Number of columns

  • LeftMargin, RightMargin, TopMargin, BottomMargin: Quiet zone. the minimum width of quiet zone is 2X.


C# sample code: PDF417 barcode symbol size setting.

PDF417 barcode = new PDF417();
barcode.Data = "PDF-417";

// Barcode Size Related Settings
barcode.AutoResize = false;
barcode.UOM = UnitOfMeasure.PIXEL;
barcode.X = 5;              //  Module Width 4 pixels
barcode.XtoYRatio = 0.3333f;   //  Module Height 10 pixels
barcode.Resolution = 300;

barcode.ColumnCount = 5;    //  5 data columns per row
barcode.RowCount = 12;      //  12 rows

barcode.LeftMargin = 0;
barcode.RightMargin = 0;
barcode.TopMargin = 0;
barcode.BottomMargin = 0;

barcode.drawBarcode("C://Output//csharp-pdf417-symbol-size.png");






Create, print PDF417 barcode with options using C#

Top

PDF-417 Error detection and correction (ECL) in C#

Each PDF417 symbol contains at least two error correction codewords. The Error Correction codewords provide capability for both error detection and correction.

The error correction level for a PDF417 symbol is selectable at the time of symbol creation. The barcode software provides property "ECL". The following table shows the number of error correction codewords for each error correction level.

Error Correction Level Total Number of Error Correction Codewords
0 2
1 4
2 8
3 16
4 32
5 64
6 128
7 256
8 512




How to create Compact (Truncated) PDF417 barcodes using C#

Compact PDF417 is also named as Truncated PDF417. In the original AIM USA (1994) and AIM Europe (1994) PDF417 specifications, the term Truncated PDF417 has been used in a technically synonymous manner.

Compact PDF417 may be used where space considerations are a primary concern and symbol damage is unlikely.

To create compact PDF417 using PDF417 generator C# library, you need set property Truncated to true;

PDF417 barcode = new PDF417();
barcode.Data = "PDF417";
barcode.Truncated = true;
barcode.drawBarcode("C://Output//csharp-pdf417-truncated-demo.png");





Create Macro PDF417 barcodes using C#

Macro PDF417 provides a mechanism for the data in a file to be split into blocks and be represented in more than one PDF417 symbol. This mechanism is similar to the Structured Append feature in other symbologies.

Each Macro PDF417 symbol shall contain additional control information to enable the original data file to be properly reconstructed, irrespective of the sequence in which the individual PDF417 symbols are scanned and decoded.

Up to 99 999 individual PDF417 symbols may be used to encode data in Macro PDF417.

PDF417 barcode = new PDF417();
barcode.Data = "MacroPDF";

//  Macro PDF417 provides a mechanism to split a large data file into 
//  segaments and one PDF417 symbol for each segament.
//  Enable Macro PDF417 feature and set additional properties.
barcode.Macro = true;
//  File ID is 3. 
barcode.MacroFileIndex = 3;    
//  Total 10 segements for the file.     
barcode.MacroSegmentCount = 10;     
//  This symbol is Segment 2. The first Segment Index is 0
barcode.MacroSegmentIndex = 2;      

barcode.drawBarcode("C://Output//csharp-pdf417-macro.png");




PDF-417 Barcode Property Settings

Top
C#.NET Barcode Generator library has included 20+ property settings to customize the generated PDF417 barcode images. You view the complete list of PDF147 barcode properties here.












Common Asked Questions

What is PDF417 used for?

PDF417 is a high density, 2D stacked barcode format used in a variety of applications, such as driver's license, airline boarding pass, transport, and inventory management. You can easily create PDF417 in C# ASP.NET, Windows application using C# Barcode Generator Library. Create a PDF417 and input the encoding PDF417 data and create PDF417 image in C# class.

What is the maximum capacity of a PDF417?

The maximum number of characters a PDF417 barcode at lowest error correction level (0).
  • Text Compaction mode: 1,850 characters
  • Byte Compaction mode: 1,108 characters
  • Numeric Compaction mode: 2,710 characters
Using C# Barcode Generator library, you can choose PDF417DataMode.Auto, the barcode library will automatically choose the correct PDF417 data modes.

What is the aspect ratio of a PDF417?

The aspect ratio of the printed PDF417 barcode shall be defined by two dimensions:
  • X: the dimension of the narrowest bar and narrowest space. Using C# barcode library, you can customize X value using property X
  • X to Y ratio: the ratio of bar width vs bar height. Using C# barcode library, you can customize it using property XtoYRatio

What is the difference between a PDF417 and a QR Code?

Both PDF417 and QR Code are 2D barcode formats. PDF417 can be scannable even if up to 50% of it is damaged. QR Code can accept up to 30% damages. C# Barcode library supports both PDF417 and QR Code 2d barcode generations.

In C# class, you can create a PDF417 object to generate PDF417 barcode images, and create a QRCode object to print QR Code images using C#.




Summary

Top
OnBarcode C# Barcode Generator makes it easy to generate, create PDF-417 and other linear & 2d barcodes in Microsoft Word.

OnBarcode provides multiple PDF-417 Generator components and software, including Excel PDF-417, Java PDF-417, VB.NET PDF-417, ASP.NET PDF-417, PDF-417 Generator.

This document is providing a detailed C# source code about generating PDF-417 barcodes in C# class using C# Barcode generation component.





































Terms of Use | Privacy Policy
Copyright © OnBarcode.com . All rights reserved.