Package com.itextpdf.text.pdf

Examples of com.itextpdf.text.pdf.PdfPCell


    document.add(title);
  }

  private void addTable(Document document) throws DocumentException {

    PdfPCell cell = null;

    // Compute the column count in order to initialize the iText table
    int columnCount = table.getLastHeaderRow().getColumns(ReservedFormat.ALL, ReservedFormat.PDF).size();

    if (columnCount != 0) {

      PdfPTable pdfTable = new PdfPTable(columnCount);
      pdfTable.setWidthPercentage(100f);

      // Header
      if (exportConf != null && exportConf.getIncludeHeader()) {

        for (HtmlRow htmlRow : table.getHeadRows()) {

          for (HtmlColumn column : htmlRow.getColumns(ReservedFormat.ALL, ReservedFormat.PDF)) {

            cell = new PdfPCell();
            cell.setPhrase(new Phrase(column.getContent().toString()));
            pdfTable.addCell(cell);
          }
        }
      }

      for (HtmlRow htmlRow : table.getBodyRows()) {

        for (HtmlColumn column : htmlRow.getColumns(ReservedFormat.ALL, ReservedFormat.PDF)) {

          cell = new PdfPCell();
          cell.setPhrase(new Phrase(column.getContent().toString()));
          pdfTable.addCell(cell);
        }
      }

      document.add(pdfTable);
View Full Code Here


  public PdfPTable createTable(String airport) {

    // Creation of PdfTable with 4 columns
    final PdfPTable table = new PdfPTable(4);

    final PdfPCell cell1 = new PdfPCell(new Paragraph("Service", BFONT));
    cell1.setGrayFill(0.3f);
    final PdfPCell cell2 = new PdfPCell(new Paragraph("Thème", BFONT));
    cell2.setGrayFill(0.3f);
    final PdfPCell cell3 = new PdfPCell(
        new Paragraph("Observations", BFONT));
    cell3.setGrayFill(0.3f);
    final PdfPCell cell4 = new PdfPCell(new Paragraph("Action(s)", BFONT));
    cell4.setGrayFill(0.3f);

    table.addCell(cell1);
    table.addCell(cell2);
    table.addCell(cell3);
    table.addCell(cell4);
View Full Code Here

      document.add(paragraph);
      addEmptyLine(document, 2);
      PdfPTable table = new PdfPTable(5);

      Phrase phrase = new Phrase("Dzień miesiąca", f);
      PdfPCell c1 = new PdfPCell(phrase);
      c1.setHorizontalAlignment(Element.ALIGN_CENTER);
      table.addCell(c1);

      c1 = new PdfPCell(new Phrase("Czas pracy\u0144", f));
      c1.setHorizontalAlignment(Element.ALIGN_CENTER);
      table.addCell(c1);

      c1 = new PdfPCell(new Phrase("Program"));
      c1.setHorizontalAlignment(Element.ALIGN_CENTER);
      table.addCell(c1);

      c1 = new PdfPCell(new Phrase("Czas nieobecności", f));
      c1.setHorizontalAlignment(Element.ALIGN_CENTER);
      table.addCell(c1);

      c1 = new PdfPCell(new Phrase("Przyczyna nieobecność", f));
      c1.setHorizontalAlignment(Element.ALIGN_CENTER);
      table.addCell(c1);

      table.setHeaderRows(1);

      for (Day day : days) {
        PdfPCell cell = new PdfPCell(new Phrase(getValue(day.getDay()), f));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(getValue(day.getWorkTime()), f));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(getValue(day.getProgram()), f));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(getValue(day.getAbsenceTime()), f));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(getValue(day.getAbsenceReason()), f));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);

      }
      document.add(table);
View Full Code Here

     * @param  tag    a cell tag
     * @param  chain  the hierarchy chain
     * @return the created PdfPCell
     */
  public PdfPCell createPdfPCell(final String tag, final ChainedProperties chain) {
    PdfPCell cell = new PdfPCell((Phrase)null);
        // colspan
    String value = chain.getProperty(HtmlTags.COLSPAN);
        if (value != null)
            cell.setColspan(Integer.parseInt(value));
        // rowspan
        value = chain.getProperty(HtmlTags.ROWSPAN);
        if (value != null)
            cell.setRowspan(Integer.parseInt(value));
        // horizontal alignment
        if (tag.equals(HtmlTags.TH))
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        value = chain.getProperty(HtmlTags.ALIGN);
        if (value != null) {
            cell.setHorizontalAlignment(HtmlUtilities.alignmentValue(value));
        }
        // vertical alignment
        value = chain.getProperty(HtmlTags.VALIGN);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        if (value != null) {
            cell.setVerticalAlignment(HtmlUtilities.alignmentValue(value));
        }
        // border
        value = chain.getProperty(HtmlTags.BORDER);
        float border = 0;
        if (value != null)
            border = Float.parseFloat(value);
        cell.setBorderWidth(border);
        // cellpadding
        value = chain.getProperty(HtmlTags.CELLPADDING);
        if (value != null)
            cell.setPadding(Float.parseFloat(value));
        cell.setUseDescender(true);
        // background color
        value = chain.getProperty(HtmlTags.BGCOLOR);
        cell.setBackgroundColor(HtmlUtilities.decodeColor(value));
        return cell;
  }
View Full Code Here

  public void align(int col, String alignment) { alignments[col] = alignment;  }

  private int cellcount = 0;
  public void cell(int colspan, String txt, String align) {
    Font f = new Font(fontfamily, fontsize, fontstyle);
    PdfPCell c = new PdfPCell(new Phrase(txt,f));
    int col = cellcount % alignments.length;
    String al = alignments[col];
    if (al != null) {
      //print("align: " + col + " " + al);
      if ("right".equals(al)) c.setHorizontalAlignment(Element.ALIGN_RIGHT);
      if ("left".equals(al)) c.setHorizontalAlignment(Element.ALIGN_LEFT);
      if ("center".equals(al)) c.setHorizontalAlignment(Element.ALIGN_CENTER);
    }
    c.setBorder(border);
    if (colspan > 1) {
      c.setColspan(colspan);
      cellcount += colspan;
    } else {
      cellcount++;
    }
    table.addCell(c);
View Full Code Here

        String[] headers = new String[] { "Fecha", "Equipo",
            "Comentario" };
        tabla = new PdfPTable(headers.length);
        for (int i = 0; i < headers.length; i++) {
          String header = headers[i];
          PdfPCell cell = new PdfPCell();
          cell.setGrayFill(0.9f);
          cell.setPhrase(new Phrase(header.toUpperCase(), new Font(
              FontFamily.HELVETICA, 10, Font.BOLD)));
          tabla.addCell(cell);
        }
        tabla.completeRow();

        while (iteNovedades.hasNext()) {
          BitacoraLN falla = iteNovedades.next();
          PdfPCell cell0 = new PdfPCell();
          PdfPCell cell1 = new PdfPCell();
          PdfPCell cell2 = new PdfPCell();

          SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
          String fecha = sdf.format(falla.getFecha());
          cell0.setPhrase(new Phrase(fecha, new Font(
              FontFamily.HELVETICA, 10, Font.NORMAL)));
          cell1.setPhrase(new Phrase(falla.getEquipoNombre(),
              new Font(FontFamily.HELVETICA, 10, Font.NORMAL)));
          cell2.setPhrase(new Phrase(falla.getComentario().getValue(), new Font(
              FontFamily.HELVETICA, 10, Font.NORMAL)));
          tabla.addCell(cell0);
          tabla.addCell(cell1);
          tabla.addCell(cell2);
          tabla.completeRow();
View Full Code Here

          tabla.setWidths(widths);

          for (int i = 0; i < headers.length; i++) {
            String header = headers[i];
            PdfPCell cell = new PdfPCell();
            cell.setGrayFill(0.9f);
            cell.setPhrase(new Phrase(header.toUpperCase(),
                new Font(FontFamily.HELVETICA, 10, Font.BOLD)));
            tabla.addCell(cell);
          }
          tabla.completeRow();
          while (iteNovedadesfallas.hasNext()) {

            BitacoraLN bitacora = iteNovedadesfallas.next();
            PdfPCell cell0 = new PdfPCell();
            PdfPCell cell1 = new PdfPCell();
            PdfPCell cell2 = new PdfPCell();
            PdfPCell cell3 = new PdfPCell();
            PdfPCell cell4 = new PdfPCell();
            SimpleDateFormat sdf = new SimpleDateFormat(
                "dd/MM/yyyy");
            String fecha = sdf.format(bitacora.getFecha());
            cell0.setPhrase(new Phrase(fecha, new Font(
                FontFamily.HELVETICA, 8, Font.NORMAL)));
            if (bitacora.getUsuarioNombre() != null) {
              cell1.setPhrase(new Phrase(bitacora
                  .getUsuarioNombre(), new Font(
                  FontFamily.HELVETICA, 8, Font.NORMAL)));
            } else {
              cell1.setPhrase(new Phrase("", new Font(
                  FontFamily.HELVETICA, 8, Font.NORMAL)));
            }
            cell2.setPhrase(new Phrase(bitacora.getTurnoNombre(),
                new Font(FontFamily.HELVETICA, 8, Font.NORMAL)));
            cell3.setPhrase(new Phrase(bitacora.getEquipoNombre(),
                new Font(FontFamily.HELVETICA, 8, Font.NORMAL)));
            cell4.setPhrase(new Phrase(bitacora.getComentario().getValue(),
                new Font(FontFamily.HELVETICA, 8, Font.NORMAL)));
            tabla.addCell(cell0);
            tabla.addCell(cell1);
            tabla.addCell(cell2);
            tabla.addCell(cell3);
View Full Code Here

       
        tabla.setWidths(widths);
       
        for (int i = 0; i < headers.length; i++) {
          String header = headers[i];
          PdfPCell cell = new PdfPCell();
          cell.setGrayFill(0.9f);
          cell.setPhrase(new Phrase(header.toUpperCase(), new Font(
              FontFamily.HELVETICA, 10, Font.BOLD)));
          tabla.addCell(cell);
        }
        tabla.completeRow();

        while (iteFallas.hasNext()) {
          FallaLN falla = iteFallas.next();
          PdfPCell cell0 = new PdfPCell();
          PdfPCell cell1 = new PdfPCell();
          PdfPCell cell2 = new PdfPCell();

          SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
          String fecha = sdf.format(falla.getFecha());
          cell0.setPhrase(new Phrase(fecha, new Font(
              FontFamily.HELVETICA, 8, Font.NORMAL)));
          cell1.setPhrase(new Phrase(falla.getEquipoNombre(),
              new Font(FontFamily.HELVETICA, 8, Font.NORMAL)));
          cell2.setPhrase(new Phrase(falla.getProblema(), new Font(
              FontFamily.HELVETICA, 8, Font.NORMAL)));
          tabla.addCell(cell0);
          tabla.addCell(cell1);
          tabla.addCell(cell2);
          tabla.completeRow();
        }
      } else if (tipo.equals("1")) {// novedad
        if (texto.trim().length() > 0) {
          novedadList = ReporteLNBO.reporteNovedades(fechaini,
              fechater, texto, idEquipo);
        } else {
          novedadList = ReporteLNBO.reporteNovedadesSinTexto(
              fechaini, fechater, idEquipo);
        }
        Iterator<BitacoraLN> iteNovedadesfallas = novedadList
            .iterator();
        String[] headers = new String[] { "Fecha", "Usuario", "Turno",
            "Equipo", "Novedad" };
        tabla = new PdfPTable(headers.length);
        tabla.setWidthPercentage(100);
       
       
        float[] widths = new float[] { 2f, 2f, 1f,2f, 5f };
       
        tabla.setWidths(widths);
       
        for (int i = 0; i < headers.length; i++) {
          String header = headers[i];
          PdfPCell cell = new PdfPCell();
          cell.setGrayFill(0.9f);
          cell.setPhrase(new Phrase(header.toUpperCase(), new Font(
              FontFamily.HELVETICA, 10, Font.BOLD)));
          tabla.addCell(cell);
        }
        tabla.completeRow();
        while (iteNovedadesfallas.hasNext()) {

          BitacoraLN bitacora = iteNovedadesfallas.next();
          PdfPCell cell0 = new PdfPCell();
          PdfPCell cell1 = new PdfPCell();
          PdfPCell cell2 = new PdfPCell();
          PdfPCell cell3 = new PdfPCell();
          PdfPCell cell4 = new PdfPCell();
          SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
          String fecha = sdf.format(bitacora.getFecha());
          cell0.setPhrase(new Phrase(fecha, new Font(
              FontFamily.HELVETICA, 8, Font.NORMAL)));
          if (bitacora.getUsuarioNombre() != null) {
            cell1.setPhrase(new Phrase(bitacora.getUsuarioNombre(),
                new Font(FontFamily.HELVETICA, 8, Font.NORMAL)));
          } else {
            cell1.setPhrase(new Phrase("", new Font(
                FontFamily.HELVETICA, 8, Font.NORMAL)));
          }
          cell2.setPhrase(new Phrase(bitacora.getTurnoNombre(),
              new Font(FontFamily.HELVETICA, 8, Font.NORMAL)));
          cell3.setPhrase(new Phrase(bitacora.getEquipoNombre(),
              new Font(FontFamily.HELVETICA, 8, Font.NORMAL)));
          cell4.setPhrase(new Phrase(bitacora.getComentario().getValue(),
              new Font(FontFamily.HELVETICA, 8, Font.NORMAL)));
          tabla.addCell(cell0);
          tabla.addCell(cell1);
          tabla.addCell(cell2);
          tabla.addCell(cell3);
View Full Code Here

      try {

        Rectangle page = document.getPageSize();

        PdfPCell imageCell = null;
        PdfPCell textCell = null;

        PdfPTable head = new PdfPTable(2);
        float[] widths = new float[] { 1f, 4f };
        head.setWidths(widths);
        ServletContext context = getServletContext();
       
        String relativeWebPath = "/images/logo_melon.gif";
        String absoluteDiskPath = context.getRealPath(relativeWebPath);
        Image headImage = Image.getInstance(absoluteDiskPath);
        headImage.scaleToFit(75, 75);

        imageCell = new PdfPCell(headImage);
        imageCell.setBorder(Rectangle.NO_BORDER);
        head.addCell(imageCell);

        Font catFont = new Font(Font.FontFamily.HELVETICA, 16,
            Font.BOLD);
        textCell = new PdfPCell(new Phrase("Reporte de Novedades: "
            + negocio, catFont));
        textCell.setBorder(Rectangle.NO_BORDER);
        head.addCell(textCell);

        head.setTotalWidth(page.getWidth() - document.leftMargin()
            - document.rightMargin());
View Full Code Here

            try {
       
                Rectangle page = document.getPageSize();

                PdfPCell imageCell = null;
                PdfPCell textCell = null;

                PdfPTable head = new PdfPTable(2);
                float[] widths = new float[] { 1f, 4f };
                head.setWidths(widths);

            ServletContext context = ServletActionContext.getServletContext();
        String relativeWebPath = "/images/logo_melon.gif";
        String absoluteDiskPath = context.getRealPath(relativeWebPath);
        Image headImage = Image.getInstance(absoluteDiskPath);
        headImage.scaleToFit(75, 75);
       
                imageCell = new PdfPCell(headImage);
                imageCell.setBorder(Rectangle.NO_BORDER);
                head.addCell(imageCell);

                Font catFont = new Font(Font.FontFamily.HELVETICA, 16,
                  Font.BOLD);
                textCell = new PdfPCell(new Phrase("Reporte de Novedades: " + negocio,catFont));
                textCell.setBorder(Rectangle.NO_BORDER);
                head.addCell(textCell);

                head.setTotalWidth(page.getWidth() - document.leftMargin()
                                - document.rightMargin());
View Full Code Here

TOP

Related Classes of com.itextpdf.text.pdf.PdfPCell

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.