Example usage for com.itextpdf.text FontFactory getFont

List of usage examples for com.itextpdf.text FontFactory getFont

Introduction

In this page you can find the example usage for com.itextpdf.text FontFactory getFont.

Prototype


public static Font getFont(final String fontname) 

Source Link

Document

Constructs a Font-object.

Usage

From source file:be.thomasmore.controller.PdfController.java

public void createPdfKlas() {

    Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext()
            .getRequestParameterMap();//from   w  w w.j  a v  a2  s.  c o m
    String KlasId = params.get("klasId");
    int id = Integer.parseInt(KlasId);
    Document document = new Document();
    Klas klas = service.getKlas(id);
    List<Klastest> klastesten = klas.getKlastestList();
    List<Test> testen = new ArrayList<Test>();

    HttpServletResponse res = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext()
            .getResponse();
    res.setHeader("Content-Disposition", "attachement; filename=" + klas.getNummer() + "-resultaten.pdf");
    res.setContentType("application/pdf");

    try {
        PdfWriter.getInstance(document, res.getOutputStream());

        document.open();

        Font font = FontFactory.getFont("Calibri");
        Font fontbold = FontFactory.getFont("Calibri", Font.BOLD);

        PdfPTable table = new PdfPTable(3); // 3 columns.

        PdfPCell cell1 = new PdfPCell(new Paragraph("Vak", font));
        PdfPCell cell2 = new PdfPCell(new Paragraph("Student", font));
        PdfPCell cell3 = new PdfPCell(new Paragraph("Behaald", font));

        table.addCell(cell1);
        table.addCell(cell2);
        table.addCell(cell3);

        for (Klastest klastest : klastesten) {
            Test test = klastest.getTestId();
            testen.add(service.getTest(test.getId()));
        }

        for (Test test : testen) {
            List<Score> scores = test.getScoreList();
            Vak vak = test.getVakId();
            for (Score score : scores) {
                Student student = score.getStudentId();
                PdfPCell cellVak = new PdfPCell(new Paragraph(vak.getNaam(), font));
                PdfPCell cellStudent = new PdfPCell(new Paragraph(student.getVoornaam(), font));
                PdfPCell cellScore = new PdfPCell(new Paragraph(score.getScore().toString(), font));

                table.addCell(cellVak);
                table.addCell(cellStudent);
                table.addCell(cellScore);
            }
        }

        document.add(new Phrase("Klas: ", font));
        document.add(new Phrase(klas.getNummer(), font));
        document.add(table);

        document.close();
    } catch (Exception e) {

    }

}

From source file:be.thomasmore.controller.PdfController.java

public void createPdfTest() {
    Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext()
            .getRequestParameterMap();/* ww  w. ja  v  a 2  s  .  co  m*/
    String KlasId = params.get("klasId3");
    String TestId = params.get("testId");
    int klasId = Integer.parseInt(KlasId);
    int id = Integer.parseInt(TestId);
    Document document = new Document();
    Test test = service.getTest(id);
    List<Score> scores = test.getScoreList();
    Klas klas = service.getKlas(klasId);
    Vak vak = test.getVakId();

    HttpServletResponse res = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext()
            .getResponse();
    res.setHeader("Content-Disposition", "attachement; filename=" + test.getBeschrijving() + "-resultaten.pdf");
    res.setContentType("application/pdf");

    try {
        PdfWriter.getInstance(document, res.getOutputStream());

        document.open();

        Font font = FontFactory.getFont("Calibri");
        Font fontbold = FontFactory.getFont("Calibri", Font.BOLD);

        PdfPTable table = new PdfPTable(3); // 3 columns.

        PdfPCell cell1 = new PdfPCell(new Paragraph("Test", font));
        PdfPCell cell2 = new PdfPCell(new Paragraph("Student", font));
        PdfPCell cell3 = new PdfPCell(new Paragraph("Score", font));

        table.addCell(cell1);
        table.addCell(cell2);
        table.addCell(cell3);

        for (Score score : scores) {
            Student student = score.getStudentId();
            PdfPCell cellTest = new PdfPCell(new Paragraph(test.getBeschrijving(), font));
            PdfPCell cellStudent = new PdfPCell(new Paragraph(student.getVoornaam(), font));
            PdfPCell cellScore = new PdfPCell(new Paragraph(score.getScore().toString()));

            table.addCell(cellTest);
            table.addCell(cellStudent);
            table.addCell(cellScore);
        }

        document.add(new Phrase("Klas: ", font));
        document.add(new Phrase(klas.getNummer(), font));
        document.add(new Phrase("  Vak: ", font));
        document.add(new Phrase(vak.getNaam(), font));
        document.add(table);

        document.close();
    } catch (Exception e) {

    }

}

From source file:be.thomasmore.controller.PdfController.java

public void createPdfVak() {
    Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext()
            .getRequestParameterMap();//  w  ww . ja  v  a 2  s.co m
    String KlasId = params.get("klasId2");
    String VakId = params.get("vakId");
    int klasId = Integer.parseInt(KlasId);
    int id = Integer.parseInt(VakId);
    Document document = new Document();
    Vak vak = service.getVak(id);
    List<Test> testen = vak.getTestList();
    Klas klas = service.getKlas(klasId);

    HttpServletResponse res = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext()
            .getResponse();
    res.setHeader("Content-Disposition", "attachement; filename=" + vak.getNaam() + "-resultaten.pdf");
    res.setContentType("application/pdf");

    try {
        PdfWriter.getInstance(document, res.getOutputStream());

        document.open();

        Font font = FontFactory.getFont("Calibri");
        Font fontbold = FontFactory.getFont("Calibri", Font.BOLD);

        PdfPTable table = new PdfPTable(3); // 3 columns.

        PdfPCell cell1 = new PdfPCell(new Paragraph("Test", font));
        PdfPCell cell2 = new PdfPCell(new Paragraph("Student", font));
        PdfPCell cell3 = new PdfPCell(new Paragraph("Score", font));

        table.addCell(cell1);
        table.addCell(cell2);
        table.addCell(cell3);

        for (Test test : testen) {
            List<Score> scores = test.getScoreList();
            for (Score score : scores) {
                Student student = score.getStudentId();
                PdfPCell cellTest = new PdfPCell(new Paragraph(test.getBeschrijving(), font));
                PdfPCell cellStudent = new PdfPCell(new Paragraph(student.getVoornaam(), font));
                PdfPCell cellScore = new PdfPCell(new Paragraph(score.getScore().toString()));

                table.addCell(cellTest);
                table.addCell(cellStudent);
                table.addCell(cellScore);
            }
        }

        document.add(new Phrase("Klas: ", font));
        document.add(new Phrase(klas.getNummer(), font));
        document.add(new Phrase("  Vak: ", font));
        document.add(new Phrase(vak.getNaam(), font));
        document.add(table);

        document.close();
    } catch (Exception e) {

    }
}

From source file:be.thomasmore.controller.PdfController.java

public void createPdfStudent() {
    Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext()
            .getRequestParameterMap();/*from   w ww  .ja  v a 2 s.com*/
    String StudentId = params.get("studentId");
    int id = Integer.parseInt(StudentId);
    Document document = new Document();
    Student student = service.getStudent(id);
    List<Score> scores = student.getScoreList();
    Klas klas = student.getKlasId();

    HttpServletResponse res = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext()
            .getResponse();
    res.setHeader("Content-Disposition",
            "attachement; filename=" + student.getNaam() + student.getVoornaam() + "-resultaten.pdf");
    res.setContentType("application/pdf");

    try {
        PdfWriter.getInstance(document, res.getOutputStream());

        document.open();

        Font font = FontFactory.getFont("Calibri");

        PdfPTable table = new PdfPTable(3); // 3 columns.

        PdfPCell cell1 = new PdfPCell(new Paragraph("Vak", font));
        PdfPCell cell2 = new PdfPCell(new Paragraph("Test", font));
        PdfPCell cell3 = new PdfPCell(new Paragraph("Score", font));

        table.addCell(cell1);
        table.addCell(cell2);
        table.addCell(cell3);

        for (Score score : scores) {
            Test test = score.getTestId();
            PdfPCell cellVak = new PdfPCell(new Paragraph(test.getVakId().getNaam(), font));
            PdfPCell cellTest = new PdfPCell(new Paragraph(test.getBeschrijving(), font));
            PdfPCell cellScore = new PdfPCell(new Paragraph(score.getScore().toString()));

            table.addCell(cellVak);
            table.addCell(cellTest);
            table.addCell(cellScore);
        }

        document.add(new Phrase("Student: ", font));
        document.add(new Phrase((student.getNaam() + " " + student.getVoornaam()), font));
        document.add(new Phrase("Klas: ", font));
        document.add(new Phrase(klas.getNummer(), font));
        document.add(table);

        document.close();
    } catch (Exception e) {

    }

}

From source file:com.coderbd.pos.pdf.OrderFileBuilder.java

public String makePdf(ShopOrder shopOrder) {
    Document document = new Document(new Rectangle(205, 800));
    String fileName = directory + "\\" + shopOrder.getCustomerOrder().getOrderBarcode() + ".pdf";
    String receiptText = receipt.getIndentedOrder(shopOrder);
    System.out.println(receiptText);

    document.setMargins(3, 2, 2, 2);//from   w ww .j a  v  a 2  s .  co  m

    Font courierFont = FontFactory.getFont("courier");
    courierFont.setSize(10f);

    try {
        PdfWriter.getInstance(document, new FileOutputStream(fileName));

        document.open();
        document.add(new Paragraph(receiptText, courierFont));
        document.close();

    } catch (DocumentException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    return fileName;
}

From source file:com.dandymadeproductions.ajqvue.structures.DataExportProperties.java

License:Open Source License

private void loadPDFFonts() {
    // Method Instances.
    String fileSeparator;// www .j  a v  a2  s  .  c  o  m
    String fontPath, fontName;
    String fontsDirectoryName;
    Iterator<String> fontNameIterator;
    File fontsDirectory;
    File[] fontsSubDirectories;
    String[] fontNames;
    TreeSet<String> fonts;

    // Setting up.
    fileSeparator = Utils.getFileSeparator();
    fontsDirectoryName = "fonts" + fileSeparator;
    fonts = new TreeSet<String>();

    // Insure have one default font.

    fontTreeMap.put(PDFExportPreferencesPanel.DEFAULT_FONT, new Font(Font.FontFamily.UNDEFINED));

    // Create the default registered fonts.

    fontNameIterator = FontFactory.getRegisteredFonts().iterator();

    while (fontNameIterator.hasNext()) {
        fontName = fontNameIterator.next();
        fontTreeMap.put(fontName, FontFactory.getFont(fontName));
    }

    // Create embedded fonts from fonts directory.

    fontsDirectory = new File(fontsDirectoryName);

    if (fontsDirectory.exists()) {
        // Handle one level of sub-directories.
        fontsSubDirectories = fontsDirectory.listFiles(new DirectoriesFilter());

        if (fontsSubDirectories != null) {
            for (int i = 0; i < fontsSubDirectories.length; i++) {
                fontNames = fontsSubDirectories[i].list(new FontNameFilter());

                if (fontNames != null)
                    for (int j = 0; j < fontNames.length; j++)
                        fonts.add(fontsSubDirectories[i] + fileSeparator + fontNames[j]);
            }
        }

        // Handle all direct font names in the directory.
        fontNames = fontsDirectory.list(new FontNameFilter());

        if (fontNames != null) {
            for (int i = 0; i < fontNames.length; i++)
                fonts.add(fontsDirectoryName + fontNames[i]);
        }

        // Load the found fonts.
        fontNameIterator = fonts.iterator();

        while (fontNameIterator.hasNext()) {
            fontPath = fontNameIterator.next();
            if (fontPath.indexOf(fileSeparator) != -1)
                fontName = fontPath.substring((fontPath.lastIndexOf(fileSeparator) + 1), fontPath.indexOf("."));
            else
                fontName = fontPath.substring(0, fontPath.indexOf("."));

            // System.out.println(fontName + " " + fontPath);
            try {
                BaseFont currentBaseFont = BaseFont.createFont(fontPath, BaseFont.IDENTITY_H,
                        BaseFont.EMBEDDED);
                fontTreeMap.put(fontName, new Font(currentBaseFont, 12));
            } catch (DocumentException de) {
            } catch (IOException ioe) {
            }
        }
    }
}

From source file:com.dandymadeproductions.myjsqlview.structures.DataExportProperties.java

License:Open Source License

private void loadPDFFonts() {
    // Method Instances.
    String fileSeparator;/*  w ww.  j  a  v  a2s .  c  o m*/
    String fontPath, fontName;
    String fontsDirectoryName;
    Iterator<String> fontNameIterator;
    File fontsDirectory;
    File[] fontsSubDirectories;
    String[] fontNames;
    TreeSet<String> fonts;

    // Setting up.
    fileSeparator = MyJSQLView_Utils.getFileSeparator();
    fontsDirectoryName = "fonts" + fileSeparator;
    fonts = new TreeSet<String>();

    // Insure have one default font.

    fontTreeMap.put(PDFExportPreferencesPanel.DEFAULT_FONT, new Font(Font.FontFamily.UNDEFINED));

    // Create the default registered fonts.

    fontNameIterator = FontFactory.getRegisteredFonts().iterator();

    while (fontNameIterator.hasNext()) {
        fontName = fontNameIterator.next();
        fontTreeMap.put(fontName, FontFactory.getFont(fontName));
    }

    // Create embedded fonts from fonts directory.

    fontsDirectory = new File(fontsDirectoryName);

    if (fontsDirectory.exists()) {
        // Handle one level of sub-directories.
        fontsSubDirectories = fontsDirectory.listFiles(directoriesFilter);

        for (int i = 0; i < fontsSubDirectories.length; i++) {
            fontNames = fontsSubDirectories[i].list(fontNameFilter);

            for (int j = 0; j < fontNames.length; j++)
                fonts.add(fontsSubDirectories[i] + fileSeparator + fontNames[j]);
        }

        // Handle all direct font names in the directory.
        fontNames = fontsDirectory.list(fontNameFilter);

        for (int i = 0; i < fontNames.length; i++)
            fonts.add(fontsDirectoryName + fontNames[i]);

        // Load the found fonts.
        fontNameIterator = fonts.iterator();

        while (fontNameIterator.hasNext()) {
            fontPath = fontNameIterator.next();
            if (fontPath.indexOf(fileSeparator) != -1)
                fontName = fontPath.substring((fontPath.lastIndexOf(fileSeparator) + 1), fontPath.indexOf("."));
            else
                fontName = fontPath.substring(0, fontPath.indexOf("."));

            // System.out.println(fontName + " " + fontPath);
            try {
                BaseFont currentBaseFont = BaseFont.createFont(fontPath, BaseFont.IDENTITY_H,
                        BaseFont.EMBEDDED);
                fontTreeMap.put(fontName, new Font(currentBaseFont, 12));
            } catch (DocumentException de) {
            } catch (IOException ioe) {
            }
        }
    }
}

From source file:com.empatkepala.view.MyPdfView.java

@Override
protected void buildPdfDocument(Map<String, Object> model, Document document, PdfWriter writer,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    List<CV> cvs = (List<CV>) model.get("cv");
    List<String> cvValue = new ArrayList<>();
    List<String> namaAtribut = new ArrayList<>();

    namaAtribut.add("ID CV :");
    cvValue.add(Long.toString(cvs.get(0).getIdCV()));
    namaAtribut.add("Uid :");
    cvValue.add(cvs.get(0).getUid());/*from  ww  w. ja v  a2s.  c om*/
    namaAtribut.add("Title :");
    cvValue.add(cvs.get(0).getTitle());
    // <<<<<<< feature/mpp
    //         namaAtribut.add("Department :"); cvValue.add(cvs.get(0).getDepartment().toString());
    // =======
    namaAtribut.add("Department :");
    cvValue.add(cvs.get(0).getDepartment());
    // >>>>>>> dev
    namaAtribut.add("Job Title :");
    cvValue.add(cvs.get(0).getJobTitle());
    namaAtribut.add("Full Name :");
    cvValue.add(cvs.get(0).getFullName());
    namaAtribut.add("Place Date Of Birth :");
    cvValue.add(cvs.get(0).getPlaceDateOfBirth());
    namaAtribut.add("Id Card Number :");
    cvValue.add(cvs.get(0).getIdCardNumber());
    namaAtribut.add("Driving License :");
    cvValue.add(cvs.get(0).getDrivingLicense().toString());

    namaAtribut.add("Email :");
    cvValue.add(cvs.get(0).getEmailAddress());
    namaAtribut.add("twitter :");
    cvValue.add(cvs.get(0).getTwitter());
    namaAtribut.add("facebook :");
    cvValue.add(cvs.get(0).getFacebook());
    namaAtribut.add("linkedIn :");
    cvValue.add(cvs.get(0).getLinkedIn());
    namaAtribut.add("blog :");
    cvValue.add(cvs.get(0).getBlog());
    namaAtribut.add("handphone :");
    cvValue.add(cvs.get(0).getHandphone());
    namaAtribut.add("religion :");
    cvValue.add(cvs.get(0).getReligion());
    namaAtribut.add("ethnicty :");
    cvValue.add(cvs.get(0).getEthnicity());

    namaAtribut.add("Marital Status :");
    cvValue.add(cvs.get(0).getMaritalStatus());
    namaAtribut.add("Current Address :");
    cvValue.add(cvs.get(0).getCurrentAddress());
    namaAtribut.add("Home Address :");
    cvValue.add(cvs.get(0).getHomeAddress());
    namaAtribut.add("Home Phone :");
    cvValue.add(cvs.get(0).getHomePhone());
    namaAtribut.add("Emergency Call :");
    cvValue.add(cvs.get(0).getEmergencyCall());
    namaAtribut.add("Father Name :");
    cvValue.add(cvs.get(0).getFatherName());
    namaAtribut.add("Father Birthday :");
    cvValue.add(cvs.get(0).getFatherBirthday());
    namaAtribut.add("Father Latest Education :");
    cvValue.add(cvs.get(0).getFatherLatestEducation());
    namaAtribut.add("Father CurrentJob :");
    cvValue.add(cvs.get(0).getFatherCurrentJob());
    namaAtribut.add("Mother Name :");
    cvValue.add(cvs.get(0).getMotherName());
    namaAtribut.add("Mother Birthday :");
    cvValue.add(cvs.get(0).getMotherBirthday());
    namaAtribut.add("Mother Latest Education :");
    cvValue.add(cvs.get(0).getMotherLatestEducation());
    namaAtribut.add("Mother Current Job :");
    cvValue.add(cvs.get(0).getmotherCurrentJob());
    namaAtribut.add("Spouse Name :");
    cvValue.add(cvs.get(0).getSpouseName());
    namaAtribut.add("Spouse BirthDay :");
    cvValue.add(cvs.get(0).getSpousebirthDay());
    namaAtribut.add("SpouseLatestEducation :");
    cvValue.add(cvs.get(0).getSpouseLatestEducation());
    namaAtribut.add("SpouseCurrentJob() :");
    cvValue.add(cvs.get(0).getSpouseCurrentJob());
    namaAtribut.add("Responsibilities :");
    cvValue.add(cvs.get(0).getResponsibilities());
    namaAtribut.add("Responsibilities Type :");
    cvValue.add(cvs.get(0).getResponsibilitiesType());

    namaAtribut.add("School :");
    cvValue.add(cvs.get(0).getSchool().get(0).getSchoolName());
    namaAtribut.add("Major :");
    cvValue.add(cvs.get(0).getSchool().get(0).getMajor());
    namaAtribut.add("City :");
    cvValue.add(cvs.get(0).getSchool().get(0).getCity());
    namaAtribut.add("Periode :");
    cvValue.add(cvs.get(0).getSchool().get(0).getPeriode());
    namaAtribut.add("GPA :");
    cvValue.add(cvs.get(0).getSchool().get(0).getGpa().toString());
    namaAtribut.add("School :");
    cvValue.add(cvs.get(0).getSchool().get(1).getSchoolName());
    namaAtribut.add("Major :");
    cvValue.add(cvs.get(0).getSchool().get(1).getMajor());
    namaAtribut.add("City :");
    cvValue.add(cvs.get(0).getSchool().get(1).getCity());
    namaAtribut.add("Periode :");
    cvValue.add(cvs.get(0).getSchool().get(1).getPeriode());
    namaAtribut.add("GPA :");
    cvValue.add(cvs.get(0).getSchool().get(1).getGpa().toString());

    namaAtribut.add("Reason Major :");
    cvValue.add(cvs.get(0).getReasonMajor());
    namaAtribut.add("mother titleThesis :");
    cvValue.add(cvs.get(0).getTitleThesis());

    namaAtribut.add("Non Formal Course");
    cvValue.add(cvs.get(0).getNonFrmlCrs().get(0).getNameOfCourse());
    namaAtribut.add("Organizer");
    cvValue.add(cvs.get(0).getNonFrmlCrs().get(0).getOrganizer());
    namaAtribut.add("Year");
    cvValue.add(String.valueOf(cvs.get(0).getNonFrmlCrs().get(0).getYear()));
    namaAtribut.add("Notes");
    cvValue.add(cvs.get(0).getNonFrmlCrs().get(0).getNotes());
    namaAtribut.add("Non Formal Course");
    cvValue.add(cvs.get(0).getNonFrmlCrs().get(1).getNameOfCourse());
    namaAtribut.add("Organizer");
    cvValue.add(cvs.get(0).getNonFrmlCrs().get(0).getOrganizer());
    namaAtribut.add("Year");
    cvValue.add(String.valueOf(cvs.get(0).getNonFrmlCrs().get(1).getYear()));
    namaAtribut.add("Notes");
    cvValue.add(cvs.get(0).getNonFrmlCrs().get(1).getNotes());
    namaAtribut.add("Non Formal Course");
    cvValue.add(cvs.get(0).getNonFrmlCrs().get(2).getNameOfCourse());
    namaAtribut.add("Organizer");
    cvValue.add(cvs.get(0).getNonFrmlCrs().get(2).getOrganizer());
    namaAtribut.add("Year");
    cvValue.add(String.valueOf(cvs.get(0).getNonFrmlCrs().get(2).getYear()));
    namaAtribut.add("Notes");
    cvValue.add(cvs.get(0).getNonFrmlCrs().get(2).getNotes());

    namaAtribut.add("Achievements");
    cvValue.add(cvs.get(0).getAchievements().get(0).getAchievement());
    namaAtribut.add("year");
    cvValue.add(String.valueOf(cvs.get(0).getAchievements().get(0).getYear()));
    namaAtribut.add("notes");
    cvValue.add(cvs.get(0).getAchievements().get(0).getNotes());

    namaAtribut.add("Achievements");
    cvValue.add(cvs.get(0).getAchievements().get(1).getAchievement());
    namaAtribut.add("year");
    cvValue.add(String.valueOf(cvs.get(0).getAchievements().get(1).getYear()));
    namaAtribut.add("notes");
    cvValue.add(cvs.get(0).getAchievements().get(1).getNotes());

    namaAtribut.add("Social Activity");
    cvValue.add(cvs.get(0).getSocialact().get(0).getNameOrganization());
    namaAtribut.add("FieldOfOrganization");
    cvValue.add(String.valueOf(cvs.get(0).getSocialact().get(0).getFieldOfOrganization()));
    namaAtribut.add("AttendancePeriod");
    cvValue.add(String.valueOf(cvs.get(0).getSocialact().get(0).getAttendancePeriod()));
    namaAtribut.add("Notes");
    cvValue.add(cvs.get(0).getSocialact().get(0).getNotes());

    namaAtribut.add("Social Activity");
    cvValue.add(cvs.get(0).getSocialact().get(1).getNameOrganization());
    namaAtribut.add("FieldOfOrganization");
    cvValue.add(String.valueOf(cvs.get(0).getSocialact().get(1).getFieldOfOrganization()));
    namaAtribut.add("AttendancePeriod");
    cvValue.add(String.valueOf(cvs.get(0).getSocialact().get(1).getAttendancePeriod()));
    namaAtribut.add("Notes");
    cvValue.add(cvs.get(0).getSocialact().get(1).getNotes());

    namaAtribut.add("Language");
    cvValue.add(cvs.get(0).getLanguage().get(0).getNameOfLanguage());
    namaAtribut.add("spokenLanguage");
    cvValue.add(String.valueOf(cvs.get(0).getLanguage().get(0).getspokenLanguage()));
    namaAtribut.add("writtenLanguage");
    cvValue.add(String.valueOf(cvs.get(0).getLanguage().get(0).getwrittenLanguage()));

    namaAtribut.add("Reason Interested In GDN :");
    cvValue.add(cvs.get(0).getReasonInterestedInGDN());
    namaAtribut.add("Reason Apply On That Position :");
    cvValue.add(cvs.get(0).getReasonApplyOnThatPosition());
    namaAtribut.add("Factor Encourage You On That Job :");
    cvValue.add(cvs.get(0).getFactorEncourageYouOnThatJob());
    namaAtribut.add("Kind Of Environtment :");
    cvValue.add(cvs.get(0).getKindOfEnvirontment());
    namaAtribut.add("LifeValue :");
    cvValue.add(cvs.get(0).getLifeValue());
    namaAtribut.add("SpesificSkill :");
    cvValue.add(cvs.get(0).getSpesificSkill());
    namaAtribut.add("Hobbies :");
    cvValue.add(cvs.get(0).getHobbies());
    namaAtribut.add("Describe About You :");
    cvValue.add(cvs.get(0).getDescribeAboutYou());
    namaAtribut.add("PlaceGetInformationGDN :");
    cvValue.add(cvs.get(0).getPlaceGetInformationGDN());
    namaAtribut.add("Relative Working On GDN :");
    cvValue.add(cvs.get(0).getRelativeWorkingOnGDN());
    namaAtribut.add("Have Applied On GDN :");
    cvValue.add(cvs.get(0).getHaveAppliedOnGDN());
    namaAtribut.add("Have Part Time Job :");
    cvValue.add(cvs.get(0).getHavePartTimejob());
    namaAtribut.add("Time Start Work :");
    cvValue.add(cvs.get(0).getTimeStartWork());
    namaAtribut.add("Applicant Status :");
    cvValue.add(cvs.get(0).getApplicantStatus());

    namaAtribut.add("Children");
    cvValue.add(cvs.get(0).getChil().get(0).getChildrenName());
    namaAtribut.add("Children Birthday");
    cvValue.add(String.valueOf(cvs.get(0).getChil().get(0).getChildrenBirthday()));
    namaAtribut.add("Children Current Job");
    cvValue.add(String.valueOf(cvs.get(0).getChil().get(0).getChildrenCurrentJob()));
    namaAtribut.add("Children Last Education");
    cvValue.add(String.valueOf(cvs.get(0).getChil().get(0).getChilLatestEdu()));

    namaAtribut.add("Children");
    cvValue.add(cvs.get(0).getChil().get(0).getChildrenName());
    namaAtribut.add("Children Birthday");
    cvValue.add(String.valueOf(cvs.get(0).getChil().get(0).getChildrenBirthday()));
    namaAtribut.add("Children Current Job");
    cvValue.add(String.valueOf(cvs.get(0).getChil().get(0).getChildrenCurrentJob()));
    namaAtribut.add("Children Latest Education");
    cvValue.add(String.valueOf(cvs.get(0).getChil().get(0).getChilLatestEdu()));

    namaAtribut.add("Brothers");
    cvValue.add(String.valueOf(cvs.get(0).getBro().get(0).getBrothersName()));
    namaAtribut.add("Brother Birthday");
    cvValue.add(String.valueOf(cvs.get(0).getBro().get(0).getBrothersBirthday()));
    namaAtribut.add("Brother Latest Education");
    cvValue.add(String.valueOf(cvs.get(0).getBro().get(0).getBrotherLatestEducation()));
    namaAtribut.add("Brother Current Job");
    cvValue.add(String.valueOf(cvs.get(0).getBro().get(0).getBrotherCurrentJob()));

    namaAtribut.add("Work Experience");
    cvValue.add(cvs.get(0).getWorkExp().get(0).getCompanyName());
    namaAtribut.add("Company Field");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(0).getCompanyField()));
    namaAtribut.add("Position");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(0).getPosition()));
    namaAtribut.add("Period");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(0).getPeriod()));
    namaAtribut.add("Work Experience");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(0).getJobDescription()));
    namaAtribut.add("Reason to Leave");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(0).getReasonToLeave()));
    namaAtribut.add("References Name");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(0).getReferenceName()));
    namaAtribut.add("Reference Position");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(0).getReferencePosition()));
    namaAtribut.add("Reference Phone Number");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(0).getReferencePhoneNumber()));
    namaAtribut.add("Organization Chart");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(0).getOrganizationalChart()));

    namaAtribut.add("Work Experience");
    cvValue.add(cvs.get(0).getWorkExp().get(1).getCompanyName());
    namaAtribut.add("Company Field");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(1).getCompanyField()));
    namaAtribut.add("Position");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(1).getPosition()));
    namaAtribut.add("Period");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(1).getPeriod()));
    namaAtribut.add("Work Experience");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(1).getJobDescription()));
    namaAtribut.add("Reason to Leave");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(1).getReasonToLeave()));
    namaAtribut.add("References Name");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(1).getReferenceName()));
    namaAtribut.add("Reference Position");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(1).getReferencePosition()));
    namaAtribut.add("Reference Phone Number");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(1).getReferencePhoneNumber()));
    namaAtribut.add("Organization Chart");
    cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(1).getOrganizationalChart()));

    //

    PdfPTable table = new PdfPTable(2);
    table.setWidthPercentage(85);
    table.setWidths(new int[] { 3, 4 });

    Font headFont = FontFactory.getFont(FontFactory.HELVETICA_BOLD);
    for (CV cv : cvs) {
        for (int i = 0; i < namaAtribut.size(); i++) {
            PdfPCell hcell;
            hcell = new PdfPCell(new Phrase("  " + namaAtribut.get(i), headFont));
            hcell.setHorizontalAlignment(Element.ALIGN_LEFT);
            table.addCell(hcell);

            hcell = new PdfPCell(new Phrase("   " + cvValue.get(i)));
            hcell.setHorizontalAlignment(Element.ALIGN_LEFT);
            table.addCell(hcell);

        }
    }

    //        PdfPTable table = new PdfPTable(1);
    //        table.setWidthPercentage(60);
    //        table.setWidths(new int[] {4});
    //
    //        Font headFont = FontFactory.getFont(FontFactory.HELVETICA_BOLD);

    //        PdfPCell hcell;
    //        hcell = new PdfPCell(new Phrase("Data", headFont));
    //        hcell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    //        hcell.setHorizontalAlignment(Element.ALIGN_CENTER);
    //        table.addCell(hcell);

    for (CV cv : cvs) {

        //            PdfPCell cell;
        //
        //            cell = new PdfPCell(new Phrase("ID CV :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(Long.toString(cv.getIdCV())));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Uid :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getUid()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Title :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getTitle()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Job Title :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getJobTitle()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Full Name :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getFullName()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Place Date Of Birth :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getTitle()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("idCardNumber :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getIdCardNumber()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Driving License :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            ArrayList<String> sim = new ArrayList<String>();
        //            sim = cv.getDrivingLicense();
        //            cell = new PdfPCell(new Phrase(sim.toString()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Email :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getEmailAddress()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("twitter :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getTwitter()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("facebook :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getFacebook()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("linkedIn :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getLinkedIn()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("blog :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getBlog()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("handphone :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getHandphone()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("religion :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getReligion()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("ethnicty :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getEthnicity()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Marital Status :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getMaritalStatus()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Content Address :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getCurrentAddress()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Home Address :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getEmailAddress()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Home Phone :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getHomePhone()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("emergency Call :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getEmergencyCall()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Father Name :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getFatherName()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Father Birthday :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getFatherBirthday()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Father Latest Education :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getFatherLatestEducation()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Father Current Job :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getFatherCurrentJob()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Mother Name :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getMotherName()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Mother Birthday :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getMotherBirthday()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Mother Latest Education :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getEmailAddress()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Mother Current Job :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getEmailAddress()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Spouse name :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getSpouseName()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Spouse Birthday :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getSpousebirthDay()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Spouse Latest Education :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getSpouseLatestEducation()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Spouse Current Job :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getSpouseCurrentJob()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Responsibilities :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getResponsibilities()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Responsibilities Type :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getResponsibilitiesType()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase("Responsibilities :"));
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell(new Phrase(cv.getResponsibilities()));
        //            cell.setPaddingLeft(5);
        //            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table.addCell(cell);

    }

    document.add(table);
}

From source file:com.javaPdf.app.GeneradorContrato.java

public static void writePDF() {

    //        Document document = new Document() ;
    Document document = new Document(PageSize.LETTER, 65, 65, 60, 60);

    try {/*from   ww  w  . j a v  a2  s . c  om*/

        /*Font que usaran las palabras destacadas con NEGRITA*/

        Font font_negrita = FontFactory.getFont("Times New Roman");
        font_negrita.setSize(11);
        font_negrita.setStyle(Font.BOLD);
        font_negrita.setFamily(Font.FontFamily.TIMES_ROMAN.toString());

        Scanner sc = new Scanner(System.in);

        Calendar calendarioGragoriano = new GregorianCalendar(12, Calendar.MONTH, 2017);

        /*Inicializar un objeto de tipo Calendar con un metodo de clase (Static) el cual
        obtiene una onstancia de la clase puede ser mas sencillo*/
        Calendar calendario = Calendar.getInstance();

        System.out.println(Calendar.DAY_OF_MONTH);
        System.out.println(calendario.getTime());

        /*Datos ingresados por teclado*/

        System.out.println("Ingrese el NOMBRE DEL EMPLEADOR: ");

        Chunk nombreEmpleador = new Chunk("[EMPLEADOR]", font_negrita);

        System.out.println("Ingrese el RUT DEL EMPLEADOR: ");

        Chunk rutEmpleador = new Chunk("xx.xxx.xxx-x", font_negrita);
        System.out.println("Ingrese el NOMBRE DEL TRABAJADOR: ");
        //            Chunk nombreTrabajador = new Chunk ("DATO DE PRUEBA", font_negrita);
        Chunk nombreTrabajador = new Chunk(sc.nextLine(), font_negrita);

        System.out.println("Ingrese el RUT DEL TRABAJADOR: ");
        //            Chunk rutTrabajador = new Chunk ("DATO DE PRUEBA", font_negrita);
        Chunk rutTrabajador = new Chunk(sc.nextLine(), font_negrita);

        System.out.println("Ingrese la DIRECCIN DEL TRABAJADOR: ");
        //            Chunk direccionTrabajador = new Chunk ("DATO DE PRUEBA", font_negrita);
        Chunk direccionTrabajador = new Chunk(sc.nextLine(), font_negrita);

        System.out.println("Ingrese la COMUNA DEL TRABAJADOR: ");
        //            Chunk comunaTrabajador = new Chunk ("DATO DE PRUEBA", font_negrita);
        Chunk comunaTrabajador = new Chunk(sc.nextLine(), font_negrita);

        System.out.println("Ingrese la FECHA DE NACIMIENTO DEL TRABAJADOR: ");
        //            Chunk fechaNacimientoTrabajador = new Chunk ("DATO DE PRUEBA", font_negrita);
        Chunk fechaNacimientoTrabajador = new Chunk(sc.nextLine(), font_negrita);

        System.out.println("Ingrese el SUELDO QUE TENDRA EL TRABAJADOR: ");
        //            Chunk sueldoTrabajador = new Chunk ("DATO DE PRUEBA", font_negrita);
        Chunk sueldoTrabajador = new Chunk(sc.nextLine(), font_negrita);

        System.out.println("Ingrese la FUNCION QUE TENDRA EL TRABAJADOR: ");
        //            Chunk funcionTrabajador = new Chunk ("DATO DE PRUEBA", font_negrita);
        Chunk funcionTrabajador = new Chunk(sc.nextLine().toUpperCase(), font_negrita);

        System.out.println("Ingrese la FECHA DE INICIO DE CONTRATO DEL TRABAJADOR: ");
        //            Chunk fechaInicioContrato = new Chunk ("DATO DE PRUEBA", font_negrita);
        Chunk fechaInicioContrato = new Chunk(sc.nextLine(), font_negrita);

        System.out.println("Ingrese la FECHA DE TERMINO DE CONTRATO DEL TRABAJADOR: ");
        //            Chunk fechaTerminoContrato = new Chunk ("DATO DE PRUEBA", font_negrita);
        Chunk fechaTerminoContrato = new Chunk(sc.nextLine(), font_negrita);

        /*Clausulas*/
        Chunk primero = new Chunk(TEXTOPRIMERO, font_negrita);
        Chunk segundo = new Chunk(TEXTOSEGUNDO, font_negrita);
        Chunk tercero = new Chunk(TEXTOTERCERO, font_negrita);
        Chunk cuarto = new Chunk(TEXTOCUARTO, font_negrita);
        Chunk quinto = new Chunk(TEXTOQUINTO, font_negrita);
        Chunk sexto = new Chunk(TEXTOSEXTO, font_negrita);
        Chunk septimo = new Chunk(TEXTOSEPTIMO, font_negrita);
        Chunk octavo = new Chunk(TEXTOOCTAVO, font_negrita);
        Chunk noveno = new Chunk(TEXTONOVENO, font_negrita);
        //            Chunk afp = new Chunk (TEXTONOVENO2, font_negrita);
        //            Chunk salud = new Chunk (TEXTONOVENO4, font_negrita);
        //            Chunk cesantia = new Chunk (TEXTONOVENO6, font_negrita);
        Chunk decimo = new Chunk(TEXTODECIMO, font_negrita);
        Chunk undecimo = new Chunk(TEXTOUNDECIMO, font_negrita);

        //            Calendar calendario = Calendar.getInstance();
        SimpleDateFormat formateador = new SimpleDateFormat("dd 'de' MMMM 'de' yyyy", new Locale("es"));
        Date fechaDate = new Date();
        Chunk fecha = new Chunk(formateador.format(fechaDate), font_negrita);

        String path = new File(".").getCanonicalPath();
        String FILE_NAME = path + "/CONTRATO " + nombreTrabajador + " RUT " + rutTrabajador + ".pdf";

        PdfWriter.getInstance(document, new FileOutputStream(new File(FILE_NAME)));

        //            Image firmaEmpleador = Image.getInstance(path + "/img/firmaEmpleador.png");
        //            firmaEmpleador.scaleAbsoluteWidth(150f);
        //            firmaEmpleador.scaleAbsoluteHeight(70f);
        //            firmaEmpleador.setAbsolutePosition(70f, 200f);
        //            
        Image timbreGerencia = Image.getInstance(path + "/img/timbreGerencia.png");
        timbreGerencia.scaleAbsoluteWidth(90f);
        timbreGerencia.scaleAbsoluteHeight(75f);
        timbreGerencia.setAbsolutePosition(230, 200f);
        //            
        Image firmaTrabajador = Image.getInstance(path + "/img/firmaTrabajador.png");
        firmaTrabajador.scaleAbsoluteWidth(160f);
        firmaTrabajador.scaleAbsoluteHeight(70f);
        firmaTrabajador.setAbsolutePosition(350, 175f);
        //            
        //            Image todoEnUno = Image.getInstance(path + "/img/todoEnUno.png");
        //            todoEnUno.scaleAbsoluteWidth(550);
        //            todoEnUno.scaleAbsoluteHeight(150);
        //            todoEnUno.setAbsolutePosition(15, 120f);

        document.open();
        FontFactory.registerDirectories();

        /*Parrafo de Titulo*/

        String tituloContrato_texto = "CONTRATO DE TRABAJO:\n";

        Font font_titulo = FontFactory.getFont("Times New Roman");
        font_titulo.setSize(14);
        font_titulo.setStyle(Font.BOLD | Font.UNDERLINE);
        font_titulo.setFamily(Font.FontFamily.TIMES_ROMAN.toString());
        Paragraph parrafoTitulo = new Paragraph(tituloContrato_texto, font_titulo);
        parrafoTitulo.setAlignment(Element.ALIGN_CENTER);

        document.add(parrafoTitulo);

        Font font_primer_parrafo = FontFactory.getFont("Times New Roman");
        font_primer_parrafo.setSize(11);
        //            font_primer_parrafo.setStyle(Font.BOLD | Font.UNDERLINE);
        font_primer_parrafo.setFamily(Font.FontFamily.TIMES_ROMAN.toString());

        Paragraph primer_parrafo = new Paragraph();

        /*Agregar CHunks a el parrafo*/
        /*PRIMER PARRAFO*/
        primer_parrafo.setAlignment(Element.ALIGN_JUSTIFIED);
        primer_parrafo.setLeading(15);
        primer_parrafo.setFont(font_primer_parrafo);
        primer_parrafo.add(TEXTO1);
        primer_parrafo.add(fecha);
        primer_parrafo.add(TEXTO2);
        primer_parrafo.add(nombreEmpleador);
        primer_parrafo.add(TEXTO3);
        primer_parrafo.add(rutEmpleador);
        primer_parrafo.add(TEXTO4);
        primer_parrafo.add(nombreTrabajador);
        primer_parrafo.add(TEXTO5);
        primer_parrafo.add(rutTrabajador);
        primer_parrafo.add(TEXTO6);
        primer_parrafo.add(direccionTrabajador);
        primer_parrafo.add(TEXTO7);
        primer_parrafo.add(comunaTrabajador);
        primer_parrafo.add(TEXTO8);
        primer_parrafo.add(fechaNacimientoTrabajador);
        primer_parrafo.add(TEXTO9);

        /*PRIMERA CLAUSULA*/
        primer_parrafo.add(primero);
        primer_parrafo.add(TEXTOPRIMERO1);
        primer_parrafo.add(funcionTrabajador);
        primer_parrafo.add(TEXTOPRIMERO2);

        /*SEGUNDA CLAUSULA*/
        primer_parrafo.add(segundo);
        //            primer_parrafo.add(TEXTOSEGUNDO1);

        /*TERCERA CLAUSULA*/
        primer_parrafo.add(tercero);
        primer_parrafo.add(TEXTOTERCERO1);
        primer_parrafo.add(Chunk.TABBING);
        primer_parrafo.add(TEXTOTERCERO2A);
        primer_parrafo.add(sueldoTrabajador);
        primer_parrafo.add(TEXTOTERCERO3A);
        primer_parrafo.add(Chunk.TABBING);
        primer_parrafo.add(TEXTOTERCERO4B);

        /*CUARTA CLAUSULA*/
        primer_parrafo.add(cuarto);
        //            primer_parrafo.add(TEXTOCUARTO1);

        /*QUINTA CLAUSULA*/
        primer_parrafo.add(quinto);
        //            primer_parrafo.add(TEXTOQUINTO1);

        /*SEXTA CLAUSULA*/
        primer_parrafo.add(sexto);
        //            primer_parrafo.add(TEXTOSEXTO1);

        /*SEPTIMA CLAUSULA*/
        primer_parrafo.add(septimo);
        //            primer_parrafo.add(TEXTOSEPTIMO1);
        primer_parrafo.add(Chunk.TABBING);
        //            primer_parrafo.add(TEXTOSEPTIMO2A);
        primer_parrafo.add(Chunk.TABBING);
        //            primer_parrafo.add(TEXTOSEPTIMO3B);
        primer_parrafo.add(Chunk.TABBING);
        //            primer_parrafo.add(TEXTOSEPTIMO4C);
        primer_parrafo.add(Chunk.TABBING);
        //            primer_parrafo.add(TEXTOSEPTIMO5D);
        primer_parrafo.add(Chunk.TABBING);
        //            primer_parrafo.add(TEXTOSEPTIMO6E);
        primer_parrafo.add(Chunk.TABBING);
        //            primer_parrafo.add(TEXTOSEPTIMO7F);
        primer_parrafo.add(Chunk.TABBING);
        //            primer_parrafo.add(TEXTOSEPTIMO8G);
        primer_parrafo.add(Chunk.TABBING);
        //            primer_parrafo.add(TEXTOSEPTIMO9H);

        /*OCTAVA CLAUSULA*/
        primer_parrafo.add(octavo);
        //            primer_parrafo.add(TEXTOOCTAVO1);

        /*NOVENA CLAUSULA*/
        primer_parrafo.add(noveno);
        //            primer_parrafo.add(TEXTONOVENO1);
        //            primer_parrafo.add(afp);
        //            primer_parrafo.add(TEXTONOVENO3);
        //            primer_parrafo.add(salud);
        //            primer_parrafo.add(TEXTONOVENO5);
        //            primer_parrafo.add(cesantia);

        /*public static final String TEXTONOVENO2 = " PROVIDA";
        public static final String TEXTONOVENO3 = "  Salud:";
        public static final String TEXTONOVENO4 = "FONASA";
        public static final String TEXTONOVENO5 = ", y las de cesanta en:";
        public static final String TEXTONOVENO6 = " AFC. \n\n";*/

        /*DCIMA CLAUSULA*/
        primer_parrafo.add(decimo);
        primer_parrafo.add(TEXTODECIMO1);
        primer_parrafo.add(fechaInicioContrato);
        primer_parrafo.add(TEXTODECIMO2);
        primer_parrafo.add(fechaTerminoContrato);
        primer_parrafo.add(TEXTODECIMO3);

        /*UNDECIMA CLAUSULA*/
        primer_parrafo.add(undecimo);
        //            primer_parrafo.add(TEXTOUNDECIMO1);

        document.add(primer_parrafo);

        //            document.add(todoEnUno);
        document.add(timbreGerencia);
        document.add(firmaTrabajador);
        document.addAuthor("IGVI");
        document.addTitle("CONTRATO DE TRABAJO IGVI");
        document.close();

    } catch (DocumentException e) {
        e.getMessage();
    } catch (IOException e) {
        e.getMessage();
    }

}

From source file:com.sapito.pdf.PDFView.PDFGeneratorActivosFijos.java

public void crearPDFInversion(HttpServletResponse hsr1, ArrayList<HashMap> resultados,
        double granTotalDepActual, double granTotalValorActual, double granTotalValorOr) throws Exception {
    Document dcmntaf = new Document();

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PdfWriter.getInstance(dcmntaf, baos);
    System.out.println(resultados.get(0).size());

    dcmntaf.open();/*from www.j  a va 2s .c  om*/
    dcmntaf.open();
    dcmntaf.addTitle("Sapito PDFs");
    dcmntaf.addSubject("Pdf de sapito");

    //------------------------ TAIS  ______________________________
    Image tais = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/tais-banner.jpg"));
    dcmntaf.add(tais);

    //---------------------  BODY    ---------------------------------------------------------
    Image body = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/body.png"));
    body.setAlignment(Image.UNDERLYING);
    body.setTransparency(new int[] { 0x00, 0x10 });
    body.setAbsolutePosition(50, 250);
    dcmntaf.add(body);
    //-------------------------------------------------------------------------------------------
    Image footer = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/footer.jpg"));
    footer.setAbsolutePosition(50, 20);
    dcmntaf.add(footer);
    //----------------------  TITLE ---------------------------
    String titulo = "Reporte de Inversin"; //Cambiar el titulo del PDF aqui
    Font f = new Font(FontFamily.HELVETICA, 25.0f, Font.BOLD, BaseColor.BLACK);
    Chunk c = new Chunk(titulo + " \n ", f);
    c.setBackground(BaseColor.WHITE);
    Paragraph title = new Paragraph(c);
    title.setAlignment(Element.ALIGN_CENTER);

    String titulo2 = "Reporte de Activos Fijos por Tipo"; //Cambiar el titulo del PDF aqui
    Font f2 = new Font(FontFamily.HELVETICA, 12.0f, Font.NORMAL, BaseColor.BLACK);
    Chunk c2 = new Chunk(titulo2 + " \n ", f2);
    c2.setBackground(BaseColor.WHITE);
    Paragraph title2 = new Paragraph(c2);
    title2.setAlignment(Element.ALIGN_LEFT);
    title2.setIndentationLeft(50);
    //-------------------------  CONTENIDO -------------------------------------------------------
    dcmntaf.add(title); //Titulo del PDF
    dcmntaf.add(title2);
    PdfPTable table = new PdfPTable(4);

    //                                 PdfPCell cell;
    //                            cell = new PdfPCell(new Phrase("Tipo de A", FontFactory.getFont("TIMES_ROMAN", 12, Font.BOLD, BaseColor.BLACK)));                     
    //                        table.addCell(cell);      
    table.addCell("Tipo de Activo fijo");
    table.addCell("Valor Original");
    table.addCell("Depreciacin Actual ");
    table.addCell("Valor Actual");
    //        Iterator it = resultados.get(0).entrySet().iterator();
    for (int i = 0; i < resultados.size(); i++) {
        table.addCell(resultados.get(i).get("tipo").toString());
        table.addCell(resultados.get(i).get("valorOriginal").toString());
        table.addCell(resultados.get(i).get("depreciacionActual").toString());
        table.addCell(resultados.get(i).get("valoreActual").toString());
    }

    //        while (it.hasNext()) {
    //            Map.Entry e = (Map.Entry) it.next();
    //            System.out.println(e.getKey() + " " + e.getValue());
    //            
    //            table.addCell(e.getValue().toString());
    //        }

    dcmntaf.add(table);

    String titulo3 = "Reporte Total de Activos Fijos"; //Cambiar el titulo del PDF aqui
    Font f3 = new Font(FontFamily.HELVETICA, 12.0f, Font.NORMAL, BaseColor.BLACK);
    Chunk c3 = new Chunk(titulo3 + " \n ", f3);
    c3.setBackground(BaseColor.WHITE);

    Paragraph title3 = new Paragraph(c3);
    title3.setAlignment(Element.ALIGN_LEFT);
    title3.setIndentationLeft(50);
    dcmntaf.add(title3);

    PdfPTable table2 = new PdfPTable(3);
    //                                 PdfPCell cell;
    //                            cell = new PdfPCell(new Phrase("Tipo de A", FontFactory.getFont("TIMES_ROMAN", 12, Font.BOLD, BaseColor.BLACK)));                     
    //                        table.addCell(cell);                        
    table2.addCell("Valor Original Total");
    table2.addCell("Depreciacin Anual Total");
    table2.addCell("Valor Total");
    table2.addCell(granTotalValorOr + "");
    table2.addCell(granTotalDepActual + "");
    table2.addCell(granTotalValorActual + "");

    dcmntaf.add(table2);

    PdfPTable table3 = new PdfPTable(1);
    table3.setWidthPercentage(100.0f);
    table3.setWidths(new float[] { 2.0f });
    table3.setSpacingBefore(10);

    // define font for table header row
    Font font = FontFactory.getFont(FontFactory.COURIER_BOLD);
    font.setColor(BaseColor.WHITE);

    // define table header cell
    PdfPCell cell = new PdfPCell();
    cell.setBackgroundColor(BaseColor.BLUE);
    cell.setPadding(5);

    // write table header 
    cell.setPhrase(new Phrase("Resultado", font));
    table3.addCell(cell);
    Depreciacion dep = new Depreciacion();

    String bla = a + " ";
    table3.addCell(bla);

    //-------------------------- FIN CONTENIDO -----------------
    dcmntaf.close();

    dcmntaf.close();

    byte[] bytes = baos.toByteArray();

    hsr1.setContentType("application/pdf");
    hsr1.setContentLength(bytes.length);
    hsr1.getOutputStream().write(bytes);
}