Examples of PdfPTable


Examples of com.itextpdf.text.pdf.PdfPTable

  }

  public String reporteFallasPDF() {
    try {

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

      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      PdfWriter writer = PdfWriter.getInstance(document, baos);
      Map<String, Object> session = ActionContext.getContext().getSession();

      HeaderFooter event = new HeaderFooter((String)session.get("txtNegocio"));
      writer.setPageEvent(event);

      document.open();

      if (tipo.equals("0")) {// falla
        if (texto.trim().length() > 0) {
          fallaList = ReporteLNBO.reporteFallas(fechaini, fechater,
              texto, idEquipo);
        } else {
          fallaList = ReporteLNBO.reporteFallasSinTexto(fechaini,
              fechater, idEquipo);
        }
        Iterator<FallaLN> iteFallas = fallaList.iterator();
        String[] headers = new String[] { "Fecha", "Equipo", "Problema" };
        tabla = new PdfPTable(headers.length);
        tabla.setWidthPercentage(100);
       
        float[] widths = new float[] { 1f, 3f, 4f };
       
        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);
          tabla.addCell(cell4);
          tabla.completeRow();
        }
      }

      document.add(tabla);
View Full Code Here

Examples of com.itextpdf.text.pdf.PdfPTable

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

        head.writeSelectedRows(
            0,
            -1,
            document.leftMargin(),
            page.getHeight() - document.topMargin()
                + head.getTotalHeight(),
            writer.getDirectContent());
        document.add(new Paragraph("\n"));

      } catch (Exception de) {
        log.severe(de.getMessage());
View Full Code Here

Examples of com.itextpdf.text.pdf.PdfPTable

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

                head.writeSelectedRows(0, -1, document.leftMargin(), page
                                .getHeight()
                                - document.topMargin() + head.getTotalHeight(), writer
                                .getDirectContent())
                document.add(new Paragraph("\n"));

            }
            catch(Exception de) {
View Full Code Here

Examples of com.lowagie.text.pdf.PdfPTable

      if (!convert2pdfptable) {
        throw new BadElementException("No error, just an old style table");
      }
        setAutoFillEmptyCells(true);
      complete();
      PdfPTable pdfptable = new PdfPTable(widths);
      pdfptable.setComplete(complete);
      if (isNotAddedYet())
        pdfptable.setSkipFirstHeader(true);
      pdfptable.setTableEvent(SimpleTable.getDimensionlessInstance(this, cellspacing));
      pdfptable.setHeaderRows(lastHeaderRow + 1);
      pdfptable.setSplitLate(cellsFitPage);
      pdfptable.setKeepTogether(tableFitsPage);
      if (!Float.isNaN(offset)) {
        pdfptable.setSpacingBefore(offset);
      }
      pdfptable.setHorizontalAlignment(alignment);
      if (locked) {
        pdfptable.setTotalWidth(width);
        pdfptable.setLockedWidth(true);
      }
      else {
        pdfptable.setWidthPercentage(width);
      }
      Row row;
        for (Iterator iterator = iterator(); iterator.hasNext(); ) {
            row = (Row) iterator.next();
            Element cell;
            PdfPCell pcell;
            for (int i = 0; i < row.getColumns(); i++) {
                if ((cell = (Element)row.getCell(i)) != null) {
                  if (cell instanceof Table) {
                    pcell = new PdfPCell(((Table)cell).createPdfPTable());
                  }
                  else if (cell instanceof Cell) {
                    pcell = ((Cell)cell).createPdfPCell();
                     pcell.setPadding(cellpadding + cellspacing / 2f);
                         pcell.setCellEvent(SimpleCell.getDimensionlessInstance((Cell)cell, cellspacing));
                  }
                  else {
                    pcell = new PdfPCell();
                  }
                  pdfptable.addCell(pcell);
                }
            }
        }
      return pdfptable;
    }
View Full Code Here

Examples of com.lowagie.text.pdf.PdfPTable

      cell = (SimpleCell)i.next();
      columns += cell.getColspan();
    }
    float[] widths = new float[columns];
    float[] widthpercentages = new float[columns];
    PdfPTable table = new PdfPTable(columns);
    table.setTableEvent(this);
    table.setHorizontalAlignment(alignment);
    int pos;
    for (Iterator rows = content.iterator(); rows.hasNext(); ) {
      row = (SimpleCell)rows.next();
      pos = 0;
      for (Iterator cells = row.getContent().iterator(); cells.hasNext(); ) {
        cell = (SimpleCell)cells.next();
        if (Float.isNaN(cell.getSpacing_left()))  {
          cell.setSpacing_left(cellspacing / 2f);
        }
        if (Float.isNaN(cell.getSpacing_right()))  {
          cell.setSpacing_right(cellspacing / 2f);
        }
        if (Float.isNaN(cell.getSpacing_top()))  {
          cell.setSpacing_top(cellspacing / 2f);
        }
        if (Float.isNaN(cell.getSpacing_bottom()))  {
          cell.setSpacing_bottom(cellspacing / 2f);
        }
        cell.setPadding(cellpadding);
        table.addCell(cell.createPdfPCell(row));
        if (cell.getColspan() == 1) {
          if (cell.getWidth() > 0) widths[pos] = cell.getWidth();
          if (cell.getWidthpercentage() > 0) widthpercentages[pos] = cell.getWidthpercentage();
        }
        pos += cell.getColspan();
      }
    }
    float sumWidths = 0f;
    for(int i = 0; i < columns; i++) {
      if (widths[i] == 0) {
        sumWidths = 0;
        break;
      }
      sumWidths += widths[i];
    }
    if (sumWidths > 0) {
      table.setTotalWidth(sumWidths);
      table.setWidths(widths);
    }
    else {
      for(int i = 0; i < columns; i++) {
        if (widthpercentages[i] == 0) {
          sumWidths = 0;
          break;
        }
        sumWidths += widthpercentages[i];
      }
      if (sumWidths > 0) {
        table.setWidths(widthpercentages);
      }
    }
    if (width > 0) {
      table.setTotalWidth(width);
    }
    if (widthpercentage > 0) {
      table.setWidthPercentage(widthpercentage);
    }
    return table;
  }
View Full Code Here

Examples of com.lowagie.text.pdf.PdfPTable

      if (tag.equals("table")) {
        if (pendingTR)
          endElement("tr");
        cprops.removeChain("table");
        IncTable table = (IncTable) stack.pop();
        PdfPTable tb = table.buildTable();
        tb.setSplitRows(true);
        if (stack.empty())
          document.add(tb);
        else
          ((TextElementArray) stack.peek()).add(tb);
        boolean state[] = (boolean[]) tableState.pop();
View Full Code Here

Examples of com.lowagie.text.pdf.PdfPTable

         
          if(preProcessor != null) {
          preProcessor.invoke(facesContext.getELContext(), new Object[]{document});
        }
         
      PdfPTable pdfTable = exportPDFTable(table, pageOnly,excludeColumns, encodingType);
        document.add(pdfTable);
       
        if(postProcessor != null) {
          postProcessor.invoke(facesContext.getELContext(), new Object[]{document});
        }
View Full Code Here

Examples of com.lowagie.text.pdf.PdfPTable

  }
 
  private PdfPTable exportPDFTable(UIData table, boolean pageOnly, int[] excludeColumns, String encoding) {
    List<UIColumn> columns = getColumnsToExport(table, excludeColumns);
      int numberOfColumns = columns.size();
      PdfPTable pdfTable = new PdfPTable(numberOfColumns);
      Font font = FontFactory.getFont(FontFactory.TIMES, encoding);
      Font headerFont = FontFactory.getFont(FontFactory.TIMES, encoding, Font.DEFAULTSIZE, Font.BOLD);
     
      int first = pageOnly ? table.getFirst() : 0;
      int size = pageOnly ? (first + table.getRows()) : table.getRowCount();
View Full Code Here

Examples of com.lowagie.text.pdf.PdfPTable

//          image.setAbsolutePosition(450, 730);
//          writer.addDirectImageSimple(image);
//     
     
      doc.open();
       PdfPTable headerTable= new PdfPTable(2);
          Image ii = Image.getInstance("c:/smi-logo.gif");
          ii.setAlignment(Element.ALIGN_RIGHT);
          ii.scalePercent(25);
      
          PdfPCell cell1 = new PdfPCell(ii,false);
          cell1.setBorder(0);
         
          headerTable.addCell(cell1);
      
       //   cell = borderlessCell("Code of Doom Order Form");
         

       

Date now = new Date();
System.out.println("date--> " + now);
DateFormat df = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a");
String s1 = df.format(now);
         
Chunk CONNECT = new Chunk(new LineSeparator(5.5f, 95, Color.BLUE, Element.ALIGN_CENTER, 3.5f));
  //  LineSeparator UNDERLINE =new LineSeparator(1, 100, null, Element.ALIGN_CENTER, -2);

//public HeaderFooter getMyHeader(String titulo) throws ServletException { 
//    Phrase p= new Phrase(); 
//    Chunk chunkTemp = new Chunk("My Company Name\n", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.NORMAL); 
//    p.add(chunkTemp); 
//    chunkTemp = new Chunk("_____________________________________________________________________________________________________", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.NORMAL); 
//    p.add(chunkTemp); 
//    HeaderFooter header = new HeaderFooter(p, false); 
//    return header; 



          headerTable.addCell(main.borderlessCell(s1));
      
//          headerTable.addCell(borderlessCell("Customer Name"));
//          headerTable.addCell(borderlessCell(c.getName()));
//          headerTable.addCell(borderlessCell("Address"));
//          headerTable.addCell(borderlessCell(c.getAddress()));
//          headerTable.addCell(borderlessCell("Phone Number"));
//          headerTable.addCell(borderlessCell(c.getPhone()));
          doc.add(headerTable);
//              Phrase phrase = new Phrase(50);
//              doc.add(phrase);
          Paragraph paragraph = new Paragraph( "");
          main.addEmptyLine(paragraph,10);
         paragraph.add(CONNECT);
          doc.add( paragraph )
         
//          Chunk c = new Chunk( text, font );
//          c.setAction( new PdfAction( new URL( url ) ) );
//          c.setUnderline(0.8f, -0.8f);
//          doc.add( c );
         
         
         
         
          PdfPTable tab=new PdfPTable(6);
        PdfPCell cell = new PdfPCell(new Paragraph("Process Details"));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBackgroundColor(new Color(20,105,160));
        cell.setColspan(6);
        tab.addCell(cell);
        tab.addCell("id");
        tab.addCell("pid");
        tab.addCell("mid");
        tab.addCell("processname");
        tab.addCell("workingsetsize");
        tab.addCell("date");
        doc.add(tab);
       
     
     
     
      PdfPTable table=new PdfPTable(i);
      Iterator it =list.iterator();
            while(it.hasNext())
            {
              Object o[]=(Object [])it.next();
             
              //                   System.out.println(o[0] + "==" + o[1]);
                 
               //  String str=(String) it.next();
                 for(int j=0; j<i; j++ )
                 {
                   System.out.println(o[j]);
                  
        //table.addCell(o[j]);//String.valueOf(list.get(i).getProcessName()));
        table.addCell(String.valueOf(o[j]));
       
      }}
            System.out.println("loop complate");
      doc.add(table);
      System.out.println("add table complate");
View Full Code Here

Examples of com.lowagie.text.pdf.PdfPTable

            Image image = Image.getInstance( DroolsDocsBuilder.class.getResource( "drools-guvnor.png" ) );
            image.setAlignment( Image.RIGHT );
            image.scaleAbsolute( 100,
                                 30 );
            Rectangle page = document.getPageSize();
            PdfPTable head = new PdfPTable( 2 );

            PdfPCell cell1 = new PdfPCell( image );
            cell1.setHorizontalAlignment( Element.ALIGN_LEFT );
            cell1.setBorder( 0 );

            head.addCell( cell1 );

            PdfPCell cell2 = new PdfPCell( new Phrase( currentDate,
                                                       DroolsDocsComponentFactory.HEADER_FOOTER_TEXT ) );
            cell2.setHorizontalAlignment( Element.ALIGN_RIGHT );
            cell2.setBorder( 0 );

            head.addCell( cell2 );

            head.setTotalWidth( page.getWidth() - document.leftMargin() - document.rightMargin() );
            head.writeSelectedRows( 0,
                                    -1,
                                    document.leftMargin(),
                                    page.getHeight() - document.topMargin() + head.getTotalHeight(),
                                    writer.getDirectContent() );

        } catch ( Exception e ) {
            throw new ExceptionConverter( e );
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.