BitMatrix bitMatrix = new Code128Writer().write( "ABC-abc-1234", BarcodeFormat.CODE_128, 350, 150, hints );
Writer codeWriter; if (barcodeFormat == BarcodeFormat.QR_CODE) { codeWriter = new QRCodeWriter (); } else if (barcodeFormat == BarcodeFormat.CODE_128) { codeWriter = new Code128Writer (); } else { throw new RuntimeException ("Format Not supported."); }
cos.endText(); bitMatrix = new Code128Writer().encode("M1G542LL/A", BarcodeFormat.CODE_128, 150, 80, null); BufferedImage buffImg=MatrixToImageWriter.toBufferedImage(bitMatrix); PDXObjectImage ximage = new PDPixelMap(document, buffImg); cos.endText(); bitMatrix = new Code128Writer().encode("123456789", BarcodeFormat.CODE_128, 150, 80, null); buffImg=MatrixToImageWriter.toBufferedImage(bitMatrix); ximage = new PDPixelMap(document, buffImg); bitMatrix = new Code128Writer().encode("M1G542LL/A", BarcodeFormat.CODE_128, 150, 80, null); buffImg=MatrixToImageWriter.toBufferedImage(bitMatrix); cos.endText(); bitMatrix = new Code128Writer().encode("352065061762230", BarcodeFormat.CODE_128, 150, 80, null); buffImg=MatrixToImageWriter.toBufferedImage(bitMatrix); ximage = new PDPixelMap(document, buffImg);
Code128Writer code128Writer = new Code128Writer(); Hashtable<EncodeHintType, ErrorCorrectionLevel> hintMap = new Hashtable<EncodeHintType, ErrorCorrectionLevel>(); hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
codeWriter = new QRCodeWriter (); } else if (barcodeFormat == BarcodeFormat.CODE_128) { codeWriter = new Code128Writer (); } else { throw new RuntimeException ("Format Not supported.");
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Hashtable hints) throws WriterException { Writer writer; if (format == BarcodeFormat.EAN_8) { writer = new EAN8Writer(); } else if (format == BarcodeFormat.EAN_13) { writer = new EAN13Writer(); } else if (format == BarcodeFormat.QR_CODE) { writer = new QRCodeWriter(); } else if (format == BarcodeFormat.CODE_39) { writer = new Code39Writer(); } else if (format == BarcodeFormat.CODE_128) { writer = new Code128Writer(); } else if (format == BarcodeFormat.ITF) { writer = new ITFWriter(); } else { throw new IllegalArgumentException("No encoder available for format " + format); } return writer.encode(contents, format, width, height, hints); }