Home  >  Barcode Libraries  >  Java Barcode  >  Java Barcode Generation Guide  >  Java Barcode PDF 417 Generator for Java Class

Java Barcode PDF 417 Generator


Barcode PDF-417 Generation in Java Class, Jasper Reports, iReport, BIRT

Java Barcode offers the most affordable Java barcode generator for barcode Java professionals.


Java PDF-417 Introduction


PDF-417 is also known as Portable Data File 417, PDF 417, PDF417 Truncated

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 Properties


Class Properties HTTP Parameters Default Comments
data data "" Barcode value to encode
uom uom PIXEL Unit of meature for all size related settings. 0: pixel; 1: cm; 2: inch. Default is pixel
X x 1 Width of barcode module (narrow bar), default is 1 pixel
barRatio bar-ratio 3 bar height, bar width ratio
leftMargin left-margin 0 Barcode image left margin
rightMargin right-margin 0 Barcode image right margin
topMargin top-margin 0 Barcode image top margin
bottomMargin bottom-margin 0 Barcode image bottom margin
resolution resolution 72 Barcode image resolution in dpi
rotate rotate 0 Barcode rotate angle, valid values: 0, 90, 180, 270
processTilde process-tilde false Set the processTilde property to true, if you want use the tilde character "~" to specify special characters in the input data. Default is false.
~NNN: is used to represent the ASCII character with the value of NNN. NNN is from 000 - 255.
dataMode data-mode 1 (MODE_TEXT) valid values: 0 (MODE_AUTO), 1 (MODE_TEXT), 2 (MODE_BYTE), 3(MODE_NUMERIC)
ecl ecl 2 (ECL_2) Error correction level, values are from 0 to 8, default is 2.
rowCount row-count 3 The number of rows for PDF417. The value range is from 3 to 90. The default is 3.
columnCount column-count 5 Number of columns. The value range is from 1 to 30. The default is 5. Increase this value, if your data size is large.
truncated truncated false truncated PDF417 may be used where space considerations are a primary concern and symbol damage is unlikely.
isMacro macro false Set isMacro property to true, then Macro PDF417 is enabled.
macroSegmentIndex macro-segment-index 0 the position of current symbol in the secuence (Start with 0).
macroSegmentCount macro-segment-count 0 the number of total symbols which make the sequence.
macroFileIndex macro-file-index 0 be identified to the same file



Java Barcode PDF 417 Generator - Java Class Implementation

The following Java code illustrates how to generate a barcode in Java class:



22       private static void testLinear() throws Exception 
23       { 
24           Linear barcode = new Linear(); 
25    
26           // set barcode properties 
27           barcode.setType(Linear.CODE128); 
28           barcode.setData("1234567890"); 
29    
30           // draw and generate barcode to specified file 
31           barcode.draw("C:\\Code128.gif"); 
32       } 


Java Barcode PDF 417 Generator - Java Servlet Implementation

The following Java code illustrates how to generate a barcode in Java Servlet class:

11   public class BarcodeServlet extends HttpServlet { 
12       public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException 
13       { 
14           try { 
15               Linear barcode = new Linear(); 
16    
17               // set barcode properties 
18               barcode.setType(Linear.CODE128); 
19               barcode.setData("1234567890"); 
20    
21               // draw and generate barcode to response's ServletOutputStream 
22               ServletOutputStream servletoutputstream = response.getOutputStream(); 
23    
24               barcode.draw(servletoutputstream); 
25    
26           } catch (Exception e) { 
27               throw new ServletException(e); 
28           } 
29       } 
30   } 
31   


View BarcodeServlet.java source code


Java Barcode PDF 417 Generator - HTTP Request Implementation

  1. Install Java Barcode Generator Servlet application to Tomcat or JBoss, developers need copy the barcode folder to your Tomcat application folder, and restart the Tomcat.

  2. After Tomcat restarted, open your browser and navigate to http://your_tomcat_url:port/barcode/linear?data=12345678&type=8

  3. You can also insert barcodes in HTML or JSP pages.

    <img src="http://your_tomcat_url:port/barcode/linear?data=12345678&type=8">


Java Barcode PDF 417 Generator - java.awt.Image Object Implementation

The following Java source code shows how to generate a barcode in a java.awt.Image object:


21    
22       private static void testLinear() throws Exception 
23       { 
24           Linear barcode = new Linear(); 
25            
26           // set barcode properties 
27           barcode.setType(Linear.CODE128); 
28           barcode.setData("1234567890"); 
29            
30           // create image object 
31           java.awt.image.BufferedImage image = new java.awt.image.BufferedImage(300,300,java.awt.image.BufferedImage.TYPE_BYTE_INDEXED ); 
32           // get graphic context of image 
33           java.awt.Graphics2D imgGraphics = image.createGraphics(); 
34    
35           // draw barcode to specified location in Rectangle 
36           barcode.draw(imgGraphics, new java.awt.Rectangle(0, 0, 300, 300)); 
37       } 






Java Barcode supports:

2D / Matrix Barcode Symbologies:

           Data Matrix, PDF-417, QR-Code

1D / Linear Barcode Symbologies:

           Codabar, Code 11, Code 2 of 5, Interleaved 2 of 5, Code 39,

           Code 93, Code 128 EAN 128, EAN 8, EAN 13,

           UPC-A, UPC-E, ISBN, ISSN, ITF-14,

           Identcode, Leitcode, MSI Plessey, Onecode, Planet,

           Postnet, RM4SCC,