Our Customers
Contact Us Email: support@barcodelib.com
Home > Java Barcode Generator > Java Barcode Generation Guide > Java PDF-417 Barcode Generator
Download Barcode for Java Trial

Java PDF-417 Barcodes Generator Guide

PDF-417 Bar Code Generation Guide in Java class, J2EE, Jasper Reports, iReport & Eclipse BIRT
  • Easily generate readable PDF-417 barcodes in Java applications
  • Compatible with the latest PDF-417 ISO specification [ISO/IEC 15438 (Second edition 2006-06-01)]
  • Generate high quality PDF-417 images in JPEG, GIF & PNG formats
  • 100% build in Java, fully compatible with JDK 1.4 and later versions
  • Generate PDF-417 barcodes on any platforms that have Java virtual machine installed
  • Generate PDF-417 in Jasper Reports & iReport
  • Generate PDF-417 in Eclipse BIRT
  • High performance Java Barcode Generator library which enjoys customer appreciation for more than 10 years
  • Royalty-free developer license, one time purchase for lifetime use
Java PDF-417 Introduction
PDF-417 is also known as Portable Data File 417, PDF 417, PDF417 Truncated.
Compatibility: Barcode for Java library is compatible with the latest PDF-417 ISO specification [ISO/IEC 15438 (Second edition 2006-06-01)].
PDF417, or Portable Data File 417, is a two-dimensional stacked barcode symbology capable of encoding over a kilobyte of data per label. It was developed by Symbol Technologies (1989-1992) and is currently maintained by ANSI / AIM USA.
Large amounts of text and data can be stored securely and inexpensively when using the PDF417 symbology. The printed symbol consists of several linear rows of stacked codewords. Each codeword represents 1 of 929 possible values from one of three different clusters. A different cluster is chosen for each row, repeating after every three rows.
Java PDF-417 Basic Characteristics
PDF417 is a bar code symbology with the following basic characteristics:
  1. Encodable character set:
    • 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.
    • Up to 811 800 different character sets or data interpretations.
    • Various function codewords for control purposes.
  2. Symbol character structure: (n, k, m) characters of 17 modules (n), 4 bar and 4 space elements (k), with
    the largest element 6 modules wide (m).
  3. Maximum possible number of data characters per symbol (at error correction level 0): 925 data
    codewords which can encode:
    • Text Compaction mode: 1 850 characters (at 2 data characters per codeword).
    • Byte Compaction mode: 1 108 characters (at 1,2 data characters per codeword).
    • Numeric Compaction mode: 2 710 characters (at 2,93 data characters per codeword)
  4. At the minimum recommended error correction level, there is a maximum of 863 data codewords which
    can encode:
    • Text Compaction mode: 1 726 characters (at 2 data characters per codeword).
    • Byte Compaction mode: 1 033 characters (at 1,2 data characters per codeword).
    • Numeric Compaction mode: 2 528 characters (at 2,93 data characters per codeword).
  5. Symbol size:( Since the number of rows and the number of columns are selectable, the aspect ratio of a PDF417 symbolmay be varied when printing to suit the spatial requirements of the application.)
    • Number of rows: 3 to 90.
    • Number of columns: 1 to 30.
    • Width in modules: 90X to 583X including quiet zones.
    • Maximum codeword capacity: 928 codewords.
    • Maximum data codeword capacity: 925 codewords.
  6. Selectable error correction: 2 to 512 codewords per symbol
  7. Non-data overhead:
    • Per row: 73 modules, including quiet zones.
    • Per symbol: a minimum of 3 codewords, represented as symbol characters.
  8. Code type: continuous, multi-row two-dimensional.
  9. Character self-checking: Yes.
  10. Bi-directionally decodable: Yes.
Java PDF-417 Encoding Data Scope
PDF417 Barcode for Java supports:
  • all 128 characters of ASCII.
  • values 128-255 in accordance with ISO 8859-1. There are referred to as extended ASCII.
How to Generate PDF-417 Barcode in Java Class?
The following Java code illustrates how to create a PDF-417 barcode, and output to various formats.
1     PDF417 barcode = new PDF417(); 
2 barcode.setData("PDF 417");

// add more PDF417 property settings here
3 barcode.renderBarcode("c:/barcode.gif");

4 BufferedImage bufferedImage = barcode.renderBarcode();

5 byte[] barcodeBytes = barcode.renderBarcodeToBytes();

6 Graphics2D g = ...
7 Rectangle2D rectangle = ...
8 barcode.renderBarcode(g, rectangle);

9 OutputStream outputStream = ...
10 barcode.renderBarcode(outputStream);
  • Create a PDF417 barcode object (line 1)
  • Set PDF417 object barcode properties (line 2)
  • Generate PDF-417 barcode and encode into gif image format (line 3)
  • Generate PDF-417 and output to BufferedImage object (line 4)
  • Generate PDF-417 in bitmap and output to byte[] (line 5)
  • Generate PDF-417 and draw to defined area (Rectangle2D) on Graphics2D (line 6-8)
  • Generate PDF-417 and output to OutputStream (line 9-10)
How to Generate Barcode PDF-417 Image in Java Web Applications?
There are two methods to create PDF-417 barcode images in your Java web applications.
  1. The simplest way is to stream barcode image using our buildin barcode servlet application.
    • Download the Barcode for Java Trial Package, and unzip it.
    • Under java_barcode_trial package, copy barcode folder to your java servlet container like tomcat.
    • Restart tomcat. Now you have installed successfully.
    • To test your installation, open your web browser and navigate to:
      http://YourDomain:Port/barcode/pdf417?Data=123456789
    • To create barcode image in your JSP or html page, you need pass the url to IMG tag src value. For example,
      <img src="http://YourDomain:Port/barcode/pdf417?Data=123456789" />
      Using this method, it will not generate any barcode images in your server side.
  2. The second method is to generate barcode images in your server side.
    • Create a barcode image in server side, like
      PDF417 barcode = new PDF417();
      barcode.setData("123456789");
      barcode.renderBarcode("C:/Tools/Tomcat 5.5/webapps/YourWebApp/barcode-images/barcode.gif");
    • In your JSP or HTML page, you need use IMG tag to display generated image, like
      <img src="http://YourDomain:Port/YourWebApp/barcode-images/barcode.gif" />
How to Generate Barcode PDF-417 Image in Jasper Reports, iReport, Eclipse BIRT?
Java PDF-417 Property Settings
  1. Set the data property with the value to encode. Type is String.
    Servlet URL Parameter: "Data".
  2. Set the dataMode property. Default is PDF417.Text.
    Servlet URL Parameter: "DataMode". Sample: &DataMode=1
    • PDF417.AUTO (0): Barcode Library will use the different compaction modes and switching procedures automatically.
    • PDF417.MODE_TEXT (1) (default): It allows encoding all printable ASCII characters, i.e. values
      from 32 to 126 inclusive in accordance with ISO/IEC 646, as well as selected control characters such as TAB (horizontal tab ASCII 9), LF (NL line feed, new line ASCII 10) and CR (carriage return ASCII 13).
    • PDF417.MODE_BYTE (2): It allows encoding all 256 possible 8-bit byte values. This includes all ASCII characters value from 0 to 127 inclusive and provides for international character set support.
    • PDF417.MODE_NUMERIC (3): It allows encoding numeric data.
  3. Set the processTilde property to true, if you want use the tilde character "~" to specify special characters in the encoding data. Default is false.
    Servlet Parameter: "ProcessTilde". Value: "t" (true), "f" (false). Sample: &ProcessTilde=t.
    Format of the tilde:
    • ~NNN: is used to represent the ASCII character with the value of NNN. NNN is from 000 - 255.
    • ~6NNNNN: is used to represent the Unicode. NNNNN is from 00000 - 65535.
    • ~7NNNNNN: is used to specify the Extended Channel Interpretations and NNNNNN is a value between 000000 and 999999.
    • ~rp: is used only at the very beginning of the symbol for the reader programming purpose.
  4. Set the ecl property. PDF417 Error Correction Level. Default is PDF417.ECL_2 (2).
    Servlet URL Parameter: "ECL". Sample: &ECL=2.
  5. Set the truncated property to true, if you want truncated PDF417. Default is false.
    truncated PDF417 may be used where space considerations are a primary concern and symbol damage is unlikely.
    Servlet URL Parameter: "Truncated". Value: "t" (true), "f" (false). Sample: &Truncated=t.
  6. Set the column property value.
    Number of columns. The value range is from 1 to 30. The default is 5. Increase this value, if your data size is large.
    Servlet URL Parameter: "ColumnCount". Sample: &ColumnCount=5.
  7. Set the row property value.
    The number of rows for PDF417. The value range is from 3 to 90. The default is 3.
    Servlet URL Parameter: "RowCount". Sample: &RowCount=3.
  8. Macro PDF 417
    PDF 417 can be divided into multiple data areas, also called Macro PDF 417. Conversely, information stored in multiple PDF417 symbols can be reconstructed as single data symbols.
    • SetisMacro property to true, then Macro PDF417 is enabled.
      Servlet Parameter: "IsMacro".
    • Set macroSegmentCount property to the number of total symbols which make the sequence.
      Servlet Parameter: "MacroSegmentCount".
    • Set macroSegmentIndex property to the position of current symbol in the secuence (Start with 0).
      Servlet Parameter: "MacroSegmentIndex".
    • Set macroFileIndex property to be identified to the same file .
      Servlet Parameter: "MacroFileIndex".
  9. Setting up barcode image size.
    • Set property uom (Unit of Measure) for properties X, Y, leftMargin, rightMargin, topMargin and bottomMargin.
      Default is Linear.UOM_PIXEL (0). Valid values are Linear.UOM_PIXEL (0), Linear.UOM_CM (1), Linear.UOM_Inch (2).
      Servlet URL Parameter: "UOM". Value: 0 (pixel), 1 (cm), 2 (inch). Sample: &UOM=0.
    • Set the X (for barcode module width) and barRatio (barcode module height = X * barRatio) properties.
      X type is float, default is 1.
      barRatio type is int, default is 5.
      Servlet URL Parameter: "X", "BarRatio".
    • Set the leftMargin, rightMargin, topMargin and bottomMargin properties, and types are all float.
      Default values are 0 for all 4 margin settings.
      Servlet URL Parameter: "LeftMargin", "RightMargin", "TopMargin", "BottomMargin". Sample: &LeftMargin=0.
    • Set the resolution property (Value is expressed in DPI - Dots per inch).
      Default is 72 dpi.
      Servlet URL Parameter: "Resolution". Sample: &Resolution=72.
  10. With rotate property, you can display barcode horizontally or vertically.
    Default value is 0.
    Servlet URL Parameter: "Rotate". Sample: &Rotate=0.
    Value can be:
    • 0 (Linear.ANGLE_0),
    • 1 (Linear.ANGLE_90),
    • 2 (Linear.ANGLE_180),
    • 3 (Linear.ANGLE_270).
How to Set Generated PDF-417 Image Size?

All Java Barcode Types/Symbologies

Encode Linear Barcodes:
Encode Matrix Barcodes: