public class BarcodeDataMatrix extends Barcode2D
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_DATA_MATRIX_ENCODING |
static int |
DM_ASCII
ASCII encodation.
|
static int |
DM_AUTO
The best encodation will be used.
|
static int |
DM_B256
Binary encodation.
|
static int |
DM_C40
C40 encodation.
|
static int |
DM_EDIFACT
EDIFACT encodation.
|
static int |
DM_ERROR_EXTENSION
An error while parsing an extension.
|
static int |
DM_ERROR_INVALID_SQUARE
The dimensions given for the symbol are illegal.
|
static int |
DM_ERROR_TEXT_TOO_BIG
The text is too big for the symbology capabilities.
|
static int |
DM_EXTENSION
Allows extensions to be embedded at the start of the text.
|
static int |
DM_NO_ERROR
No error.
|
static int |
DM_RAW
No encodation needed.
|
static int |
DM_TEST
Doesn't generate the image but returns all the other information.
|
static int |
DM_TEXT
TEXT encodation.
|
static int |
DM_X12
X12 encodation.
|
static int |
DM_X21
Deprecated.
Use
DM_X12 instead.
|
DEFAULT_MODULE_SIZE
Constructor and Description |
---|
BarcodeDataMatrix()
Creates an instance of this class.
|
BarcodeDataMatrix(String code) |
BarcodeDataMatrix(String code, String encoding) |
Modifier and Type | Method and Description |
---|---|
Image |
createAwtImage(Color foreground, Color background)
Creates a java.awt.Image .
|
PdfFormXObject |
createFormXObject(Color foreground, float moduleSide, PdfDocument document)
Creates a PdfFormXObject with the barcode with given module width and module height.
|
PdfFormXObject |
createFormXObject(Color foreground, PdfDocument document)
Creates a PdfFormXObject with the barcode.
|
Rectangle |
getBarcodeSize()
Gets the maximum area that the barcode and the text, if any, will occupy.
|
Rectangle |
getBarcodeSize(float moduleHeight, float moduleWidth)
Gets the barcode size
|
String |
getEncoding() |
int |
getHeight()
Gets the height of the barcode.
|
int |
getOptions()
Gets the barcode options.
|
int |
getWidth()
Gets the width of the barcode.
|
int |
getWs()
Gets the whitespace border around the barcode.
|
Rectangle |
placeBarcode(PdfCanvas canvas, Color foreground)
Places the barcode in a PdfCanvas .
|
Rectangle |
placeBarcode(PdfCanvas canvas, Color foreground, float moduleSide) |
int |
setCode(byte[] text, int textOffset, int textSize)
Creates a barcode.
|
int |
setCode(String text)
Creates a barcode.
|
void |
setEncoding(String encoding)
setting encoding for data matrix code ( default encoding iso-8859-1)
|
void |
setHeight(int height)
Sets the height of the barcode.
|
void |
setOptions(int options)
Sets the options for the barcode generation.
|
void |
setWidth(int width)
Sets the width of the barcode.
|
void |
setWs(int ws)
Sets the whitespace border around the barcode.
|
createFormXObject
public static final int DM_NO_ERROR
public static final int DM_ERROR_TEXT_TOO_BIG
public static final int DM_ERROR_INVALID_SQUARE
public static final int DM_ERROR_EXTENSION
public static final int DM_AUTO
public static final int DM_ASCII
public static final int DM_C40
public static final int DM_TEXT
public static final int DM_B256
public static final int DM_X12
@Deprecated public static final int DM_X21
DM_X12
instead.
public static final int DM_EDIFACT
public static final int DM_RAW
public static final int DM_EXTENSION
public static final int DM_TEST
public static final String DEFAULT_DATA_MATRIX_ENCODING
public BarcodeDataMatrix()
public BarcodeDataMatrix(String code)
public Rectangle getBarcodeSize()
Barcode2D
getBarcodeSize
in class Barcode2D
public Rectangle placeBarcode(PdfCanvas canvas, Color foreground)
Barcode2D
PdfCanvas
. The barcode is always placed at coordinates (0, 0). Use the translation matrix to move it elsewhere.
placeBarcode
in class Barcode2D
canvas
- the PdfCanvas
where the barcode will be placed
foreground
- the foreground color. It can be null
public PdfFormXObject createFormXObject(Color foreground, PdfDocument document)
Barcode2D
createFormXObject
in class Barcode2D
foreground
- The color of the pixels. It can be null
document
- The document
public PdfFormXObject createFormXObject(Color foreground, float moduleSide, PdfDocument document)
foreground
- The color of the pixels. It can be null
moduleSide
- The side (width and height) of the pixels.
document
- The document
public Image createAwtImage(Color foreground, Color background)
java.awt.Image
. A successful call to the method generate()
before calling this method is required.
foreground
- the color of the bars
background
- the color of the background
public Rectangle getBarcodeSize(float moduleHeight, float moduleWidth)
moduleHeight
- The height of the module
moduleWidth
- The width of the module
public int setCode(String text)
String
is interpreted with the ISO-8859-1 encoding
text
- the text
DM_NO_ERROR
- no error.
DM_ERROR_TEXT_TOO_BIG
- the text is too big for the symbology capabilities.
DM_ERROR_INVALID_SQUARE
- the dimensions given for the symbol are illegal.
DM_ERROR_EXTENSION
- an error was while parsing an extension.
public int setCode(byte[] text, int textOffset, int textSize)
text
- the text
textOffset
- the offset to the start of the text
textSize
- the text size
DM_NO_ERROR
- no error.
DM_ERROR_TEXT_TOO_BIG
- the text is too big for the symbology capabilities.
DM_ERROR_INVALID_SQUARE
- the dimensions given for the symbol are illegal.
DM_ERROR_EXTENSION
- an error was while parsing an extension.
public int getHeight()
generate()
. This height doesn't include the whitespace border, if any.
public void setHeight(int height)
10, 10
12, 12
8, 18
14, 14
8, 32
16, 16
12, 26
18, 18
20, 20
12, 36
22, 22
16, 36
24, 24
26, 26
16, 48
32, 32
36, 36
40, 40
44, 44
48, 48
52, 52
64, 64
72, 72
80, 80
88, 88
96, 96
104, 104
120, 120
132, 132
144, 144
height
- the height of the barcode
public int getWidth()
generate()
. This width doesn't include the whitespace border, if any.
public void setWidth(int width)
10, 10
12, 12
8, 18
14, 14
8, 32
16, 16
12, 26
18, 18
20, 20
12, 36
22, 22
16, 36
24, 24
26, 26
16, 48
32, 32
36, 36
40, 40
44, 44
48, 48
52, 52
64, 64
72, 72
80, 80
88, 88
96, 96
104, 104
120, 120
132, 132
144, 144
width
- the width of the barcode
public int getWs()
public void setWs(int ws)
ws
- the whitespace border around the barcode
public int getOptions()
public void setOptions(int options)
One of:
DM_AUTO
- the best encodation will be used
DM_ASCII
- ASCII encodation
DM_C40
- C40 encodation
DM_TEXT
- TEXT encodation
DM_B256
- binary encodation
DM_X12
- X12 encodation
DM_EDIFACT
- EDIFACT encodation
DM_RAW
- no encodation. The bytes provided are already encoded and will be added directly to the barcode, using padding if needed. It assumes that the encodation state is left at ASCII after the last byte.
One of:
DM_EXTENSION
- allows extensions to be embedded at the start of the text:
exxxxxx - ECI number xxxxxx
m5 - macro 5
m6 - macro 6
f - FNC1
saabbccccc - Structured Append, aa symbol position (1-16), bb total number of symbols (2-16), ccccc file identification (0-64515)
p - Reader programming
. - extension terminator
Example for a structured append, symbol 2 of 6, with FNC1 and ECI 000005. The actual text is "Hello".
s020600075fe000005.Hello
One of:
DM_TEST
- doesn't generate the image but returns all the other information.
options
- the barcode options
public void setEncoding(String encoding)
encoding
- encoding for data matrix code
public String getEncoding()
Copyright © 1998–2018 iText Group NV. All rights reserved.