List of usage examples for com.lowagie.text.pdf Barcode128 setGenerateChecksum
public void setGenerateChecksum(boolean generateChecksum)
From source file:com.isdemu.controller.TBS_UsuarioController.java
@RequestMapping(value = "/codigo_barra", method = RequestMethod.POST) @ResponseBody//www . ja v a 2s. co m public String codigo(@RequestBody String codigos) throws FileNotFoundException, DocumentException { JSONObject array = new JSONObject(codigos); Document document = new Document(); File file = new File(this.getClass().getResource("/codigoBarraIsdemu.pdf").getFile()); String absolutePath = file.getAbsolutePath(); absolutePath = absolutePath.replaceAll("%20", " "); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(absolutePath)); Rectangle one = new Rectangle(76, 35); document.setPageSize(one); document.setMargins(2, 2, 2, 2); document.open(); Barcode128 code128 = new Barcode128(); code128.setGenerateChecksum(true); JSONArray object = array.getJSONArray("Inventario"); for (int i = 0; i < object.length(); i++) { JSONObject object2 = object.getJSONObject(i); //JSONArray object = array.getJSONArray("Inventario"); String id = object2.getString("idInv"); code128.setCode(id); document.add(code128.createImageWithBarcode(writer.getDirectContent(), null, null)); document.newPage(); } document.close(); return "Almacenado"; }