List of usage examples for com.itextpdf.text.pdf PdfPCell PdfPCell
public PdfPCell()
PdfPCell
. From source file:com.maxl.java.amikodesk.SaveBasket.java
License:Open Source License
public PdfPTable getShoppingBasketForAuthor(Author a, PdfContentByte cb) { int position = 0; float subtotal_CHF = 0.0f; float shipping_CHF = 0.0f; float vat25_CHF = 0.0f; float vat80_CHF = 0.0f; String author = a.getShortName(); BarcodeEAN codeEAN = new BarcodeEAN(); // Pos | Menge | Eancode | Bezeichnung | MwSt | Preis PdfPTable table = new PdfPTable(new float[] { 1, 2, 3, 6, 1, 2 }); table.setWidthPercentage(100f);/*from w ww . j a va 2 s. c o m*/ table.getDefaultCell().setPadding(5); table.setSpacingAfter(5f); PdfPCell cell = new PdfPCell(); table.addCell(getStringCell(m_rb.getString("position"), font_bold_10, Rectangle.TOP | Rectangle.BOTTOM, Element.ALIGN_MIDDLE, 1)); table.addCell(getStringCell(m_rb.getString("quantity"), font_bold_10, Rectangle.TOP | Rectangle.BOTTOM, Element.ALIGN_MIDDLE, 1)); table.addCell(getStringCell(m_rb.getString("ean"), font_bold_10, Rectangle.TOP | Rectangle.BOTTOM, Element.ALIGN_MIDDLE, 1)); table.addCell(getStringCell(m_rb.getString("article"), font_bold_10, Rectangle.TOP | Rectangle.BOTTOM, Element.ALIGN_MIDDLE, 1)); table.addCell(getStringCell(m_rb.getString("vat"), font_bold_10, Rectangle.TOP | Rectangle.BOTTOM, Element.ALIGN_RIGHT, 1)); table.addCell(getStringCell(m_rb.getString("price") + " (CHF)", font_bold_10, Rectangle.TOP | Rectangle.BOTTOM, Element.ALIGN_RIGHT, 1)); if (m_shopping_basket.size() > 0 && !author.isEmpty()) { for (Map.Entry<String, Article> entry : m_shopping_basket.entrySet()) { Article article = entry.getValue(); if (article.getAuthor().trim().toLowerCase().contains(author)) { String price_pruned = ""; String total_price_CHF = ""; if (article.getCode() != null && article.getCode().equals("ibsa")) { float cr = article.getCashRebate(); if (article.getDraufgabe() > 0) { price_pruned = String.format("%.2f", article.getBuyingPrice(0.0f)); total_price_CHF = String.format("%.2f", article.getTotBuyingPrice(0.0f)); } else { price_pruned = String.format("%.2f", article.getBuyingPrice(cr)); total_price_CHF = String.format("%.2f", article.getTotBuyingPrice(cr)); } } else { price_pruned = article.getCleanExfactoryPrice(); total_price_CHF = String.format("%.2f", article.getTotExfactoryPrice()); } if (!price_pruned.isEmpty() && !price_pruned.equals("..")) { // Index table.addCell(getStringCell(Integer.toString(++position), font_norm_10, PdfPCell.NO_BORDER, Element.ALIGN_MIDDLE, 1)); // Anzahl table.addCell(getStringCell(Integer.toString(article.getQuantity()), font_norm_10, PdfPCell.NO_BORDER, Element.ALIGN_MIDDLE, 1)); // EAN code codeEAN.setCode(article.getEanCode()); Image img = codeEAN.createImageWithBarcode(cb, null, null); img.scalePercent(120); cell = new PdfPCell(img); cell.setBorder(Rectangle.NO_BORDER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setUseBorderPadding(true); cell.setBorderWidth(5); if (position == 1) cell.setPaddingTop(8); else cell.setPaddingTop(0); cell.setPaddingBottom(8); table.addCell(cell); // Artikelbezeichnung table.addCell(getStringCell(article.getPackTitle(), font_norm_10, PdfPCell.NO_BORDER, Element.ALIGN_MIDDLE, 1)); // MwSt table.addCell(getStringCell(String.format("%.1f%%", article.getVat()), font_norm_10, PdfPCell.NO_BORDER, Element.ALIGN_RIGHT, 1)); // Preis (exkl. MwSt) // float price_CHF = article.getQuantity()*Float.parseFloat(price_pruned); table.addCell(getStringCell(total_price_CHF, font_norm_10, PdfPCell.NO_BORDER, Element.ALIGN_RIGHT, 1)); } } } subtotal_CHF = a.getSubtotal(); shipping_CHF = a.getShippingCosts(); vat25_CHF = a.getVat25(); vat80_CHF = a.getVat80() + a.getShippingCosts() * 0.08f; float fulltotal_CHF = subtotal_CHF + shipping_CHF + vat25_CHF + vat80_CHF; table.addCell(getStringCell(m_rb.getString("subtotal"), font_bold_10, Rectangle.TOP, Element.ALIGN_MIDDLE, 2)); table.addCell(getStringCell("", font_bold_10, Rectangle.TOP, Element.ALIGN_MIDDLE, 2)); table.addCell(getStringCell(String.format("%.2f", subtotal_CHF), font_bold_10, Rectangle.TOP, Element.ALIGN_RIGHT, 2)); table.addCell(getStringCell(m_rb.getString("shipping"), font_norm_10, PdfPCell.NO_BORDER, Element.ALIGN_MIDDLE, 2)); table.addCell(getStringCell("", font_norm_10, PdfPCell.NO_BORDER, Element.ALIGN_MIDDLE, 2)); table.addCell(getStringCell(String.format("%.2f", shipping_CHF), font_norm_10, PdfPCell.NO_BORDER, Element.ALIGN_RIGHT, 2)); table.addCell(getStringCell(m_rb.getString("vat") + " (2.5%)", font_norm_10, PdfPCell.NO_BORDER, Element.ALIGN_MIDDLE, 2)); table.addCell(getStringCell("", font_norm_10, PdfPCell.NO_BORDER, Element.ALIGN_MIDDLE, 2)); table.addCell(getStringCell(String.format("%.2f", vat25_CHF), font_norm_10, PdfPCell.NO_BORDER, Element.ALIGN_RIGHT, 2)); table.addCell(getStringCell(m_rb.getString("vat") + " (8.0%)", font_norm_10, PdfPCell.NO_BORDER, Element.ALIGN_MIDDLE, 2)); table.addCell(getStringCell("", font_norm_10, PdfPCell.NO_BORDER, Element.ALIGN_MIDDLE, 2)); table.addCell(getStringCell(String.format("%.2f", vat80_CHF), font_norm_10, PdfPCell.NO_BORDER, Element.ALIGN_RIGHT, 2)); table.addCell(getStringCell(m_rb.getString("gesamttotal"), font_bold_10, PdfPCell.NO_BORDER, Element.ALIGN_MIDDLE, 2)); table.addCell(getStringCell("", font_bold_10, PdfPCell.NO_BORDER, Element.ALIGN_MIDDLE, 2)); table.addCell(getStringCell(String.format("%.2f", fulltotal_CHF), font_bold_10, PdfPCell.NO_BORDER, Element.ALIGN_RIGHT, 2)); } return table; }
From source file:com.maxl.java.amikodesk.SaveBasket.java
License:Open Source License
public PdfPTable getFullShoppingBasket(PdfContentByte cb, String mode) { int position = 0; float sub_total_CHF = 0.0f; BarcodeEAN codeEAN = new BarcodeEAN(); // Pos | Menge | Eancode | Bezeichnung | Preis PdfPTable table = new PdfPTable(new float[] { 1, 1, 3, 6, 2 }); table.setWidthPercentage(100f);/*from www .java 2 s . co m*/ table.getDefaultCell().setPadding(5); table.setSpacingAfter(5f); PdfPCell cell = new PdfPCell(); table.addCell(getStringCell(m_rb.getString("position"), font_bold_10, Rectangle.TOP | Rectangle.BOTTOM, Element.ALIGN_MIDDLE, 1)); table.addCell(getStringCell(m_rb.getString("quantity"), font_bold_10, Rectangle.TOP | Rectangle.BOTTOM, Element.ALIGN_MIDDLE, 1)); table.addCell(getStringCell(m_rb.getString("ean"), font_bold_10, Rectangle.TOP | Rectangle.BOTTOM, Element.ALIGN_MIDDLE, 1)); table.addCell(getStringCell(m_rb.getString("article"), font_bold_10, Rectangle.TOP | Rectangle.BOTTOM, Element.ALIGN_MIDDLE, 1)); table.addCell(getStringCell(m_rb.getString("price") + " (CHF)", font_bold_10, Rectangle.TOP | Rectangle.BOTTOM, Element.ALIGN_RIGHT, 1)); if (m_shopping_basket.size() > 0) { for (Map.Entry<String, Article> entry : m_shopping_basket.entrySet()) { Article article = entry.getValue(); if (mode.equals("all") || (mode.equals("rest") && (m_map_of_authors == null || !anyElemIsContained(m_map_of_authors, article.getAuthor().trim().toLowerCase())))) { String price_pruned = ""; if (article.getCode() != null && article.getCode().equals("ibsa")) { float cr = article.getCashRebate(); if (article.getDraufgabe() > 0) price_pruned = String.format("%.2f", article.getBuyingPrice(0.0f)); else price_pruned = String.format("%.2f", article.getBuyingPrice(cr)); } else { price_pruned = article.getCleanExfactoryPrice(); } if (!price_pruned.isEmpty() && !price_pruned.equals("..")) { table.addCell(getStringCell(Integer.toString(++position), font_norm_10, PdfPCell.NO_BORDER, Element.ALIGN_MIDDLE, 1)); table.addCell(getStringCell(Integer.toString(article.getQuantity()), font_norm_10, PdfPCell.NO_BORDER, Element.ALIGN_MIDDLE, 1)); codeEAN.setCode(article.getEanCode()); Image img = codeEAN.createImageWithBarcode(cb, null, null); img.scalePercent(120); cell = new PdfPCell(img); cell.setBorder(Rectangle.NO_BORDER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setUseBorderPadding(true); cell.setBorderWidth(5); if (position == 1) cell.setPaddingTop(8); else cell.setPaddingTop(0); cell.setPaddingBottom(8); table.addCell(cell); table.addCell(getStringCell(article.getPackTitle(), font_norm_10, PdfPCell.NO_BORDER, Element.ALIGN_MIDDLE, 1)); float price_CHF = article.getQuantity() * Float.parseFloat(price_pruned); sub_total_CHF += price_CHF; table.addCell(getStringCell(String.format("%.2f", price_CHF), font_norm_10, PdfPCell.NO_BORDER, Element.ALIGN_RIGHT, 1)); } } } table.addCell(getStringCell(m_rb.getString("subtotal"), font_bold_10, Rectangle.TOP, Element.ALIGN_MIDDLE, 2)); table.addCell(getStringCell("", font_bold_10, Rectangle.TOP, Element.ALIGN_MIDDLE, 2)); table.addCell(getStringCell(String.format("%.2f", sub_total_CHF), font_bold_10, Rectangle.TOP, Element.ALIGN_RIGHT, 2)); table.addCell(getStringCell(m_rb.getString("vat") + " (2.5%)", font_norm_10, PdfPCell.NO_BORDER, Element.ALIGN_MIDDLE, 2)); table.addCell(getStringCell("", font_norm_10, PdfPCell.NO_BORDER, Element.ALIGN_MIDDLE, 2)); table.addCell(getStringCell(String.format("%.2f", sub_total_CHF * 0.025f), font_norm_10, PdfPCell.NO_BORDER, Element.ALIGN_RIGHT, 2)); table.addCell(getStringCell(m_rb.getString("gesamttotal"), font_bold_10, PdfPCell.NO_BORDER, Element.ALIGN_MIDDLE, 2)); table.addCell(getStringCell("", font_bold_10, PdfPCell.NO_BORDER, Element.ALIGN_MIDDLE, 2)); table.addCell(getStringCell(String.format("%.2f", sub_total_CHF * 1.025f), font_bold_10, PdfPCell.NO_BORDER, Element.ALIGN_RIGHT, 2)); } return table; }
From source file:com.mim.controllers.HomeCtrl.java
private void ordenReport(Document document, Lugar lugar) throws BadElementException, DocumentException, IOException { document.addTitle(current.getNumeroOrden()); // step 3/* ww w. ja va 2 s . c o m*/ // step 4 PdfPTable table = new PdfPTable(8); //LEFT HEADER CONTENT PdfPTable leftHeaderTable = new PdfPTable(4); PdfPCell imgCell = new PdfPCell(); imgCell.setBorder(Rectangle.NO_BORDER); imgCell.setPaddingTop(14); imgCell.setColspan(1); imgCell.setFixedHeight(25); //Image img = Image.getInstance("/opt/shared/home/logo.png"); Image img = Image.getInstance("http://mimconstructions.com/img/mim%20trendy.png"); imgCell.addElement(img); PdfPCell reportTitleCell = new PdfPCell(new Paragraph("REPORTE MANTENIMIENTO")); reportTitleCell.setPaddingTop(14); reportTitleCell.setPaddingLeft(20); reportTitleCell.setColspan(3); reportTitleCell.setBorder(Rectangle.NO_BORDER); leftHeaderTable.addCell(imgCell); leftHeaderTable.addCell(reportTitleCell); PdfPCell leftHeaderMainCell = new PdfPCell(leftHeaderTable); leftHeaderMainCell.setColspan(4); //END CONTENT //RIGHT HEADER WITH INFO ABOUT ORDER AND DATE PdfPTable infHeader = new PdfPTable(3); PdfPCell numberOrderLabel = new PdfPCell(new Paragraph("#ORDEN")); numberOrderLabel.setHorizontalAlignment(Element.ALIGN_CENTER); numberOrderLabel.setColspan(1); String numeroOrden = null; if (current.getNumeroOrden() != null) { numeroOrden = current.getNumeroOrden(); } else { numeroOrden = current.getActividad(); } PdfPCell numberOrderValue = new PdfPCell(new Paragraph(numeroOrden)); numberOrderValue.setHorizontalAlignment(Element.ALIGN_CENTER); numberOrderValue.setColspan(2); PdfPCell prioridadLabel = new PdfPCell(new Paragraph("PRIORIDAD")); prioridadLabel.setHorizontalAlignment(Element.ALIGN_CENTER); prioridadLabel.setColspan(1); PdfPCell prioridadValue = new PdfPCell(new Paragraph(current.getPrioridad())); prioridadValue.setHorizontalAlignment(Element.ALIGN_CENTER); prioridadValue.setColspan(2); PdfPCell fechaLabel = new PdfPCell(new Paragraph("FECHA")); fechaLabel.setHorizontalAlignment(Element.ALIGN_CENTER); fechaLabel.setColspan(1); //dd-MM-yyyy SimpleDateFormat format1 = new SimpleDateFormat("dd-MM-yyyy"); Date startDate = current.getStartDate(); if (startDate == null) { startDate = new Date(); } String fecha = format1.format(startDate); PdfPCell fechaValue = new PdfPCell(new Paragraph(fecha)); fechaValue.setHorizontalAlignment(Element.ALIGN_CENTER); fechaValue.setColspan(2); infHeader.addCell(numberOrderLabel); infHeader.addCell(numberOrderValue); infHeader.addCell(prioridadLabel); infHeader.addCell(prioridadValue); infHeader.addCell(fechaLabel); infHeader.addCell(fechaValue); PdfPCell cellHeaderRight = new PdfPCell(infHeader); cellHeaderRight.setColspan(4); //END HEADER PdfPCell areaLabel = new PdfPCell(new Paragraph("AREA")); areaLabel.setHorizontalAlignment(Element.ALIGN_CENTER); areaLabel.setVerticalAlignment(Element.ALIGN_CENTER); areaLabel.setFixedHeight(30); areaLabel.setPaddingTop(5); areaLabel.setColspan(2); PdfPCell actividadLabel = new PdfPCell(new Paragraph("ACTIVIDAD")); actividadLabel.setHorizontalAlignment(Element.ALIGN_CENTER); actividadLabel.setFixedHeight(30); actividadLabel.setVerticalAlignment(Element.ALIGN_CENTER); actividadLabel.setPaddingTop(5); actividadLabel.setColspan(3); PdfPCell responsableLabel = new PdfPCell(new Paragraph("RESPONSABLE DE OPERACION")); responsableLabel.setHorizontalAlignment(Element.ALIGN_CENTER); responsableLabel.setFixedHeight(30); responsableLabel.setVerticalAlignment(Element.ALIGN_CENTER); responsableLabel.setPaddingTop(5); responsableLabel.setColspan(3); String area; if (lugar.getNombre().contains("linea")) { area = "envasado"; } else if (lugar.getNombre().contains("otro")) { area = "Tecate 500"; } else if (lugar.getNombre().contains("PD")) { area = "concretos"; } else if (lugar.getNombre().contains("planta agua")) { area = "cerveceria"; } else { area = "elaboracion"; } PdfPCell areaValor = new PdfPCell(new Paragraph(area)); areaValor.setFixedHeight(25); areaValor.setHorizontalAlignment(Element.ALIGN_CENTER); areaValor.setColspan(2); PdfPCell actividadValor = new PdfPCell(new Paragraph(current.getActividad())); actividadValor.setHorizontalAlignment(Element.ALIGN_CENTER); actividadValor.setFixedHeight(25); actividadValor.setColspan(3); PdfPCell responsableValor = new PdfPCell(new Paragraph(current.getEncargado())); responsableValor.setHorizontalAlignment(Element.ALIGN_CENTER); responsableValor.setFixedHeight(25); responsableValor.setColspan(3); // 2 FILAS PARA INF. EQUIPO Y LUGAR PdfPCell equipoLabel = new PdfPCell(new Paragraph("EQUIPO/CONJUNTO")); equipoLabel.setHorizontalAlignment(Element.ALIGN_CENTER); equipoLabel.setVerticalAlignment(Element.ALIGN_CENTER); equipoLabel.setFixedHeight(30); equipoLabel.setPaddingTop(5); equipoLabel.setColspan(4); PdfPCell lugarLabel = new PdfPCell(new Paragraph("LUGAR")); lugarLabel.setHorizontalAlignment(Element.ALIGN_CENTER); lugarLabel.setFixedHeight(30); lugarLabel.setVerticalAlignment(Element.ALIGN_CENTER); lugarLabel.setPaddingTop(5); lugarLabel.setColspan(4); String numeroEquipo = null; if (equipo.getNumeroEquipo() != null) { numeroEquipo = equipo.getNumeroEquipo(); } else { numeroEquipo = "n/a"; } PdfPCell equipoValor = new PdfPCell(new Paragraph(numeroEquipo)); equipoValor.setHorizontalAlignment(Element.ALIGN_CENTER); equipoValor.setFixedHeight(25); equipoValor.setColspan(4); PdfPCell lugarValor = new PdfPCell(new Paragraph(lugar.getNombre())); lugarValor.setHorizontalAlignment(Element.ALIGN_CENTER); lugarValor.setFixedHeight(25); lugarValor.setColspan(4); //END INFO EQUIPO // 4 ROW and 5 ROW PdfPCell descripcionLabel = new PdfPCell(new Paragraph("DESCRIPCION")); descripcionLabel.setPadding(12); descripcionLabel.setHorizontalAlignment(Element.ALIGN_CENTER); descripcionLabel.setColspan(8); PdfPCell descripcionValor = new PdfPCell(new Paragraph(current.getDescripcion())); descripcionValor.setPadding(10); descripcionValor.setColspan(8); //END ROWS //ROW BEFORE HISTORIAL_DETALLES PdfPCell historialLabel = new PdfPCell(new Paragraph("OBSERVACIONES")); historialLabel.setPadding(12); historialLabel.setHorizontalAlignment(Element.ALIGN_CENTER); historialLabel.setColspan(8); //END HISTORIAL table.addCell(leftHeaderMainCell); table.addCell(cellHeaderRight); table.addCell(areaLabel); table.addCell(actividadLabel); table.addCell(responsableLabel); table.addCell(areaValor); table.addCell(actividadValor); table.addCell(responsableValor); table.addCell(equipoLabel); table.addCell(lugarLabel); table.addCell(equipoValor); table.addCell(lugarValor); table.addCell(descripcionLabel); table.addCell(descripcionValor); List<HistorialDetalles> observaciones = hisFacade.findAllByOrder(current.getIdorden()); if (observaciones != null) { if (observaciones.size() > 0) { table.addCell(historialLabel); //LOOP HISTORIAL_DETALLES for (int i = 0; i < observaciones.size(); i++) { HistorialDetalles historial = observaciones.get(i); PdfPCell paramCell = new PdfPCell(); paramCell.setColspan(3); paramCell.addElement(new Paragraph(historial.getParametro())); paramCell.setVerticalAlignment(Element.ALIGN_CENTER); paramCell.setPaddingLeft(10); paramCell.setPaddingBottom(10); PdfPCell valueParamCell = new PdfPCell(); valueParamCell.setColspan(5); valueParamCell.setPaddingLeft(10); valueParamCell.setVerticalAlignment(Element.ALIGN_CENTER); valueParamCell.addElement(new Paragraph(historial.getValor())); valueParamCell.setPaddingBottom(10); if (historial.getValor() != null) { if (historial.getValor().length() > 0) { table.addCell(paramCell); table.addCell(valueParamCell); } } } } } //END LOOP HISTORIAL // FIRST ROWS OF FOTOGRAPHIC REPORT PdfPCell pasoLabel = new PdfPCell(new Paragraph("PASO")); pasoLabel.setFixedHeight(20); pasoLabel.setHorizontalAlignment(Element.ALIGN_CENTER); pasoLabel.setColspan(1); PdfPCell accionLabel = new PdfPCell(new Paragraph("ACCION")); accionLabel.setFixedHeight(20); accionLabel.setHorizontalAlignment(Element.ALIGN_CENTER); accionLabel.setColspan(3); PdfPCell imagenLabel = new PdfPCell(new Paragraph("IMAGENES")); imagenLabel.setFixedHeight(20); imagenLabel.setHorizontalAlignment(Element.ALIGN_CENTER); imagenLabel.setColspan(4); //END ROWS PdfPTable table2 = new PdfPTable(8); //ROW BEFORE HISTORIAL_DETALLES PdfPCell headerPictures = new PdfPCell(new Paragraph("PROCEDIMIENTO")); headerPictures.setPadding(12); headerPictures.setHorizontalAlignment(Element.ALIGN_CENTER); headerPictures.setColspan(8); table2.addCell(headerPictures); //END HISTORIAL table2.addCell(pasoLabel); table2.addCell(accionLabel); table2.addCell(imagenLabel); //fotos loop List<Fotos> fotos = fotoFacade.findAllByOrder(current.getIdorden()); for (int i = 0; i < fotos.size(); i++) { Fotos foto = fotos.get(i); PdfPCell pasoVal = new PdfPCell(new Paragraph(String.valueOf(i))); pasoVal.setHorizontalAlignment(Element.ALIGN_CENTER); pasoVal.setColspan(1); PdfPCell detail = new PdfPCell(new Paragraph(foto.getTitulo())); detail.setPadding(5); detail.setBorder(Rectangle.NO_BORDER); PdfPCell accionVal = new PdfPCell(); accionVal.addElement(new Paragraph(foto.getDescripcion())); accionVal.setHorizontalAlignment(Element.ALIGN_CENTER); accionVal.setBorder(Rectangle.NO_BORDER); //accionVal.setColspan(3); PdfPTable infoTable = new PdfPTable(1); infoTable.addCell(detail); infoTable.addCell(accionVal); PdfPCell infiCell = new PdfPCell(); infiCell.setColspan(3); infiCell.addElement(infoTable); //Table collumn //System.getenv("OPENSHIFT_DATA_DIR") + "imagenes/" + name) //Image imgFoto = Image.getInstance("http://mantenimiento-contactres.rhcloud.com/MantenimientoRest/webresources/com.mim.entities.fotos/api/" + foto.getIdfotos()); String archivo = foto.getArchivo(); String[] split = archivo.split("/"); int size = split.length; final String name = split[size - 1]; System.out.println("Valor " + name); Image imgFoto = Image.getInstance("/opt/shared/home/" + "imagenes/" + name); PdfPTable imagenTable = new PdfPTable(1); PdfPCell fotoCell = new PdfPCell(); fotoCell.setColspan(1); fotoCell.addElement(imgFoto); fotoCell.setFixedHeight(310); fotoCell.setHorizontalAlignment(Element.ALIGN_CENTER); fotoCell.setBorder(Rectangle.NO_BORDER); imagenTable.addCell(fotoCell); PdfPCell imagenVal = new PdfPCell(); imagenVal.setColspan(4); imagenVal.addElement(imagenTable); table2.addCell(pasoVal); table2.addCell(infiCell); table2.addCell(imagenVal); } //end loop //table.addCell(tiempoLabel); document.add(table); document.newPage(); document.add(table2); }
From source file:com.mim.controllers.OrdenCtrl.java
private void ordenReport(Document document, Lugar lugar) throws BadElementException, DocumentException, IOException { document.addTitle(current.getNumeroOrden()); // step 3/*from w w w .j ava 2 s . c o m*/ // step 4 PdfPTable table = new PdfPTable(8); //LEFT HEADER CONTENT PdfPTable leftHeaderTable = new PdfPTable(4); PdfPCell imgCell = new PdfPCell(); imgCell.setBorder(Rectangle.NO_BORDER); imgCell.setPaddingTop(14); imgCell.setColspan(1); imgCell.setFixedHeight(25); //Image img = Image.getInstance("/opt/shared/home/logo.png"); Image img = Image.getInstance("http://mimconstructions.com/img/mim%20trendy.png"); imgCell.addElement(img); PdfPCell reportTitleCell = new PdfPCell(new Paragraph("REPORTE MANTENIMIENTO")); reportTitleCell.setPaddingTop(14); reportTitleCell.setPaddingLeft(20); reportTitleCell.setColspan(3); reportTitleCell.setBorder(Rectangle.NO_BORDER); leftHeaderTable.addCell(imgCell); leftHeaderTable.addCell(reportTitleCell); PdfPCell leftHeaderMainCell = new PdfPCell(leftHeaderTable); leftHeaderMainCell.setColspan(4); //END CONTENT //RIGHT HEADER WITH INFO ABOUT ORDER AND DATE PdfPTable infHeader = new PdfPTable(3); PdfPCell numberOrderLabel = new PdfPCell(new Paragraph("#ORDEN")); numberOrderLabel.setHorizontalAlignment(Element.ALIGN_CENTER); numberOrderLabel.setColspan(1); String numeroOrden = null; if (current.getNumeroOrden() != null) { numeroOrden = current.getNumeroOrden(); } else { numeroOrden = current.getActividad(); } PdfPCell numberOrderValue = new PdfPCell(new Paragraph(numeroOrden)); numberOrderValue.setHorizontalAlignment(Element.ALIGN_CENTER); numberOrderValue.setColspan(2); PdfPCell prioridadLabel = new PdfPCell(new Paragraph("PRIORIDAD")); prioridadLabel.setHorizontalAlignment(Element.ALIGN_CENTER); prioridadLabel.setColspan(1); PdfPCell prioridadValue = new PdfPCell(new Paragraph(current.getPrioridad())); prioridadValue.setHorizontalAlignment(Element.ALIGN_CENTER); prioridadValue.setColspan(2); PdfPCell fechaLabel = new PdfPCell(new Paragraph("FECHA")); fechaLabel.setHorizontalAlignment(Element.ALIGN_CENTER); fechaLabel.setColspan(1); //dd-MM-yyyy SimpleDateFormat format1 = new SimpleDateFormat("dd-MM-yyyy"); Date startDate = current.getStartDate(); if (startDate == null) { startDate = new Date(); } String fecha = format1.format(startDate); PdfPCell fechaValue = new PdfPCell(new Paragraph(fecha)); fechaValue.setHorizontalAlignment(Element.ALIGN_CENTER); fechaValue.setColspan(2); infHeader.addCell(numberOrderLabel); infHeader.addCell(numberOrderValue); infHeader.addCell(prioridadLabel); infHeader.addCell(prioridadValue); infHeader.addCell(fechaLabel); infHeader.addCell(fechaValue); PdfPCell cellHeaderRight = new PdfPCell(infHeader); cellHeaderRight.setColspan(4); //END HEADER PdfPCell areaLabel = new PdfPCell(new Paragraph("AREA")); areaLabel.setHorizontalAlignment(Element.ALIGN_CENTER); areaLabel.setVerticalAlignment(Element.ALIGN_CENTER); areaLabel.setFixedHeight(30); areaLabel.setPaddingTop(5); areaLabel.setColspan(2); PdfPCell actividadLabel = new PdfPCell(new Paragraph("ACTIVIDAD")); actividadLabel.setHorizontalAlignment(Element.ALIGN_CENTER); actividadLabel.setFixedHeight(30); actividadLabel.setVerticalAlignment(Element.ALIGN_CENTER); actividadLabel.setPaddingTop(5); actividadLabel.setColspan(3); PdfPCell responsableLabel = new PdfPCell(new Paragraph("RESPONSABLE DE OPERACION")); responsableLabel.setHorizontalAlignment(Element.ALIGN_CENTER); responsableLabel.setFixedHeight(30); responsableLabel.setVerticalAlignment(Element.ALIGN_CENTER); responsableLabel.setPaddingTop(5); responsableLabel.setColspan(3); PdfPCell areaValor = new PdfPCell(new Paragraph("concretera")); areaValor.setFixedHeight(25); areaValor.setHorizontalAlignment(Element.ALIGN_CENTER); areaValor.setColspan(2); PdfPCell actividadValor = new PdfPCell(new Paragraph(current.getActividad())); actividadValor.setHorizontalAlignment(Element.ALIGN_CENTER); actividadValor.setFixedHeight(25); actividadValor.setColspan(3); PdfPCell responsableValor = new PdfPCell(new Paragraph(current.getEncargado())); responsableValor.setHorizontalAlignment(Element.ALIGN_CENTER); responsableValor.setFixedHeight(25); responsableValor.setColspan(3); // 2 FILAS PARA INF. EQUIPO Y LUGAR PdfPCell equipoLabel = new PdfPCell(new Paragraph("EQUIPO/CONJUNTO")); equipoLabel.setHorizontalAlignment(Element.ALIGN_CENTER); equipoLabel.setVerticalAlignment(Element.ALIGN_CENTER); equipoLabel.setFixedHeight(30); equipoLabel.setPaddingTop(5); equipoLabel.setColspan(4); PdfPCell lugarLabel = new PdfPCell(new Paragraph("LUGAR")); lugarLabel.setHorizontalAlignment(Element.ALIGN_CENTER); lugarLabel.setFixedHeight(30); lugarLabel.setVerticalAlignment(Element.ALIGN_CENTER); lugarLabel.setPaddingTop(5); lugarLabel.setColspan(4); String numeroEquipo = null; if (equipo.getNumeroEquipo() != null) { numeroEquipo = equipo.getNumeroEquipo(); } else { numeroEquipo = "n/a"; } PdfPCell equipoValor = new PdfPCell(new Paragraph(numeroEquipo)); equipoValor.setHorizontalAlignment(Element.ALIGN_CENTER); equipoValor.setFixedHeight(25); equipoValor.setColspan(4); PdfPCell lugarValor = new PdfPCell(new Paragraph(lugar.getNombre())); lugarValor.setHorizontalAlignment(Element.ALIGN_CENTER); lugarValor.setFixedHeight(25); lugarValor.setColspan(4); //END INFO EQUIPO // 4 ROW and 5 ROW PdfPCell descripcionLabel = new PdfPCell(new Paragraph("DESCRIPCION")); descripcionLabel.setPadding(12); descripcionLabel.setHorizontalAlignment(Element.ALIGN_CENTER); descripcionLabel.setColspan(8); PdfPCell descripcionValor = new PdfPCell(new Paragraph(current.getDescripcion())); descripcionValor.setPadding(10); descripcionValor.setColspan(8); //END ROWS //ROW BEFORE HISTORIAL_DETALLES PdfPCell historialLabel = new PdfPCell(new Paragraph("OBSERVACIONES")); historialLabel.setPadding(12); historialLabel.setHorizontalAlignment(Element.ALIGN_CENTER); historialLabel.setColspan(8); //END HISTORIAL table.addCell(leftHeaderMainCell); table.addCell(cellHeaderRight); table.addCell(areaLabel); table.addCell(actividadLabel); table.addCell(responsableLabel); table.addCell(areaValor); table.addCell(actividadValor); table.addCell(responsableValor); table.addCell(equipoLabel); table.addCell(lugarLabel); table.addCell(equipoValor); table.addCell(lugarValor); table.addCell(descripcionLabel); table.addCell(descripcionValor); List<HistorialDetalles> observaciones = hisFacade.findAllByOrder(current.getIdorden()); if (observaciones != null) { if (observaciones.size() > 0) { table.addCell(historialLabel); //LOOP HISTORIAL_DETALLES for (int i = 0; i < observaciones.size(); i++) { HistorialDetalles historial = observaciones.get(i); PdfPCell paramCell = new PdfPCell(); paramCell.setColspan(3); paramCell.addElement(new Paragraph(historial.getParametro())); paramCell.setVerticalAlignment(Element.ALIGN_CENTER); paramCell.setPaddingLeft(10); paramCell.setPaddingBottom(10); PdfPCell valueParamCell = new PdfPCell(); valueParamCell.setColspan(5); valueParamCell.setPaddingLeft(10); valueParamCell.setVerticalAlignment(Element.ALIGN_CENTER); valueParamCell.addElement(new Paragraph(historial.getValor())); valueParamCell.setPaddingBottom(10); table.addCell(paramCell); table.addCell(valueParamCell); } } } //END LOOP HISTORIAL // FIRST ROWS OF FOTOGRAPHIC REPORT PdfPCell pasoLabel = new PdfPCell(new Paragraph("PASO")); pasoLabel.setFixedHeight(20); pasoLabel.setHorizontalAlignment(Element.ALIGN_CENTER); pasoLabel.setColspan(1); PdfPCell accionLabel = new PdfPCell(new Paragraph("ACCION")); accionLabel.setFixedHeight(20); accionLabel.setHorizontalAlignment(Element.ALIGN_CENTER); accionLabel.setColspan(3); PdfPCell imagenLabel = new PdfPCell(new Paragraph("IMAGENES")); imagenLabel.setFixedHeight(20); imagenLabel.setHorizontalAlignment(Element.ALIGN_CENTER); imagenLabel.setColspan(4); //END ROWS PdfPTable table2 = new PdfPTable(8); //ROW BEFORE HISTORIAL_DETALLES PdfPCell headerPictures = new PdfPCell(new Paragraph("PROCEDIMIENTO")); headerPictures.setPadding(12); headerPictures.setHorizontalAlignment(Element.ALIGN_CENTER); headerPictures.setColspan(8); table2.addCell(headerPictures); //END HISTORIAL table2.addCell(pasoLabel); table2.addCell(accionLabel); table2.addCell(imagenLabel); //fotos loop List<Fotos> fotos = fotoFacade.findAllByOrder(current.getIdorden()); for (int i = 0; i < fotos.size(); i++) { Fotos foto = fotos.get(i); PdfPCell pasoVal = new PdfPCell(new Paragraph(String.valueOf(i))); pasoVal.setHorizontalAlignment(Element.ALIGN_CENTER); pasoVal.setColspan(1); PdfPCell detail = new PdfPCell(new Paragraph(foto.getTitulo())); detail.setPadding(5); detail.setBorder(Rectangle.NO_BORDER); PdfPCell accionVal = new PdfPCell(); accionVal.addElement(new Paragraph(foto.getDescripcion())); accionVal.setHorizontalAlignment(Element.ALIGN_CENTER); accionVal.setBorder(Rectangle.NO_BORDER); //accionVal.setColspan(3); PdfPTable infoTable = new PdfPTable(1); infoTable.addCell(detail); infoTable.addCell(accionVal); PdfPCell infiCell = new PdfPCell(); infiCell.setColspan(3); infiCell.addElement(infoTable); //Table collumn //System.getenv("OPENSHIFT_DATA_DIR") + "imagenes/" + name) //Image imgFoto = Image.getInstance("http://mantenimiento-contactres.rhcloud.com/MantenimientoRest/webresources/com.mim.entities.fotos/api/" + foto.getIdfotos()); String archivo = foto.getArchivo(); String[] split = archivo.split("/"); int size = split.length; final String name = split[size - 1]; System.out.println("Valor " + name); Image imgFoto = Image.getInstance("/opt/shared/home/" + "imagenes/" + name); PdfPTable imagenTable = new PdfPTable(1); PdfPCell fotoCell = new PdfPCell(); fotoCell.setColspan(1); fotoCell.addElement(imgFoto); fotoCell.setFixedHeight(310); fotoCell.setHorizontalAlignment(Element.ALIGN_CENTER); fotoCell.setBorder(Rectangle.NO_BORDER); imagenTable.addCell(fotoCell); PdfPCell imagenVal = new PdfPCell(); imagenVal.setColspan(4); imagenVal.addElement(imagenTable); table2.addCell(pasoVal); table2.addCell(infiCell); table2.addCell(imagenVal); } //end loop //table.addCell(tiempoLabel); document.add(table); document.newPage(); document.add(table2); }
From source file:com.mim.servlet.ReportGen.java
private void ordenReport(Document document, Lugar lugar) throws BadElementException, DocumentException, IOException { document.addTitle(current.getNumeroOrden()); // step 3//from w w w .j ava 2s . c om // step 4 PdfPTable table = new PdfPTable(8); //LEFT HEADER CONTENT PdfPTable leftHeaderTable = new PdfPTable(4); PdfPCell imgCell = new PdfPCell(); imgCell.setBorder(Rectangle.NO_BORDER); imgCell.setPaddingTop(14); imgCell.setColspan(1); imgCell.setFixedHeight(25); //Image img = Image.getInstance("/opt/shared/home/logo.png"); Image img = Image.getInstance("http://mimconstructions.com/img/mim%20trendy.png"); imgCell.addElement(img); PdfPCell reportTitleCell = new PdfPCell(new Paragraph("REPORTE MANTENIMIENTO")); reportTitleCell.setPaddingTop(14); reportTitleCell.setPaddingLeft(20); reportTitleCell.setColspan(3); reportTitleCell.setBorder(Rectangle.NO_BORDER); leftHeaderTable.addCell(imgCell); leftHeaderTable.addCell(reportTitleCell); PdfPCell leftHeaderMainCell = new PdfPCell(leftHeaderTable); leftHeaderMainCell.setColspan(4); //END CONTENT //RIGHT HEADER WITH INFO ABOUT ORDER AND DATE PdfPTable infHeader = new PdfPTable(3); PdfPCell numberOrderLabel = new PdfPCell(new Paragraph("#ORDEN")); numberOrderLabel.setHorizontalAlignment(Element.ALIGN_CENTER); numberOrderLabel.setColspan(1); String numeroOrden = null; if (current.getNumeroOrden() != null) { numeroOrden = current.getNumeroOrden(); } else { numeroOrden = current.getActividad(); } PdfPCell numberOrderValue = new PdfPCell(new Paragraph(numeroOrden)); numberOrderValue.setHorizontalAlignment(Element.ALIGN_CENTER); numberOrderValue.setColspan(2); PdfPCell prioridadLabel = new PdfPCell(new Paragraph("PRIORIDAD")); prioridadLabel.setHorizontalAlignment(Element.ALIGN_CENTER); prioridadLabel.setColspan(1); PdfPCell prioridadValue = new PdfPCell(new Paragraph(current.getPrioridad())); prioridadValue.setHorizontalAlignment(Element.ALIGN_CENTER); prioridadValue.setColspan(2); PdfPCell fechaLabel = new PdfPCell(new Paragraph("FECHA")); fechaLabel.setHorizontalAlignment(Element.ALIGN_CENTER); fechaLabel.setColspan(1); //dd-MM-yyyy SimpleDateFormat format1 = new SimpleDateFormat("dd-MM-yyyy"); Date startDate = current.getStartDate(); if (startDate == null) { startDate = new Date(); } String fecha = format1.format(startDate); PdfPCell fechaValue = new PdfPCell(new Paragraph(fecha)); fechaValue.setHorizontalAlignment(Element.ALIGN_CENTER); fechaValue.setColspan(2); infHeader.addCell(numberOrderLabel); infHeader.addCell(numberOrderValue); infHeader.addCell(prioridadLabel); infHeader.addCell(prioridadValue); infHeader.addCell(fechaLabel); infHeader.addCell(fechaValue); PdfPCell cellHeaderRight = new PdfPCell(infHeader); cellHeaderRight.setColspan(4); //END HEADER PdfPCell areaLabel = new PdfPCell(new Paragraph("AREA")); areaLabel.setHorizontalAlignment(Element.ALIGN_CENTER); areaLabel.setVerticalAlignment(Element.ALIGN_CENTER); areaLabel.setFixedHeight(30); areaLabel.setPaddingTop(5); areaLabel.setColspan(2); PdfPCell actividadLabel = new PdfPCell(new Paragraph("ACTIVIDAD")); actividadLabel.setHorizontalAlignment(Element.ALIGN_CENTER); actividadLabel.setFixedHeight(30); actividadLabel.setVerticalAlignment(Element.ALIGN_CENTER); actividadLabel.setPaddingTop(5); actividadLabel.setColspan(3); PdfPCell responsableLabel = new PdfPCell(new Paragraph("RESPONSABLE DE OPERACION")); responsableLabel.setHorizontalAlignment(Element.ALIGN_CENTER); responsableLabel.setFixedHeight(30); responsableLabel.setVerticalAlignment(Element.ALIGN_CENTER); responsableLabel.setPaddingTop(5); responsableLabel.setColspan(3); PdfPCell areaValor = new PdfPCell(new Paragraph("concretera")); areaValor.setFixedHeight(25); areaValor.setHorizontalAlignment(Element.ALIGN_CENTER); areaValor.setColspan(2); PdfPCell actividadValor = new PdfPCell(new Paragraph(current.getActividad())); actividadValor.setHorizontalAlignment(Element.ALIGN_CENTER); actividadValor.setFixedHeight(25); actividadValor.setColspan(3); PdfPCell responsableValor = new PdfPCell(new Paragraph(current.getEncargado())); responsableValor.setHorizontalAlignment(Element.ALIGN_CENTER); responsableValor.setFixedHeight(25); responsableValor.setColspan(3); // 2 FILAS PARA INF. EQUIPO Y LUGAR PdfPCell equipoLabel = new PdfPCell(new Paragraph("EQUIPO/CONJUNTO")); equipoLabel.setHorizontalAlignment(Element.ALIGN_CENTER); equipoLabel.setVerticalAlignment(Element.ALIGN_CENTER); equipoLabel.setFixedHeight(30); equipoLabel.setPaddingTop(5); equipoLabel.setColspan(4); PdfPCell lugarLabel = new PdfPCell(new Paragraph("LUGAR")); lugarLabel.setHorizontalAlignment(Element.ALIGN_CENTER); lugarLabel.setFixedHeight(30); lugarLabel.setVerticalAlignment(Element.ALIGN_CENTER); lugarLabel.setPaddingTop(5); lugarLabel.setColspan(4); String numeroEquipo = null; if (equipo.getNumeroEquipo() != null) { numeroEquipo = equipo.getNumeroEquipo(); } else { numeroEquipo = "n/a"; } PdfPCell equipoValor = new PdfPCell(new Paragraph(numeroEquipo)); equipoValor.setHorizontalAlignment(Element.ALIGN_CENTER); equipoValor.setFixedHeight(25); equipoValor.setColspan(4); PdfPCell lugarValor = new PdfPCell(new Paragraph(lugar.getNombre())); lugarValor.setHorizontalAlignment(Element.ALIGN_CENTER); lugarValor.setFixedHeight(25); lugarValor.setColspan(4); //END INFO EQUIPO // 4 ROW and 5 ROW PdfPCell descripcionLabel = new PdfPCell(new Paragraph("DESCRIPCION")); descripcionLabel.setPadding(12); descripcionLabel.setHorizontalAlignment(Element.ALIGN_CENTER); descripcionLabel.setColspan(8); PdfPCell descripcionValor = new PdfPCell(new Paragraph(current.getDescripcion())); descripcionValor.setPadding(10); descripcionValor.setColspan(8); //END ROWS //ROW BEFORE HISTORIAL_DETALLES PdfPCell historialLabel = new PdfPCell(new Paragraph("OBSERVACIONES")); historialLabel.setPadding(12); historialLabel.setHorizontalAlignment(Element.ALIGN_CENTER); historialLabel.setColspan(8); //END HISTORIAL table.addCell(leftHeaderMainCell); table.addCell(cellHeaderRight); table.addCell(areaLabel); table.addCell(actividadLabel); table.addCell(responsableLabel); table.addCell(areaValor); table.addCell(actividadValor); table.addCell(responsableValor); table.addCell(equipoLabel); table.addCell(lugarLabel); table.addCell(equipoValor); table.addCell(lugarValor); table.addCell(descripcionLabel); table.addCell(descripcionValor); List<HistorialDetalles> observaciones = hisFacade.findAllByOrder(current.getIdorden()); if (observaciones != null) { if (observaciones.size() > 0) { table.addCell(historialLabel); //LOOP HISTORIAL_DETALLES for (int i = 0; i < observaciones.size(); i++) { HistorialDetalles historial = observaciones.get(i); if (historial.getValor() != null) { if (historial.getValor().length() > 0) { PdfPCell paramCell = new PdfPCell(); paramCell.setColspan(3); paramCell.addElement(new Paragraph(historial.getParametro())); paramCell.setVerticalAlignment(Element.ALIGN_CENTER); paramCell.setPaddingLeft(10); paramCell.setPaddingBottom(10); PdfPCell valueParamCell = new PdfPCell(); valueParamCell.setColspan(5); valueParamCell.setPaddingLeft(10); valueParamCell.setVerticalAlignment(Element.ALIGN_CENTER); valueParamCell.addElement(new Paragraph(historial.getValor())); valueParamCell.setPaddingBottom(10); table.addCell(paramCell); table.addCell(valueParamCell); } } } } } //END LOOP HISTORIAL // FIRST ROWS OF FOTOGRAPHIC REPORT PdfPCell pasoLabel = new PdfPCell(new Paragraph("PASO")); pasoLabel.setFixedHeight(20); pasoLabel.setHorizontalAlignment(Element.ALIGN_CENTER); pasoLabel.setColspan(1); PdfPCell accionLabel = new PdfPCell(new Paragraph("ACCION")); accionLabel.setFixedHeight(20); accionLabel.setHorizontalAlignment(Element.ALIGN_CENTER); accionLabel.setColspan(3); PdfPCell imagenLabel = new PdfPCell(new Paragraph("IMAGENES")); imagenLabel.setFixedHeight(20); imagenLabel.setHorizontalAlignment(Element.ALIGN_CENTER); imagenLabel.setColspan(4); //END ROWS PdfPTable table2 = new PdfPTable(8); //ROW BEFORE HISTORIAL_DETALLES PdfPCell headerPictures = new PdfPCell(new Paragraph("PROCEDIMIENTO")); headerPictures.setPadding(12); headerPictures.setHorizontalAlignment(Element.ALIGN_CENTER); headerPictures.setColspan(8); table2.addCell(headerPictures); //END HISTORIAL table2.addCell(pasoLabel); table2.addCell(accionLabel); table2.addCell(imagenLabel); //fotos loop List<Fotos> fotos = fotoFacade.findAllByOrder(current.getIdorden()); for (int i = 0; i < fotos.size(); i++) { Fotos foto = fotos.get(i); PdfPCell pasoVal = new PdfPCell(new Paragraph(String.valueOf(i))); pasoVal.setHorizontalAlignment(Element.ALIGN_CENTER); pasoVal.setColspan(1); PdfPCell detail = new PdfPCell(new Paragraph(foto.getTitulo())); detail.setPadding(5); detail.setBorder(Rectangle.NO_BORDER); PdfPCell accionVal = new PdfPCell(); accionVal.addElement(new Paragraph(foto.getDescripcion())); accionVal.setHorizontalAlignment(Element.ALIGN_CENTER); accionVal.setBorder(Rectangle.NO_BORDER); //accionVal.setColspan(3); PdfPTable infoTable = new PdfPTable(1); infoTable.addCell(detail); infoTable.addCell(accionVal); PdfPCell infiCell = new PdfPCell(); infiCell.setColspan(3); infiCell.addElement(infoTable); //Table collumn //System.getenv("OPENSHIFT_DATA_DIR") + "imagenes/" + name) //Image imgFoto = Image.getInstance("http://mantenimiento-contactres.rhcloud.com/MantenimientoRest/webresources/com.mim.entities.fotos/api/" + foto.getIdfotos()); String archivo = foto.getArchivo(); String[] split = archivo.split("/"); int size = split.length; final String name = split[size - 1]; System.out.println("Valor " + name); Image imgFoto = Image.getInstance("/opt/shared/home/" + "imagenes/" + name); PdfPTable imagenTable = new PdfPTable(1); PdfPCell fotoCell = new PdfPCell(); fotoCell.setColspan(1); fotoCell.addElement(imgFoto); fotoCell.setFixedHeight(310); fotoCell.setHorizontalAlignment(Element.ALIGN_CENTER); fotoCell.setBorder(Rectangle.NO_BORDER); imagenTable.addCell(fotoCell); PdfPCell imagenVal = new PdfPCell(); imagenVal.setColspan(4); imagenVal.addElement(imagenTable); table2.addCell(pasoVal); table2.addCell(infiCell); table2.addCell(imagenVal); } //end loop //table.addCell(tiempoLabel); document.add(table); document.newPage(); document.add(table2); }
From source file:com.netsteadfast.greenstep.bsc.command.KpiReportPdfCommand.java
License:Apache License
private void createHead(PdfPTable table, VisionVO vision) throws Exception { PdfPCell cell = new PdfPCell(); cell.addElement(new Phrase(vision.getTitle() + "\n" + BscReportSupportUtils.parse2(vision.getScore()), this.getFont(vision.getFontColor(), true))); this.setCellBackgroundColor(cell, vision.getBgColor()); cell.setColspan(MAX_COLSPAN);//from w w w.j a va2s.c om table.addCell(cell); cell = new PdfPCell(); cell.addElement(new Phrase(BscReportPropertyUtils.getPerspectiveTitle(), this.getFont(BscReportPropertyUtils.getFontColor(), true))); this.setCellBackgroundColor(cell, BscReportPropertyUtils.getBackgroundColor()); table.addCell(cell); cell = new PdfPCell(); cell.addElement(new Phrase(BscReportPropertyUtils.getObjectiveTitle(), this.getFont(BscReportPropertyUtils.getFontColor(), true))); this.setCellBackgroundColor(cell, BscReportPropertyUtils.getBackgroundColor()); table.addCell(cell); cell = new PdfPCell(); cell.addElement(new Phrase(BscReportPropertyUtils.getKpiTitle(), this.getFont(BscReportPropertyUtils.getFontColor(), true))); this.setCellBackgroundColor(cell, BscReportPropertyUtils.getBackgroundColor()); table.addCell(cell); }
From source file:com.netsteadfast.greenstep.bsc.command.KpiReportPdfCommand.java
License:Apache License
private void createBody(PdfPTable table, VisionVO vision) throws Exception { Map<String, String> managementMap = BscKpiCode.getManagementMap(false); //Map<String, String> calculationMap = BscKpiCode.getCalculationMap(false); PdfPCell cell = null;/*from w ww. j av a 2s .com*/ for (PerspectiveVO perspective : vision.getPerspectives()) { Image pImage = Image.getInstance(BscReportSupportUtils.getByteIconBase("PERSPECTIVES", perspective.getTarget(), perspective.getMin(), perspective.getScore(), "", "", 0)); pImage.setWidthPercentage(10f); String content = this.getItemsContent(perspective.getName(), perspective.getScore(), perspective.getWeight(), perspective.getTarget(), perspective.getMin()); cell = new PdfPCell(); cell.addElement(pImage); cell.addElement(new Phrase("\n" + content, this.getFont(perspective.getFontColor(), false))); this.setCellBackgroundColor(cell, perspective.getBgColor()); cell.setRowspan(perspective.getRow()); table.addCell(cell); for (ObjectiveVO objective : perspective.getObjectives()) { Image oImage = Image.getInstance(BscReportSupportUtils.getByteIconBase("OBJECTIVES", objective.getTarget(), objective.getMin(), objective.getScore(), "", "", 0)); oImage.setWidthPercentage(10f); content = this.getItemsContent(objective.getName(), objective.getScore(), objective.getWeight(), objective.getTarget(), objective.getMin()); cell = new PdfPCell(); cell.addElement(oImage); cell.addElement(new Phrase("\n" + content, this.getFont(objective.getFontColor(), false))); this.setCellBackgroundColor(cell, objective.getBgColor()); cell.setRowspan(objective.getRow()); table.addCell(cell); for (KpiVO kpi : objective.getKpis()) { /* content = this.getKpisContent( kpi, managementMap, calculationMap); */ Image kImage = Image.getInstance(BscReportSupportUtils.getByteIconBase("KPI", kpi.getTarget(), kpi.getMin(), kpi.getScore(), kpi.getCompareType(), kpi.getManagement(), kpi.getQuasiRange())); kImage.setWidthPercentage(10f); content = this.getKpisContent(kpi, managementMap); cell = new PdfPCell(); cell.addElement(kImage); cell.addElement(new Phrase("\n" + content, this.getFont(kpi.getFontColor(), false))); this.setCellBackgroundColor(cell, kpi.getBgColor()); table.addCell(cell); } } } }
From source file:com.netsteadfast.greenstep.bsc.command.KpiReportPdfCommand.java
License:Apache License
private void createDateRange(PdfPTable table, VisionVO vision, Context context, int maxRows) throws Exception { String frequency = (String) context.get("frequency"); String startYearDate = StringUtils.defaultString((String) context.get("startYearDate")).trim(); String endYearDate = StringUtils.defaultString((String) context.get("endYearDate")).trim(); String startDate = StringUtils.defaultString((String) context.get("startDate")).trim(); String endDate = StringUtils.defaultString((String) context.get("endDate")).trim(); String date1 = startDate;/* ww w . ja v a2 s . c o m*/ String date2 = endDate; if (BscMeasureDataFrequency.FREQUENCY_QUARTER.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_HALF_OF_YEAR.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_YEAR.equals(frequency)) { date1 = startYearDate + "/01/01"; date2 = endYearDate + "/12/" + SimpleUtils.getMaxDayOfMonth(Integer.parseInt(endYearDate), 12); } Map<String, Object> headContentMap = new HashMap<String, Object>(); this.fillHeadContent(context, headContentMap); String content = "Frequency: " + BscMeasureDataFrequency.getFrequencyMap(false).get(frequency) + " Date range: " + date1 + " ~ " + date2 + "\n" + StringUtils.defaultString((String) headContentMap.get("headContent")); PdfPCell cell = null; cell = new PdfPCell(); cell.addElement(new Phrase(content, this.getFont(BscReportPropertyUtils.getFontColor(), false))); this.setCellBackgroundColor(cell, BscReportPropertyUtils.getBackgroundColor()); cell.setColspan(maxRows); table.addCell(cell); for (PerspectiveVO perspective : vision.getPerspectives()) { for (ObjectiveVO objective : perspective.getObjectives()) { for (KpiVO kpi : objective.getKpis()) { cell = new PdfPCell(); cell.addElement(new Phrase(kpi.getName(), this.getFont(kpi.getFontColor(), false))); this.setCellBackgroundColor(cell, kpi.getBgColor()); cell.setColspan(4); cell.setRowspan(2); table.addCell(cell); for (DateRangeScoreVO dateScore : kpi.getDateRangeScores()) { cell = new PdfPCell(); cell.addElement( new Phrase(dateScore.getDate(), this.getFont(dateScore.getFontColor(), false))); this.setCellBackgroundColor(cell, dateScore.getBgColor()); table.addCell(cell); } for (DateRangeScoreVO dateScore : kpi.getDateRangeScores()) { Image image = Image .getInstance(BscReportSupportUtils.getByteIcon(kpi, dateScore.getScore())); image.setWidthPercentage(20f); cell = new PdfPCell(); cell.addElement(new Phrase(BscReportSupportUtils.parse2(dateScore.getScore()), this.getFont(dateScore.getFontColor(), false))); cell.addElement(image); this.setCellBackgroundColor(cell, dateScore.getBgColor()); table.addCell(cell); } } } } }
From source file:com.netsteadfast.greenstep.bsc.command.KpiReportPdfCommand.java
License:Apache License
private void putCharts(PdfPTable table, Context context) throws Exception { String pieBase64Content = SimpleUtils.getPNGBase64Content((String) context.get("pieCanvasToData")); String barBase64Content = SimpleUtils.getPNGBase64Content((String) context.get("barCanvasToData")); BufferedImage pieImage = SimpleUtils.decodeToImage(pieBase64Content); BufferedImage barImage = SimpleUtils.decodeToImage(barBase64Content); ByteArrayOutputStream pieBos = new ByteArrayOutputStream(); ImageIO.write(pieImage, "png", pieBos); pieBos.flush();//from w w w. j ava 2 s. com ByteArrayOutputStream barBos = new ByteArrayOutputStream(); ImageIO.write(barImage, "png", barBos); barBos.flush(); PdfPCell cell = null; Image pieImgObj = Image.getInstance(pieBos.toByteArray()); pieImgObj.setWidthPercentage(100f); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.addElement(pieImgObj); table.addCell(cell); Image barImgObj = Image.getInstance(barBos.toByteArray()); barImgObj.setWidthPercentage(100f); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.addElement(barImgObj); table.addCell(cell); }
From source file:com.netsteadfast.greenstep.bsc.command.KpiReportPdfCommand.java
License:Apache License
private void putSignature(PdfPTable table, Context context) throws Exception { String uploadOid = (String) context.get("uploadSignatureOid"); if (StringUtils.isBlank(uploadOid)) { return;// w ww.j av a 2 s . com } byte[] imageBytes = UploadSupportUtils.getDataBytes(uploadOid); if (null == imageBytes) { return; } Image signatureImgObj = Image.getInstance(imageBytes); signatureImgObj.setWidthPercentage(40f); PdfPCell cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.addElement(signatureImgObj); table.addCell(cell); }