Package com.lowagie.text.pdf

Examples of com.lowagie.text.pdf.PdfPTable


    for (PdfPCell pdfPCell : commantaireTableHeader) {
      pdfPCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    }
 
    PdfPTable commantaireTable = new PdfPTable(1);
   
    //addCellsToTable(commantaireTable, commantaireTableHeader);
    PdfPCell pdfPCell = new PdfPCell(new Phrase(commentaire + "\n" + internalCommentaire, contentNormalFont));
    pdfPCell.setBorder(Rectangle.NO_BORDER);
    commantaireTable.addCell(pdfPCell)
    float[] wf = {
        15
      };
    try {
      commantaireTable.setWidths(wf);
      commantaireTable.setHorizontalAlignment(PdfPTable.ALIGN_LEFT);
    } catch (DocumentException e) {
      e.printStackTrace();
    }
    return commantaireTable;
  }
View Full Code Here


    addProcessDto();
  }
 
  private void addProcessDto() throws DocumentException {   
    //Title
    PdfPTable headerTable = new PdfPTable(1);
    headerTable.setWidthPercentage(100f);
   
    PdfPCell headerCell = new PdfPCell(new Phrase(messageSource.getMessage("pdf.process.titlebox.suividesavancementssusoustraitant", null, localtion), contentBoldFont));
    headerCell.setBorder(Rectangle.NO_BORDER);
    headerCell.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
    headerTable.addCell(headerCell);
    addContent(headerTable);
   
    //Information Generals
    headerTable = new PdfPTable(1);
    headerTable.setWidthPercentage(100f);
    headerCell = new PdfPCell(new Phrase(messageSource.getMessage("FicheST.generalInformation", null, localtion), contentBoldFont));
    headerCell.setBorder(Rectangle.NO_BORDER);
    headerCell.setHorizontalAlignment(PdfPTable.ALIGN_LEFT);
    headerTable.addCell(headerCell);
    addContent(headerTable);
 
    // Information Details
    String arrGeneraleInformation[]= generaleInformation.split(Constants.SEPRATE);
    PdfPTable generaleInformationTable = new PdfPTable(6);
    PdfPCell generaleInformationCell;
    generaleInformationTable.setWidthPercentage(100f);
    String [] messages = {messageSource.getMessage("FicheST.chantier",null, localtion) + " : ",messageSource.getMessage("FicheST.lot", null, localtion) + " : ",
        messageSource.getMessage("FicheST.foreman", null, localtion) + " : ",
        messageSource.getMessage("pdf.synthese.societe", null, localtion) + " : ",messageSource.getMessage("FicheST.lotType", null, localtion) + " : ",
        messageSource.getMessage("pdf.gestiondto.montantobjectif",null,localtion) + " : "};
    for(int i=0;i<arrGeneraleInformation.length;i++){
      switch (i) {
        case 0
          generaleInformationCell = new PdfPCell(new Phrase(messages[0], contentBoldFont));
          generaleInformationCell.setBorder(Rectangle.NO_BORDER);
          generaleInformationCell.enableBorderSide(Rectangle.TOP);
          generaleInformationCell.enableBorderSide(Rectangle.LEFT);
          generaleInformationTable.addCell(generaleInformationCell);
         
          break;
        case 1
          generaleInformationCell = new PdfPCell(new Phrase(messages[1], contentBoldFont));
          generaleInformationCell.setBorder(Rectangle.NO_BORDER);
          generaleInformationCell.enableBorderSide(Rectangle.TOP);
          generaleInformationTable.addCell(generaleInformationCell);
          break;
        case 2
          generaleInformationCell = new PdfPCell(new Phrase(messages[2], contentBoldFont));
          generaleInformationCell.setBorder(Rectangle.NO_BORDER);
          generaleInformationCell.enableBorderSide(Rectangle.TOP);
          generaleInformationTable.addCell(generaleInformationCell);
          break;
        case 3
          generaleInformationCell = new PdfPCell(new Phrase(messages[3], contentBoldFont));
          generaleInformationCell.setBorder(Rectangle.NO_BORDER);
          generaleInformationCell.enableBorderSide(Rectangle.BOTTOM);
          generaleInformationCell.enableBorderSide(Rectangle.LEFT);
          generaleInformationTable.addCell(generaleInformationCell);
          break;
        case 4
          generaleInformationCell = new PdfPCell(new Phrase(messages[4], contentBoldFont));
          generaleInformationCell.setBorder(Rectangle.NO_BORDER);
          generaleInformationCell.enableBorderSide(Rectangle.BOTTOM);
          generaleInformationTable.addCell(generaleInformationCell);
          break;
        case 5
          generaleInformationCell = new PdfPCell(new Phrase(messages[5], contentBoldFont));
          generaleInformationCell.setBorder(Rectangle.NO_BORDER);
          generaleInformationCell.enableBorderSide(Rectangle.BOTTOM);
          generaleInformationTable.addCell(generaleInformationCell);
          break;
      }
      generaleInformationCell = new PdfPCell(new Phrase(arrGeneraleInformation[i].equals("null") ? "" : arrGeneraleInformation[i], contentNormalFont));
      if(i == 0 || i == 1 || i == 2){
        generaleInformationCell.setBorder(Rectangle.NO_BORDER);
        generaleInformationCell.enableBorderSide(Rectangle.TOP);
        if(i == 2)
          generaleInformationCell.enableBorderSide(Rectangle.RIGHT);
        generaleInformationTable.addCell(generaleInformationCell);
      }
      if(i == 3 || i == 4 || i == 5){
        generaleInformationCell.setBorder(Rectangle.NO_BORDER);
        generaleInformationCell.enableBorderSide(Rectangle.BOTTOM);
        if(i == 5)
          generaleInformationCell.enableBorderSide(Rectangle.RIGHT);
        generaleInformationTable.addCell(generaleInformationCell);
      }
    }
    float[] wfGeneraleInformation = {
        3,
        6,
        3,
        6,
        7,
        6
      };
    generaleInformationTable.setWidths(wfGeneraleInformation);
    addContent(generaleInformationTable);
    lineBreak();
   
    headerTable = new PdfPTable(1);
    headerTable.setWidthPercentage(100f);
    headerTable.setSpacingAfter(15f);
    headerCell = new PdfPCell(new Phrase(messageSource.getMessage("pdf.process.titlebox.suvidesavancements", null, localtion), contentBoldFont));
    headerCell.setBorder(Rectangle.NO_BORDER);
    headerTable.addCell(headerCell);
    headerTable.setSpacingAfter(0f);
    addContent(headerTable);
   
    headerTable = new PdfPTable(2);
    headerTable.setWidthPercentage(40f);
    headerTable.setHorizontalAlignment(Rectangle.ALIGN_LEFT);
    headerTable.setSpacingAfter(15f);
    float[] wf1 = {
        5,10 };
    headerCell = new PdfPCell(new Phrase(messageSource.getMessage("pdf.process.titlebox.etatdavancement", null, localtion) + " : ", contentBoldFont));
    headerCell.setBorder(Rectangle.NO_BORDER);
    headerTable.addCell(headerCell);
   
    headerCell = new PdfPCell(new Phrase(etatAvancement + Constants.SPACE + messageSource.getMessage("pdf.process.titlebox.percentavancementmarche", null, localtion), contentNormalFont));
    headerCell.setBorder(Rectangle.NO_BORDER);
    headerTable.addCell(headerCell);
    headerTable.setSpacingAfter(0f);
    headerTable.setWidths(wf1);
    addContent(headerTable);
   
    PdfPTable parent = new PdfPTable(3);
    parent.setSpacingBefore(0f);
    parent.setWidthPercentage(100f);
    float[] wfParent = {
        70,
        5,
        25
      };
    parent.setWidths(wfParent);
    PdfPCell cellLeft,cellMiddle,cellRight;

    //Add Group Header
    PdfPCell[] groupHeaderCell = new PdfPCell[3];
    groupHeaderCell[0] = new PdfPCell();
    groupHeaderCell[0].setBorder(Rectangle.NO_BORDER);
   
    groupHeaderCell[1] = new PdfPCell(new Phrase(messageSource.getMessage("pdf.process.titlebox.advancement", null, localtion), contentBoldFont));
    groupHeaderCell[1].setBackgroundColor(new Color(181,181,181));

    groupHeaderCell[2] = new PdfPCell(new Phrase(messageSource.getMessage("pdf.process.titlebox.retenues", null, localtion), contentBoldFont));
    groupHeaderCell[2].setBackgroundColor(new Color(181,181,181));
   
    float[] wfGroupHeader = {
        25,
        20,
        20
      };
    for (PdfPCell pdfPCell : groupHeaderCell) {
      pdfPCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    }

    PdfPTable groupHeaderTable = new PdfPTable(3);
    groupHeaderTable.setWidthPercentage(100f);
    groupHeaderTable.setWidths(wfGroupHeader);
    addCellsToTable(groupHeaderTable,groupHeaderCell);
   
    cellLeft = new PdfPCell(groupHeaderTable);
    cellLeft.setBorder(Rectangle.NO_BORDER);
    parent.addCell(cellLeft);
   
    cellMiddle = new PdfPCell();
    cellMiddle.setBorder(Rectangle.NO_BORDER);
    parent.addCell(cellMiddle);
   
    cellRight = new PdfPCell(new Phrase(messageSource.getMessage("FicheST.comment2", null, localtion) + " : ", contentBoldFont));
    cellRight.setBorder(Rectangle.NO_BORDER);
    parent.addCell(cellRight);

    //Header
    //create table header
    PdfPCell[] processTableHeader = new PdfPCell[7];
    processTableHeader[0] = new PdfPCell(new Phrase(messageSource.getMessage("FicheST.number", null, localtion), contentBoldFont));
    processTableHeader[1] = new PdfPCell(new Phrase(messageSource.getMessage("pdf.process.titlebox.libelle", null, localtion), contentBoldFont));
    processTableHeader[2] = new PdfPCell(new Phrase(messageSource.getMessage("pdf.process.titlebox.date", null, localtion), contentBoldFont));
    processTableHeader[3] = new PdfPCell(new Phrase(messageSource.getMessage("pdf.process.titlebox.cumule", null, localtion), contentBoldFont));
    processTableHeader[4] = new PdfPCell(new Phrase(messageSource.getMessage("pdf.process.titlebox.mois", null, localtion), contentBoldFont));
    processTableHeader[5] = new PdfPCell(new Phrase(messageSource.getMessage("pdf.process.titlebox.cumule", null, localtion), contentBoldFont));
    processTableHeader[6] = new PdfPCell(new Phrase(messageSource.getMessage("pdf.process.titlebox.mois", null, localtion), contentBoldFont));
   
    for (PdfPCell pdfPCell : processTableHeader) {
      pdfPCell.setBackgroundColor(new Color(181,181,181));
      pdfPCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    }
    //End
    PdfPTable processDtoTable = new PdfPTable(COL);
    processDtoTable.setWidthPercentage(100f);
    addCellsToTable(processDtoTable, processTableHeader);
   
    float[] wf = {
        5,   //No 3
        10//Libellé risque codification
        10,   //Origine de détection
        10,   //CR 3
        10// Niveau de risque 5
        10,
        10
      };
    processDtoTable.setWidthPercentage(70f);
    processDtoTable.setWidths(wf);
    processDtoTable.setHorizontalAlignment(PdfPTable.ALIGN_LEFT);

    cellLeft = new PdfPCell(processDtoTable);
    cellLeft.setBorder(Rectangle.NO_BORDER);
    parent.addCell(cellLeft);
   
    cellMiddle = new PdfPCell();
    cellMiddle.setBorder(Rectangle.NO_BORDER);
   
    parent.addCell(cellMiddle);
   
    cellRight = new PdfPCell();
    cellRight.setBorder(Rectangle.NO_BORDER);
    cellRight.enableBorderSide(Rectangle.TOP);
    cellRight.enableBorderSide(Rectangle.RIGHT);
    cellRight.enableBorderSide(Rectangle.LEFT);
    parent.addCell(cellRight);
   
   
    processDtoTable.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
   
    String tmp;
    processDtoTable = new PdfPTable(COL);
    if(processes!=null && processes.length() > 0){
      String arr[] = processes.split(Constants.SEPRATE);
      for(int i=0;i < arr.length;i++){
        tmp = arr[i];
        processDtoTable.addCell(new PdfPCell(new Phrase(tmp.equals("null") ? "" : tmp, contentNormalFont)));
      }
      processDtoTable.setWidthPercentage(70f);
      processDtoTable.setWidths(wf);
      processDtoTable.setHorizontalAlignment(PdfPTable.ALIGN_LEFT);
    }
    cellLeft = new PdfPCell(processDtoTable);
    parent.addCell(cellLeft);
   
    cellMiddle = new PdfPCell();
    cellMiddle.setBorder(Rectangle.NO_BORDER);
    parent.addCell(cellMiddle);
   
    PdfPTable commanttaire = addProcessCommantaire();
    commanttaire.setWidthPercentage(70f);
    cellRight = new PdfPCell(commanttaire);
    cellRight.setBorder(Rectangle.NO_BORDER);
    cellRight.enableBorderSide(Rectangle.RIGHT);
    cellRight.enableBorderSide(Rectangle.LEFT);
    parent.addCell(cellRight);
View Full Code Here

    addContent(parent);
   
  }
 
  private PdfPTable addtotalsituation(String totalsituation){
    PdfPTable processDtoTable = new PdfPTable(5);
    processDtoTable.addCell(new PdfPCell(new Phrase(messageSource.getMessage("FicheST.totalSituation",null, localtion), contentBoldFont)));
    boolean isEmpty = true;
    if(totalsituation!=null && totalsituation.length() > 0){
      String[] tmp = totalsituation.split(Constants.SEPRATE);
      if(tmp != null && tmp.length > 3){
        processDtoTable.addCell(new PdfPCell(new Phrase(tmp[0], contentNormalFont)));
        processDtoTable.addCell(new PdfPCell(new Phrase(tmp[1], contentNormalFont)));
        processDtoTable.addCell(new PdfPCell(new Phrase(tmp[2], contentNormalFont)));
        processDtoTable.addCell(new PdfPCell(new Phrase(tmp[3], contentNormalFont)));
        isEmpty = false;
      }
    }
    if(isEmpty){
      processDtoTable.addCell(new PdfPCell(new Phrase("0", contentNormalFont)));
      processDtoTable.addCell(new PdfPCell(new Phrase("0", contentNormalFont)));
      processDtoTable.addCell(new PdfPCell(new Phrase("0", contentNormalFont)));
      processDtoTable.addCell(new PdfPCell(new Phrase("0", contentNormalFont)));
    }

    float[] wf = {
        25,
        10,
        10,
        10,
        10
      };
    try {
      processDtoTable.setWidths(wf);
    } catch (DocumentException e) {
      e.printStackTrace();
    }
    return processDtoTable;
  }
View Full Code Here

   
    for (PdfPCell pdfPCell : grid2TableHeader) {
      pdfPCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    }
   
    PdfPTable grid2Table = new PdfPTable(3);
    PdfPCell grid2Cell;
   
    addCellsToTable(grid2Table, grid2TableHeader);
    String[] tmp = grid2.split(Constants.SEPRATE);
    String[] messages = {messageSource.getMessage("FicheST.Refacturations", null, localtion) ,messageSource.getMessage("FicheST.Prorata", null, localtion),
        messageSource.getMessage("FicheST.RefacturationsDontProrata", null, localtion),messageSource.getMessage("FicheST.RefacturationsDontProrataEtAutre", null, localtion),
        messageSource.getMessage("pdf.process.titlebox.penalites", null, localtion)};
   
    for(int i=0; i < tmp.length ; i++){
      switch (i) {
      case 0:
        grid2Cell = new PdfPCell(new Phrase(messages[0], contentBoldFont));
        grid2Cell.setBackgroundColor(new Color(181,181,181));
        grid2Table.addCell(grid2Cell);
        break;
      case 2:
        grid2Cell = new PdfPCell(new Phrase(messages[1], contentBoldFont));
        grid2Cell.setBackgroundColor(new Color(181,181,181));
        grid2Table.addCell(grid2Cell);
        break;
      case 4:
        grid2Cell = new PdfPCell(new Phrase(messages[2], contentBoldFont));
        grid2Cell.setBackgroundColor(new Color(181,181,181));
        grid2Table.addCell(grid2Cell);
        break;
      case 6:
        grid2Cell = new PdfPCell(new Phrase(messages[3], contentBoldFont));
        grid2Cell.setBackgroundColor(new Color(181,181,181));
        grid2Table.addCell(grid2Cell);
        break;
      case 8:
        grid2Cell = new PdfPCell(new Phrase(messages[4], contentBoldFont));
        grid2Cell.setBackgroundColor(new Color(181,181,181));
        grid2Table.addCell(grid2Cell);
        break;
      }
      grid2Table.addCell(new PdfPCell(new Phrase(tmp[i], contentBoldFont)));
   
    float[] wf = {
        25,
        10,
        20
      };
    grid2Table.setHorizontalAlignment(PdfPTable.ALIGN_LEFT);
    grid2Table.setWidths(wf);
    return grid2Table;
  }
View Full Code Here

   
   
    for (PdfPCell pdfPCell : grid3TableHeader) {
      pdfPCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
   
    PdfPTable grid3Table = new PdfPTable(8);
    PdfPCell grid3Cell;
   
    addCellsToTable(grid3Table, grid3TableHeader);
     
    String[] tmp = grid3.split(Constants.SEPRATE);
   
    String[] messages = {"Nombre","Montant"};
    for(int i=0; i < tmp.length ; i++){
      switch (i) {
      case 0:
        grid3Cell = new PdfPCell(new Phrase(messages[0], contentBoldFont));
        grid3Cell.setBackgroundColor(new Color(181,181,181));
        grid3Table.addCell(grid3Cell);
        break;
      case 7:
        grid3Cell = new PdfPCell(new Phrase(messages[1], contentBoldFont));
        grid3Cell.setBackgroundColor(new Color(181,181,181));
        grid3Table.addCell(grid3Cell);
        break;
      }
      grid3Table.addCell(new PdfPCell(new Phrase(tmp[i], contentNormalFont)));
   
    float[] wf = {
        15,
        10,
        10,
        10,
        10,
        10,10,
        10
      };
    grid3Table.setWidths(wf);
    grid3Table.setHorizontalAlignment(PdfPTable.ALIGN_LEFT);
    return grid3Table;
  }
View Full Code Here

    return grid3Table;
  }
 
  private PdfPTable addProcessCommantaire() throws DocumentException{
    //create table header
    PdfPTable commantaireTable = new PdfPTable(1);
    PdfPCell pdfPCell = new PdfPCell(new Phrase(commentaire.equals("null") ? "" : commentaire, contentNormalFont));
    pdfPCell.setBorder(Rectangle.NO_BORDER);
    commantaireTable.addCell(pdfPCell)
    float[] wf = {
        15
      };
    commantaireTable.setWidths(wf);
    commantaireTable.setHorizontalAlignment(PdfPTable.ALIGN_LEFT);
    return commantaireTable;
  }
View Full Code Here

    int startLine = 0;
    int startColumn = 0;
    int endLine = matrix.length;
    int endColumn = colNumber;

    PdfPTable table = new PdfPTable(colNumber);
    table.setWidths(widths);
    table.setWidthPercentage(98.3f);

    PdfPCell headerCell = new PdfPCell(header);
    headerCell.setColspan(colNumber);
    headerCell.setBackgroundColor(HEADER_COLOR);
    table.addCell(headerCell);

    //BaseFont font = BaseFont.createFont("Helvetica", "winansi", false);
    for (int lineIndex = startLine; lineIndex < endLine; lineIndex++) {
      for (int colIndex = startColumn; colIndex < endColumn; colIndex++) {

        PdfPCell cell = new PdfPCell(matrix[lineIndex][colIndex]);
        cell.setFixedHeight(80f);
        cell.setLeading(50f, 0f);
        cell.setHorizontalAlignment(DEFAULT_HORZ_ALIGN);
        cell.setVerticalAlignment(DEFAULT_VERT_ALIGN);

        table.addCell(cell);
      }
    }

    return table;
  }
View Full Code Here

         * com.lowagie.text.Document)
         */
        public void onEndPage(PdfWriter writer, Document document)
        {
            /** The headertable. */
            PdfPTable table = new PdfPTable(2);
            /** A template that will hold the total number of pages. */
            PdfTemplate tpl = writer.getDirectContent().createTemplate(100, 100);
            /** The font that will be used. */
            BaseFont helv = null;
            try
            {
                helv = BaseFont.createFont("Helvetica", BaseFont.WINANSI, false);
            }
            catch (DocumentException e)
            {
            }
            catch (IOException e)
            {
            }
            PdfContentByte cb = writer.getDirectContent();
            cb.saveState();
            // write the headertable
            table.setTotalWidth(document.right() - document.left());
            table.writeSelectedRows(0, -1, document.left(), document.getPageSize().getHeight() - 50, cb);
            // compose the footer
            String text = "Page " + writer.getPageNumber();
            float textSize = helv.getWidthPoint(text, 12);
            float textBase = document.bottom() - 20;
            cb.beginText();
View Full Code Here

    }
  }
 
  protected PdfPTable exportPDFTable(FacesContext context, DataTable table, boolean pageOnly, boolean selectionOnly, String encoding) {
      int columnsCount = getColumnsCount(table);
      PdfPTable pdfTable = new PdfPTable(columnsCount);
      this.cellFont = FontFactory.getFont(FontFactory.TIMES, encoding);
      this.facetFont = FontFactory.getFont(FontFactory.TIMES, encoding, Font.DEFAULTSIZE, Font.BOLD);
     
      addColumnFacets(table, pdfTable, ColumnType.HEADER);
       
View Full Code Here

      return pdfTable;
  }
   
    @Override
    protected void exportCells(DataTable table, Object document) {
        PdfPTable pdfTable = (PdfPTable) document;
        for (UIColumn col : table.getColumns()) {
            if (col instanceof DynamicColumn) {
                ((DynamicColumn) col).applyStatelessModel();
            }
           
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.