Package com.pdfjet.datamatrix
Class DataMatrix
java.lang.Object
com.pdfjet.datamatrix.DataMatrix
- All Implemented Interfaces:
Drawable
Used to create 2D Data Matrix barcodes: ECC 200 symbols as specified in
ISO/IEC 16022. The text is encoded as UTF-8 in the smallest symbol that holds
it. Please see Example_37.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDataMatrix(String str) Creates a square Data Matrix barcode.DataMatrix(String str, int shape) Creates a Data Matrix barcode. -
Method Summary
Modifier and TypeMethodDescriptionfloat[]Draws this barcode on the specified page.static DataMatrixCreates a square GS1 DataMatrix barcode, as medicines, medical devices and, more and more, retail goods carry.static DataMatrixCreates a GS1 DataMatrix barcode.boolean[][]Returns the modules of this barcode, by row and column; true is dark.setAltDescription(String altDescription) Sets what the barcode says for a screen reader: a tagged document, PDF/UA or a PDF/A of level A, then has the barcode as a figure of that description.setLocation(float x, float y) Sets the location where this barcode will be drawn on the page.setModuleColor(int color) Sets the color of the barcode.setModuleLength(float moduleLength) Sets the module length of this barcode.
-
Field Details
-
SQUARE
public static final int SQUARESquare symbols, from 10x10 to 144x144 modules.- See Also:
-
RECTANGLE
public static final int RECTANGLERectangular symbols, from 8x18 to 16x48 modules. Data that does not fit in a rectangular symbol gets a square symbol.- See Also:
-
-
Constructor Details
-
DataMatrix
Creates a square Data Matrix barcode.- Parameters:
str- the text to encode.
-
DataMatrix
Creates a Data Matrix barcode.- Parameters:
str- the text to encode.shape- DataMatrix.SQUARE or DataMatrix.RECTANGLE.- Throws:
IllegalArgumentException- if the text does not fit in the largest symbol.
-
-
Method Details
-
fromGS1
Creates a square GS1 DataMatrix barcode, as medicines, medical devices and, more and more, retail goods carry. The data is written as people read it: each Application Identifier in parentheses and its data after it, such as "(01)09506000134352(17)261231(10)ABC123". The symbol starts with FNC1, which says it is GS1, and a field of no set length is ended with GS when another follows.- Parameters:
str- the GS1 data.- Returns:
- the barcode.
- Throws:
IllegalArgumentException- if the data is not GS1: an Application Identifier that is not two to four digits, or with no data; a character GS1 does not allow, a parenthesis among them; data longer than 90 characters; data of a field of set length, such as the GTIN of (01) or the date of (17), that is not that many digits; or a wrong check digit of an SSCC (00), a GTIN (01) or (02), or a GLN (410) to (417). Also if the data does not fit in the largest symbol.
-
fromGS1
Creates a GS1 DataMatrix barcode. SeefromGS1(String).- Parameters:
str- the GS1 data.shape- DataMatrix.SQUARE or DataMatrix.RECTANGLE.- Returns:
- the barcode.
- Throws:
IllegalArgumentException- if the data is not GS1, or does not fit in the largest symbol.
-
setLocation
Sets the location where this barcode will be drawn on the page.- Specified by:
setLocationin interfaceDrawable- Parameters:
x- the x coordinate of the top left corner of the barcode.y- the y coordinate of the top left corner of the barcode.- Returns:
- this DataMatrix object.
-
setModuleLength
Sets the module length of this barcode. The default value is 2.0f. Leave a margin of at least one module around the barcode.- Parameters:
moduleLength- the module length.- Returns:
- this DataMatrix object.
-
setModuleColor
Sets the color of the barcode.- Parameters:
color- the color as a 0xRRGGBB value.- Returns:
- this DataMatrix object.
-
getModules
public boolean[][] getModules()Returns the modules of this barcode, by row and column; true is dark.- Returns:
- the modules.
-
setAltDescription
Sets what the barcode says for a screen reader: a tagged document, PDF/UA or a PDF/A of level A, then has the barcode as a figure of that description. Without one, its modules are decoration, which a screen reader skips.- Parameters:
altDescription- the description.- Returns:
- this DataMatrix object.
-
drawOn
Draws this barcode on the specified page. With no page nothing is drawn. The brush of the page is as it was after it.
-