Example usage for com.itextpdf.text.pdf PdfPTable addCell

List of usage examples for com.itextpdf.text.pdf PdfPTable addCell

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfPTable addCell.

Prototype

public void addCell(final Phrase phrase) 

Source Link

Document

Adds a cell element.

Usage

From source file:be.mxs.common.util.pdf.general.dossierCreators.StaffDossierPDFCreator.java

private void displayTimeBlock(PdfPTable table, String sDayIdx, String sBeginHour, String sEndHour,
        String sDuration, boolean isInDefaultSchedule) {
    table.addCell(createValueCell(
            getTimeblockDetails(sDayIdx, sBeginHour, sEndHour, sDuration, isInDefaultSchedule), 10));
}

From source file:be.mxs.common.util.pdf.general.dossierCreators.StaffDossierPDFCreator.java

private void displayLanguageSkills(PdfPTable table, String sLS) {
    if (sLS.length() > 0 && sLS.indexOf("|") > -1) {
        // header
        table.addCell(createHeaderCell(getTran("web.hr", "languages"), 10));

        // subtitle
        table.addCell(createSubtitleCell(getTran("web.hr", "languages.language"), 4));
        table.addCell(createSubtitleCell(getTran("web.hr", "languages.spoken"), 2));
        table.addCell(createSubtitleCell(getTran("web.hr", "languages.reading"), 2));
        table.addCell(createSubtitleCell(getTran("web.hr", "languages.writing"), 2));

        String sTmpLang, sTmpSpoken, sTmpReading, sTmpWriting;
        String sTmpLS = sLS;//ww  w .  j a va2 s.c o  m
        sLS = "";

        // parse value
        while (sTmpLS.indexOf("$") > -1) {
            sTmpLang = "";
            sTmpSpoken = "";
            sTmpReading = "";
            sTmpWriting = "";

            if (sTmpLS.indexOf("|") > -1) {
                sTmpLang = sTmpLS.substring(0, sTmpLS.indexOf("|"));
                sTmpLS = sTmpLS.substring(sTmpLS.indexOf("|") + 1);
            }

            if (sTmpLS.indexOf("|") > -1) {
                sTmpSpoken = sTmpLS.substring(0, sTmpLS.indexOf("|"));
                sTmpLS = sTmpLS.substring(sTmpLS.indexOf("|") + 1);
            }

            if (sTmpLS.indexOf("|") > -1) {
                sTmpReading = sTmpLS.substring(0, sTmpLS.indexOf("|"));
                sTmpLS = sTmpLS.substring(sTmpLS.indexOf("|") + 1);
            }

            if (sTmpLS.indexOf("$") > -1) {
                sTmpWriting = sTmpLS.substring(0, sTmpLS.indexOf("$"));
                sTmpLS = sTmpLS.substring(sTmpLS.indexOf("$") + 1);
            }

            // one language skill
            table.addCell(createValueCell(getTran("hr.skills.languages", sTmpLang), 4));
            table.addCell(createValueCell(getTran("hr.skills.range1", sTmpSpoken), 2));
            table.addCell(createValueCell(getTran("hr.skills.range1", sTmpReading), 2));
            table.addCell(createValueCell(getTran("hr.skills.range1", sTmpWriting), 2));
        }
    } else {
        // no records found
        table.addCell(createValueCell(getTran("web", "noRecordsFound"), 10));
    }
}

From source file:be.mxs.common.util.pdf.general.dossierCreators.StaffDossierPDFCreator.java

private void displayComputerSkills(PdfPTable table, Skill skill) {
    if (skill.itOffice.length() > 0 || skill.itInternet.length() > 0 || skill.itOther.length() > 0) {
        // header
        table.addCell(createHeaderCell(getTran("web.hr", "computerSkills"), 10));

        // a - office
        table.addCell(createValueCell(getTran("web.hr", "itOffice"), 4));
        table.addCell(createValueCell(getTran("hr.skills.range1", skill.itOffice), 6));

        // b - internet
        table.addCell(createValueCell(getTran("web.hr", "itInternet"), 4));
        table.addCell(createValueCell(getTran("hr.skills.range1", skill.itInternet), 6));

        // c - other
        table.addCell(createValueCell(getTran("web.hr", "itOther"), 4));
        table.addCell(createValueCell(skill.itOther.replaceAll("\r\n", ", "), 6));
    } else {//from  www .  jav  a 2  s  .co  m
        // no records found
        table.addCell(createValueCell(getTran("web", "noRecordsFound"), 10));
    }
}

From source file:be.mxs.common.util.pdf.general.oc.examinations.PDFDrivingLicenseDeclaration.java

private void addQuestionnaire() {
    if (isAtLeastOneQuestionAnswered()) {
        contentTable = new PdfPTable(1);
        table = new PdfPTable(5);

        PdfPTable questions = new PdfPTable(40);

        // header
        questions.addCell(createTitleCell(
                getTran("medwan.common.driving-license-declaration.candidate-questionnaire"), 40));

        // questions
        String questionPrefix = "medwan.common.driving-license-declaration.candidate-questionnaire.question-";
        for (int i = 1; i <= 20; i++) {
            questions = addQuestion(questions, i, getTran(questionPrefix + i),
                    IConstants_PREFIX + "ITEM_TYPE_DLD_Q" + i);
        }//from www.ja  v a  2 s  . c o  m

        // commitment
        String commPart1 = getTran(
                "medwan.common.driving-license-declaration.candidate-questionnaire.commitment") + " ";
        String commPart2 = getTran(
                "medwan.common.driving-license-declaration.candidate-questionnaire.commitment1");

        cell = new PdfPCell(new Phrase(commPart1 + commPart2, FontFactory.getFont(FontFactory.HELVETICA,
                Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
        cell.setColspan(40);
        cell.setBorder(PdfPCell.BOX);
        cell.setBorderColor(innerBorderColor);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        questions.addCell(cell);

        // add content to document
        if (questions.size() > 0) {
            contentTable
                    .addCell(createCell(new PdfPCell(questions), 1, PdfPCell.ALIGN_CENTER, PdfPCell.NO_BORDER));
            tranTable.addCell(createContentCell(contentTable));
        }
    }
}

From source file:be.mxs.common.util.pdf.general.oc.examinations.PDFDrivingLicenseDeclaration.java

private PdfPTable addQuestion(PdfPTable table, int id, String question, String answer) {
    // cel 1 : nr
    cell = new PdfPCell(new Phrase(id + "", FontFactory.getFont(FontFactory.HELVETICA,
            Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL)));
    cell.setColspan(1);/*from  w  w  w  .  j  av  a2 s .co  m*/
    cell.setBorder(PdfPCell.BOX);
    cell.setBorderColor(innerBorderColor);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);

    // cel 2-38 : question
    cell = new PdfPCell(new Phrase(question, FontFactory.getFont(FontFactory.HELVETICA,
            Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL)));
    cell.setColspan(37);
    cell.setBorder(PdfPCell.BOX);
    cell.setBorderColor(innerBorderColor);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);

    // cel 39 and 40 : answer
    cell = new PdfPCell(new Phrase(getTran(getItemValue(answer)), FontFactory.getFont(FontFactory.HELVETICA,
            Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL)));
    cell.setColspan(2);
    cell.setBorder(PdfPCell.BOX);
    cell.setBorderColor(innerBorderColor);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);

    return table;
}

From source file:be.rheynaerde.poolsheets.AbstractPoolSheet.java

License:Open Source License

protected void buildTitle(Document document) throws DocumentException {
    //the title is placed in a one-column table of width 100%
    PdfPTable table = new PdfPTable(1);
    table.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
    table.setWidthPercentage(100f);//from   www .  ja  va 2 s  . c  o m

    //one row for the title
    PdfPCell cell = new PdfPCell(new Phrase(configuration.getTitle(), configuration.getTitleFont()));
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setPaddingBottom(10f);
    table.addCell(cell);

    //one row for the subtitle
    cell = new PdfPCell(new Phrase(configuration.getSubtitle(), configuration.getSubtitleFont()));
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setBorder(Rectangle.TOP);
    table.addCell(cell);

    //make sure that there is some spacing between the title and the scores
    //20f just seems to work allright, but maybe something more configurable
    //would be better.
    table.setSpacingAfter(20f);
    document.add(table);
}

From source file:be.rheynaerde.poolsheets.AbstractPoolSheet.java

License:Open Source License

protected void buildBoutOrder(Document document) throws DocumentException {
    PdfPTable table = new PdfPTable(configuration.getBoutOrderColumns());
    BoutOrder mo = configuration.getBoutOrder();
    if (mo.getNrOfBouts() == 0)
        return;//w w w  . j  a  v  a2  s.  c o  m
    int rows = mo.getNrOfBouts() / configuration.getBoutOrderColumns();
    if (mo.getNrOfBouts() % configuration.getBoutOrderColumns() != 0)
        rows++;
    int shortComing = (rows - (mo.getNrOfBouts() % rows)) % rows;
    for (int i = 0; i < rows - shortComing; i++) {
        for (int j = 0; j < configuration.getBoutOrderColumns(); j++) {
            int boutNumber = j * rows + i;
            table.addCell(getBoutCell(mo, boutNumber));
        }
        for (int j = 0; j < configuration.getBoutOrderSpacing(); j++) {
            for (int k = 0; k < configuration.getBoutOrderColumns(); k++) {
                PdfPCell spacing = new PdfPCell();
                spacing.setBorder(Rectangle.NO_BORDER);
                spacing.setFixedHeight(configuration.getSquareCellSize());
                table.addCell(spacing);
            }
        }
    }
    for (int i = rows - shortComing; i < rows; i++) {
        for (int j = 0; j < configuration.getBoutOrderColumns() - 1; j++) {
            int boutNumber = j * rows + i;
            table.addCell(getBoutCell(mo, boutNumber));
        }
        PdfPCell cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);
        for (int j = 0; j < configuration.getBoutOrderSpacing(); j++) {
            for (int k = 0; k < configuration.getBoutOrderColumns(); k++) {
                PdfPCell spacing = new PdfPCell();
                spacing.setBorder(Rectangle.NO_BORDER);
                spacing.setFixedHeight(configuration.getSquareCellSize());
                table.addCell(spacing);
            }
        }
    }
    table.setSpacingBefore(20f);
    document.add(table);
}

From source file:be.rheynaerde.poolsheets.AbstractPoolSheet.java

License:Open Source License

protected PdfPTable getBout(String player1, String player2) {
    PdfPTable table = new PdfPTable(2);
    table.setTotalWidth(configuration.getSquareCellSize() * 2);
    PdfPCell player1Name = new PdfPCell(new Phrase(player1));
    player1Name.setBorder(Rectangle.BOTTOM);
    player1Name.setHorizontalAlignment(Element.ALIGN_CENTER);
    player1Name.setFixedHeight(configuration.getSquareCellSize());
    PdfPCell player2Name = new PdfPCell(new Phrase(player2));
    player2Name.setBorder(Rectangle.BOTTOM);
    player2Name.setHorizontalAlignment(Element.ALIGN_CENTER);
    player2Name.setFixedHeight(configuration.getSquareCellSize());
    PdfPCell player1Score = new PdfPCell(new Phrase(" "));
    player1Score.setBorder(Rectangle.RIGHT);
    player1Score.setFixedHeight(configuration.getSquareCellSize());
    PdfPCell player2Score = new PdfPCell(new Phrase(" "));
    player2Score.setBorder(Rectangle.LEFT);
    player2Score.setFixedHeight(configuration.getSquareCellSize());
    table.addCell(player1Name);
    table.addCell(player2Name);/*w w  w  . j a  v a  2 s .c  o m*/
    table.addCell(player1Score);
    table.addCell(player2Score);
    table.setSpacingBefore(10);
    return table;
}

From source file:be.rheynaerde.poolsheets.AbstractPufPoolSheet.java

License:Open Source License

@Override
protected void buildTable(Document document) throws DocumentException {
    //large table to take care of the layout
    PdfPTable largeTable = new PdfPTable(3);
    largeTable.setWidths(new int[] { 19, 1, 20 });
    final float largeTableHeight = configuration.getSquareCellSize() * (getNumberOfRows() + 1);
    PdfPCell cell1 = getEmptyCell();//from  w  w  w. j  a va2s .  co  m
    cell1.setFixedHeight(largeTableHeight);
    cell1.addElement(getNameTable());
    largeTable.addCell(cell1);
    PdfPCell cellSpacer = getEmptyCell();
    cellSpacer.setFixedHeight(largeTableHeight);
    largeTable.addCell(cellSpacer);
    PdfPCell cell2 = getEmptyCell();
    cell2.setFixedHeight(largeTableHeight);
    cell2.addElement(getScoreTable());
    largeTable.addCell(cell2);
    document.add(largeTable);
}

From source file:be.rheynaerde.poolsheets.AbstractPufPoolSheet.java

License:Open Source License

protected PdfPTable getNameTable() {
    //table with names
    PdfPTable nameTable = new PdfPTable(1);
    nameTable.setWidthPercentage(100.0F);
    nameTable.addCell(getEmptyCell());
    nameTable.addCell(getEmptyCell());//from   w  w w.  ja  v  a  2  s  .c  om
    for (int i = 1; i <= getNumberOfPlayers(); i++) {
        nameTable.addCell(getNameCell(getPlayerName(i)));
    }
    return nameTable;
}