|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.faceless.pdf2.BarCode
public class BarCode
This class allows the creation of various bar code symbols. Simply call
the appropriate method to create your BarCode then draw the result of
getCanvas() onto a page:
BarCode code = BarCode.newCode128("Code 128 Test");
PDFCanvas canvas = code.getCanvas();
page.drawCanvas(canvas, x, y, x+canvas.getWidth(), y+canvas.getHeight());
| Field Summary | |
|---|---|
static char |
MAXICODE_GS
Represents the MaxiCode "Group Seperator" characters (U+001D). |
static char |
MAXICODE_LATCHA
Represents the MaxiCode "LATCH-A" control character. |
static char |
MAXICODE_LATCHB
Represents the MaxiCode "LATCH-B" control character. |
static char |
MAXICODE_LOCK
Represents the MaxiCode "LOCK-A", "LOCK-B" and "LOCK-C" control characters |
static char |
MAXICODE_SHIFTA
Represents the MaxiCode "SHIFT-A" control character. |
static char |
MAXICODE_SHIFTB
Represents the MaxiCode "SHIFT-B" control character. |
static char |
MAXICODE_SHIFTC
Represents the MaxiCode "SHIFT-C" control character. |
static char |
MAXICODE_SHIFTD
Represents the MaxiCode "SHIFT-D" control character. |
static char |
MAXICODE_SHIFTE
Represents the MaxiCode "SHIFT-E" control character. |
static char |
MAXICODE_THREESHIFTA
Represents the MaxiCode "3 SHIFT-A" control character. |
static char |
MAXICODE_TWOSHIFTA
Represents the MaxiCode "2 SHIFT-A" control character. |
| Method Summary | |
|---|---|
PDFCanvas |
getCanvas()
Return a PDFCanvas containing the barcode. |
float |
getHeight()
Return the height of the symbol. |
float |
getMinimumHeight()
Return the recommended minimum height for this symbol. |
float |
getWidth()
Return the width of the symbol. |
static BarCode |
newCodabar(String value,
float xunit)
Create a new Codabar BarCode. |
static BarCode |
newCode128(String value)
Create a new Code-128 BarCode with an X-unit of 1pt (0.353mm) |
static BarCode |
newCode128(String value,
double xunit)
Create a new Code-128 BarCode. |
static BarCode |
newCode39(String value,
boolean checksum)
Create a new Code 3 of 9 code with an X-unit of 1 and a thick/thin bar ratio of 2.8. |
static BarCode |
newCode39(String value,
boolean checksum,
float xunit,
float ratio)
Create a new Code 3 of 9 code. |
static BarCode |
newCode39Extended(String value,
boolean checksum)
Create a new Extended Code 3 of 9 ("Code 39+") code with an X-unit of 1pt (0.353mm) and a thick/thin bar ratio of 2.8 This algorithm uses the same symbology as Code 3 of 9 but can display all ASCII characters. |
static BarCode |
newCode39Extended(String value,
boolean checksum,
float xunit,
float ratio)
Create a new Extended Code 3 of 9 ("Code 39+") code. |
static BarCode |
newDeutschePostCode(String value)
Create a new DeutschePost Interleaved 2 of 5 code. |
static BarCode |
newDeutschePostIdentcode(int dist,
int customer,
int mailing)
Create a new DeutschePost "IdentCode", a variation on Interleaved 2 of 5 with a (4,9) weighted modulo 10 checkdigit. |
static BarCode |
newDeutschePostLeitcode(int pz,
int street,
int number,
int product)
Create a new DeutschePost "LeitCode", a variation on Interleaved 2 of 5 with a (4,9) weighted modulo 10 checkdigit. |
static BarCode |
newEAN13(String value)
Create a new GS1 EAN-13 code at a scale of 80%, giving a symbol an inch wide. |
static BarCode |
newEAN13(String value,
double scale)
Create a new GS1 EAN-13 code. |
static BarCode |
newInterleaved25(String value,
boolean checksum)
Create a new Interleaved 2 of 5 BarCode with an X-unit of 1pt (0.353mm) and a thick/thin ratio of 2.8. |
static BarCode |
newInterleaved25(String value,
boolean checksum,
float xunit,
float ratio)
Create a new Interleaved 2 of 5 BarCode. |
static BarCode |
newMaxiCode(int service,
String postcode,
int country,
String address)
Create a new MaxiCode representing an address. |
static BarCode |
newMaxiCode(int service,
String postcode,
String country,
String address)
Create a new MaxiCode representing an address. |
static BarCode |
newMaxiCode(String value,
boolean eec)
Create a new MaxiCode representing an address with the specified message. |
static BarCode |
newPDF417(String value)
Create a new PDF417 BarCode, a two-dimensional code defined in ISO15438 which can represent any character in Windows Codepage CP437. |
static BarCode |
newPDF417(String value,
float xunit,
int securitylevel,
int columns)
Create a new PDF417 BarCode, a two-dimensional code defined in ISO15438 which can represent any character in Windows Codepage CP437. |
static BarCode |
newPostnet(String value)
Create a new PostNet code, a numeric barcode used by the United States Postal Service. |
static BarCode |
newQRCode(byte[] value,
double modulesize,
int ecc,
int version)
Create a new QR-Code which encodes a series of raw bytes. |
static BarCode |
newQRCode(String value,
double modulesize,
int ecc,
int version)
Create a new QR-Code, a two-dimensional algorithm defined in ISO18004 and originally developed by Denso corporation. |
static BarCode |
newRM4SCC(String value)
Create a new Royal Mail 4-state Customer Code, an algorithm used by the Royal Mail in the UK. |
void |
setHeight(float height)
Set the height of this symbol. |
void |
setShowText(boolean show)
Request that a human-readable version of the barcode value is displayed below the code. |
void |
setWidth(float width)
Set the width of this symbol. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final char MAXICODE_SHIFTA
public static final char MAXICODE_SHIFTB
public static final char MAXICODE_SHIFTC
public static final char MAXICODE_SHIFTD
public static final char MAXICODE_SHIFTE
public static final char MAXICODE_TWOSHIFTA
public static final char MAXICODE_THREESHIFTA
public static final char MAXICODE_LATCHA
public static final char MAXICODE_LATCHB
public static final char MAXICODE_LOCK
public static final char MAXICODE_GS
| Method Detail |
|---|
public static BarCode newInterleaved25(String value,
boolean checksum)
value - the value of the BarCodechecksum - whether to apply a check digit using the standard (1,3) weighted modulo 10 algorithm
public static BarCode newInterleaved25(String value,
boolean checksum,
float xunit,
float ratio)
value - the value of the BarCodechecksum - whether to apply a check digit using the standard (1,3) weighted modulo 10 algorithmxunit - the size of the X-Dimension of the barcode, in points.ratio - the ratio of thick-bar width to thin-bar width - typically between 2 and 3
public static BarCode newDeutschePostLeitcode(int pz,
int street,
int number,
int product)
pz - the postal zone (5 digits)street - the street number (3 digits)number - the house number (3 digits)product - the product number (2 digits)
public static BarCode newDeutschePostIdentcode(int dist,
int customer,
int mailing)
dist - the distribution center code (2 digits)customer - the customer number (3 digits)mailing - the mailing number (6 digits)public static BarCode newDeutschePostCode(String value)
value - the value of the BarCode
public static BarCode newCode39(String value,
boolean checksum)
value - the value of the BarCodechecksum - whether to apply the standard Code 3 of 9 checksum algorithm
public static BarCode newCode39(String value,
boolean checksum,
float xunit,
float ratio)
value - the value of the BarCodechecksum - whether to apply the standard Code 3 of 9 checksum algorithmxunit - the size of the X-Dimension of the barcode, in points.ratio - the ratio of thick-bar width to thin-bar width - typically between 2 and 3
public static BarCode newCode39Extended(String value,
boolean checksum)
value - the value of the BarCodechecksum - whether to apply the standard Code 3 of 9 checksum algorithm
public static BarCode newCode39Extended(String value,
boolean checksum,
float xunit,
float ratio)
value - the value of the BarCodechecksum - whether to apply the standard Code 3 of 9 checksum algorithmxunit - the size of the X-Dimension of the barcode, in points.ratio - the ratio of thick-bar width to thin-bar width - typically between 2 and 3public static BarCode newEAN13(String value)
value - the value of the BarCode - 12 or 13 digits (if 12, the check digit will be appended)
public static BarCode newEAN13(String value,
double scale)
value - the value of the BarCode - 12 or 13 digits (if 12, the check digit will be appended)scale - the scale of the code - typically from 0.8 to 2, representing 80% to 200% scale. A value of
1 results in an X-dimension of 0.936pt (0.33mm).
public static BarCode newCodabar(String value,
float xunit)
value - the value of the BarCodexunit - the size of the X-Dimension of the barcode in pointspublic static BarCode newCode128(String value)
value - the value of the BarCodenewCode128(String, double)
public static BarCode newCode128(String value,
double xunit)
Create a new Code-128 BarCode. 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.
GS1 EAN128 barcodes can also be printed by using a newline (\n) to represent the FNC1 control character.
value - the value of the BarCodexunit - The size of the X-Dimension of the barcode in points. GS1-128 codes recommend an X-unit of 1.4pt (0.495mm)public static BarCode newPostnet(String value)
value - the value of the BarCodepublic static BarCode newRM4SCC(String value)
value - the value of the BarCodepublic static BarCode newPDF417(String value)
value - the value of the BarCodenewPDF417(String, float, int, int)
public static BarCode newPDF417(String value,
float xunit,
int securitylevel,
int columns)
value - the value of the BarCodexunit - the X-dimension of the barcode in points - typically around 1.securitylevel - how much error correction to apply: -1 to choose an appropriate level or a value from 0 (none) to 8 (512 bytes of error correction). Recommended values are 2 for up to about 70 characters, 3 for up to about 200, 4 for up to about 400 and 5 for more. Remember setting this too high for large volumes of text may cause the maxiumum number of codewords to be reached, which will cause an exception.columns - the number of data codeword columns in the code - a value greater than 0 will fix the width of the code and allow only the height to vary, whereas 0 will allow the code to auto-size to fit the available space (recommended).
public static BarCode newMaxiCode(String value,
boolean eec)
MAXICODE_SHIFTA, MAXICODE_LATCHB and
MAXICODE_LOCK may be inserted directly into the value.
value - the value of the BarCodeeec - whether to use Extended Error Correction (mode 5).
public static BarCode newMaxiCode(int service,
String postcode,
int country,
String address)
BarCode code = BarCode.newMaxiCode(999, "B1050", 57,
"Comité Européean de Normalisation"+BarCode.MAXICODE_GS+
"rue de Stassart 36"+BarCode.MAXICODE_GS+"Bruxelles");
service - the service level, from 1 to 999postcode - the postcode of the address, either up to nine numeric digits or up to six alphanumeric digitscountry - the numeric ISO-3166 country codeaddress - the address to place in the secondary message. Lines in the address should be separated with the MAXICODE_GS character.
public static BarCode newMaxiCode(int service,
String postcode,
String country,
String address)
newMaxiCode(int, String, int, String)
but the country is be specified as a two-letter ISO-3166 country code. For example, to create a
MaxiCode for a US address:
class="example">
BarCode code = BarCode.newMaxiCode(1, "524032140", "US",
"AIM USA"+BarCode.MAXICODE_GS+"634 ALPHA DRIVE"+BarCode.MAXICODE_GS+"PITTSBURGH PA");
service - the service level, from 1 to 999postcode - the postcode of the address, either up to nine numeric digits or up to six alphanumeric digitscountry - the two-letter ISO-3166 country codeaddress - the address to place in the secondary message. Lines in the address should be separated with the MAXICODE_GS character.
public static BarCode newQRCode(String value,
double modulesize,
int ecc,
int version)
value - the value of the BarCodemodulesize - The size of a module in mm. This value depends on the scanning device, but recommended absolute minimum values for 600dpi printing are 0.17, 0.21 or 0.25mm. 0.5mm seems to be fairly typical.ecc - the level of error correction, from 1 (lowest) to 4 (highest) offering 7%, 15%, 25% and 30% redundancy respectively. If in doubt we recommend 2.version - the "version" or size of the code - 0 to auto-size, or a value from 1 to 40.
public static BarCode newQRCode(byte[] value,
double modulesize,
int ecc,
int version)
value - the value of the BarCode - up to 2593 bytes.modulesize - The size of a module in mm. This value depends on the scanning device, but recommended absolute minimum values for 600dpi printing are 0.17, 0.21 or 0.25mm. 0.5mm seems to be fairly typical.ecc - the level of error correction, from 1 (lowest) to 4 (highest) offering 7%, 15%, 25% and 30% redundancy respectively. If in doubt we recommend 2.version - the "version" or size of the code - 0 to auto-size, or a value from 1 to 40.newQRCode(String, double, int, int)public float getWidth()
getCanvas()
public void setWidth(float width)
IllegalArgumentException. For other algorithms, this will request the
size of the symbol is set to no larger than the specified width (the actual
width chosen result may be smaller). This method will also increase the height
of the barcode to at least that returned by getMinimumHeight()
width - the requested width of the symbol in points.public float getMinimumHeight()
public void setShowText(boolean show)
getHeight() and
getMinimumHeight()
public float getHeight()
setShowText(boolean) is true, and the returned value will match the
height of the canvas returned by getCanvas().
public void setHeight(float height)
getMinimumHeight(). Not all symbologies can
have their height adjusted, and this method may throw an IllegalArgumentException
if that is the case.
height - the full height of the canvas to be returned by getCanvas(), in points.public PDFCanvas getCanvas()
PDFCanvas containing the barcode. The dimensions will match those returned
by getWidth() and getHeight(). Although we suggest drawing it onto the page
at the size it's returned, it is possible to stretch the canvas to suit.
PDFCanvas canvas = barcode.getCanvas(); page.drawCanvas(canvas, x, y, x+canvas.getWidth(), y+canvas.getHeight()):
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||