Package com.itextpdf.text.pdf

Examples of com.itextpdf.text.pdf.PdfPTable$ColumnMeasurementState


    // 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


   * @param airport
   */
  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);

    table.setComplete(true);
    table.setWidthPercentage(100);

    // Filling the table from database
    String query = "SELECT m.`service`, m.`theme`,m.`observations`, m.`action` FROM myActions m WHERE idAeroport=? GROUP BY theme";

    // getting a connection
    Connection c = DBConnexion.getConnection();

    // create statement
    try {
      PreparedStatement ps = c.prepareStatement(query);
      ps.setString(1, airport);
      ResultSet rs = ps.executeQuery();
      while (rs.next()) {

        table.addCell(rs.getString("service"));
        table.addCell(rs.getString("theme"));
        table.addCell(rs.getString("observations"));
        table.addCell(rs.getString("action"));
      }
      rs.close();
      ps.close();

    } catch (SQLException e) {
View Full Code Here

      Paragraph paragraph = new Paragraph("Zestawienie czasu pracy pracownika za " + date
          + " - " + person, f);
      paragraph.setAlignment(Element.ALIGN_CENTER);
      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);

      addEmptyLine(document, 3);
View Full Code Here

     * @return  a PdfPTable
     */
    public PdfPTable createTable() {
      // no rows = simplest table possible
        if (rows.isEmpty())
            return new PdfPTable(1);
        // how many columns?
        int ncol = 0;
        for (PdfPCell pc : rows.get(0)) {
            ncol += pc.getColspan();
        }
        PdfPTable table = new PdfPTable(ncol);
        // table width
        String width = styles.get(HtmlTags.WIDTH);
        if (width == null)
            table.setWidthPercentage(100);
        else {
            if (width.endsWith("%"))
                table.setWidthPercentage(Float.parseFloat(width.substring(0, width.length() - 1)));
            else {
                table.setTotalWidth(Float.parseFloat(width));
                table.setLockedWidth(true);
            }
        }
        // horizontal alignment
        String alignment = styles.get(HtmlTags.ALIGN);
        int align = Element.ALIGN_LEFT;
        if (alignment != null) {
          align = HtmlUtilities.alignmentValue(alignment);
        }
        table.setHorizontalAlignment(align);
        // column widths
    try {
      if (colWidths != null)
        table.setWidths(colWidths);
    } catch (Exception e) {
      // fail silently
    }
    // add the cells
        for (List<PdfPCell> col : rows) {
            for (PdfPCell pc : col) {
                table.addCell(pc);
            }
        }
        return table;
    }
View Full Code Here

   * @throws DocumentException
   * @since 5.0.6
   */
  public void processTable() throws DocumentException{
    TableWrapper table = (TableWrapper) stack.pop();
    PdfPTable tb = table.createTable();
    tb.setSplitRows(true);
    if (stack.empty())
      document.add(tb);
    else
      ((TextElementArray) stack.peek()).add(tb);
  }
View Full Code Here

        if (entry.getValue() instanceof List<?>) {
          if (!((List<?>)entry.getValue() ).isEmpty()) {
            final List<Dto> list = (List<Dto>) entry.getValue();
            final ModuleDto listModuleDto = config.getModuleDtos().get(list.get(0).getModule());
           
            PdfPTable table = new PdfPTable(listModuleDto.getListFieldIds().length);
            table.setHeaderRows(1);

            for (final String col: listModuleDto.getListFieldIds()) {
              final String colHeader = listModuleDto.getFieldById(col).getLabel();
              table.addCell(new Phrase(colHeader, new Font(FontFamily.HELVETICA, 12, Font.BOLD)));
            }
           
            for (int i = 0; i < list.size(); i++) {
              for (final String col: listModuleDto.getListFieldIds()) {
                final String colValue;
               
                if (list.get(i).getAllData().containsKey(col + "_resolved")) {
                  final Dto resolved = (Dto) list.get(i).get(col + "_resolved");
                  colValue = String.valueOf(resolved.get("name"));
                } else {
                  colValue = String.valueOf(list.get(i).get(col));
                }

                if ("true".equals(colValue) || "false".equals(colValue)) {
                  // final RadioCheckField r = new RadioCheckField(writer, new Rectangle(10, 10, 20, 20), "asd", "v1");
                  // r.setChecked("true".equals(colValue));
                  table.addCell(new Phrase("true".equals(colValue) ? "X" : ""));
                } else {
                  table.addCell(new Phrase(colValue));
                }
              }
            }
           
            document.add(new Chunk(label, new Font(FontFamily.HELVETICA, 12, Font.BOLD)));
View Full Code Here

            GerenciarDB banco = new GerenciarDB();
           
            if (tipo==0) { //Usuario
                String[][] mtx = banco.getExtratoUsuario(ID);
                int i;
                PdfPTable table = new PdfPTable(3);
               
                Paragraph head = new Paragraph("Nome: "+banco.getUsername(ID) ,fonte);
                head.setSpacingAfter(20);
                doc.add(head);
               
                for (i=(mtx[0].length)-1;i>=0;i--){
                    table.addCell(mtx[0][i]);
                    table.addCell(mtx[1][i]);
                    table.addCell(mtx[2][i]);
               }
               doc.add(table);
               Paragraph fim = new Paragraph("Saldo total: R$ "+banco.getSaldoCartaoDB(ID) ,fonte);
               doc.add(fim);
             
            } else if (tipo==1) { //Estabelecimento
                String[][] mtx = banco.getExtratoEst(ID);
                int j;
                PdfPTable table = new PdfPTable(2);
               
                Paragraph head = new Paragraph("Nome: "+banco.getEstabelecimentoDB(ID) ,fonte);
                head.setSpacingAfter(20);
                doc.add(head);

                for (j=(mtx[0].length)-1;j>=0;j--){
                    table.addCell(mtx[0][j]);
                    table.addCell(mtx[2][j]);
                }
                doc.add(table);
                Paragraph fim = new Paragraph("Receita total: R$ "+banco.getVendaTotalEstabelecimentoDB(ID) ,fonte);
                doc.add(fim);
            } else {
View Full Code Here

 
  private String[] alignments;
  private int border = 0;
  public void border(int v) { border = v; }
  public void table(float[] widths, float totalWidth, int borderwidth) {
    table = new PdfPTable(widths);
    table.setTotalWidth(totalWidth);
    border = borderwidth;
    alignments = new String[widths.length];
    cellcount = 0;
  }
View Full Code Here

  public void doPost(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    try {

      PdfPTable tabla = null;
      Document document = new Document();

      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      PdfWriter.getInstance(document, baos);

      document.open();

      List<BitacoraLN> bitacoraList = BitacoraLNDAO
          .obtenerNovedadesAyer();

      if (!bitacoraList.isEmpty()) {

        Iterator<BitacoraLN> iteNovedades = bitacoraList.iterator();

        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();
        }

        document.add(tabla);

        document.close();
View Full Code Here

  }

  public void mandaCorreo(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {

    PdfPTable tabla = null;
    List<BitacoraLN> bitacoraList;

    try {

      Iterable<Entity> usuarios = Util.listObjectEntities("UsuarioLN",
          "correo", new Boolean(true));

      for (Entity usuario : usuarios) {
        Long idNegocio = (Long) usuario.getProperty("idNegocio");
        String email = (String) usuario.getProperty("email");
        String nombres =(String) usuario.getProperty("nombres");
        String apepa =(String) usuario.getProperty("apepa");
       
        NegocioLN negocio = NegocioLNBO.editarNegocioLN(String
            .valueOf(idNegocio.longValue()));
        String txtNegocio = negocio.getNombre();
        bitacoraList = BitacoraLNDAO.obtenerNovedadesParaCorreo(idNegocio);

        if (!bitacoraList.isEmpty()) {

          Document document = new Document();

          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          PdfWriter writer = PdfWriter.getInstance(document, baos);

          Cabecera event = new Cabecera(txtNegocio);
          writer.setPageEvent(event);

          document.open();

          Iterator<BitacoraLN> iteNovedadesfallas = bitacoraList
              .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);
            tabla.addCell(cell4);
            tabla.completeRow();
          }

          document.add(tabla);

          document.close();
View Full Code Here

TOP

Related Classes of com.itextpdf.text.pdf.PdfPTable$ColumnMeasurementState

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.