Example usage for com.itextpdf.text.pdf PdfPCell addElement

List of usage examples for com.itextpdf.text.pdf PdfPCell addElement

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfPCell addElement.

Prototype

public void addElement(Element element) 

Source Link

Document

Adds an iText element to the cell.

Usage

From source file:utils.pdf.cv_templates.Template3.java

private void addSoftware(List<Software> softwareList) throws DocumentException, IOException {
    Paragraph paragraph1, paragraph2;/*from   w w w.  j a v a  2  s. c  o m*/
    PdfPCell cell1, cell2, cell3;
    PdfPTable table1, table2, table3;

    // TABLE 1
    table1 = new PdfPTable(new float[] { 5 });
    table1.setWidthPercentage(100);
    cell1 = new PdfPCell();
    cell1.setBorder(PdfPCell.NO_BORDER);
    cell1.setPaddingRight(15);
    cell1.setPaddingLeft(50);
    cell1.setPaddingTop(15);

    paragraph1 = new Paragraph("Programas informticos", font1);
    paragraph1.setAlignment(paragraph1.ALIGN_LEFT);
    cell1.addElement(paragraph1);
    table1.addCell(cell1);
    document.add(table1);

    // TABLE 2
    table2 = new PdfPTable(new float[] { 9, 1 });
    table2.setWidthPercentage(100);

    // First column
    cell2 = new PdfPCell();
    cell2.setBorder(PdfPCell.NO_BORDER);
    cell2.setPaddingTop(5);
    Image long_line_img = Image.getInstance(LONG_LINE_IMAGE);
    long_line_img.setBorderWidth(10);
    long_line_img.setBorderColor(BaseColor.WHITE);
    long_line_img.scaleToFit(475, 50);
    cell2.addElement(long_line_img);
    table2.addCell(cell2);

    // Second column
    cell2 = new PdfPCell();
    cell2.setBorder(PdfPCell.NO_BORDER);
    table2.addCell(cell2);

    document.add(table2);

    // TABLE 3
    for (int i = 0; i < softwareList.size(); i++) {
        table3 = new PdfPTable(new float[] { 6, 4 });
        table3.setWidthPercentage(100);
        table3.setSpacingBefore(5);

        //First column
        cell3 = new PdfPCell();
        cell3.setBorder(PdfPCell.NO_BORDER);
        cell3.setPaddingRight(15);
        cell3.setPaddingLeft(50);
        if (i == 0) {
            cell3.setPaddingTop(-1);
        }

        paragraph2 = new Paragraph(softwareList.get(i).software + ".", font3);
        paragraph2.setSpacingBefore(10);
        cell3.addElement(paragraph2);

        table3.addCell(cell3);

        //Second column
        cell3 = new PdfPCell();
        cell3.setBorder(PdfPCell.NO_BORDER);
        cell3.setPaddingRight(15);
        cell3.setPaddingLeft(50);
        if (i == 0) {
            cell3.setPaddingTop(-1);
        }

        paragraph2 = new Paragraph(softwareList.get(i).level + ".", font3);
        paragraph2.setAlignment(paragraph2.ALIGN_LEFT);
        cell3.addElement(paragraph2);

        table3.addCell(cell3);
        document.add(table3);
    }
}

From source file:utils.pdf.cv_templates.Template3.java

private void addLanguages(List<Language> languages) throws DocumentException, IOException {
    Paragraph paragraph1, paragraph2;//from  w  w w .  j  av  a 2 s.co  m
    PdfPCell cell1, cell2, cell3;
    PdfPTable table1, table2, table3;

    // TABLE 1
    table1 = new PdfPTable(new float[] { 5 });
    table1.setWidthPercentage(100);
    cell1 = new PdfPCell();
    cell1.setBorder(PdfPCell.NO_BORDER);
    cell1.setPaddingRight(15);
    cell1.setPaddingLeft(50);
    cell1.setPaddingTop(15);

    paragraph1 = new Paragraph("Idiomas", font1);
    paragraph1.setAlignment(paragraph1.ALIGN_LEFT);
    cell1.addElement(paragraph1);
    table1.addCell(cell1);
    document.add(table1);

    // TABLE 2
    table2 = new PdfPTable(new float[] { 9, 1 });
    table2.setWidthPercentage(100);

    // First column
    cell2 = new PdfPCell();
    cell2.setBorder(PdfPCell.NO_BORDER);
    cell2.setPaddingTop(5);
    Image long_line_img = Image.getInstance(LONG_LINE_IMAGE);
    long_line_img.setBorderWidth(10);
    long_line_img.setBorderColor(BaseColor.WHITE);
    long_line_img.scaleToFit(475, 50);
    cell2.addElement(long_line_img);
    table2.addCell(cell2);

    // Second column
    cell2 = new PdfPCell();
    cell2.setBorder(PdfPCell.NO_BORDER);
    table2.addCell(cell2);

    document.add(table2);

    //TABLE 3
    for (int i = 0; i < languages.size(); i++) {
        table3 = new PdfPTable(new float[] { 6 });
        table3.setWidthPercentage(100);
        table3.setSpacingBefore(5);

        //First column
        cell3 = new PdfPCell();
        cell3.setBorder(PdfPCell.NO_BORDER);
        cell3.setPaddingRight(15);
        cell3.setPaddingLeft(50);
        if (i == 0) {
            cell3.setPaddingTop(-1);
        }

        paragraph2 = new Paragraph(languages.get(i).language + ". " + languages.get(i).level + ".", font3);
        paragraph2.setSpacingBefore(10);
        cell3.addElement(paragraph2);

        table3.addCell(cell3);
        document.add(table3);
    }
}

From source file:utils.pdf.cv_templates.Template3.java

private void addSkills(User user, List<String> personalCharacteristics, List<Skill> skills)
        throws DocumentException, IOException {
    Paragraph paragraph1, paragraph2;/*from w  w  w.  ja va2s  .  c  om*/
    PdfPCell cell1, cell2, cell3;
    PdfPTable table1, table2, table3;

    // TABLE 1
    table1 = new PdfPTable(new float[] { 5 });
    table1.setWidthPercentage(100);
    cell1 = new PdfPCell();
    cell1.setBorder(PdfPCell.NO_BORDER);
    cell1.setPaddingRight(15);
    cell1.setPaddingLeft(50);
    cell1.setPaddingTop(15);

    paragraph1 = new Paragraph("Cualidades", font1);
    paragraph1.setAlignment(paragraph1.ALIGN_LEFT);
    cell1.addElement(paragraph1);
    table1.addCell(cell1);
    document.add(table1);

    // TABLE 2
    table2 = new PdfPTable(new float[] { 9, 1 });
    table2.setWidthPercentage(100);

    // First column
    cell2 = new PdfPCell();
    cell2.setBorder(PdfPCell.NO_BORDER);
    cell2.setPaddingTop(5);
    Image long_line_img = Image.getInstance(LONG_LINE_IMAGE);
    long_line_img.setBorderWidth(10);
    long_line_img.setBorderColor(BaseColor.WHITE);
    long_line_img.scaleToFit(475, 50);
    cell2.addElement(long_line_img);
    table2.addCell(cell2);

    // Second column
    cell2 = new PdfPCell();
    cell2.setBorder(PdfPCell.NO_BORDER);
    table2.addCell(cell2);

    document.add(table2);

    // TABLE 3
    List<String> rankedSkills = selectSkills(skills);
    if (personalCharacteristics.size() != 0 && rankedSkills.size() != 0) {
        table3 = new PdfPTable(new float[] { 6 });
        table3.setWidthPercentage(100);
        table3.setSpacingBefore(5);

        //First column
        cell3 = new PdfPCell();
        cell3.setBorder(PdfPCell.NO_BORDER);
        paragraph2 = new Paragraph(
                "Me defino como una persona de carcter " + personalCharacteristics.get(1).toLowerCase()
                        + " y " + personalCharacteristics.get(0).toLowerCase() + ".",
                font3);
        paragraph2.setAlignment(Paragraph.ALIGN_LEFT);
        cell3.setPaddingRight(15);
        cell3.setPaddingLeft(50);
        cell3.setPaddingTop(-1);

        cell3.addElement(paragraph2);
        table3.addCell(cell3);

        //First column
        cell3 = new PdfPCell();
        cell3.setBorder(PdfPCell.NO_BORDER);
        paragraph2 = new Paragraph("Entre mis puntos fuertes destacan las " + rankedSkills.get(0).toLowerCase()
                + " y las " + rankedSkills.get(1).toLowerCase() + ".", font3);
        cell3.setBorder(PdfPCell.NO_BORDER);
        paragraph2.setAlignment(Paragraph.ALIGN_LEFT);
        cell3.setPaddingRight(15);
        cell3.setPaddingLeft(50);
        cell3.addElement(paragraph2);
        table3.addCell(cell3);

        //First column
        cell3 = new PdfPCell();
        cell3.setBorder(PdfPCell.NO_BORDER);
        paragraph2 = new Paragraph(
                "Considero que soy una persona activa que presenta " + rankedSkills.get(2).toLowerCase() + ".",
                font3);
        cell3.setBorder(PdfPCell.NO_BORDER);
        paragraph2.setAlignment(Paragraph.ALIGN_LEFT);
        cell3.setPaddingRight(15);
        cell3.setPaddingLeft(50);
        cell3.addElement(paragraph2);
        table3.addCell(cell3);

        //First column
        cell3 = new PdfPCell();
        cell3.setBorder(PdfPCell.NO_BORDER);
        paragraph2 = new Paragraph("Adems, una de las caractersticas que me define es que soy "
                + personalCharacteristics.get(2).toLowerCase() + ".", font3);
        cell3.setBorder(PdfPCell.NO_BORDER);
        paragraph2.setAlignment(Paragraph.ALIGN_LEFT);
        cell3.setPaddingRight(15);
        cell3.setPaddingLeft(50);
        cell3.addElement(paragraph2);
        table3.addCell(cell3);

        document.add(table3);

    }
}

From source file:utils.pdf.cv_templates.Template4.java

private void addPersonalInformation(User user) throws DocumentException {

    Paragraph paragraph;//  www .  j  av  a  2s  .  c  o  m
    PdfPCell cell;
    PdfPTable table;
    table = new PdfPTable(new float[] { 1f, 1.45f, 0.8f });
    table.setWidthPercentage(100);
    table.setSpacingBefore(5);

    //First column
    cell = new PdfPCell();
    cell.setBorder(PdfPCell.RIGHT);
    paragraph = new Paragraph("INFORMACIN PERSONAL", font1);
    cell.setBorder(PdfPCell.RIGHT);

    paragraph.setAlignment(Paragraph.ALIGN_RIGHT);
    cell.setPaddingRight(10);
    cell.addElement(paragraph);
    table.addCell(cell);

    //Second column
    cell = new PdfPCell();
    cell.setBorder(PdfPCell.NO_BORDER);
    cell.setPaddingLeft(10);
    cell.setPaddingTop(0);

    paragraph = new Paragraph("");
    cell.setBorder(PdfPCell.NO_BORDER);
    table.addCell(cell);

    //  IMG column
    cell = new PdfPCell();
    cell.setPaddingLeft(10);
    cell.setPaddingTop(0);
    cell.setBorder(PdfPCell.NO_BORDER);

    paragraph = new Paragraph("");
    cell.addElement(paragraph);
    table.addCell(cell);

    //First column
    cell = new PdfPCell();
    cell.setBorder(PdfPCell.RIGHT);
    paragraph = new Paragraph("Nombre completo", font2);
    cell.setBorder(PdfPCell.RIGHT);

    paragraph.setAlignment(Paragraph.ALIGN_RIGHT);
    cell.setPaddingRight(10);
    cell.addElement(paragraph);
    table.addCell(cell);

    //Second column
    cell = new PdfPCell();
    cell.setPaddingLeft(10);
    cell.setPaddingTop(0);
    cell.setBorder(PdfPCell.NO_BORDER);
    paragraph = new Paragraph(user.name + " " + user.surnames, font2);
    cell.addElement(paragraph);
    table.addCell(cell);

    //  IMG column
    cell = new PdfPCell();
    cell.setPaddingLeft(10);
    cell.setPaddingTop(0);
    cell.setBorder(PdfPCell.NO_BORDER);

    paragraph = new Paragraph("");
    cell.addElement(paragraph);
    table.addCell(cell);

    //First column
    cell = new PdfPCell();
    cell.setBorder(PdfPCell.RIGHT);
    paragraph = new Paragraph("Direccin", font2);
    cell.setBorder(PdfPCell.RIGHT);

    paragraph.setAlignment(Paragraph.ALIGN_RIGHT);
    cell.setPaddingRight(10);
    cell.addElement(paragraph);
    table.addCell(cell);

    //Second column
    cell = new PdfPCell();
    cell.setPaddingLeft(10);
    cell.setPaddingTop(0);
    cell.setBorder(PdfPCell.NO_BORDER);
    paragraph = new Paragraph("Calle " + user.residenceAddress + " , " + " N " + user.residenceNumber + " , "
            + " CP: " + user.residenceZipCode + " , " + user.residenceCity, font2);
    cell.addElement(paragraph);
    table.addCell(cell);

    //  IMG column
    cell = new PdfPCell();
    cell.setPaddingLeft(10);
    cell.setPaddingTop(0);
    cell.setBorder(PdfPCell.NO_BORDER);

    paragraph = new Paragraph("");
    cell.addElement(paragraph);
    table.addCell(cell);

    //First column
    cell = new PdfPCell();
    cell.setBorder(PdfPCell.RIGHT);
    paragraph = new Paragraph("Telfono", font2);
    cell.setBorder(PdfPCell.RIGHT);
    paragraph.setAlignment(Paragraph.ALIGN_RIGHT);
    cell.setPaddingRight(10);
    cell.addElement(paragraph);
    table.addCell(cell);

    //Second column
    cell = new PdfPCell();
    cell.setPaddingLeft(10);
    cell.setPaddingTop(0);
    cell.setBorder(PdfPCell.NO_BORDER);

    paragraph = new Paragraph(user.phoneNumber, font2);
    cell.addElement(paragraph);
    table.addCell(cell);

    //  IMG column
    cell = new PdfPCell();
    cell.setPaddingLeft(10);
    cell.setPaddingTop(0);
    cell.setBorder(PdfPCell.NO_BORDER);
    paragraph = new Paragraph("");
    cell.addElement(paragraph);
    table.addCell(cell);

    //First column
    cell = new PdfPCell();
    cell.setBorder(PdfPCell.RIGHT);
    paragraph = new Paragraph("Email", font2);
    cell.setBorder(PdfPCell.RIGHT);

    paragraph.setAlignment(Paragraph.ALIGN_RIGHT);
    cell.setPaddingRight(10);
    cell.addElement(paragraph);
    table.addCell(cell);

    //Second column
    cell = new PdfPCell();
    cell.setPaddingLeft(10);
    cell.setPaddingTop(0);
    cell.setBorder(PdfPCell.NO_BORDER);

    paragraph = new Paragraph(user.email, font2);
    cell.addElement(paragraph);
    table.addCell(cell);

    //  IMG column
    cell = new PdfPCell();
    cell.setPaddingLeft(10);
    cell.setPaddingTop(0);
    cell.setBorder(PdfPCell.NO_BORDER);

    paragraph = new Paragraph("");
    cell.addElement(paragraph);
    table.addCell(cell);

    //First column
    cell = new PdfPCell();
    cell.setBorder(PdfPCell.RIGHT);
    paragraph = new Paragraph("Fecha de nacimiento", font2);
    cell.setBorder(PdfPCell.RIGHT);

    paragraph.setAlignment(Paragraph.ALIGN_RIGHT);
    cell.setPaddingRight(10);
    cell.addElement(paragraph);
    table.addCell(cell);

    //Second column
    cell = new PdfPCell();
    cell.setPaddingLeft(10);
    cell.setPaddingTop(0);
    cell.setBorder(PdfPCell.NO_BORDER);

    paragraph = new Paragraph(user.birthDate, font2);
    cell.addElement(paragraph);
    table.addCell(cell);

    //  IMG column
    cell = new PdfPCell();
    cell.setPaddingLeft(10);
    cell.setPaddingTop(0);
    cell.setBorder(PdfPCell.NO_BORDER);

    paragraph = new Paragraph("");
    cell.addElement(paragraph);
    table.addCell(cell);

    document.add(table);
}

From source file:utils.pdf.cv_templates.Template4.java

private void addProfessionalExperience(List<ProfessionalExperience> experienceList) throws DocumentException {
    Paragraph paragraph;/*from   w w  w. ja  v a 2  s .  c  o m*/
    PdfPCell cell;
    PdfPTable table;

    for (int i = 0; i < experienceList.size(); i++) {

        table = new PdfPTable(new float[] { 1f, 2.25f });
        table.setWidthPercentage(100);
        table.setSpacingBefore(5);

        //First column
        cell = new PdfPCell();
        cell.setBorder(PdfPCell.RIGHT);
        if (i == 0) {
            paragraph = new Paragraph("EXPERIENCIA PROFESIONAL", font1);
            cell.setBorder(PdfPCell.RIGHT);
        } else {
            paragraph = new Paragraph("");
        }
        paragraph.setAlignment(Paragraph.ALIGN_RIGHT);
        cell.setPaddingRight(10);
        cell.addElement(paragraph);
        table.addCell(cell);

        //Second column
        cell = new PdfPCell();
        cell.setPaddingLeft(10);
        cell.setPaddingTop(0);
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph = new Paragraph("");
        cell.addElement(paragraph);
        table.addCell(cell);

        //First column
        cell = new PdfPCell();
        cell.setBorder(PdfPCell.RIGHT);
        paragraph = new Paragraph("Ttulo", font2);
        cell.setBorder(PdfPCell.RIGHT);

        paragraph.setAlignment(Paragraph.ALIGN_RIGHT);
        cell.setPaddingRight(10);
        cell.addElement(paragraph);
        table.addCell(cell);

        //Second column
        cell = new PdfPCell();
        cell.setPaddingLeft(10);
        cell.setPaddingTop(0);
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph = new Paragraph(experienceList.get(i).job, font2);
        cell.addElement(paragraph);
        table.addCell(cell);

        //First column
        cell = new PdfPCell();
        cell.setBorder(PdfPCell.RIGHT);
        paragraph = new Paragraph("Empresa y lugar", font2);
        cell.setBorder(PdfPCell.RIGHT);

        paragraph.setAlignment(Paragraph.ALIGN_RIGHT);
        cell.setPaddingRight(10);
        cell.addElement(paragraph);
        table.addCell(cell);

        //Second column
        cell = new PdfPCell();
        cell.setPaddingLeft(10);
        cell.setPaddingTop(0);
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph = new Paragraph(experienceList.get(i).company, font2);
        cell.addElement(paragraph);
        table.addCell(cell);

        //First column
        cell = new PdfPCell();
        cell.setBorder(PdfPCell.RIGHT);
        paragraph = new Paragraph("Fecha", font2);
        cell.setBorder(PdfPCell.RIGHT);

        paragraph.setAlignment(Paragraph.ALIGN_RIGHT);
        cell.setPaddingRight(10);
        cell.addElement(paragraph);
        table.addCell(cell);

        //Second column
        cell = new PdfPCell();
        cell.setPaddingLeft(10);
        cell.setPaddingTop(0);
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph = new Paragraph(experienceList.get(i).startDate + " - " + experienceList.get(i).endDate,
                font2);
        cell.addElement(paragraph);
        table.addCell(cell);

        document.add(table);
    }
}

From source file:utils.pdf.cv_templates.Template4.java

private void addStudies(User user) throws DocumentException {
    Paragraph paragraph;//  www  . j  a v  a  2s  . c o  m
    PdfPCell cell;
    PdfPTable table;

    table = new PdfPTable(new float[] { 1f, 2.25f });
    table.setWidthPercentage(100);
    table.setSpacingBefore(5);

    //First column
    cell = new PdfPCell();
    cell.setBorder(PdfPCell.RIGHT);
    if (!user.studyTitle.equals("")) {
        paragraph = new Paragraph("EXPERIENCIA ACADMICA", font1);
        cell.setBorder(PdfPCell.RIGHT);
    } else {
        paragraph = new Paragraph("");
    }
    paragraph.setAlignment(Paragraph.ALIGN_RIGHT);
    cell.setPaddingRight(10);
    cell.addElement(paragraph);
    table.addCell(cell);

    //Second column
    cell = new PdfPCell();
    cell.setPaddingLeft(10);
    cell.setPaddingTop(0);
    cell.setBorder(PdfPCell.NO_BORDER);
    paragraph = new Paragraph("");
    cell.addElement(paragraph);
    table.addCell(cell);

    //First column
    cell = new PdfPCell();
    cell.setBorder(PdfPCell.RIGHT);
    paragraph = new Paragraph("Ttulo", font2);
    cell.setBorder(PdfPCell.RIGHT);

    paragraph.setAlignment(Paragraph.ALIGN_RIGHT);
    cell.setPaddingRight(10);
    cell.addElement(paragraph);
    table.addCell(cell);

    //Second column
    cell = new PdfPCell();
    cell.setPaddingLeft(10);
    cell.setPaddingTop(0);
    cell.setBorder(PdfPCell.NO_BORDER);
    paragraph = new Paragraph(user.studyTitle, font2);
    cell.addElement(paragraph);
    table.addCell(cell);

    //First column
    cell = new PdfPCell();
    cell.setBorder(PdfPCell.RIGHT);
    paragraph = new Paragraph("Centro y lugar", font2);
    cell.setBorder(PdfPCell.RIGHT);

    paragraph.setAlignment(Paragraph.ALIGN_RIGHT);
    cell.setPaddingRight(10);
    cell.addElement(paragraph);
    table.addCell(cell);

    //Second column
    cell = new PdfPCell();
    cell.setPaddingLeft(10);
    cell.setPaddingTop(0);
    cell.setBorder(PdfPCell.NO_BORDER);
    paragraph = new Paragraph(user.studyLocation, font2);
    cell.addElement(paragraph);
    table.addCell(cell);

    document.add(table);
}

From source file:utils.pdf.cv_templates.Template4.java

private void addSoftware(List<Software> softwareList) throws DocumentException {
    Paragraph paragraph;/*from  ww w .j  a  va2 s  . com*/
    PdfPCell cell;
    PdfPTable table;

    for (int i = 0; i < softwareList.size(); i++) {

        table = new PdfPTable(new float[] { 1f, 2.25f });
        table.setWidthPercentage(100);
        table.setSpacingBefore(5);

        //First column
        cell = new PdfPCell();
        cell.setBorder(PdfPCell.RIGHT);
        if (i == 0) {
            paragraph = new Paragraph("PROGRAMAS INFORM?TICOS", font1);
            cell.setBorder(PdfPCell.RIGHT);
        } else {
            paragraph = new Paragraph("");
        }
        paragraph.setAlignment(Paragraph.ALIGN_RIGHT);
        cell.setPaddingRight(10);
        cell.addElement(paragraph);
        table.addCell(cell);

        //Second column
        cell = new PdfPCell();
        cell.setPaddingLeft(10);
        cell.setPaddingTop(0);
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph = new Paragraph("");
        cell.addElement(paragraph);
        table.addCell(cell);

        //First column
        cell = new PdfPCell();
        cell.setBorder(PdfPCell.RIGHT);
        paragraph = new Paragraph("Nombre", font2);
        cell.setBorder(PdfPCell.RIGHT);

        paragraph.setAlignment(Paragraph.ALIGN_RIGHT);
        cell.setPaddingRight(10);
        cell.addElement(paragraph);
        table.addCell(cell);

        //Second column
        cell = new PdfPCell();
        cell.setPaddingLeft(10);
        cell.setPaddingTop(0);
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph = new Paragraph(softwareList.get(i).software, font2);
        cell.addElement(paragraph);
        table.addCell(cell);

        //First column
        cell = new PdfPCell();
        cell.setBorder(PdfPCell.RIGHT);
        paragraph = new Paragraph("Nivel", font2);
        cell.setBorder(PdfPCell.RIGHT);

        paragraph.setAlignment(Paragraph.ALIGN_RIGHT);
        cell.setPaddingRight(10);
        cell.addElement(paragraph);
        table.addCell(cell);

        //Second column
        cell = new PdfPCell();
        cell.setPaddingLeft(10);
        cell.setPaddingTop(0);
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph = new Paragraph(softwareList.get(i).level, font2);
        cell.addElement(paragraph);
        table.addCell(cell);

        document.add(table);
    }
}

From source file:utils.pdf.cv_templates.Template4.java

private void addCourses(List<Course> courseList) throws DocumentException {
    Paragraph paragraph;/*from  w w w  . j  a va2  s .  c o  m*/
    PdfPCell cell;
    PdfPTable table;

    for (int i = 0; i < courseList.size(); i++) {

        table = new PdfPTable(new float[] { 1f, 2.25f });
        table.setWidthPercentage(100);
        table.setSpacingBefore(5);

        //First column
        cell = new PdfPCell();
        cell.setBorder(PdfPCell.RIGHT);
        if (i == 0) {
            paragraph = new Paragraph("CURSOS", font1);
            cell.setBorder(PdfPCell.RIGHT);
        } else {
            paragraph = new Paragraph("");
        }
        paragraph.setAlignment(Paragraph.ALIGN_RIGHT);
        cell.setPaddingRight(10);
        cell.addElement(paragraph);
        table.addCell(cell);

        //Second column
        cell = new PdfPCell();
        cell.setPaddingLeft(10);
        cell.setPaddingTop(0);
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph = new Paragraph("");
        cell.addElement(paragraph);
        table.addCell(cell);

        //First column
        cell = new PdfPCell();
        cell.setBorder(PdfPCell.RIGHT);
        paragraph = new Paragraph("Ttulo", font2);
        cell.setBorder(PdfPCell.RIGHT);

        paragraph.setAlignment(Paragraph.ALIGN_RIGHT);
        cell.setPaddingRight(10);
        cell.addElement(paragraph);
        table.addCell(cell);

        //Second column
        cell = new PdfPCell();
        cell.setPaddingLeft(10);
        cell.setPaddingTop(0);
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph = new Paragraph(courseList.get(i).name, font2);
        cell.addElement(paragraph);
        table.addCell(cell);

        //First column
        cell = new PdfPCell();
        cell.setBorder(PdfPCell.RIGHT);
        paragraph = new Paragraph("Centro y lugar", font2);
        cell.setBorder(PdfPCell.RIGHT);

        paragraph.setAlignment(Paragraph.ALIGN_RIGHT);
        cell.setPaddingRight(10);
        cell.addElement(paragraph);
        table.addCell(cell);

        //Second column
        cell = new PdfPCell();
        cell.setPaddingLeft(10);
        cell.setPaddingTop(0);
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph = new Paragraph(courseList.get(i).company, font2);
        cell.addElement(paragraph);
        table.addCell(cell);

        //First column
        cell = new PdfPCell();
        cell.setBorder(PdfPCell.RIGHT);
        paragraph = new Paragraph("Nmero de horas", font2);
        cell.setBorder(PdfPCell.RIGHT);

        paragraph.setAlignment(Paragraph.ALIGN_RIGHT);
        cell.setPaddingRight(10);
        cell.addElement(paragraph);
        table.addCell(cell);

        //Second column
        cell = new PdfPCell();
        cell.setPaddingLeft(10);
        cell.setPaddingTop(0);
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph = new Paragraph(courseList.get(i).length, font2);
        cell.addElement(paragraph);
        table.addCell(cell);

        document.add(table);
    }
}

From source file:utils.pdf.cv_templates.Template4.java

private void addLanguage(List<Language> languageList) throws DocumentException {
    Paragraph paragraph;//from w w w  . j  av  a2s  .  c o m
    PdfPCell cell;
    PdfPTable table;

    for (int i = 0; i < languageList.size(); i++) {

        table = new PdfPTable(new float[] { 1f, 2.25f });
        table.setWidthPercentage(100);
        table.setSpacingBefore(5);

        //First column
        cell = new PdfPCell();
        cell.setBorder(PdfPCell.RIGHT);
        if (i == 0) {
            paragraph = new Paragraph("IDIOMAS", font1);
            cell.setBorder(PdfPCell.RIGHT);
        } else {
            paragraph = new Paragraph("");
        }
        paragraph.setAlignment(Paragraph.ALIGN_RIGHT);
        cell.setPaddingRight(10);
        cell.addElement(paragraph);
        table.addCell(cell);

        //Second column
        cell = new PdfPCell();
        cell.setPaddingLeft(10);
        cell.setPaddingTop(0);
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph = new Paragraph("");
        cell.addElement(paragraph);
        table.addCell(cell);

        //First column
        cell = new PdfPCell();
        cell.setBorder(PdfPCell.RIGHT);
        paragraph = new Paragraph("Nombre", font2);
        cell.setBorder(PdfPCell.RIGHT);

        paragraph.setAlignment(Paragraph.ALIGN_RIGHT);
        cell.setPaddingRight(10);
        cell.addElement(paragraph);
        table.addCell(cell);

        //Second column
        cell = new PdfPCell();
        cell.setPaddingLeft(10);
        cell.setPaddingTop(0);
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph = new Paragraph(languageList.get(i).language, font2);
        cell.addElement(paragraph);
        table.addCell(cell);

        //First column
        cell = new PdfPCell();
        cell.setBorder(PdfPCell.RIGHT);
        paragraph = new Paragraph("Nivel", font2);
        cell.setBorder(PdfPCell.RIGHT);

        paragraph.setAlignment(Paragraph.ALIGN_RIGHT);
        cell.setPaddingRight(10);
        cell.addElement(paragraph);
        table.addCell(cell);

        //Second column
        cell = new PdfPCell();
        cell.setPaddingLeft(10);
        cell.setPaddingTop(0);
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph = new Paragraph(languageList.get(i).level, font2);
        cell.addElement(paragraph);
        table.addCell(cell);

        document.add(table);
    }
}

From source file:utils.pdf.cv_templates.Template4.java

private void addSkills(User user, List<String> personalCharacteristics, List<Skill> skills)
        throws DocumentException {
    Paragraph paragraph;/*from  ww  w .j  a va2  s .co  m*/
    PdfPCell cell;
    PdfPTable table;

    List<String> rankedSkills = selectSkills(skills);
    if (personalCharacteristics.size() != 0 && rankedSkills.size() != 0) {
        table = new PdfPTable(new float[] { 1f });
        table.setWidthPercentage(100);
        table.setSpacingBefore(5);

        //First column
        cell = new PdfPCell();
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph = new Paragraph("HABILIDADES PERSONALES", font1);
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph.setAlignment(Paragraph.ALIGN_LEFT);
        cell.setPaddingRight(10);
        cell.addElement(paragraph);
        table.addCell(cell);

        //First column
        cell = new PdfPCell();
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph = new Paragraph(
                "Me defino como una persona de carcter " + personalCharacteristics.get(1).toLowerCase()
                        + " y " + personalCharacteristics.get(0).toLowerCase() + ".",
                font2);
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph.setAlignment(Paragraph.ALIGN_LEFT);
        cell.setPaddingRight(10);
        cell.addElement(paragraph);
        table.addCell(cell);

        //First column
        cell = new PdfPCell();
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph = new Paragraph("Entre mis puntos fuertes destacan las " + rankedSkills.get(0).toLowerCase()
                + " y las " + rankedSkills.get(1).toLowerCase() + ".", font2);
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph.setAlignment(Paragraph.ALIGN_LEFT);
        cell.setPaddingRight(10);
        cell.addElement(paragraph);
        table.addCell(cell);

        //First column
        cell = new PdfPCell();
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph = new Paragraph(
                "Considero que soy una persona activa que presenta " + rankedSkills.get(2).toLowerCase() + ".",
                font2);
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph.setAlignment(Paragraph.ALIGN_LEFT);
        cell.setPaddingRight(10);
        cell.addElement(paragraph);
        table.addCell(cell);

        //First column
        cell = new PdfPCell();
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph = new Paragraph("Adems, una de las caractersticas que me define es que soy "
                + personalCharacteristics.get(2).toLowerCase() + ".", font2);
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph.setAlignment(Paragraph.ALIGN_LEFT);
        cell.setPaddingRight(10);
        cell.addElement(paragraph);
        table.addCell(cell);

        if (!user.drivingLicense.equals("No tengo carnet")) {
            //First column
            cell = new PdfPCell();
            cell.setBorder(PdfPCell.NO_BORDER);
            paragraph = new Paragraph("Permiso de conducir: " + user.drivingLicense + ".", font2);
            cell.setBorder(PdfPCell.NO_BORDER);
            paragraph.setAlignment(Paragraph.ALIGN_LEFT);
            cell.setPaddingRight(10);
            cell.addElement(paragraph);
            table.addCell(cell);
        }

        document.add(table);

    }
}