Example usage for com.itextpdf.text Paragraph Paragraph

List of usage examples for com.itextpdf.text Paragraph Paragraph

Introduction

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

Prototype

public Paragraph() 

Source Link

Document

Constructs a Paragraph.

Usage

From source file:client.welcome2.java

private void genRepButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_genRepButtonActionPerformed
    Document doc = new Document();
    PdfWriter docWriter = null;/*www . j a  v a  2 s .com*/
    int repID = ThreadLocalRandom.current().nextInt(10000, 99999 + 1);
    DecimalFormat df = new DecimalFormat("0.00");
    //Date d = Calendar.getInstance().getTime();
    DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
    Date date = new Date();

    try {

        //special font sizes
        Font bfBold12 = new Font(FontFamily.TIMES_ROMAN, 12, Font.BOLD, new BaseColor(0, 0, 0));
        Font bf12 = new Font(FontFamily.TIMES_ROMAN, 12);

        //file path
        String dt = dateFormat.format(date);
        sFileName = "Report No- " + repID + " Project Report- " + dt + " Status " + report_status + " .pdf";
        String path = "src/ProjectReports/" + sFileName;
        docWriter = PdfWriter.getInstance(doc, new FileOutputStream(path));

        DateFormat dateFormat3 = new SimpleDateFormat("dd/MM/yyyy HH:mm");
        String d = dateFormat3.format(Calendar.getInstance().getTime());

        //document header attributes
        doc.addCreationDate();
        doc.setPageSize(PageSize.LETTER);

        //open document
        doc.open();

        //create a paragraph
        DateFormat dateFormat2 = new SimpleDateFormat("dd/MM/yyyy");
        String sd2 = dateFormat2.format(pBeginDateChooser.getDate());
        String ed2 = dateFormat2.format(pEndDateChooser.getDate());
        Image image = Image.getInstance("src/Images/logo for pdf.png");
        Font font1 = new Font(Font.FontFamily.HELVETICA, 25, Font.BOLD);
        Paragraph paragraph = new Paragraph();
        Paragraph paragraph2 = new Paragraph("This report was generated by " + loginGUI.username + " at " + d
                + "\nYou can see all projects from " + sd2 + " to " + ed2);
        image.setAlignment(Image.RIGHT);
        doc.add(image);

        //specify column widths
        float[] columnWidths = { 2f, 2f, 2f, 2f, 2f };
        //create PDF table with the given widths
        PdfPTable table = new PdfPTable(columnWidths);
        // set table width a percentage of the page width
        table.setWidthPercentage(100f);

        //insert column headings
        insertCell(table, "Project ID", Element.ALIGN_CENTER, 1, bfBold12);
        insertCell(table, "Project Name", Element.ALIGN_CENTER, 1, bfBold12);
        insertCell(table, "Start Date", Element.ALIGN_CENTER, 1, bfBold12);
        insertCell(table, "Due Date", Element.ALIGN_CENTER, 1, bfBold12);
        insertCell(table, "Status", Element.ALIGN_CENTER, 1, bfBold12);
        table.setHeaderRows(1);

        //insert an empty row
        /* insertCell(table, "", Element.ALIGN_LEFT, 4, bfBold12);*/
        //create section heading by cell merging
        /* insertCell(table, "New York Orders ...", Element.ALIGN_LEFT, 4, bfBold12);*/
        /*double orderTotal, total = 0;*/

        String add1, add2, add3, add4, add5;
        DateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
        String sd = dateFormat1.format(pBeginDateChooser.getDate());
        String ed = dateFormat1.format(pEndDateChooser.getDate());

        if (report_status.equals("All")) {
            try {

                String sql = "select project_id,project_name,start_date,due_date,status from projects where due_date >= '"
                        + sd + "' and due_date <= '" + ed + "' and start_date >= '" + sd
                        + "'and start_date <= '" + ed + "'";
                pst = conn.prepareStatement(sql);
                rs = pst.executeQuery();
                while (rs.next()) {
                    add1 = rs.getString("project_id");
                    add2 = rs.getString("project_name");
                    add3 = dateFormat.format(rs.getDate("start_date"));
                    add4 = dateFormat.format(rs.getDate("due_date"));
                    add5 = rs.getString("status");
                    insertCell(table, add1, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add2, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add3, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add4, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add5, Element.ALIGN_CENTER, 1, bf12);

                }
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, e);

            }
        } else {
            try {

                String sql = "select project_id,project_name,start_date,due_date,status from projects where status = '"
                        + report_status + "' and due_date >= '" + sd + "' and due_date <= '" + ed
                        + "' and start_date >= '" + sd + "'and start_date <= '" + ed + "'";
                pst = conn.prepareStatement(sql);
                rs = pst.executeQuery();
                while (rs.next()) {
                    add1 = rs.getString("project_id");
                    add2 = rs.getString("project_name");
                    add3 = dateFormat.format(rs.getDate("start_date"));
                    add4 = dateFormat.format(rs.getDate("due_date"));
                    add5 = rs.getString("status");
                    insertCell(table, add1, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add2, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add3, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add4, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add5, Element.ALIGN_CENTER, 1, bf12);

                }
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, e);

            }
        }

        //add the PDF table to the paragraph
        paragraph2.add(table);

        // add the paragraph to the document
        doc.add(new Paragraph("\nProject Status Report " + dt + "\n", font1));
        doc.add(paragraph2);
    } catch (DocumentException dex) {
        dex.printStackTrace();
    } catch (Exception ex) {
        ex.printStackTrace();
    } finally {
        if (doc != null) {
            //close the document
            doc.close();
            JOptionPane.showMessageDialog(null, "Report No " + repID + " Generated!");
        }
        if (docWriter != null) {
            //close the writer
            docWriter.close();
        }
    }
    saveToDB(report_status, date, repID);
}

From source file:client.welcome3.java

private void genRepButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_genRepButtonActionPerformed
    Document doc = new Document();
    PdfWriter docWriter = null;// ww w. ja  v a2 s  .c  o  m
    int repID = ThreadLocalRandom.current().nextInt(10000, 99999 + 1);
    DecimalFormat df = new DecimalFormat("0.00");
    //Date d = Calendar.getInstance().getTime();
    DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
    Date date = new Date();

    try {

        //special font sizes
        Font bfBold12 = new Font(FontFamily.TIMES_ROMAN, 12, Font.BOLD, new BaseColor(0, 0, 0));
        Font bf12 = new Font(FontFamily.TIMES_ROMAN, 12);

        //file path
        String dt = dateFormat.format(date);
        sFileName = "Report No- " + repID + " Project Report- " + dt + " Status " + report_status + " .pdf";
        String path = "src/ProjectReports/" + sFileName;
        docWriter = PdfWriter.getInstance(doc, new FileOutputStream(path));

        DateFormat dateFormat3 = new SimpleDateFormat("dd/MM/yyyy HH:mm");
        String d = dateFormat3.format(Calendar.getInstance().getTime());

        //document header attributes
        doc.addCreationDate();
        doc.setPageSize(PageSize.LETTER);

        //open document
        doc.open();

        //create a paragraph
        DateFormat dateFormat2 = new SimpleDateFormat("dd/MM/yyyy");
        String sd2 = dateFormat2.format(pBeginDateChooser.getDate());
        String ed2 = dateFormat2.format(pEndDateChooser.getDate());
        Image image = Image.getInstance("src/Images/logo for pdf.png");
        Font font1 = new Font(Font.FontFamily.HELVETICA, 25, Font.BOLD);
        Paragraph paragraph = new Paragraph();
        Paragraph paragraph2 = new Paragraph("This report was generated by " + loginGUI.username + " at " + d
                + "\nYou can see all projects from " + sd2 + " to " + ed2);
        image.setAlignment(Image.RIGHT);
        doc.add(image);

        //specify column widths
        float[] columnWidths = { 2f, 2f, 2f, 2f, 2f };
        //create PDF table with the given widths
        PdfPTable table = new PdfPTable(columnWidths);
        // set table width a percentage of the page width
        table.setWidthPercentage(100f);

        //insert column headings
        insertCell(table, "Project ID", Element.ALIGN_CENTER, 1, bfBold12);
        insertCell(table, "Project Name", Element.ALIGN_CENTER, 1, bfBold12);
        insertCell(table, "Start Date", Element.ALIGN_CENTER, 1, bfBold12);
        insertCell(table, "Due Date", Element.ALIGN_CENTER, 1, bfBold12);
        insertCell(table, "Status", Element.ALIGN_CENTER, 1, bfBold12);
        table.setHeaderRows(1);

        //insert an empty row
        /* insertCell(table, "", Element.ALIGN_LEFT, 4, bfBold12);*/
        //create section heading by cell merging
        /* insertCell(table, "New York Orders ...", Element.ALIGN_LEFT, 4, bfBold12);*/
        /*double orderTotal, total = 0;*/

        String add1, add2, add3, add4, add5;
        DateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
        String sd = dateFormat1.format(pBeginDateChooser.getDate());
        String ed = dateFormat1.format(pEndDateChooser.getDate());

        if (report_status.equals("All")) {
            try {

                String sql = "select project_id,project_name,start_date,due_date,status from projects where due_date >= '"
                        + sd + "' and due_date <= '" + ed + "' and start_date >= '" + sd
                        + "'and start_date <= '" + ed + "'";
                pst = conn.prepareStatement(sql);
                rs = pst.executeQuery();
                while (rs.next()) {
                    add1 = rs.getString("project_id");
                    add2 = rs.getString("project_name");
                    add3 = dateFormat.format(rs.getDate("start_date"));
                    add4 = dateFormat.format(rs.getDate("due_date"));
                    add5 = rs.getString("status");
                    insertCell(table, add1, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add2, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add3, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add4, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add5, Element.ALIGN_CENTER, 1, bf12);

                }
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, e);

            }
        } else {
            try {

                String sql = "select project_id,project_name,start_date,due_date,status from projects where status = '"
                        + report_status + "' and due_date >= '" + sd + "' and due_date <= '" + ed
                        + "' and start_date >= '" + sd + "'and start_date <= '" + ed + "'";
                pst = conn.prepareStatement(sql);
                rs = pst.executeQuery();
                while (rs.next()) {
                    add1 = rs.getString("project_id");
                    add2 = rs.getString("project_name");
                    add3 = dateFormat.format(rs.getDate("start_date"));
                    add4 = dateFormat.format(rs.getDate("due_date"));
                    add5 = rs.getString("status");
                    insertCell(table, add1, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add2, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add3, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add4, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add5, Element.ALIGN_CENTER, 1, bf12);

                }
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, e);

            }
        }

        //add the PDF table to the paragraph 
        paragraph2.add(table);

        // add the paragraph to the document
        doc.add(new Paragraph("\nProject Status Report " + dt + "\n", font1));
        doc.add(paragraph2);
    } catch (DocumentException dex) {
        dex.printStackTrace();
    } catch (Exception ex) {
        ex.printStackTrace();
    } finally {
        if (doc != null) {
            //close the document
            doc.close();
            JOptionPane.showMessageDialog(null, "Report No " + repID + " Generated!");
        }
        if (docWriter != null) {
            //close the writer
            docWriter.close();
        }
    }
    saveToDB(report_status, date, repID);
}

From source file:com.ainfosec.macresponse.report.PdfGenerator.java

License:Open Source License

private static void addTitlePage(Document document) throws DocumentException {
    Paragraph preface = new Paragraph();
    // We add one empty line
    preface.add(Chunk.NEWLINE);/*from  w w  w . j a  v  a2s . c  o  m*/
    // Lets write a big header
    preface.add(new Paragraph("MAC Response", chapterTitleFont));

    preface.add(Chunk.NEWLINE);
    // Will create: Report generated by: _name, _date
    preface.add(new Paragraph("Report generated by: " + System.getProperty("user.name") + ", " + new Date(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            contentFont));
    //      preface.add(Chunk.NEWLINE);
    //      preface.add(Chunk.NEWLINE);
    //      preface.add(Chunk.NEWLINE);
    //      preface.add(new Paragraph(
    //            "This document describes something which is very important ",
    //            contentFont));

    document.add(preface);
    // Start a new page
    document.newPage();
}

From source file:com.ainfosec.macresponse.report.PdfGenerator.java

License:Open Source License

private static void addTables(Document document, TreeObject rootObject) throws DocumentException {
    // TODO Paul add table of contents/etc.?
    // Table of Contents
    Paragraph paragraph = new Paragraph();
    paragraph.add("Table of Contents\n\n");

    for (TreeObject treeObject : rootObject.getChildObjects()) {
        if (treeObject.isChecked()) {
            addTocSection(paragraph, treeObject, String.valueOf(currentChapter));
            currentChapter++;//  ww w . j a v a2  s  .  c  om
        }
    }
    currentChapter = 1;

    document.add(paragraph);

    // Table of Figures
    // Table of Tables
}

From source file:com.athena.chameleon.engine.core.PDFCommonEventHelper.java

License:Apache License

/**
 * /*from w  w w . j  a  va  2 s  .  c o m*/
 *  Paragraph ?.(Navigation  ?  title ) 
 *
 * @param title 
 * @param pageNumber 
 * @param depth 
 * @param x1 document left 
 * @param x2 document right 
 * @return Paragraph
 */
public Paragraph getTocParagraph(String title, int pageNumber, int depth, float x1, float x2) {

    Font tocFont = new Font(bfKorean, 10);
    if (depth == 0)
        tocFont.setStyle(Font.BOLD);

    Paragraph p = new Paragraph();
    p.setSpacingAfter(5);

    Chunk tit = new Chunk(title + " ", tocFont);
    tit.setAction(PdfAction.gotoLocalPage(title, false));

    Chunk point = new Chunk(".", tocFont);

    Chunk number = new Chunk(" " + pageNumber, tocFont);
    number.setAction(PdfAction.gotoLocalPage(title, false));

    p.add(tit);

    float width = x2 - x1 - tit.getWidthPoint() - number.getWidthPoint() - (depth * 12);

    if ((x2 - x1) < tit.getWidthPoint())
        width = x2 - x1 - (tit.getWidthPoint() - (x2 - x1)) - number.getWidthPoint() - (depth * 12) - 65;

    float i = point.getWidthPoint();
    while (i < width) {
        p.add(point);
        i += point.getWidthPoint();
    }

    p.add(number);

    return p;
}

From source file:com.athena.chameleon.engine.core.PDFDocGenerator.java

License:Apache License

public static void setLastPageInfo(Document doc, PdfWriter writer, int cNum) throws Exception {
    Chapter chapter = PDFWriterUtil.getChapter(MessageUtil.getMessage("pdf.message.chapter.confirm.title"),
            cNum);/*from   w ww  . j  ava  2  s  .  c o  m*/

    Paragraph preP = new Paragraph();
    preP.add(new Phrase(MessageUtil.getMessage("pdf.message.chapter.confirm.prepared1"),
            PDFWriterUtil.fnNormalBold));
    preP.add(new Phrase("                                                           ",
            new Font(bfKorean, 10, Font.UNDERLINE)));
    preP.setSpacingBefore(15);
    preP.setSpacingAfter(2);
    chapter.add(preP);

    preP = new Paragraph();
    preP.add(new Phrase(MessageUtil.getMessage("pdf.message.chapter.confirm.prepared2"),
            PDFWriterUtil.fnNormal));
    preP.setIndentationLeft(65);
    preP.setSpacingAfter(14);
    chapter.add(preP);

    preP = new Paragraph();
    preP.add(new Phrase(MessageUtil.getMessage("pdf.message.chapter.confirm.approved1"),
            PDFWriterUtil.fnNormalBold));
    preP.add(new Phrase("                                                           ",
            new Font(bfKorean, 10, Font.UNDERLINE)));
    preP.setSpacingBefore(15);
    preP.setSpacingAfter(2);
    chapter.add(preP);

    preP = new Paragraph();
    preP.add(new Phrase(MessageUtil.getMessage("pdf.message.chapter.confirm.approved2"),
            PDFWriterUtil.fnNormal));
    preP.setIndentationLeft(65);
    preP.setSpacingAfter(14);
    chapter.add(preP);

    cNum++;
    doc.add(chapter);

    chapter = PDFWriterUtil.getChapter(MessageUtil.getMessage("pdf.message.chapter.appendices.title"), cNum);
    Section section = PDFWriterUtil.getSection(chapter,
            MessageUtil.getMessage("pdf.message.chapter.appendices.label1"));

    Chunk url = new Chunk(MessageUtil.getMessage("pdf.message.chapter.appendices.text1"), PDFWriterUtil.fnURL);
    url.setAction(new PdfAction(new URL(MessageUtil.getMessage("pdf.message.chapter.appendices.text1"))));

    preP = new Paragraph(url);
    preP.setIndentationLeft(23);
    preP.setSpacingAfter(14);
    section.add(preP);

    section = PDFWriterUtil.getSection(chapter,
            MessageUtil.getMessage("pdf.message.chapter.appendices.label2"));

    doc.add(chapter);
}

From source file:com.athena.chameleon.engine.utils.PDFWriterUtil.java

License:Apache License

/**
 * Chapter  ?// w  w w  . j a va2 s  . c  om
 *
 * @param text Chapter title
 * @param chapterNo Chapter Number
 * @return Chapter
 */
public static Chapter getChapter(String text, int chapterNo) {

    Chapter chapter = new Chapter(text, chapterNo);
    String title = chapter.getTitle().getContent();

    Chunk c = new Chunk(text, fnChapter);
    c.setLocalDestination(title);
    Paragraph chapterPh = new Paragraph();
    chapterPh.add(c);
    chapterPh.setSpacingAfter(12);
    chapter.setTitle(chapterPh);
    return chapter;

}

From source file:com.athena.chameleon.engine.utils.PDFWriterUtil.java

License:Apache License

/**
 * /*from   w ww.  j  a  va  2s.  c  o  m*/
 * Section  ?
 *
 * @param chapter section?  chapter ?
 * @param text section title
 * @param sectionNo section Number
 * @return Section
 */
public static Section getSection(Section chapter, String text) {
    Section section = chapter.addSection(text);
    String title = section.getTitle().getContent();

    Chunk c;
    if (section.getDepth() >= 3) {
        c = new Chunk(text, fnSection2);
    } else {
        c = new Chunk(text, fnSection);
    }
    c.setLocalDestination(title);

    Paragraph sectionPh = new Paragraph();
    sectionPh.add(c);
    sectionPh.setSpacingBefore(8);
    sectionPh.setSpacingAfter(3);
    if (section.getDepth() >= 3)
        sectionPh.setIndentationLeft(23);

    section.setTitle(sectionPh);
    return section;
}

From source file:com.auskeny.ems.print.PdfCreator.java

public static void addTitlePage(Document document) throws DocumentException {
    Paragraph preface = new Paragraph();
    // We add one empty line
    addEmptyLine(preface, 1);/*from  w ww  .j a v a  2 s  . co  m*/
    // Lets write a big header
    preface.add(new Paragraph("Title of the document", catFont));

    addEmptyLine(preface, 1);
    // Will create: Report generated by: _name, _date
    preface.add(new Paragraph("Report generated by: " + System.getProperty("user.name") + ", " + new Date(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            smallBold));
    addEmptyLine(preface, 3);
    preface.add(new Paragraph("This document describes something which is very important ", smallBold));

    addEmptyLine(preface, 8);

    preface.add(new Paragraph(
            "This document is a preliminary version and not subject to your license agreement or any other agreement with vogella.com ;-).",
            redFont));

    document.add(preface);
    // Start a new page
    document.newPage();
}

From source file:com.bougsid.printers.PrintMission.java

public void printMission(Mission mission) {
    Document document = new Document(PageSize.A4);
    try {//from w  ww  . j  a  va  2s  . c o m
        File downloadDir = new File(msg.getMessage("application.mission.downloaddir"));
        if (!downloadDir.exists()) {
            downloadDir.mkdir();
        }
        System.out.println("Dir =" + downloadDir.getPath());
        PdfWriter.getInstance(document,
                new FileOutputStream(downloadDir.getPath() + "/" + mission.getUuid() + ".pdf"));
        document.open();
        Paragraph p = new Paragraph();
        p.setSpacingAfter(60);
        document.add(p);
        //header
        Paragraph paragraph = new Paragraph(
                msg.getMessage("mission.pdf.school") + "       " + mission.getIdMission() + "           ",
                DEFAULT_FONT);
        Phrase phrase = new Phrase(msg.getMessage("mission.pdf.city") + " "
                + LocalDate.now().format(DateTimeFormatter.ofPattern("dd/MM/yyyy")));
        paragraph.add(phrase);
        paragraph.setSpacingAfter(50);
        document.add(paragraph);
        //title
        PdfPTable table = new PdfPTable(1);
        table.setWidthPercentage(40);
        PdfPCell cell = new PdfPCell(new Phrase(msg.getMessage("mission.pdf.title"),
                FontFactory.getFont(FontFactory.HELVETICA, 18)));
        cell.setBorderWidth(1);
        cell.setPadding(10);

        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);
        table.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.setSpacingAfter(40);
        document.add(table);

        //content
        table = new PdfPTable(2);
        table.setWidthPercentage(100);

        //line 1
        cell = new PdfPCell(new Paragraph(mission.getEmploye().getCivilite().getLabel(), DEFAULT_FONT_BOLD));
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setPaddingTop(20);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(": " + mission.getEmploye().getFullName(), DEFAULT_FONT));
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setPaddingTop(20);
        table.addCell(cell);

        //line 2
        cell = new PdfPCell(new Paragraph(msg.getMessage("mission.pdf.matricule"), DEFAULT_FONT_BOLD));
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setPaddingTop(20);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(": " + mission.getEmploye().getMatricule(), DEFAULT_FONT));
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setPaddingTop(20);
        table.addCell(cell);

        //line 3
        cell = new PdfPCell(new Paragraph(msg.getMessage("mission.pdf.grade"), DEFAULT_FONT_BOLD));
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setPaddingTop(20);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(": " + mission.getEmploye().getFonction(), DEFAULT_FONT));
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setPaddingTop(20);
        table.addCell(cell);

        if (mission.getEntreprise() != null) {
            //line 4
            cell = new PdfPCell(new Paragraph(msg.getMessage("mission.pdf.text_1"), DEFAULT_FONT_BOLD));
            cell.setBorder(Rectangle.NO_BORDER);
            cell.setPaddingTop(20);
            table.addCell(cell);
            cell = new PdfPCell(new Paragraph(msg.getMessage("mission.pdf.text_1_2"), DEFAULT_FONT_BOLD));
            cell.setBorder(Rectangle.NO_BORDER);
            cell.setPaddingTop(20);
            table.addCell(cell);

            //line 5
            cell = new PdfPCell(new Paragraph(" ", DEFAULT_FONT_BOLD));
            cell.setBorder(Rectangle.NO_BORDER);
            cell.setPaddingTop(20);
            table.addCell(cell);
            cell = new PdfPCell(new Paragraph(" - " + mission.getEntreprise().getNom(), DEFAULT_FONT));
            cell.setBorder(Rectangle.NO_BORDER);
            cell.setPaddingTop(20);
            table.addCell(cell);
        }

        //line 6
        cell = new PdfPCell(new Paragraph(msg.getMessage("mission.pdf.lieu"), DEFAULT_FONT_BOLD));
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setPaddingTop(20);
        table.addCell(cell);
        p = new Paragraph();
        p.setFont(DEFAULT_FONT);
        for (Ville ville : mission.getVilles()) {
            p.add(ville.getNom() + "\n");
        }
        cell = new PdfPCell(p);
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setPaddingTop(20);
        table.addCell(cell);

        //line 7
        cell = new PdfPCell(new Paragraph(msg.getMessage("mission.pdf.startdate"), DEFAULT_FONT_BOLD));
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setPaddingTop(20);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(
                ": " + mission.getStartDate().format(DateTimeFormatter.ofPattern("dd/MM/yyyy")) + "    Heure : "
                        + mission.getStartDate().format(DateTimeFormatter.ofPattern("HH:mm")),
                DEFAULT_FONT));
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setPaddingTop(20);
        table.addCell(cell);

        //line 8
        cell = new PdfPCell(new Paragraph(msg.getMessage("mission.pdf.enddate"), DEFAULT_FONT_BOLD));
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setPaddingTop(20);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(
                ": " + mission.getEndDate().format(DateTimeFormatter.ofPattern("dd/MM/yyyy")) + "    Heure : "
                        + mission.getEndDate().format(DateTimeFormatter.ofPattern("HH:mm")),
                DEFAULT_FONT));

        cell.setBorder(Rectangle.NO_BORDER);
        cell.setPaddingTop(20);
        table.addCell(cell);

        //line 9
        cell = new PdfPCell(new Paragraph(msg.getMessage("mission.pdf.transport"), DEFAULT_FONT_BOLD));
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setPaddingTop(20);
        table.addCell(cell);
        switch (mission.getTransportType()) {
        case PERSONNEL:
            cell = new PdfPCell(new Paragraph(": " + msg.getMessage("mission.pdf.perso") + " "
                    + mission.getEmploye().getVehicule().getMarque() + " " + msg.getMessage("mission.pdf.mat")
                    + " " + mission.getEmploye().getVehicule().getMatricule() + " ", DEFAULT_FONT));
            break;
        case Accompagnement:
            cell = new PdfPCell(new Paragraph(": " + msg.getMessage("mission.pdf.accomp") + " "
                    + mission.getAccompEmploye().getCivilite() + " " + mission.getAccompEmploye().getFullName()
                    + " " + msg.getMessage("mission.pdf.accomp.voitue") + " "
                    + mission.getAccompEmploye().getVehicule().getMarque() + " "
                    + msg.getMessage("mission.pdf.mat") + " "
                    + mission.getAccompEmploye().getVehicule().getMatricule() + " ", DEFAULT_FONT));
            break;
        case Service:
            cell = new PdfPCell(new Paragraph(": " + msg.getMessage("mission.pdf.service") + " "
                    + mission.getEmploye().getVehicule().getMarque() + " " + msg.getMessage("mission.pdf.mat")
                    + " " + mission.getEmploye().getVehicule().getMatricule() + " ", DEFAULT_FONT));
            break;
        default: {
            cell = new PdfPCell(new Paragraph(
                    ": " + mission.getTransportType().getLabel() + " " + msg.getMessage("mission.pdf.taxi"),
                    DEFAULT_FONT));
        }
        }
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setPaddingTop(20);
        table.addCell(cell);

        table.setSpacingAfter(40);
        document.add(table);

        //note
        document.add(new Paragraph(msg.getMessage("mission.pdf.TEXT_2"), DEFAULT_FONT));

        //signature
        if (mission.getEmploye().getGrade().getType() == GradeType.DG) {

        } else {
            Employe dir = employeService.getDG();
            if (dir != null)
                paragraph = new Paragraph(dir.getFullName(), DEFAULT_FONT);
            paragraph.setAlignment(Element.ALIGN_RIGHT);
            paragraph.setSpacingBefore(40);
            document.add(paragraph);
            paragraph = new Paragraph(msg.getMessage("mission.pdf.DG"), DEFAULT_FONT);
            paragraph.setAlignment(Element.ALIGN_RIGHT);
            document.add(paragraph);
        }

    } catch (DocumentException ex) {
        ex.printStackTrace();
    } catch (FileNotFoundException ex) {
        ex.printStackTrace();
    }
    document.close();
    //        try {
    //            Desktop.getDesktop().open(new File("./order.pdf"));
    //        } catch (IOException ex) {
    //            JOptionPane.showMessageDialog(null, "Fichier gner mais ne peut pas etre ouvert vrifier le dossier");
    //        }
}