|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.faceless.pdf2.AbstractBarCode
org.faceless.pdf2.BarCode
A class representing a Bar Code, which can be created and drawn
onto a PDFPage
object using the PDFPage.drawBarCode
method.
One of several algorithms can be used, each with it's own features and limitations. For example, to draw a Code-128 barcode centered on a page, try something like this:
float x = page.getWidth()/2; float y = page.getHeight()/2; BarCode code = new BarCode(BarCode.CODE128, "My Text"); float w = code.getWidth(); float h = code.getHeight(); page.drawBarCode(code, x-w/2, y-h/2, x+w/2, y+h/2);
PDFPage.drawBarCode
,
PDFCanvas.drawBarCode
,
MaxiCode
Field Summary | |
static int |
CODABAR
Represents the "Codabar" barcode algorithm. |
static int |
CODE128
Represents the "Code 128" barcode algorithm. |
static int |
CODE39
Reresents a "Code 3 of 9" barcode. |
static int |
CODE39_CHECKSUM
Identical to the algorithm represented by CODE39 , except a checkdigit
is calculated automatically and added to the end of the code.
|
static int |
CODE39X
Represents the "Extended Code 3 of 9" barcode. |
static int |
CODE39X_CHECKSUM
Identical to the algorithm represented by CODE39X , except a checkdigit
is calculated automatically and added to the end of the code.
|
static int |
EAN13
Represents the EAN-13 barcode. |
static int |
INTERLEAVED25
Represents the "Interleaved 2 of 5" barcode. |
static int |
INTERLEAVED25_CHECKSUM
Identical to the INTERLEAVED25 algorithm, except a checkdigit
is added at the end. |
static int |
INTERLEAVED25_DEUTSCHENPOST
Represents the Interleaved 2/5 variation used by Deutschen Post in Germany for the Identcode and Leitcode algorithms. |
static int |
MAXICODE
Represents a UPS MaxiCode, a type of 2-Dimensional barcode. |
static int |
POSTNET
Represents the "PostNet" barcode algorithm, a numeric barcode used by the United States Postal Service to encode information for mail delivery in the US. |
static int |
RM4SCC
Represents the Royal Mail 4-state Customer Code barcode algorithm used by the Royal Mail in the the UK. |
static int |
UPCA
Represents the UPC-A barcode. |
Constructor Summary | |
BarCode(int type,
String code)
Create a new BarCode object. |
Method Summary | |
float |
getHeight()
Get the height of the barcode, not including the height of the text (if any) displayed below it. |
int |
getType()
Return the type of barcode. |
float |
getWidth()
Get the width of the total barcode in points. |
void |
setBarRatio(float ratio)
Set the ratio between the thin and thick bars in a duel-width code - ie. |
void |
setBarWidth(float barwidth)
Set the width of the narrowest bar used in this barcode. |
void |
setHeight(float height)
Set the height of the barcode in points. |
void |
setShowText(boolean showtext)
Set whether to show the value of the bar as human-readable text just below the barcode. |
void |
setWidth(float width)
Set the desired width of the entire barcode. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int CODE39
setBarRatio(float)
method.
public static final int CODE39_CHECKSUM
CODE39
, except a checkdigit
is calculated automatically and added to the end of the code.
The checksum algorithm is described on
this page.
public static final int CODE39X
CODE39
algorithm, but by re-encoding can display all the characters in
the U+0000
to U+007F
range (ie. ASCII).
The re-encoding algorithm is described on
this page.
public static final int CODE39X_CHECKSUM
CODE39X
, except a checkdigit
is calculated automatically and added to the end of the code.
The checksum algorithm is described on
this page.
public static final int INTERLEAVED25
setBarRatio(float)
method.
public static final int INTERLEAVED25_CHECKSUM
INTERLEAVED25
algorithm, except a checkdigit
is added at the end. It is the value of the equation
(10 - ((s[0]*3 + s[1] + s[2]*3 + s[3] and so on,
multiplying every second digit by 3) % 10)) % 10
public static final int CODE128
Represents the "Code 128" barcode algorithm. This code can display digits, upper and lower-case letters and most punctuation characters from the U+0000 - U+007E (US-ASCII) range. A checksum is automatically included as part of the barcode.
Code 128 has three "character sets" - A, B or C - which encode different
subsets of characters. At any time during the encoding process, a subset
can be chosen by embedding the characters U+0091
, U+0092
or U+0093
into the String being encoded, to switch to set A, B or C
respectively. If no initial character set is chosen, the most appropriate one will
be used. So, for example, to force a String to be encoded using set A, you
could specify the string "\u0092CODEHERE".
EAN128 barcodes can also be printed by using a newline (\n) to represent the FNC1 control character.
public static final int EAN13
public static final int UPCA
public static final int CODABAR
public static final int POSTNET
(number of digits+1.4)*16.2
points wide.
public static final int RM4SCC
(number of symbols+1.5)*13 + 12
points wide (the 12 points
are the required 2mm quiet zone on either side of the code)
public static final int INTERLEAVED25_DEUTSCHENPOST
public static final int MAXICODE
MaxiCode
class - this value is only here
so that the getType()
method has something useful to return.
Constructor Detail |
public BarCode(int type, String code)
type
- one of the barcode algorithms listed abovecode
- the text to encode.Method Detail |
public int getType()
public void setShowText(boolean showtext)
public void setBarWidth(float barwidth)
setWidth(float)
method - they are two different means to the same end.
PostNet barcodes have fixed dimensions, so in that case this value will be ignored.
barwidth
- the width of the narrowest bar used in the barcode. Minimum value is 0.54 points (= 0.0075 inches)public void setWidth(float width)
setBarWidth(float)
method. If the specified width would result in a barcode with the minimum bar
width < 0.54 points (= 0.0075 inches), an IllegalArgumentException
will be thrown.
PostNet barcodes have fixed dimensions, so in that case this value will be ignored.
public float getWidth()
public float getHeight()
public void setHeight(float height)
public void setBarRatio(float ratio)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |