com.lowagie.text.pdf
Class PdfBarcode

java.lang.Object
  extended bycom.lowagie.text.Chunk
      extended bycom.lowagie.text.pdf.PdfBarcode
All Implemented Interfaces:
Element, MarkupAttributes

public class PdfBarcode
extends Chunk

A barcode is a Chunk with a certain type of barcode font.

With this class you can construct several types of barcode in different sizes, representing any 'product' or 'article' number.


Field Summary
static int CODE39
          This is a type of barcode.
static int EAN13
          This is a type of barcode.
static int INTERLEAVED_2_OF_5
          This is a type of barcode.
static int UPCA
          This is a type of barcode.
static int[][] variableParity
          The variable parity table in EAN 13
 
Fields inherited from class com.lowagie.text.Chunk
ACTION, attributes, BACKGROUND, COLOR, content, ENCODING, font, GENERICTAG, HSCALE, HYPHENATION, IMAGE, LOCALDESTINATION, LOCALGOTO, markupAttributes, NEWLINE, NEWPAGE, NEXTPAGE, OBJECT_REPLACEMENT_CHARACTER, PDFANNOTATION, REMOTEGOTO, SKEW, SPLITCHARACTER, SUBSUPSCRIPT, TEXTRENDERMODE, UNDERLINE
 
Fields inherited from interface com.lowagie.text.Element
ALIGN_BASELINE, ALIGN_BOTTOM, ALIGN_CENTER, ALIGN_JUSTIFIED, ALIGN_JUSTIFIED_ALL, ALIGN_LEFT, ALIGN_MIDDLE, ALIGN_RIGHT, ALIGN_TOP, ALIGN_UNDEFINED, ANCHOR, ANNOTATION, AUTHOR, CCITT_BLACKIS1, CCITT_ENCODEDBYTEALIGN, CCITT_ENDOFBLOCK, CCITT_ENDOFLINE, CCITTG3_1D, CCITTG3_2D, CCITTG4, CELL, CHAPTER, CHUNK, CREATIONDATE, CREATOR, GRAPHIC, HEADER, IMGRAW, IMGTEMPLATE, JPEG, KEYWORDS, LIST, LISTITEM, MULTI_COLUMN_TEXT, PARAGRAPH, PHRASE, PRODUCER, PTABLE, RECTANGLE, ROW, SECTION, SUBJECT, TABLE, TITLE
 
Constructor Summary
PdfBarcode(String ttf, int type, int size, long number)
          Creates a new Barcode.
PdfBarcode(String ttf, int type, int size, String number)
          Creates a new Barcode.
 
Method Summary
private static String addZero(String number, int length)
          Adds leading zeros.
private static char convertInterleaved(int digits)
          Converts an int to a convert interleaved character.
private static String convertToCode(int type, String number)
          Converts a String representing a number to a barcode with a specific barcode font.
 
Methods inherited from class com.lowagie.text.Chunk
addToArray, append, content, font, getAttributes, getChunks, getHorizontalScaling, getImage, getKeySet, getMarkupAttribute, getMarkupAttributeNames, getMarkupAttributes, getTextRise, getWidthPoint, hasAttributes, isEmpty, isTag, process, setAction, setAnchor, setAnchor, setAnnotation, setBackground, setBackground, setFont, setGenericTag, setHorizontalScaling, setHyphenation, setLocalDestination, setLocalGoto, setMarkupAttribute, setMarkupAttributes, setNewPage, setRemoteGoto, setRemoteGoto, setSkew, setSplitCharacter, setTextRenderMode, setTextRise, setUnderline, setUnderline, type
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.lowagie.text.Element
toString
 

Field Detail

CODE39

public static final int CODE39
This is a type of barcode.

See Also:
Constant Field Values

UPCA

public static final int UPCA
This is a type of barcode.

See Also:
Constant Field Values

EAN13

public static final int EAN13
This is a type of barcode.

See Also:
Constant Field Values

INTERLEAVED_2_OF_5

public static final int INTERLEAVED_2_OF_5
This is a type of barcode.

See Also:
Constant Field Values

variableParity

public static final int[][] variableParity
The variable parity table in EAN 13

Constructor Detail

PdfBarcode

public PdfBarcode(String ttf,
                  int type,
                  int size,
                  String number)
           throws BadElementException,
                  DocumentException,
                  IOException
Creates a new Barcode.

Parameters:
ttf - the ttf file representing the barcode font
size - the size of the barcode
number - the number you want to convert to a barcode in String format

PdfBarcode

public PdfBarcode(String ttf,
                  int type,
                  int size,
                  long number)
           throws BadElementException,
                  DocumentException,
                  IOException
Creates a new Barcode.

Parameters:
ttf - the ttf file representing the barcode font
size - the size of the barcode
number - the number you want to convert to a barcode in long format
Method Detail

convertToCode

private static String convertToCode(int type,
                                    String number)
                             throws BadElementException
Converts a String representing a number to a barcode with a specific barcode font.

Parameters:
type - the type of barcode
number - the number you want to convert to a barcode in long format
Throws:
BadElementException

convertInterleaved

private static char convertInterleaved(int digits)
                                throws NumberFormatException
Converts an int to a convert interleaved character.

Throws:
NumberFormatException

addZero

private static String addZero(String number,
                              int length)
Adds leading zeros.