PDF417 barcode = new PDF417();
// set barcode properties
barcode.setCodeText("PDF417");
// draw and generate barcode to buffered image object
BufferedImage pdf417Image = barcode.drawBarCode2Image();
public class BarcodeServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException
{
try {
PDF417 barcode = new PDF417();
// set barcode properties
barcode.setCodeText("PDF417");
// draw and generate barcode to response's ServletOutputStream
ServletOutputStream servletoutputstream = response.getOutputStream();
barcode.drawBarCode2Stream(servletoutputstream);
} catch (Exception e) {
throw new ServletException(e);
}
}
}
private static void demoLinearBarcode() throws Exception
{
PDF417 barcode = new PDF417();
// set barcode properties
barcode.setCodeText("PDF417");
// create image object
java.awt.image.BufferedImage image = new java.awt.image.BufferedImage(300,300,java.awt.image.BufferedImage.TYPE_BYTE_INDEXED );
// get graphic context of image
java.awt.Graphics2D imgGraphics = image.createGraphics();
// draw barcode to specified location in Rectangle
barcode.paintBarCode(imgGraphics, new java.awt.Rectangle(0, 0, 300, 300));
}
Class Properties | HTTP Parameters | Default | Comments |
---|---|---|---|
data | data | "" | Barcode value to encode |
uom | uom | PIXEL | Unit of meature for all size related settings. 0: pixel; 1: cm; 2: inch. Default is pixel |
X | x | 1 | Width of barcode module (narrow bar), default is 1 pixel |
barRatio | bar-ratio | 3 | bar height, bar width ratio |
leftMargin | left-margin | 0 | Barcode image left margin |
rightMargin | right-margin | 0 | Barcode image right margin |
topMargin | top-margin | 0 | Barcode image top margin |
bottomMargin | bottom-margin | 0 | Barcode image bottom margin |
resolution | resolution | 72 | Barcode image resolution in dpi |
rotate | rotate | 0 | Barcode rotate angle, valid values: 0, 90, 180, 270 |
processTilde | process-tilde | false | Set the processTilde property to true, if you want use the tilde character "~" to specify special characters in the input data. Default is false.
~NNN: is used to represent the ASCII character with the value of NNN. NNN is from 000 - 255. |
dataMode | data-mode | 1 (MODE_TEXT) | valid values: 0 (MODE_AUTO), 1 (MODE_TEXT), 2 (MODE_BYTE), 3(MODE_NUMERIC) |
ecl | ecl | 2 (ECL_2) | Error correction level, values are from 0 to 8, default is 2. |
rowCount | row-count | 3 | The number of rows for PDF417. The value range is from 3 to 90. The default is 3. |
columnCount | column-count | 5 | Number of columns. The value range is from 1 to 30. The default is 5. Increase this value, if your data size is large. |
truncated | truncated | false | truncated PDF417 may be used where space considerations are a primary concern and symbol damage is unlikely. |
isMacro | macro | false | Set isMacro property to true, then Macro PDF417 is enabled. |
macroSegmentIndex | macro-segment-index | 0 | the position of current symbol in the secuence (Start with 0). |
macroSegmentCount | macro-segment-count | 0 | the number of total symbols which make the sequence. |
macroFileIndex | macro-file-index | 0 | be identified to the same file |