Package com.lowagie.text.pdf

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


      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

      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

         
          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

  }
 
  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

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

            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

  public void flush(){
    getMe();
  }

  public PdfPTable getMe() {
    PdfPTable tabla = new PdfPTable(columnas);
   
    Iterator it = celdas.iterator();
    while (it.hasNext()) {
      CeldaPDF celda = (CeldaPDF) it.next();
      tabla.addCell(celda.getMe());
    }
    try {
      if (tamanioColumnas!=null){
        float[] widths = new float[tamanioColumnas.size()];
        for (int i = 0; i < tamanioColumnas.size(); i++) {
            Float f = tamanioColumnas.get(i);
            widths[i] = (f != null ? f : Float.NaN); // Or whatever default you want.
        }
        tabla.setWidths(widths);
      }
      if (agregarADocumento.booleanValue()){
        documento.add(tabla);
      }
    } catch (DocumentException e) {
View Full Code Here

        // TODO Auto-generated catch block
        e.printStackTrace();
      }
        }
        // does it have table info?
        PdfPTable table = cell.getTable();
        if(table != null) {
          this.add(table);
//            try {
//        RtfBasicElement[] rtfElements = this.document.getMapper().mapElement(table);
//        for (int i = 0; i < rtfElements.length; i++) {
View Full Code Here

        document.open();
        if (rowList.size() > 0) {
          Paragraph p = new Paragraph(rowList.get(0).get(0).toString());

          document.add(p);
          PdfPTable table = new PdfPTable(9);
          table.setSpacingBefore(20);
          for (int i = 1; i < rowList.size(); i++) {

            List<HSSFCell> row = rowList.get(i);
            for (int j = 0; j < row.size(); j++) {
              HSSFCell myCell = row.get(j);
              // TODO aufhübschen und nicht toString() nutzen

              String stringCellValue = myCell.toString();
              table.addCell(stringCellValue);
            }

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

TOP

Related Classes of com.lowagie.text.pdf.PdfPTable

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.