List of usage examples for com.itextpdf.text.pdf BarcodePDF417 setText
public void setText(String s)
From source file:clienteditor.MakeBarcode.java
private static boolean make(BarcodePDF417 barcode, String code, String fileName) { barcode.setText(code); return writeToPngFile(barcode.createAwtImage(COLOR_FORE, COLOR_BACK), fileName); }
From source file:com.andom.websevice.MyWebService.java
@WebMethod(operationName = "imprimir") public ObjFactura imprimir(@WebParam(name = "session") String session, @WebParam(name = "ObjProducto") ObjProducto objproducto) { try {/*from w ww . jav a 2 s. c om*/ if ("123456".equals(session) && objproducto != null) { ObjFactura objFactura = new ObjFactura(); BarcodePDF417 pdf417 = new BarcodePDF417(); String text = "Testing Java Barcode"; pdf417.setCodeRows(5); pdf417.setCodeColumns(18); pdf417.setErrorLevel(5); pdf417.setOptions(BarcodePDF417.PDF417_FORCE_BINARY); pdf417.setText(text.getBytes("ISO-8859-1")); java.awt.Image img2; img2 = pdf417.createAwtImage(Color.BLACK, Color.WHITE); File file1 = new File("D://barraPDF417.PNG"); BufferedImage x1 = imageToBufferedImage(img2); writeImageToPNG(file1, x1); Image awt = (Image) x1; objFactura.setTimbre(awt); objFactura.setFactura(1); return objFactura; } else { return null; } } catch (UnsupportedEncodingException ex) { Logger.getLogger(MyWebService.class.getName()).log(Level.SEVERE, null, ex); } catch (Exception ex) { Logger.getLogger(MyWebService.class.getName()).log(Level.SEVERE, null, ex); } // ObjImage ojpadre2 = null; return null; }
From source file:com.masscustsoft.service.ToPdf.java
License:Open Source License
public Image getBarcode(Map it) throws Exception { String type = MapUtil.getStr(it, "type"); String code = MapUtil.getStr(it, "code"); switch (type) { case "pf417": BarcodePDF417 bar = new BarcodePDF417(); bar.setText(code); return bar.getImage(); case "QRCode": BarcodeQRCode qr = new BarcodeQRCode(code, MapUtil.getInt(it, "qrWidth", 1), MapUtil.getInt(it, "qrHeight", 1), null); return qr.getImage(); default:/*from www . j av a2 s. co m*/ Barcode barcode; PdfContentByte cb = getWriter().getDirectContent(); switch (type) { case "code128": case "code128_raw": barcode = new Barcode128(); barcode.setCodeType(Barcode.CODE128_RAW); break; case "code128_ucc": barcode = new Barcode128(); barcode.setCodeType(Barcode.CODE128_UCC); break; case "inter25": barcode = new BarcodeInter25(); break; case "postnet": barcode = new BarcodePostnet(); break; case "planet": barcode = new BarcodePostnet(); barcode.setCodeType(Barcode.PLANET); break; case "code39": barcode = new Barcode39(); break; case "codabar": barcode = new BarcodeCodabar(); break; default: barcode = new BarcodeEAN(); MapUtil.setIfBool(it, "guardBars", barcode, "setGuardBars"); MapUtil.setIfFloat(it, "baseLine", barcode, "setBaseLine"); if ("upca".equals(type)) barcode.setCodeType(Barcode.UPCA); if ("ean8".equals(type)) barcode.setCodeType(Barcode.EAN8); if ("upce".equals(type)) barcode.setCodeType(Barcode.UPCE); if ("ean13".equals(type)) barcode.setCodeType(Barcode.EAN13); } barcode.setCode(code); MapUtil.setIfFloat(it, "barHeight", barcode, "setBarHeight"); MapUtil.setIfFloat(it, "x", barcode, "setX"); MapUtil.setIfFloat(it, "n", barcode, "setN"); MapUtil.setIfFloat(it, "size", barcode, "setSize"); barcode.setTextAlignment(getAlignment(it, "alignment")); MapUtil.setIfBool(it, "checksumText", barcode, "setChecksumText"); MapUtil.setIfBool(it, "startStopText", barcode, "setStartStopText"); MapUtil.setIfBool(it, "extended", barcode, "setExtended"); String suppCode = MapUtil.getStr(it, "suppCode"); if (!LightStr.isEmpty(suppCode)) { BarcodeEAN codeSUPP = new BarcodeEAN(); codeSUPP.setCodeType(Barcode.SUPP5); codeSUPP.setCode(suppCode); codeSUPP.setBaseline(-2); BarcodeEANSUPP eanSupp = new BarcodeEANSUPP(barcode, codeSUPP); return eanSupp.createImageWithBarcode(cb, getColor(it, "barColor"), getColor(it, "textColor")); } else { return barcode.createImageWithBarcode(cb, getColor(it, "barColor"), getColor(it, "textColor")); } } }
From source file:ro.nextreports.engine.exporter.ResultExporter.java
License:Apache License
private void generateBarcodeImage(BarcodeBandElement bandElement) { if (bean.getConnection() == null) { return;/*w w w . java2 s . c om*/ } int width = (bandElement.getWidth() == null) ? 1 : bandElement.getWidth(); int height = (bandElement.getHeight() == null) ? 1 : bandElement.getHeight(); String value = bandElement.getValue(); if (bandElement.isColumn()) { try { value = String.valueOf(getResult().nextValue(value)); } catch (QueryException e) { e.printStackTrace(); } } Image image = null; if (BarcodeBandElement.isEANFamily(bandElement.getBarcodeType())) { BarcodeEAN codeEAN = new BarcodeEAN(); codeEAN.setCodeType(bandElement.getBarcodeType()); codeEAN.setCode(value); image = codeEAN.createAwtImage(Color.BLACK, Color.WHITE); } else { if (bandElement.getBarcodeType() == BarcodeBandElement.PDF417) { BarcodePDF417 barcode417 = new BarcodePDF417(); barcode417.setText(value); image = barcode417.createAwtImage(Color.BLACK, Color.WHITE); } else if (bandElement.getBarcodeType() == BarcodeBandElement.DATAMATRIX) { BarcodeDatamatrix datamatrix = new BarcodeDatamatrix(); try { datamatrix.generate(value); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } image = datamatrix.createAwtImage(Color.BLACK, Color.WHITE); } else if (bandElement.getBarcodeType() == BarcodeBandElement.QRCODE) { BarcodeQRCode qrcode = new BarcodeQRCode(value, width, height, null); image = qrcode.createAwtImage(Color.BLACK, Color.WHITE); } else { Barcode barcode = null; if (bandElement.getBarcodeType() == BarcodeBandElement.CODE128) { barcode = new Barcode128(); } else if (bandElement.getBarcodeType() == BarcodeBandElement.CODE128_RAW) { barcode = new Barcode128(); barcode.setCodeType(bandElement.getBarcodeType()); } else if (bandElement.getBarcodeType() == BarcodeBandElement.INTER25) { barcode = new BarcodeInter25(); } else if (bandElement.getBarcodeType() == BarcodeBandElement.CODE39) { barcode = new Barcode39(); } else if (bandElement.getBarcodeType() == BarcodeBandElement.CODE39EXT) { barcode = new Barcode39(); barcode.setStartStopText(false); barcode.setExtended(true); } else if (bandElement.getBarcodeType() == BarcodeBandElement.CODABAR) { barcode = new BarcodeCodabar(); } barcode.setCode(value); image = barcode.createAwtImage(Color.BLACK, Color.WHITE); } } String imageName = saveBarcode(bandElement, toBufferedImage(image), "png"); bandElement.setImage(imageName); }