Example usage for com.itextpdf.text.pdf PdfPCell setPaddingTop

List of usage examples for com.itextpdf.text.pdf PdfPCell setPaddingTop

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfPCell setPaddingTop.

Prototype

public void setPaddingTop(float paddingTop) 

Source Link

Document

Setter for property paddingTop.

Usage

From source file:com.ideationdesignservices.txtbook.pdf.TxtBookPdf.java

public Boolean createBackCoverPage(Document document, String backCoverNote)
        throws DocumentException, MalformedURLException, IOException {
    document.newPage();// w w w  .  j  a va 2s  . c  o m
    Image backCoverImageFrame = Image
            .getInstance(ImageUtilities.getImageDataForFile(this.mContext, "pdf/txtbook_backpage_300.png"));
    backCoverImageFrame.scalePercent(24.0f);
    backCoverImageFrame.setAbsolutePosition(87.0f, 78.0f);
    backCoverImageFrame.setCompressionLevel(this.settings.compressionLevel);
    document.add(backCoverImageFrame);
    PdfContentByte canvas = this.writer.getDirectContent();
    PdfPTable table = new PdfPTable(1);
    table.setTotalWidth(215.0f);
    if (backCoverNote != null && backCoverNote.length() > 0) {
        Paragraph backCoverEl = new Paragraph(backCoverNote, this.serifFont14);
        PdfPCell cell = new PdfPCell();
        cell.setBorder(0);
        cell.addElement(backCoverEl);
        cell.setPadding(13.0f);
        cell.setIndent(0.0f);
        cell.setFixedHeight(310.0f);
        table.addCell(cell);
        table.completeRow();
    }
    Element backUrl = new Anchor("txt-book.com", this.sansFont11Gray);
    backUrl.setName("txt-book.com");
    backUrl.setReference("http://www.txt-book.com");
    Paragraph paragraph = new Paragraph();
    paragraph.setAlignment(2);
    paragraph.add(backUrl);
    PdfPCell cell2 = new PdfPCell();
    cell2.setBorder(0);
    cell2.setHorizontalAlignment(2);
    cell2.addElement(paragraph);
    cell2.setPadding(0.0f);
    cell2.setPaddingTop(0.0f);
    cell2.setIndent(0.0f);
    table.addCell(cell2);
    table.completeRow();
    table.writeSelectedRows(0, -1, 306.0f, 400.0f, canvas);
    return Boolean.valueOf(true);
}

From source file:com.maxl.java.amikodesk.SaveBasket.java

License:Open Source License

private PdfPCell getStringCell(String str, Font font, int border, int align, int colspan) {
    PdfPCell cell = new PdfPCell(new Paragraph(str, font));
    cell.setPaddingTop(5);
    cell.setPaddingBottom(5);/* w  w  w . ja va  2  s .co m*/
    cell.setBorderWidth(1);
    cell.setBorder(border);
    cell.setHorizontalAlignment(align);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE /*.ALIGN_CENTER*/);
    cell.setColspan(colspan);

    return cell;
}

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 ww w  .j  a v a2s . c  om*/
    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 w w  w  .ja  v  a  2  s  .com*/
    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// w w  w  . j  ava  2 s . co 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// w  ww.j  av a 2s  .  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//  w  w w  .  j  a  v a2 s.co 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);

                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.photoshop.misc.Indexkaartgenerator.java

private void createTable(Paragraph preface) throws BadElementException, DocumentException {
    // create header cell
    PdfPTable table = new PdfPTable(4);

    // set the width of the table to 100% of page
    table.setWidthPercentage(100);/*from  ww w .  j  av a2s.c o  m*/
    table.setWidths(new float[] { 1f, 0.6f, 0.4f, 2f });
    table.setHeaderRows(1);
    creatCell("Voorbeeld foto", table, true);
    creatCell("Aantal", table, true);
    creatCell("PhotoID", table, true);
    creatCell("Beschrijving", table, true);

    for (OrderRow row : order.getOrderRows()) {
        Photo pfdphoto = this.photoDao.getById(row.getPhoto_id());
        Image Logo = null;
        try {
            String filename = env.getProperty("uploadDir") + "thumb/" + pfdphoto.getThumbnailURL();
            Logo = Image.getInstance(filename);
            Logo.scaleAbsolute(75, 50);
        } catch (BadElementException | IOException ex) {
            Logger.getLogger(OrderController.class.getName()).log(Level.SEVERE, null, ex);
        }
        PdfPCell c1 = new PdfPCell(Logo);
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setPaddingTop(10);
        c1.setPaddingBottom(10);
        table.addCell(c1);
        creatCell(row.getAantal() + "", table, false);
        creatCell(row.getPhoto_id() + "", table, false);
        creatCell(row.getProduct().getName(), table, false);
    }
    preface.add(table);
}

From source file:com.poscoict.license.service.CertificateService.java

public Map<String, Object> getLicenseCertification(String userNo, String licenseFileName,
        HttpServletRequest req) throws Exception {
    logger.info("_________getLicenseCertification: " + userNo + " " + licenseFileName);
    String PDFFileName = userNo + licenseFileName;
    String PDFFilePath = Consts.PDF_PATH + PDFFileName + ".pdf";
    String ImgFilePath = Consts.IMG_PATH + PDFFileName + "1." + Consts.IMG_FORMAT;

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("PDFFileName", PDFFileName + ".pdf");
    map.put("ImgFileName", PDFFileName + "1." + Consts.IMG_FORMAT);

    Map<String, Object> licenseInfo = (Map<String, Object>) managementDao.getLicenseCertification(userNo,
            licenseFileName);//from  ww w.j av  a  2  s  .  c o  m

    Document document = new Document();
    try {
        PdfWriter.getInstance(document, new FileOutputStream(PDFFilePath));
        document.open();

        Paragraph p0 = new Paragraph(" ");
        Paragraph p1 = null;

        p1 = setParagraph("License Certificate", Fonts.FONT20BOLD);
        p1.setAlignment(Paragraph.ALIGN_CENTER);
        document.add(p1);

        document.add(p0);
        document.add(p0);

        document.add(
                setParagraph("? End User (?) : " + licenseInfo.get("USER_NAME"), Fonts.FONT12BOLD));
        document.add(
                setParagraph("? Address (): " + licenseInfo.get("USER_ADDRESS"), Fonts.FONT12BOLD));
        document.add(
                setParagraph("? Project (): " + licenseInfo.get("PROJECT_NAME"), Fonts.FONT12BOLD));

        document.add(p0);

        PdfPTable table = new PdfPTable(2);
        table.setWidthPercentage(100);

        PdfPCell cell;
        cell = new PdfPCell(new Phrase(" Product Description", getFont(Fonts.FONT12BOLD)));
        cell.setFixedHeight(30);
        cell.setPaddingTop(8f);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase(" " + licenseInfo.get("PRODUCT_FILE_NAME"), getFont(Fonts.FONT12NOAML)));
        cell.setFixedHeight(30);
        cell.setPaddingTop(8f);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(" License Number", getFont(Fonts.FONT12BOLD)));
        cell.setFixedHeight(30);
        cell.setPaddingTop(8f);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase(" " + licenseInfo.get("LICENSE_KEY"), getFont(Fonts.FONT12NOAML)));
        cell.setFixedHeight(30);
        cell.setPaddingTop(8f);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(" Quantity", getFont(Fonts.FONT12BOLD)));
        cell.setFixedHeight(30);
        cell.setPaddingTop(8f);
        table.addCell(cell);
        cell = new PdfPCell(
                new Phrase(" " + licenseInfo.get("LICENSE_QUANTITY") + " EA", getFont(Fonts.FONT12NOAML)));
        cell.setFixedHeight(30);
        cell.setPaddingTop(8f);
        table.addCell(cell);

        document.add(table);

        document.add(p0);

        List list = new List(false, 20);
        list.add(new ListItem(
                " License Certificate  ?? ? ?  ? ?   ?? ??.",
                getFont(Fonts.FONT12NOAML)));
        list.add(new ListItem(
                "License Certificate ?  ??  ? ?  ?    ?  ?.",
                getFont(Fonts.FONT12NOAML)));
        list.add(new ListItem(",  ? ?? .",
                getFont(Fonts.FONT12NOAML)));
        document.add(list);

        document.add(p0);
        document.add(p0);
        document.add(p0);
        document.add(p0);
        document.add(p0);
        document.add(p0);
        document.add(p0);
        document.add(p0);

        p1 = setParagraph(licenseInfo.get("USER_START_DATE").toString(), Fonts.FONT20BOLD);
        p1.setAlignment(Paragraph.ALIGN_CENTER);
        document.add(p1);
        p1 = setParagraph(licenseInfo.get("COMPANY_NAME").toString(), Fonts.FONT20BOLD);
        p1.setAlignment(Paragraph.ALIGN_CENTER);
        document.add(p1);

        //         Image img = Image.getInstance(Consts.SIGNET_IMG_PATH);
        //         img.setAbsolutePosition(350f, 390f);
        //         document.add(img);

        document.close();
    } catch (DocumentException de) {
        logger.error(ImgFilePath, de);
    } catch (IOException ioe) {
        logger.error(ImgFilePath, ioe);
    }

    String temp = req.getSession().getServletContext().getRealPath(Consts.IMG_TEMP_FOLDER);
    System.out.println("________________________________________________" + temp);
    if (extractPagesAsImage(PDFFilePath, PDFFileName, 100, "")) {
        fileCopy(ImgFilePath, temp + File.separator + map.get("ImgFileName"));
    }

    return map;
}

From source file:com.skatettoo.reportes.Generador.java

public String generarPDF() throws Exception {
    try {/*from w  w w  .ja v  a  2 s .com*/
        String path = FacesContext.getCurrentInstance().getExternalContext().getRealPath("img");
        path = path.substring(0, path.indexOf("\\build"));
        path = path + "\\web\\img\\";
        Document doc = new Document(PageSize.A4, 36, 36, 10, 10);
        PdfPTable tabla = new PdfPTable(4);
        PdfWriter.getInstance(doc, new FileOutputStream(path + "\\archivo\\reporte.pdf\\"));
        doc.open();
        Image img = Image.getInstance(path + "Skatetoo4.png");
        img.scaleAbsolute(40, 40);
        img.setAlignment(Element.ALIGN_LEFT);
        doc.add(img);
        doc.addTitle(this.titulo);
        doc.addAuthor("\n ");
        doc.addAuthor("\n ");
        doc.addAuthor("\n ");
        doc.addAuthor("\n ");
        tabla.setWidthPercentage(100);
        tabla.setWidths(new float[] { 1.4f, 0.8f, 0.8f, 0.8f });
        Object font = new Font(Font.FontFamily.HELVETICA, 14, Font.BOLD, BaseColor.WHITE);
        PdfPCell cell = new PdfPCell(new Phrase("Reporte de tatuadores", (Font) font));
        cell.setColspan(4);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setPaddingTop(0f);
        cell.setPaddingBottom(7f);
        cell.setBackgroundColor(new BaseColor(0, 0, 0));
        cell.setBorder(0);
        cell.setBorderWidthBottom(2f);
        tabla.addCell(cell);
        tabla.addCell("Tatuador");
        tabla.addCell("Cantidad de diseos");
        tabla.addCell("Citas realizadas");
        tabla.addCell("Noticias publicadas");
        for (Usuario u : this.getUsu()) {
            tabla.addCell(u.getNombre() + " " + u.getApellido());
            tabla.addCell(String.valueOf(u.getDisenioList().size()));
            tabla.addCell(String.valueOf(u.getCitaList1().size()));
            tabla.addCell(String.valueOf(u.getNoticiaList().size()));
        }
        doc.add(tabla);
        doc.bottomMargin();
        /* doc.add(new Paragraph("Tatuador mas solicitado"));
         for(Usuario u : this.getUs()){
        doc.add(new Paragraph(u.getNombre() + " " + u.getApellido()));
         }*/
        doc.close();
        FacesContext context = FacesContext.getCurrentInstance();
        ExternalContext externalContext = context.getExternalContext();

        externalContext.responseReset();
        externalContext.setResponseContentType("application/pdf");
        externalContext.setResponseHeader("Content-Disposition", "attachment;filename=\"reporte.pdf\"");

        FileInputStream inputStream = new FileInputStream(new File(path + "\\archivo\\reporte.pdf\\"));
        OutputStream outputStream = externalContext.getResponseOutputStream();

        byte[] buffer = new byte[1024];
        int length;
        while ((length = inputStream.read(buffer)) > 0) {
            outputStream.write(buffer, 0, length);
        }

        inputStream.close();
        context.responseComplete();
    } catch (Exception e) {
        throw e;
    }
    return "";
}