Example usage for com.lowagie.text Element ALIGN_LEFT

List of usage examples for com.lowagie.text Element ALIGN_LEFT

Introduction

In this page you can find the example usage for com.lowagie.text Element ALIGN_LEFT.

Prototype

int ALIGN_LEFT

To view the source code for com.lowagie.text Element ALIGN_LEFT.

Click Source Link

Document

A possible value for paragraph alignment.

Usage

From source file:org.bambrikii.photobank.web.documents.paymentcertificates.impl.PaymentCertificateBuilderRU.java

public void build(OutputStream outputStream) throws DocumentGenerationException {
    Document doc = new Document(PageSize.A4);
    PdfWriter writer;//from w w  w  .  j  a v  a 2 s  .  co m
    BaseFont baseFont = null;
    try {
        writer = PdfWriter.getInstance(doc, outputStream);

        writer.setEncryption(null, "qweasdzxc".getBytes(), PdfWriter.ALLOW_PRINTING,
                PdfWriter.ENCRYPTION_AES_128);

        doc.open();

        String baseFontPath = getResourcesPath() + "org/bambrikii/photobank/web/documents/ARIAL.TTF";
        final String stampImagePath = getResourcesPath()
                + "org/bambrikii/photobank/web/documents/paymentcertificates/PersonaStarsStamp.png";
        baseFont = BaseFont.createFont(baseFontPath, "Cp1251", true);

        Font baseTextStyle = new com.lowagie.text.Font(baseFont, 10, com.lowagie.text.Font.NORMAL,
                new Color(0, 0, 0));
        Font baseBoldTextStyle = new com.lowagie.text.Font(baseFont, 10, com.lowagie.text.Font.BOLD,
                new Color(0, 0, 0));

        Calendar cal = Calendar.getInstance(getLocale());
        cal.setTime(getData().getDate());

        // Act number
        String actNumber = MessageFormat.format(
                "\u0410\u043a\u0442 \u2116 {0} \u043e\u0442 \u00ab{1}\u00bb {2} {3} \u0433\u043e\u0434\u0430",
                String.valueOf(getData().getNumber()), cal.get(Calendar.DAY_OF_MONTH),
                monthsGenitiveCase.get(cal.get(Calendar.MONTH)).toLowerCase(),
                String.valueOf(cal.get(Calendar.YEAR)));
        Paragraph actNumberParagraph = new Paragraph(actNumber,
                new com.lowagie.text.Font(baseFont, 12, com.lowagie.text.Font.BOLD, new Color(0, 0, 0)));
        actNumberParagraph.setSpacingAfter(19);

        Paragraph cityParagraph = new Paragraph("\u0433. \u041c\u043e\u0441\u043a\u0432\u0430", baseTextStyle);
        cityParagraph.setSpacingAfter(15);

        // Licensor
        Paragraph licensorParagraph = new Paragraph();
        licensorParagraph
                .add(new Chunk("\u041b\u0438\u0446\u0435\u043d\u0437\u0438\u0430\u0440: ", baseBoldTextStyle));
        licensorParagraph.add(new Chunk(MessageFormat.format("{0}",
                "\u0418\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c \u041b\u0438\u043f\u0430\u0442\u043d\u0438\u043a\u043e\u0432 \u0415\u0432\u0433\u0435\u043d\u0438\u0439 \u0410\u0440\u043a\u0430\u0434\u044c\u0435\u0432\u0438\u0447, \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0421\u0432\u0438\u0434\u0435\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430 \u041e\u0413\u0420\u041d \u2116 305501025600011 \u043e\u0442 13.09.2005\u0433."),
                baseTextStyle));
        licensorParagraph.setSpacingAfter(15);

        // Licensee
        Paragraph licenseeParagraph = new Paragraph();
        licenseeParagraph
                .add(new Chunk("\u041b\u0438\u0446\u0435\u043d\u0437\u0438\u0430\u0442: ", baseBoldTextStyle));
        licenseeParagraph.add(new Chunk(getData().getLicensee(), baseTextStyle));
        licenseeParagraph.setSpacingAfter(15);

        // Pre text
        Paragraph pretextParagraph = new Paragraph();
        pretextParagraph.add(new Chunk(
                "\u0412 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0414\u043e\u0433\u043e\u0432\u043e\u0440\u043e\u043c \u041e\u0444\u0435\u0440\u0442\u044b \u041b\u0438\u0446\u0435\u043d\u0437\u0438\u0430\u0440 \u043f\u0435\u0440\u0435\u0434\u0430\u043b \u041b\u0438\u0446\u0435\u043d\u0437\u0438\u0430\u0442\u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0424\u043e\u0442\u043e\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f (\u0446\u0438\u0444\u0440\u043e\u0432\u044b\u0435 \u043a\u043e\u043f\u0438\u0438) \u0438 \u043d\u0435\u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u0430 \u043d\u0430 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 (\u0434\u0430\u043b\u0435\u0435 \u043f\u0440\u0430\u0432\u0430 \u043d\u0430 \u0424\u043e\u0442\u043e\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f): ",
                baseTextStyle));
        pretextParagraph.setSpacingAfter(15);

        int defaultLeading = 9;
        // Files table
        Table filesTbl = new Table(5);
        filesTbl.setWidths(new int[] { 5, 35, 35, 10, 15 });
        filesTbl.setBorder(Table.RECTANGLE);
        filesTbl.setBorderWidth(1);
        filesTbl.setSpacing(0);
        filesTbl.setPadding(2);
        filesTbl.setCellsFitPage(false);
        filesTbl.setUseVariableBorders(true);
        filesTbl.setAlignment(Element.ALIGN_LEFT);
        filesTbl.setWidth(100);

        Cell cellheader1 = new Cell(new Phrase(new Chunk("\u2116", baseBoldTextStyle)));
        cellheader1.setHeader(true);
        cellheader1.setLeading(defaultLeading);
        cellheader1.setHorizontalAlignment(Cell.ALIGN_CENTER);
        filesTbl.addCell(cellheader1);

        Cell cellheader2 = new Cell(new Phrase(
                new Chunk("\u041d\u043e\u043c\u0435\u0440 \u0444\u043e\u0442\u043e", baseBoldTextStyle)));
        cellheader2.setHeader(true);
        cellheader2.setLeading(defaultLeading);
        cellheader2.setHorizontalAlignment(Cell.ALIGN_CENTER);
        filesTbl.addCell(cellheader2);

        Cell cellheader3 = new Cell(
                new Phrase(new Chunk("\u041f\u0435\u0440\u0441\u043e\u043d\u0430", baseBoldTextStyle)));
        cellheader3.setHeader(true);
        cellheader3.setLeading(defaultLeading);
        cellheader3.setHorizontalAlignment(Cell.ALIGN_CENTER);
        filesTbl.addCell(cellheader3);

        Cell cellheader4 = new Cell(
                new Phrase(new Chunk("\u0420\u0430\u0437\u043c\u0435\u0440", baseBoldTextStyle)));
        cellheader4.setHeader(true);
        cellheader4.setLeading(defaultLeading);
        cellheader4.setHorizontalAlignment(Cell.ALIGN_CENTER);
        filesTbl.addCell(cellheader4);

        Cell cellheader5 = new Cell(
                new Phrase(new Chunk("\u0426\u0435\u043d\u0430 \u0440\u0443\u0431.", baseBoldTextStyle)));
        cellheader5.setHeader(true);
        cellheader5.setLeading(defaultLeading);
        cellheader5.setHorizontalAlignment(Cell.ALIGN_CENTER);
        filesTbl.addCell(cellheader5);
        filesTbl.endHeaders();

        Integer i = 0;
        for (PaymentCertificateDataItem item : getData().getItems()) {
            i++;
            Cell cell1 = new Cell(new Phrase(new Chunk(Integer.toString(i), baseTextStyle)));
            cell1.setLeading(defaultLeading);
            cell1.setHorizontalAlignment(Cell.ALIGN_CENTER);
            cell1.setBorder(Cell.NO_BORDER);
            filesTbl.addCell(cell1);

            Cell cell2 = new Cell(new Phrase(new Chunk(item.getFilename(), baseTextStyle)));
            cell2.setLeading(defaultLeading);
            cell2.setHorizontalAlignment(Cell.ALIGN_LEFT);
            cell2.setBorder(Cell.NO_BORDER);
            filesTbl.addCell(cell2);

            Cell cell3 = new Cell(new Phrase(new Chunk(item.getName(), baseTextStyle)));
            cell3.setLeading(defaultLeading);
            cell3.setHorizontalAlignment(Cell.ALIGN_LEFT);
            cell3.setBorder(Cell.NO_BORDER);
            filesTbl.addCell(cell3);

            Cell cell4 = new Cell(new Phrase(new Chunk(item.getSizeName(), baseTextStyle)));
            cell4.setLeading(defaultLeading);
            cell4.setHorizontalAlignment(Cell.ALIGN_CENTER);
            cell4.setBorder(Cell.NO_BORDER);
            filesTbl.addCell(cell4);

            Cell cell5 = new Cell(new Phrase(new Chunk(Double.toString(item.getPrice()), baseTextStyle)));
            cell5.setLeading(defaultLeading);
            cell5.setHorizontalAlignment(Cell.ALIGN_CENTER);
            cell5.setBorder(Cell.NO_BORDER);
            filesTbl.addCell(cell5);
        }
        filesTbl.complete();

        // filesTbl.normalize();

        String totalPrice = MessageFormat.format("{0} {1}", String.valueOf(getData().getTotal()),
                getData().getCurrency());

        Paragraph totalParagraph = new Paragraph();
        totalParagraph.setAlignment(Paragraph.ALIGN_RIGHT);

        totalParagraph.add(new Chunk("\u0418\u0442\u043e\u0433\u043e: ", baseTextStyle));
        totalParagraph.add(new Chunk(totalPrice, baseBoldTextStyle));
        totalParagraph.setSpacingAfter(25);

        Paragraph posttext1Paragraph = new Paragraph();
        posttext1Paragraph.add(new Chunk(
                "\u0412\u043e\u0437\u043d\u0430\u0433\u0440\u0430\u0436\u0434\u0435\u043d\u0438\u0435 \u0437\u0430 \u043f\u0440\u0430\u0432\u0430 \u043d\u0430 \u0424\u043e\u0442\u043e\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442: ",
                baseTextStyle));
        posttext1Paragraph.add(new Chunk(totalPrice, baseBoldTextStyle));
        // posttext1Paragraph.setSpacingAfter(15);

        Paragraph posttext2Paragraph = new Paragraph(
                "\u041d\u0414\u0421 \u043d\u0435 \u043e\u0431\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043f\u0443\u043d\u043a\u0442\u0430\u043c\u0438 2, 3 \u0438 5 \u0441\u0442\u0430\u0442\u044c\u0438 346.11 \u041d\u0430\u043b\u043e\u0433\u043e\u0432\u043e\u0433\u043e \u043a\u043e\u0434\u0435\u043a\u0441\u0430 \u0420\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u043e\u0439 \u0424\u0435\u0434\u0435\u0440\u0430\u0446\u0438\u0438.",
                baseTextStyle);
        posttext2Paragraph.setSpacingAfter(15);

        Paragraph posttext3Paragraph = new Paragraph(
                "\u041f\u0440\u0430\u0432\u0430 \u043d\u0430 \u0424\u043e\u0442\u043e\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0441\u0440\u043e\u043a\u043e\u043c \u043d\u0430 1 (\u043e\u0434\u0438\u043d) \u0433\u043e\u0434 \u0441 \u0434\u0430\u0442\u044b \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0432 \u0410\u043a\u0442\u0435.",
                baseTextStyle);
        posttext3Paragraph.setSpacingAfter(15);

        Paragraph posttext4Paragraph = new Paragraph();
        posttext4Paragraph.add(new Chunk(
                "\u041b\u0438\u0446\u0435\u043d\u0437\u0438\u0430\u0442 \u043d\u0435 \u0432\u043f\u0440\u0430\u0432\u0435 ",
                baseTextStyle));
        posttext4Paragraph.add(new Chunk("(\u0437\u0430\u043f\u0440\u0435\u0449\u0430\u0435\u0442\u0441\u044f)",
                baseBoldTextStyle));
        posttext4Paragraph.add(new Chunk(
                ": \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0442\u044c \u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c\u0438 \u043a\u043e\u043f\u0438\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u0441 \u0444\u043e\u0442\u043e\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438; \u043f\u0440\u043e\u0434\u0430\u0432\u0430\u0442\u044c, \u0441\u0434\u0430\u0432\u0430\u0442\u044c \u0432 \u043f\u0440\u043e\u043a\u0430\u0442, \u0430\u0440\u0435\u043d\u0434\u0443, \u043b\u0438\u0437\u0438\u043d\u0433, \u043a\u0430\u043a \u0441\u0430\u043c\u0438 \u0444\u043e\u0442\u043e\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0442\u0430\u043a \u0438 \u0444\u0430\u0439\u043b\u044b \u0441 \u0444\u043e\u0442\u043e\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438; \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u043e\u0442\u043e\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0434\u0438\u0437\u0430\u0439\u043d\u0435 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u0435\u0439, \u043f\u043e\u0447\u0442\u043e\u0432\u044b\u0445 \u043a\u0430\u0440\u0442\u043e\u0447\u0435\u043a \u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u043a, \u043f\u043e\u0441\u0442\u0435\u0440\u043e\u0432 \u0438 \u043e\u0431\u0440\u0430\u043c\u043b\u0435\u043d\u043d\u044b\u0445 \u0440\u0435\u043f\u0440\u043e\u0434\u0443\u043a\u0446\u0438\u0439 \u0432 \u0446\u0435\u043b\u044f\u0445 \u043f\u0440\u043e\u0434\u0430\u0436\u0438; \u043f\u043e\u043c\u0435\u0449\u0430\u0442\u044c \u0444\u043e\u0442\u043e\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0441\u0435\u0442\u044c \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u043c \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0442\u0440\u0435\u0442\u044c\u0438\u043c\u0438 \u043b\u0438\u0446\u0430\u043c\u0438, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c, \u0434\u0435\u043b\u0430\u044f \u0438\u0445 \u043e\u0431\u0449\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c\u0438.",
                baseTextStyle));
        posttext4Paragraph.setSpacingAfter(15);

        Paragraph posttext5Paragraph = new Paragraph(
                "\u0421\u0442\u043e\u0440\u043e\u043d\u044b \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u044e\u0442, \u0447\u0442\u043e \u0443\u0441\u043b\u0443\u0433\u0438 \u043f\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u043f\u0440\u0430\u0432 \u043d\u0430 \u0424\u043e\u0442\u043e\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u044b \u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0438 \u0432 \u043f\u043e\u043b\u043d\u043e\u043c \u043e\u0431\u044a\u0435\u043c\u0435. \u0421\u0442\u043e\u0440\u043e\u043d\u044b \u043f\u0440\u0435\u0442\u0435\u043d\u0437\u0438\u0439 \u0434\u0440\u0443\u0433 \u043a \u0434\u0440\u0443\u0433\u0443 \u043d\u0435 \u0438\u043c\u0435\u044e\u0442.",
                baseTextStyle);
        posttext5Paragraph.setSpacingAfter(15);

        // Signatures
        Table signaturesTable = new Table(4);
        signaturesTable.setWidths(new int[] { 10, 40, 10, 40 });
        signaturesTable.setWidth(100);
        signaturesTable.setSpacing(0);
        signaturesTable.setPadding(5);
        signaturesTable.setBorder(Table.NO_BORDER);

        Cell licensorSignature1Cell = new Cell(new Phrase(
                new Chunk("\u041b\u0438\u0446\u0435\u043d\u0437\u0438\u0430\u0440:", baseBoldTextStyle)));
        licensorSignature1Cell.setHorizontalAlignment(Cell.ALIGN_LEFT);
        licensorSignature1Cell.setBorder(Cell.NO_BORDER);

        Cell licensorSignature2Cell = new Cell(new Phrase(new Chunk(
                "______________/ \u041b\u0438\u043f\u0430\u0442\u043d\u0438\u043a\u043e\u0432 \u0415.\u0410. /",
                baseTextStyle)));
        licensorSignature2Cell.setHorizontalAlignment(Cell.ALIGN_LEFT);
        licensorSignature2Cell.setBorder(Cell.NO_BORDER);
        licensorSignature2Cell.addElement(new Paragraph("\n\n\n\n"));
        licensorSignature2Cell.add(
                // Stamp
                Image.getInstance(stampImagePath));

        Cell licenseeSignature1Cell = new Cell(new Phrase(
                new Chunk("\u041b\u0438\u0446\u0435\u043d\u0437\u0438\u0430\u0442:", baseBoldTextStyle)));
        licenseeSignature1Cell.setHorizontalAlignment(Cell.ALIGN_LEFT);
        licenseeSignature1Cell.setBorder(Cell.NO_BORDER);

        Cell licenseeSignature2Cell = new Cell(new Phrase(new Chunk(
                MessageFormat.format("______________/ {0} /", getData().getLicensee()), baseTextStyle)));
        licenseeSignature2Cell.setHorizontalAlignment(Cell.ALIGN_LEFT);
        licenseeSignature2Cell.setBorder(Cell.NO_BORDER);

        signaturesTable.addCell(new Cell() {
            {
                setBorder(Cell.NO_BORDER);
            }
        });
        signaturesTable.addCell(licensorSignature1Cell);
        signaturesTable.addCell(new Cell(true) {
            {
                setBorder(Cell.NO_BORDER);
            }
        });
        signaturesTable.addCell(licenseeSignature1Cell);
        signaturesTable.addCell(new Cell(true) {
            {
                setBorder(Cell.NO_BORDER);
            }
        });
        signaturesTable.addCell(licensorSignature2Cell);
        signaturesTable.addCell(new Cell(true) {
            {
                setBorder(Cell.NO_BORDER);
            }
        });
        signaturesTable.addCell(licenseeSignature2Cell);

        signaturesTable.addCell(new Cell(true) {
            {
                setBorder(Cell.NO_BORDER);
            }
        });
        signaturesTable.addCell(new Cell(true) {
            {
                setBorder(Cell.NO_BORDER);
            }
        });

        signaturesTable.complete();
        // PdfPTable signaturePdPfTable = signaturesTable.createPdfPTable();

        // Document items
        doc.add(actNumberParagraph);
        doc.add(cityParagraph);
        doc.add(licensorParagraph);
        doc.add(licenseeParagraph);
        doc.add(pretextParagraph);
        doc.add(filesTbl);
        doc.add(totalParagraph);
        doc.add(posttext1Paragraph);
        doc.add(posttext2Paragraph);
        doc.add(posttext3Paragraph);
        doc.add(posttext4Paragraph);
        doc.add(posttext5Paragraph);
        doc.add(signaturesTable);

        doc.close();
    } catch (DocumentException ex) {
        throw new DocumentGenerationException("Exception creating document.", ex);
    } catch (IOException ex) {
        throw new DocumentGenerationException(
                "Exception creating document, required font file may not be found.", ex);
    }
}

From source file:org.caisi.tickler.web.TicklerPrinter.java

License:Open Source License

private void addStandardTableEntry(PdfPTable table, String name, String value) {
    PdfPCell cell1 = new PdfPCell(getParagraph(name + ":"));

    cell1.setBorder(PdfPCell.BOTTOM);/*from   w w  w.j ava 2s .  c o  m*/
    cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
    PdfPCell cell2 = new PdfPCell(getParagraph(value));
    cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell2.setBorder(PdfPCell.BOTTOM);

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

From source file:org.caisi.tickler.web.TicklerPrinter.java

License:Open Source License

public void printTicklerInfo() throws DocumentException {

    PdfPTable table = new PdfPTable(2);
    table.setWidthPercentage(50f);//from   w w  w .  ja  va2  s . c  o m
    table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);

    addStandardTableEntry(table, "Created By", tickler.getProvider().getFormattedName());
    addStandardTableEntry(table, "Last Updated", formatter.format(tickler.getUpdateDate()));
    addStandardTableEntry(table, "Service Date", formatter.format(tickler.getServiceDate()));
    addStandardTableEntry(table, "Assigned To", tickler.getAssignee().getFormattedName());
    addStandardTableEntry(table, "Priority", tickler.getPriority().toString());
    addStandardTableEntry(table, "Status", tickler.getStatusWeb());
    addStandardTableEntry(table, "Program",
            (tickler.getProgram() != null) ? tickler.getProgram().getName() : "N/A");

    getDocument().add(table);

    table = new PdfPTable(1);
    table.setWidthPercentage(70f);

    PdfPCell cell1 = new PdfPCell(getParagraph("Message"));

    cell1.setBorder(PdfPCell.NO_BORDER);
    cell1.setHorizontalAlignment(Element.ALIGN_LEFT);

    table.addCell(cell1);

    cell1 = new PdfPCell(getParagraph(tickler.getMessage()));
    cell1.setHorizontalAlignment(Element.ALIGN_LEFT);

    table.addCell(cell1);

    getDocument().add(table);

}

From source file:org.cgiar.ccafs.ap.summaries.projects.pdf.CaseStudieSummaryPDF.java

License:Open Source License

/**
 * This method is used for add the main information table of project summary
 *//* www . j a  v  a2 s .  c om*/
private void addMainInformationTable() {

    String startDate, endDate;
    if (project.getStartDate() != null) {
        startDate = new SimpleDateFormat("dd-MM-yyyy").format(project.getStartDate());
    } else {
        startDate = this.messageReturn(null);
    }

    if (project.getEndDate() != null) {
        endDate = new SimpleDateFormat("dd-MM-yyyy").format(project.getEndDate());
    } else {
        endDate = this.messageReturn(null);
    }

    Paragraph cellContent;

    // Add content
    try {
        PdfPTable table = new PdfPTable(4);

        // Set table widths
        table.setLockedWidth(true);
        table.setTotalWidth(480);
        table.setWidths(new int[] { 3, 5, 3, 5 });

        // First row
        cellContent = new Paragraph(this.getText("summaries.project.startDate") + "\n" + " (dd-MM-yyyy)",
                TABLE_BODY_BOLD_FONT);
        this.addTableBodyCell(table, cellContent, Element.ALIGN_RIGHT, 0);

        cellContent = new Paragraph(this.messageReturn(startDate), TABLE_BODY_FONT);
        this.addTableBodyCell(table, cellContent, Element.ALIGN_LEFT, 0);

        cellContent = new Paragraph(this.getText("summaries.project.endDate") + "\n" + " (dd-MM-yyyy)",
                TABLE_BODY_BOLD_FONT);
        this.addTableBodyCell(table, cellContent, Element.ALIGN_RIGHT, 0);

        cellContent = new Paragraph(this.messageReturn(endDate), TABLE_BODY_FONT);
        this.addTableBodyCell(table, cellContent, Element.ALIGN_LEFT, 0);

        // Second row
        cellContent = new Paragraph(this.getText("summaries.project.managementLiaison"), TABLE_BODY_BOLD_FONT);
        this.addTableBodyCell(table, cellContent, Element.ALIGN_RIGHT, 1);

        cellContent = new Paragraph(this.messageReturn(project.getLiaisonInstitution().getAcronym() + " - "
                + project.getLiaisonInstitution().getName()), TABLE_BODY_FONT);
        this.addTableBodyCell(table, cellContent, Element.ALIGN_LEFT, 1);

        cellContent = new Paragraph(this.getText("summaries.project.contactPerson"), TABLE_BODY_BOLD_FONT);
        this.addTableBodyCell(table, cellContent, Element.ALIGN_RIGHT, 1);

        cellContent = new Paragraph(this.messageReturn(project.getOwner().getComposedName()), TABLE_BODY_FONT);
        this.addTableBodyCell(table, cellContent, Element.ALIGN_LEFT, 1);

        // Third row
        cellContent = new Paragraph(this.getText("summaries.project.leadOrganization"), TABLE_BODY_BOLD_FONT);
        this.addTableBodyCell(table, cellContent, Element.ALIGN_RIGHT, 0);
        if (project.getLeader() == null || project.getLeader().getInstitution() == null) {
            cellContent = new Paragraph(this.getText("summaries.project.empty"), TABLE_BODY_FONT);
        } else {
            cellContent = new Paragraph(
                    this.messageReturn(
                            this.messageReturn(project.getLeader().getInstitution().getComposedName())),
                    TABLE_BODY_FONT);

        }
        this.addTableBodyCell(table, cellContent, Element.ALIGN_LEFT, 0);

        cellContent = new Paragraph(this.getText("summaries.project.projectLeader"), TABLE_BODY_BOLD_FONT);
        this.addTableBodyCell(table, cellContent, Element.ALIGN_RIGHT, 0);
        if (project.getLeaderPerson() == null || project.getLeaderPerson().getUser() == null) {
            cellContent = new Paragraph(this.getText("summaries.project.empty"), TABLE_BODY_FONT);
        } else {
            cellContent = new Paragraph(
                    this.messageReturn(project.getLeaderPerson().getUser().getComposedName()), TABLE_BODY_FONT);
        }

        this.addTableBodyCell(table, cellContent, Element.ALIGN_LEFT, 0);

        // Fourth row
        cellContent = (new Paragraph(this.getText("summaries.project.projectType"), TABLE_BODY_BOLD_FONT));
        this.addTableBodyCell(table, cellContent, Element.ALIGN_RIGHT, 1);

        cellContent = new Paragraph(this.messageReturn(project.getType().replaceAll("_", " ")),
                TABLE_BODY_FONT);
        this.addTableBodyCell(table, cellContent, Element.ALIGN_LEFT, 1);

        // Fiveth row
        Chunk imdb = null;
        Font hyperLink = new Font(FontFactory.getFont("openSans", 10, Color.BLUE));
        hyperLink.setStyle(Font.UNDERLINE);

        // -- Not Bilateral
        if (!project.isBilateralProject()) {
            cellContent = (new Paragraph(this.getText("summaries.project.detailed"), TABLE_BODY_BOLD_FONT));
            this.addTableBodyCell(table, cellContent, Element.ALIGN_RIGHT, 1);

            if (project.getWorkplanName() != null && !project.getWorkplanName().equals("")) {
                imdb = new Chunk(project.getWorkplanName(), hyperLink);
                try {
                    imdb.setAction(new PdfAction(new URL(this.messageReturn(project.getWorkplanURL()))));
                } catch (MalformedURLException exp) {
                    imdb = new Chunk(project.getWorkplanName(), TABLE_BODY_FONT);
                    LOG.error("There is an Malformed exception in " + project.getWorkplanName());
                }
            } else {
                imdb = new Chunk(this.getText("summaries.project.empty"), TABLE_BODY_FONT);
            }
        }

        // -- Bilateral
        else {
            cellContent = (new Paragraph(this.getText("summaries.project.ipContributions.proposal.space"),
                    TABLE_BODY_BOLD_FONT));
            this.addTableBodyCell(table, cellContent, Element.ALIGN_RIGHT, 1);

            if (project.getBilateralContractProposalName() != null
                    && !project.getBilateralContractProposalName().equals("")) {
                imdb = new Chunk(project.getBilateralContractProposalName(), hyperLink);
                try {
                    imdb.setAction(new PdfAction(new URL(this.messageReturn(project.getWorkplanURL()))));
                } catch (MalformedURLException exp) {
                    imdb = new Chunk(project.getBilateralContractProposalName(), TABLE_BODY_FONT);
                    LOG.error("There is an Malformed exception in bilateral contract: "
                            + project.getBilateralContractProposalName());
                }
            } else {
                imdb = new Chunk(this.getText("summaries.project.empty"), TABLE_BODY_FONT);
            }
        }

        cellContent = new Paragraph();
        cellContent.add(imdb);
        this.addTableBodyCell(table, cellContent, Element.ALIGN_LEFT, 1);

        document.add(table);
        document.add(Chunk.NEWLINE);
    } catch (DocumentException e) {
        LOG.error(
                "-- generatePdf() > There was an error adding the table with content for case study summary. ",
                e);
    }
}

From source file:org.cgiar.ccafs.ap.summaries.projects.pdf.CaseStudieSummaryPDF.java

License:Open Source License

/**
 * This method is used for add Outcomes in the project summary
 *///from  www.j a  va  2 s  .  com
private void addProjectOutcomes(String number) {
    try {
        Paragraph outcomesBlock = new Paragraph();
        outcomesBlock.setAlignment(Element.ALIGN_JUSTIFIED);
        Paragraph title = new Paragraph(number + ". " + this.getText("summaries.project.outcome"),
                HEADING2_FONT);
        outcomesBlock.add(title);
        outcomesBlock.add(Chunk.NEWLINE);
        ;
        title = new Paragraph();
        title.setFont(HEADING3_FONT);
        title.add(number + ".1 " + this.getText("summaries.project.outcomeNarrative"));
        outcomesBlock.add(title);
        outcomesBlock.add(Chunk.NEWLINE);
        ;

        // Project outcome statement
        Paragraph body = new Paragraph();
        body.setFont(BODY_TEXT_BOLD_FONT);
        body.add(this.getText("summaries.project.outcomeStatement"));

        // body.setFont(BODY_TEXT_FONT);
        if (project.getOutcomes() == null || project.getOutcomes().get(String.valueOf(midOutcomeYear)) == null
                || project.getOutcomes().get(String.valueOf(midOutcomeYear)).getStatement() == null
                || project.getOutcomes().get(String.valueOf(midOutcomeYear)).getStatement().equals("")) {
            body.add(": ");
            body.setFont(BODY_TEXT_FONT);
            body.add(this.getText("summaries.project.empty"));
        } else {
            body.setFont(BODY_TEXT_FONT);
            body.add(Chunk.NEWLINE);
            body.add(this
                    .messageReturn(project.getOutcomes().get(String.valueOf(midOutcomeYear)).getStatement()));

        }
        body.add(Chunk.NEWLINE);
        ;
        outcomesBlock.add(body);

        try {
            document.newPage();
            // document.add(outcomesBlock);
        } catch (Exception e) {
            LOG.error("There was an error trying to add the project focuses to the project summary pdf", e);
        }

        Anchor anchor;

        ////////////////// Reporting
        PdfPTable table;

        // **********************************************************************************
        // *************************** Outcome Case Studies *************************************
        // **********************************************************************************

        if (project.isReporting()) {
            document.newPage();
            Paragraph cell;

            if (project.getCaseStudies().isEmpty()) {
                document.add(
                        new Paragraph(this.getText("summaries.project.reporting.outcome.not.case.studies")));
            } else {
                title = new Paragraph();
                title.add(Chunk.NEWLINE);
                // document.add(title);
            }
            List<Project> lst = projectManager.getAllProjectsBasicInfo(APConstants.REPORTING_SECTION);
            Collections.sort(lst, new Comparator<Project>() {

                @Override
                public int compare(Project s1, Project s2) {
                    Integer p1 = s1.getId();
                    Integer p2 = s2.getId();
                    return p1.compareTo(p2);
                }
            });
            for (Project project : lst) {
                project = projectManager.getProject(project.getId());
                if (project.isWorkplanRequired()) {
                    String workPlanURL = this.getWorkplanURL();
                    if (workPlanURL != null || project.getWorkplanName() != null) {
                        project.setWorkplanURL(workPlanURL + project.getWorkplanName());
                    }
                }
                // Get a route for the bilateral contract
                if (project.isBilateralProject()) {
                    String bilateralContractURL = this.getBilateralContractURL();
                    if (bilateralContractURL != null || project.getBilateralContractProposalName() != null) {
                        project.setWorkplanURL(
                                bilateralContractURL + project.getBilateralContractProposalName());
                    }
                }

                // Getting the information of the Regions program
                project.setRegions(
                        ipProgramManager.getProjectFocuses(project.getId(), APConstants.REGION_PROGRAM_TYPE));

                // Getting the information of the Flagships program
                project.setFlagships(
                        ipProgramManager.getProjectFocuses(project.getId(), APConstants.FLAGSHIP_PROGRAM_TYPE));

                List<ProjectPartner> projectPartnerList = this.partnerManager.getProjectPartners(project, 0);

                for (ProjectPartner projectPartner : projectPartnerList) {
                    projectPartner
                            .setPartnerPersons(this.partnerPersonManager.getPartnerPersons(projectPartner));
                    projectPartner.setPartnerContributors(
                            partnerManager.getProjectPartnerContributors(projectPartner));
                }
                project.setProjectPartners(projectPartnerList);
                this.project = project;

                List<CasesStudies> caseStudiesList = caseStudiesManager.getCaseStudysByProject(project.getId());

                List<IPIndicator> ipIndicatorList;
                IPIndicator ipIndicator;
                if (caseStudiesList != null) {
                    if (!caseStudiesList.isEmpty()) {
                        try {
                            this.addProjectTitle();
                            this.addMainInformationTable();
                        } catch (Exception e) {
                            System.out.println(project.getId());
                            e.printStackTrace();
                        }
                    }

                    for (CasesStudies caseStudie : caseStudiesList) {
                        ipIndicatorList = new ArrayList<IPIndicator>();
                        for (CaseStudieIndicators indicatorCaseStudie : caseStudie
                                .getCaseStudieIndicatorses()) {
                            ipIndicator = indicatorManager
                                    .getIndicatorFlgship(indicatorCaseStudie.getIdIndicator());
                            ipIndicatorList.add(ipIndicator);
                        }
                        caseStudie.setCaseStudyIndicators(ipIndicatorList);
                    }
                    project.setCaseStudies(caseStudiesList);

                    int counter = 0;
                    for (CasesStudies caseStudy : project.getCaseStudies()) {

                        counter++;
                        table = new PdfPTable(1);
                        table.setLockedWidth(true);
                        table.setTotalWidth(500);

                        // case study
                        cell = new Paragraph(
                                this.getText("summaries.project.reporting.outcome.case.study") + " #" + counter,
                                TABLE_HEADER_FONT);
                        this.addTableHeaderCell(table, cell);
                        // this.addCustomTableCell(table, cell, Element.ALIGN_LEFT, BODY_TEXT_FONT, Color.WHITE,
                        // table.getNumberOfColumns(), 0, false);

                        // Title
                        cell = new Paragraph(
                                this.getText("summaries.project.reporting.outcome.casestudy.title"),
                                TABLE_BODY_BOLD_FONT);
                        cell.setFont(TABLE_BODY_FONT);
                        cell.add(caseStudy.getTitle());
                        this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);

                        // Outcome statement
                        cell = new Paragraph(
                                this.getText("summaries.project.reporting.outcome.casestudy.outcomestatement"),
                                TABLE_BODY_BOLD_FONT);
                        cell.setFont(TABLE_BODY_FONT);
                        cell.add(caseStudy.getOutcomeStatement());
                        this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);

                        // Research outputs
                        cell = new Paragraph(
                                this.getText("summaries.project.reporting.outcome.casestudy.researchoutputs"),
                                TABLE_BODY_BOLD_FONT);
                        cell.setFont(TABLE_BODY_FONT);
                        cell.add(caseStudy.getResearchOutputs());
                        this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);

                        // Research partners
                        cell = new Paragraph(
                                this.getText("summaries.project.reporting.outcome.casestudy.researchPartners"),
                                TABLE_BODY_BOLD_FONT);
                        cell.setFont(TABLE_BODY_FONT);
                        cell.add(caseStudy.getResearchPartners());
                        this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);

                        // activities Contributed
                        cell = new Paragraph(
                                this.getText(
                                        "summaries.project.reporting.outcome.casestudy.activitiesContributed"),
                                TABLE_BODY_BOLD_FONT);
                        cell.setFont(TABLE_BODY_FONT);
                        cell.add(caseStudy.getActivities());
                        this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);

                        // Non Research Partners
                        cell = new Paragraph(
                                this.getText(
                                        "summaries.project.reporting.outcome.casestudy.nonResearchPartners"),
                                TABLE_BODY_BOLD_FONT);
                        cell.setFont(TABLE_BODY_FONT);
                        cell.add(caseStudy.getNonResearchPartneres());
                        this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);

                        // Output Users
                        cell = new Paragraph(
                                this.getText("summaries.project.reporting.outcome.casestudy.outputUsers"),
                                TABLE_BODY_BOLD_FONT);
                        cell.setFont(TABLE_BODY_FONT);
                        cell.add(caseStudy.getOutputUsers());
                        this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);

                        // Output Used
                        cell = new Paragraph(
                                this.getText("summaries.project.reporting.outcome.casestudy.outputWasUsed"),
                                TABLE_BODY_BOLD_FONT);
                        cell.setFont(TABLE_BODY_FONT);
                        cell.add(caseStudy.getOutputUsed());
                        this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);

                        // Evidence
                        cell = new Paragraph(
                                this.getText("summaries.project.reporting.outcome.casestudy.evidenceOutcome"),
                                TABLE_BODY_BOLD_FONT);
                        cell.setFont(TABLE_BODY_FONT);
                        cell.add(caseStudy.getEvidenceOutcome());
                        this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);

                        // References
                        cell = new Paragraph(
                                this.getText("summaries.project.reporting.outcome.casestudy.references"),
                                TABLE_BODY_BOLD_FONT);
                        cell.setFont(TABLE_BODY_FONT);
                        cell.add(caseStudy.getReferencesCase());
                        this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);

                        // Outcome indicators
                        cell = new Paragraph(
                                this.getText("summaries.project.reporting.outcome.casestudy.primaryOutcome",
                                        new String[] { String.valueOf(this.midOutcomeYear) }),
                                TABLE_BODY_BOLD_FONT);
                        cell.setFont(TABLE_BODY_FONT);
                        cell.add("\n");
                        for (IPIndicator _ipIndicator : caseStudy.getCaseStudyIndicators()) {
                            if (_ipIndicator.getOutcome() != null) {
                                cell.add(_ipIndicator.getOutcome().getDescription());
                            }
                            cell.add(" " + _ipIndicator.getDescription() + "\n");
                        }
                        this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);

                        // Explain link
                        cell = new Paragraph(
                                this.getText("summaries.project.reporting.outcome.casestudy.explainLink"),
                                TABLE_BODY_BOLD_FONT);
                        cell.setFont(TABLE_BODY_FONT);
                        cell.add(caseStudy.getExplainIndicatorRelation());
                        this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);

                        // year
                        cell = new Paragraph(this.getText("summaries.project.reporting.outcome.casestudy.year"),
                                TABLE_BODY_BOLD_FONT);
                        cell.setFont(TABLE_BODY_FONT);
                        cell.add(String.valueOf(caseStudy.getYear()));
                        this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);

                        // upload
                        cell = new Paragraph(
                                this.getText("summaries.project.reporting.outcome.casestudy.upload"),
                                TABLE_BODY_BOLD_FONT);
                        cell.setFont(TABLE_BODY_FONT);
                        if (caseStudy.getFile() == null || caseStudy.getFile().equals("")) {
                            cell.add(this.messageReturn(null));
                        } else {
                            anchor = new Anchor(caseStudy.getFile(), TABLE_BODY_FONT_LINK);
                            anchor.setReference(config.getDownloadURL() + "/projects/" + project.getId()
                                    + "/caseStudy/" + caseStudy.getFile());
                            cell.add(anchor);
                        }
                        this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);

                        document.add(table);
                        document.add(new Paragraph(Chunk.NEWLINE));

                    }
                }

                document.newPage();
            }
        }

    } catch (DocumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:org.cgiar.ccafs.ap.summaries.projects.pdf.ProjectSummaryPDF.java

License:Open Source License

/**
 * @param deliverable deliverable to add in the summary
 * @param counter number of deliverable//  w w w.java  2  s .c  o  m
 **/
private void addDelivable(Deliverable deliverable, int counter) {
    try {
        if (deliverable != null) {

            PdfPTable table = new PdfPTable(2);
            table.setTotalWidth(480);
            table.setLockedWidth(true);

            StringBuilder stringBuilder = new StringBuilder();
            PdfPCell cell_new;

            // **** Expected Deliverable #*********
            Paragraph deliverableBlock = new Paragraph();
            deliverableBlock.setFont(HEADING4_FONT);
            if (project.isReporting()) {
                deliverableBlock.add(this.getText("summaries.project.deliverable") + " #" + counter);
            } else {
                if (deliverable.getYear() < config.getPlanningCurrentYear()) {
                    deliverableBlock.add(this.getText("summaries.project.deliverable") + " #" + counter);
                } else {
                    deliverableBlock
                            .add(this.getText("summaries.project.deliverable.expected") + " #" + counter);
                }

            }

            deliverableBlock.add(Chunk.NEWLINE);
            deliverableBlock.add(Chunk.NEWLINE);
            document.add(deliverableBlock);

            // **** Deliverable Information *********
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(BODY_TEXT_BOLD_FONT);
            deliverableBlock.setAlignment(Element.ALIGN_LEFT);
            deliverableBlock.setFont(TABLE_HEADER_FONT);
            deliverableBlock.add(this.getText("summaries.project.deliverable.information"));

            cell_new = new PdfPCell(deliverableBlock);
            cell_new.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell_new.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell_new.setBackgroundColor(TABLE_HEADER_BACKGROUND);
            cell_new.setUseBorderPadding(true);
            cell_new.setPadding(3);
            cell_new.setBorderColor(TABLE_CELL_BORDER_COLOR);
            cell_new.setColspan(2);

            this.addTableHeaderCell(table, cell_new);

            // Title
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.deliverable.information.title") + ": ");

            deliverableBlock.setFont(TABLE_BODY_FONT);
            deliverableBlock.add(this.messageReturn(deliverable.getTitle()));
            deliverableBlock.add(Chunk.NEWLINE);
            ;
            // document.add(deliverableBlock);
            this.addTableColSpanCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1, 2);

            // MOG

            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            if (deliverable.getOutput() != null) {
                stringBuilder = new StringBuilder();
                if (deliverable.getOutput().getProgram() != null
                        && deliverable.getOutput().getProgram().getAcronym() != null) {
                    stringBuilder.append(deliverable.getOutput().getProgram().getAcronym());
                    stringBuilder.append(" - MOG # ");
                } else {
                    stringBuilder.append("MOG # ");
                }
                stringBuilder.append(this.getMOGIndex(deliverable.getOutput()));
                stringBuilder.append(": ");
                deliverableBlock.add(stringBuilder.toString());
                deliverableBlock.setFont(TABLE_BODY_FONT);
                stringBuilder = new StringBuilder();
                stringBuilder.append(deliverable.getOutput().getDescription());
            } else {
                deliverableBlock.add("MOG :");
                stringBuilder.append(this.getText("summaries.project.empty"));
            }
            deliverableBlock.add(stringBuilder.toString());
            deliverableBlock.add(Chunk.NEWLINE);
            // document.add(deliverableBlock);
            this.addTableColSpanCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1, 2);

            // Main Type
            deliverableBlock = new Paragraph();
            stringBuilder = new StringBuilder();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            stringBuilder.append(this.getText("summaries.project.deliverable.information.main"));
            stringBuilder.append(": ");
            deliverableBlock.add(stringBuilder.toString());

            deliverableBlock.setFont(TABLE_BODY_FONT);
            stringBuilder = new StringBuilder();
            if (deliverable.getType() != null && deliverable.getType().getCategory() != null) {
                stringBuilder.append(this.messageReturn(deliverable.getType().getCategory().getName()));
            } else {
                stringBuilder.append(this.messageReturn(""));
            }
            deliverableBlock.add(stringBuilder.toString());
            deliverableBlock.add(Chunk.NEWLINE);
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1);

            // Sub Type
            deliverableBlock = new Paragraph();
            stringBuilder = new StringBuilder();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            stringBuilder.append(this.getText("summaries.project.deliverable.information.sub"));
            stringBuilder.append(": ");
            deliverableBlock.add(stringBuilder.toString());
            deliverableBlock.setFont(TABLE_BODY_FONT);
            stringBuilder = new StringBuilder();
            if (deliverable.getType() == null) {
                stringBuilder.append(this.messageReturn(this.getText("summaries.project.empty")));
            } else if (deliverable.getType().getId() == 38) {
                stringBuilder.append(this.getText("summaries.project.deliverable.other.expected"));
                stringBuilder.append("(");
                stringBuilder.append(this.messageReturn(deliverable.getTypeOther()));
                stringBuilder.append(")");
            } else {
                stringBuilder.append(this.messageReturn(deliverable.getType().getName()));
            }

            deliverableBlock.add(this.messageReturn(stringBuilder.toString()));
            deliverableBlock.add(Chunk.NEWLINE);
            ;
            // document.add(deliverableBlock);
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

            // Year
            deliverableBlock = new Paragraph();
            stringBuilder = new StringBuilder();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            stringBuilder.append(this.getText("summaries.project.deliverable.information.year"));
            stringBuilder.append(": ");
            deliverableBlock.add(stringBuilder.toString());

            deliverableBlock.setFont(TABLE_BODY_FONT);
            stringBuilder = new StringBuilder();
            stringBuilder.append(deliverable.getYear());
            deliverableBlock.add(stringBuilder.toString());
            deliverableBlock.add(Chunk.NEWLINE);
            // document.add(deliverableBlock);
            this.addTableColSpanCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1, 2);

            // Status
            deliverableBlock = new Paragraph();
            stringBuilder = new StringBuilder();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            stringBuilder.append(this.getText("summaries.project.deliverable.information.statuts"));
            deliverableBlock.add(stringBuilder.toString());

            deliverableBlock.setFont(TABLE_BODY_FONT);
            stringBuilder = new StringBuilder();
            if (deliverable.getStatus() != 0) {
                if (deliverable.getStatus() == Integer.parseInt(ProjectStatusEnum.Cancelled.getStatusId())) {

                    deliverableBlock.setFont(TABLE_BODY_FONT_RED);
                }
                stringBuilder.append(this.statuses.get(String.valueOf(deliverable.getStatus())));
            } else {
                stringBuilder.append(this.messageReturn(null));
            }
            deliverableBlock.add(stringBuilder.toString());
            deliverableBlock.add(Chunk.NEWLINE);
            // document.add(deliverableBlock);

            if (deliverable.isStatusCancelled() || deliverable.isStatusExtended()
                    || deliverable.isStatusOnGoing()) {
                this.addTableColSpanCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1, 1);

                // Justification
                deliverableBlock = new Paragraph();
                stringBuilder = new StringBuilder();
                deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
                stringBuilder.append(this.getText("summaries.project.deliverable.information.justification"));
                deliverableBlock.add(stringBuilder.toString());

                deliverableBlock.setFont(TABLE_BODY_FONT);
                deliverableBlock.add(this.messageReturn(deliverable.getStatusDescription()));
                deliverableBlock.add(Chunk.NEWLINE);

                this.addTableColSpanCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1, 1);

            } else {
                this.addTableColSpanCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1, 2);
            }

            document.add(table);
            deliverableBlock = new Paragraph();
            deliverableBlock.add(Chunk.NEWLINE);
            document.add(deliverableBlock);

            // ********** Next Users**************************************

            counter = 1;
            List<NextUser> nextUsers = deliverable.getNextUsers();
            for (NextUser nextUser : nextUsers) {
                if (nextUser != null) {

                    table = new PdfPTable(1);
                    table.setTotalWidth(480);
                    table.setLockedWidth(true);

                    // Next user title
                    deliverableBlock = new Paragraph();
                    deliverableBlock.setAlignment(Element.ALIGN_LEFT);
                    deliverableBlock.setFont(TABLE_HEADER_FONT);
                    if (nextUsers.size() == 1) {
                        deliverableBlock.add(this.getText("summaries.project.deliverable.next.user"));
                    } else {
                        deliverableBlock
                                .add(this.getText("summaries.project.deliverable.next.user") + " #" + counter);
                    }

                    this.addTableHeaderCell(table, deliverableBlock);

                    // Next user
                    stringBuilder = new StringBuilder();
                    deliverableBlock = new Paragraph();
                    deliverableBlock.setFont(TABLE_BODY_FONT);
                    stringBuilder.append(nextUser.getUser());
                    deliverableBlock.add(this.messageReturn(stringBuilder.toString()));
                    this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1);

                    // Expected Changes
                    stringBuilder = new StringBuilder();
                    deliverableBlock = new Paragraph();
                    deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
                    deliverableBlock
                            .add(this.getText("summaries.project.deliverable.next.user.expected.change"));
                    deliverableBlock.setFont(TABLE_BODY_FONT);
                    stringBuilder.append(this.messageReturn(nextUser.getExpectedChanges()));
                    deliverableBlock.add(stringBuilder.toString());
                    // document.add(deliverableBlock);
                    this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1);

                    // Strategies
                    stringBuilder = new StringBuilder();
                    deliverableBlock = new Paragraph();
                    deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
                    deliverableBlock.add(this.getText("summaries.project.deliverable.next.user.strategies"));
                    deliverableBlock.setFont(TABLE_BODY_FONT);
                    stringBuilder.append(this.messageReturn(nextUser.getStrategies()));
                    deliverableBlock.add(stringBuilder.toString());
                    // document.add(deliverableBlock);
                    this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1);

                    document.add(table);
                    deliverableBlock = new Paragraph();
                    deliverableBlock.add(Chunk.NEWLINE);
                    document.add(deliverableBlock);

                    counter++;
                }

            }
            // ********** Deliverable partnership****************************

            // ******************Partner contributing
            counter = 1;

            table = new PdfPTable(1);
            table.setLockedWidth(true);
            table.setTotalWidth(480);

            // Title partners contributing
            deliverableBlock = new Paragraph();
            deliverableBlock.setAlignment(Element.ALIGN_LEFT);
            deliverableBlock.setFont(TABLE_HEADER_FONT);
            deliverableBlock.add(this.getText("summaries.project.deliverable.partnership"));
            deliverableBlock.setFont(TABLE_HEADER_FONT);
            this.addTableHeaderCell(table, deliverableBlock);

            // Organization
            stringBuilder = new StringBuilder();
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.deliverable.partnership.organization") + " #"
                    + counter + " (Responsible)" + ": ");
            deliverableBlock.setFont(TABLE_BODY_FONT);
            DeliverablePartner deliverableResponsiblePartner = deliverable.getResponsiblePartner();
            PartnerPerson partnerPersonResponsible = null;
            if (deliverableResponsiblePartner != null) {
                partnerPersonResponsible = deliverableResponsiblePartner.getPartner();
            }
            if (deliverableResponsiblePartner != null && partnerPersonResponsible != null) {
                stringBuilder.append(this.messageReturn(partnerPersonResponsible.getComposedName()));
                stringBuilder.append(", ");
                stringBuilder
                        .append(this.mapPartnerPersons.get(String.valueOf(partnerPersonResponsible.getId())));
            } else {
                stringBuilder.append(this.getText("summaries.project.empty"));
            }
            deliverableBlock.add(stringBuilder.toString());
            deliverableBlock.add(Chunk.NEWLINE);
            ;
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1);
            counter = 1;
            // ************** Other Partners
            List<DeliverablePartner> listOtherPartner = deliverable.getOtherPartners();

            PartnerPerson otherResponsiblepartnerPerson = null;

            if (!listOtherPartner.isEmpty()) {
                for (DeliverablePartner deliverablePartner : listOtherPartner) {
                    if (deliverablePartner != null) {
                        counter++;

                        // Title partners contributing
                        deliverableBlock = new Paragraph();
                        deliverableBlock.setAlignment(Element.ALIGN_LEFT);
                        deliverableBlock.setFont(BODY_TEXT_BOLD_FONT);
                        if (listOtherPartner.size() == 1) {
                            deliverableBlock.add(this.getText("summaries.project.deliverable.partnership"));
                        } else {
                            deliverableBlock.add(
                                    this.getText("summaries.project.deliverable.partnership") + " #" + counter);
                        }

                        // Organization
                        stringBuilder = new StringBuilder();
                        deliverableBlock = new Paragraph();
                        deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);

                        deliverableBlock
                                .add(this.getText("summaries.project.deliverable.partnership.organization")
                                        + " #" + counter + ": ");
                        deliverableBlock.add("");

                        deliverableBlock.setFont(TABLE_BODY_FONT);

                        otherResponsiblepartnerPerson = deliverablePartner.getPartner();
                        if (otherResponsiblepartnerPerson != null) {
                            stringBuilder.append(
                                    this.messageReturn(otherResponsiblepartnerPerson.getComposedName()));
                            stringBuilder.append(", ");
                            stringBuilder.append(this.mapPartnerPersons
                                    .get(String.valueOf(otherResponsiblepartnerPerson.getId())));
                        } else {
                            stringBuilder.append(this.getText("summaries.project.empty"));
                        }

                        deliverableBlock.add(stringBuilder.toString());
                        deliverableBlock.add(Chunk.NEWLINE);
                        ;
                        this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1);
                    }
                }
            }

            document.add(table);
            deliverableBlock = new Paragraph();
            deliverableBlock.add(Chunk.NEWLINE);
            document.add(deliverableBlock);

        }

        // ********** Ranking**************************************
        PdfPCell cell_new;
        if (project.isReporting()) {

            PdfPTable table = new PdfPTable(2);
            table.setLockedWidth(true);
            table.setTotalWidth(480);
            table.setWidths(new int[] { 7, 3 });
            DeliverablesRanking deliverableRanking = deliverable.getRanking();

            // summaries.project.reporting.deliverable.ranking
            Paragraph deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_HEADER_FONT);
            deliverableBlock.setAlignment(Element.ALIGN_LEFT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.ranking"));

            cell_new = new PdfPCell(deliverableBlock);
            cell_new.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell_new.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell_new.setBackgroundColor(TABLE_HEADER_BACKGROUND);
            cell_new.setUseBorderPadding(true);
            cell_new.setPadding(3);
            cell_new.setBorderColor(TABLE_CELL_BORDER_COLOR);
            cell_new.setColspan(2);

            this.addTableHeaderCell(table, cell_new);

            // address gender
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.addres.gender"));
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_FONT);
            if (deliverableRanking != null && deliverableRanking.getAddress() != null) {
                deliverableBlock.add(this.messageReturn(deliverableRanking.getAddress().toString()));
            } else {
                deliverableBlock.add(this.messageReturn(null));
            }
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_CENTER, 1);

            // Get Potential
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.contribution.outcome"));
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_FONT);
            if (deliverableRanking != null && deliverableRanking.getPotential() != null) {
                deliverableBlock.add(this.messageReturn(deliverableRanking.getPotential().toString()));
            } else {
                deliverableBlock.add(this.messageReturn(null));
            }
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_CENTER, 1);

            // Level
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.shared.ownership"));
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_FONT);
            if (deliverableRanking != null && deliverableRanking.getLevel() != null) {
                deliverableBlock.add(this.messageReturn(deliverableRanking.getLevel().toString()));
            } else {
                deliverableBlock.add(this.messageReturn(null));
            }
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_CENTER, 1);

            // Personal perspective
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.personal.prespective"));
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_FONT);
            if (deliverableRanking != null && deliverableRanking.getPersonalPerspective() != null) {
                deliverableBlock
                        .add(this.messageReturn(String.valueOf(deliverableRanking.getPersonalPerspective())));
            } else {
                deliverableBlock.add(this.messageReturn(null));
            }
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_CENTER, 1);

            document.add(table);
            deliverableBlock = new Paragraph();
            deliverableBlock.add(Chunk.NEWLINE);
            document.add(deliverableBlock);

            // ********** Deliverable Dissemination**************************************
            DeliverableDissemination deliverableDissemination = deliverable.getDissemination();
            table = new PdfPTable(1);
            table.setLockedWidth(true);
            table.setTotalWidth(480);

            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_HEADER_FONT);
            deliverableBlock.setAlignment(Element.ALIGN_LEFT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.dissemination"));
            this.addTableHeaderCell(table, deliverableBlock);

            // Open access
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.dissemination.open"));
            deliverableBlock.setFont(TABLE_BODY_FONT);

            if (deliverableDissemination != null) {
                if (deliverableDissemination.getIsOpenAccess() != null
                        && deliverableDissemination.getIsOpenAccess().booleanValue()) {
                    deliverableBlock.add("Yes");
                } else if (deliverableDissemination.getIntellectualProperty() != null
                        && deliverableDissemination.getIntellectualProperty().booleanValue()) {
                    deliverableBlock.add(
                            this.getText("summaries.project.reporting.deliverable.dissemination.intellectual"));
                } else if (deliverableDissemination.getLimitedExclusivity() != null
                        && deliverableDissemination.getLimitedExclusivity().booleanValue()) {
                    deliverableBlock
                            .add(this.getText("summaries.project.reporting.deliverable.dissemination.limited"));
                } else if (deliverableDissemination.getRestrictedUseAgreement() != null
                        && deliverableDissemination.getRestrictedUseAgreement().booleanValue()) {

                    deliverableBlock.add(
                            this.getText("summaries.project.reporting.deliverable.dissemination.restricted"));
                    this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

                    deliverableBlock = new Paragraph();
                    deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
                    deliverableBlock
                            .add(this.getText("summaries.project.reporting.deliverable.dissemination.access"));
                    deliverableBlock.setFont(TABLE_BODY_FONT);
                    deliverableBlock.add(deliverableDissemination.getRestrictedAccessUntilText());

                } else if (deliverableDissemination.getEffectiveDateRestriction() != null
                        && deliverableDissemination.getEffectiveDateRestriction().booleanValue()) {
                    deliverableBlock.add(
                            this.getText("summaries.project.reporting.deliverable.dissemination.effective"));
                    this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

                    deliverableBlock = new Paragraph();
                    deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
                    deliverableBlock.add(
                            this.getText("summaries.project.reporting.deliverable.dissemination.embargoed"));
                    deliverableBlock.setFont(TABLE_BODY_FONT);
                    deliverableBlock.add(deliverableDissemination.getRestrictedEmbargoedText());

                } else {
                    deliverableBlock.add(this.messageReturn(null));
                }
            } else {
                deliverableBlock.add(this.messageReturn(null));
            }
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

            // License adopted

            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.dissemination.license"));
            deliverableBlock.setFont(TABLE_BODY_FONT);

            if (deliverableDissemination != null) {
                if (deliverable
                        .getMetadataValueByEncondedName(APConstants.DELIVERABLE_ENCONDING_LICENSE) != null) {
                    deliverableBlock.add(this.messageReturn(deliverable
                            .getMetadataValueByEncondedName(APConstants.DELIVERABLE_ENCONDING_LICENSE)));
                } else {
                    deliverableBlock.add("No");
                }
            } else {
                deliverableBlock.add(this.messageReturn(null));
            }
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

            // // Dissemination channel
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.dissemination.channel"));
            deliverableBlock.setFont(TABLE_BODY_FONT);

            if (deliverableDissemination != null) {
                deliverableBlock.add(this.messageReturn(deliverableDissemination.getDisseminationChannel()));
            } else {
                deliverableBlock.add(this.messageReturn(null));
            }
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

            // Dissemination URL
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.dissemination.url"));
            deliverableBlock.setFont(TABLE_BODY_FONT_LINK);

            if (deliverableDissemination != null) {
                deliverableBlock.add(this.messageReturn(deliverableDissemination.getDisseminationUrl()));
            } else {
                deliverableBlock.add(this.messageReturn(null));
            }
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

            document.add(table);
            deliverableBlock = new Paragraph();
            deliverableBlock.add(Chunk.NEWLINE);
            document.add(deliverableBlock);

            // ********** Deliverable Metadata**************************************
            DeliverablePublicationMetadata deliverableMetadata = deliverable.getPublicationMetadata();
            table = new PdfPTable(1);
            table.setLockedWidth(true);
            table.setTotalWidth(480);

            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_HEADER_FONT);
            deliverableBlock.setAlignment(Element.ALIGN_LEFT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.metadata"));
            this.addTableHeaderCell(table, deliverableBlock);

            // Description
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.metadata.description"));
            deliverableBlock.setFont(TABLE_BODY_FONT);

            if (deliverableMetadata != null) {
                deliverableBlock.add(this.messageReturn(deliverable
                        .getMetadataValueByEncondedName(APConstants.DELIVERABLE_ENCONDING_DESCRIPTION)));
            } else {
                deliverableBlock.add(this.messageReturn(null));
            }
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

            // creator
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.metadata.creator"));
            deliverableBlock.setFont(TABLE_BODY_FONT);

            if (deliverableMetadata != null) {
                deliverableBlock.add(this.messageReturn(
                        deliverable.getMetadataValueByEncondedName(APConstants.DELIVERABLE_ENCONDING_CREATOR)));
            } else {
                deliverableBlock.add(this.messageReturn(null));
            }
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

            // authorID
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.metadata.authorID"));
            deliverableBlock.setFont(TABLE_BODY_FONT);

            if (deliverableMetadata != null) {
                deliverableBlock.add(this.messageReturn(deliverable
                        .getMetadataValueByEncondedName(APConstants.DELIVERABLE_ENCONDING_CREATOR_ID)));
            } else {
                deliverableBlock.add(this.messageReturn(null));
            }
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

            // Creation
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.metadata.creation"));
            deliverableBlock.setFont(TABLE_BODY_FONT);

            if (deliverableMetadata != null) {
                deliverableBlock.add(this.messageReturn(deliverable
                        .getMetadataValueByEncondedName(APConstants.DELIVERABLE_ENCONDING_PUBLICATION)));
            } else {
                deliverableBlock.add(this.messageReturn(null));
            }
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

            // Language
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.metadata.language"));
            deliverableBlock.setFont(TABLE_BODY_FONT);

            if (deliverableMetadata != null) {
                deliverableBlock.add(this.messageReturn(this.messageReturn(deliverable
                        .getMetadataValueByEncondedName(APConstants.DELIVERABLE_ENCONDING_LANGUAGE))));
            } else {
                deliverableBlock.add(this.messageReturn(null));
            }
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

            // Coverage
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.metadata.coverage"));
            deliverableBlock.setFont(TABLE_BODY_FONT);

            if (deliverableMetadata != null) {
                deliverableBlock.add(this.messageReturn(deliverable
                        .getMetadataValueByEncondedName(APConstants.DELIVERABLE_ENCONDING_COVERAGE)));
            } else {
                deliverableBlock.add(this.messageReturn(null));
            }
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);
            document.add(table);
            deliverableBlock = new Paragraph();
            deliverableBlock.add(Chunk.NEWLINE);
            document.add(deliverableBlock);

            // ********** Deliverable Data Sharing**************************************
            table = new PdfPTable(1);
            table.setLockedWidth(true);
            table.setTotalWidth(480);

            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_HEADER_FONT);
            deliverableBlock.setAlignment(Element.ALIGN_LEFT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.datasharing"));
            this.addTableHeaderCell(table, deliverableBlock);

            // Files
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.datasharing.files"));
            deliverableBlock.add("\n");
            deliverableBlock.setFont(TABLE_BODY_FONT);

            List<DeliverableDataSharingFile> deliverableDataSharingFileList = deliverable.getDataSharingFile();

            cell_new = new PdfPCell(deliverableBlock);
            cell_new.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell_new.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell_new.setBackgroundColor(TABLE_BODY_ODD_ROW_BACKGROUND);
            cell_new.setUseBorderPadding(true);
            cell_new.setPadding(3);
            cell_new.setBorderColor(TABLE_CELL_BORDER_COLOR);
            cell_new.setColspan(2);
            Anchor anchor;
            Phrase myurl;
            counter = 0;
            if (deliverableDataSharingFileList != null) {
                for (DeliverableDataSharingFile deliverableDataSharingFile : deliverableDataSharingFileList) {
                    if (deliverableDataSharingFile != null) {

                        anchor = new Anchor(deliverableDataSharingFile.getFile(), TABLE_BODY_FONT_LINK);
                        anchor.setReference(config.getDownloadURL() + "/projects/" + project.getId()
                                + "/deliverableDataSharing/" + deliverableDataSharingFile.getFile());
                        myurl = new Phrase();
                        myurl.add(anchor);
                        myurl.setFont(TABLE_BODY_FONT_LINK);

                        cell_new.addElement(myurl);
                        if (counter > 1) {
                            cell_new.addElement(new Paragraph("\n"));
                        }
                        counter++;
                    }
                }
                table.addCell(cell_new);
            } else {
                deliverableBlock.setFont(TABLE_BODY_FONT);
                deliverableBlock.add(this.messageReturn(null));
                this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);
            }
            document.add(table);
            deliverableBlock = new Paragraph();
            deliverableBlock.add(Chunk.NEWLINE);
            deliverableBlock.add(Chunk.NEWLINE);
            document.add(deliverableBlock);
        }

    } catch (DocumentException e) {
        LOG.error(
                "-- generatePdf() > There was an error adding the table with content for case study summary. ",
                e);
    }
}

From source file:org.cgiar.ccafs.ap.summaries.projects.pdf.ProjectSummaryPDF.java

License:Open Source License

/**
 * This is an auxiliar method for to get information project partners in the paragrapn block.
 * //from   w  w  w  .ja va  2s .  c  om
 * @param partner partner to get information
 * @param numberPP number of project partner
 * @param partnersBlock paragraph to add the information
 */
private void addPartner(ProjectPartner partner, int numberPP) {

    if (!(partner == null)) {
        try {
            PdfPTable table = new PdfPTable(1);
            table.setTotalWidth(500);
            table.setLockedWidth(true);

            // /////////////////////////////////////////////////////////////////////
            Paragraph paragraph = new Paragraph();

            // Partner #
            paragraph.setFont(HEADING3_FONT);

            if (project.getLeader() != null && partner.getId() == project.getLeader().getId()) {
                paragraph.add(this.getText("summaries.project.partner") + numberPP + " "
                        + this.getText("summaries.project.partner.leader"));
            } else {
                paragraph.add(this.getText("summaries.project.partner") + numberPP + " ");
            }

            paragraph.add(Chunk.NEWLINE);
            paragraph.add(Chunk.NEWLINE);
            document.add(paragraph);

            // Organization
            paragraph = new Paragraph();
            paragraph.setFont(BODY_TEXT_BOLD_FONT);
            paragraph.setAlignment(Element.ALIGN_LEFT);
            paragraph.add(this.getText("summaries.project.organization"));
            paragraph.setFont(BODY_TEXT_FONT);
            if (partner.getInstitution() != null) {
                if (!((partner.getInstitution().getAcronym() == null)
                        || (partner.getInstitution().getAcronym().isEmpty()))) {
                    paragraph.add(partner.getInstitution().getAcronym());
                    paragraph.add(" - ");

                }
                paragraph.add(this.messageReturn(partner.getInstitution().getName()));
            } else {
                paragraph.add("Not defined");
            }

            document.add(paragraph);

            // CCAFS Partner(s) allocating budget:
            if (!partner.getInstitution().isPPA()) {
                table = new PdfPTable(1);
                table.setTotalWidth(500);
                table.setLockedWidth(true);

                paragraph = new Paragraph();
                paragraph.add(Chunk.NEWLINE);

                // title contributing
                paragraph.setFont(BODY_TEXT_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.projectPartners.ccafs.partner.allocating"));

                List<ProjectPartner> partnersContributings = partner.getPartnerContributors();
                if (partnersContributings.isEmpty()) {
                    paragraph.add(": ");
                    paragraph.setFont(BODY_TEXT_FONT);
                    paragraph.add(this.getText("summaries.project.empty"));
                    document.add(paragraph);
                } else {
                    this.addCustomTableCell(table, paragraph, Element.ALIGN_LEFT, BODY_TEXT_BOLD_FONT,
                            Color.WHITE, table.getNumberOfColumns(), 0, false);

                    for (ProjectPartner partnerContributing : partnersContributings) {
                        paragraph = new Paragraph();
                        this.addTableBodyCell(table,
                                new Paragraph(partnerContributing.getInstitution().getComposedName(),
                                        TABLE_BODY_FONT),
                                Element.ALIGN_JUSTIFIED, 1);
                    }
                }
                document.add(table);

            }

            paragraph = new Paragraph();
            paragraph.add(Chunk.NEWLINE);
            document.add(paragraph);

            // PartnerPersons
            table = new PdfPTable(3);
            table.setTotalWidth(500);
            table.setLockedWidth(true);
            table.setWidths(new int[] { 1, 3, 6 });

            paragraph = new Paragraph();
            paragraph.setFont(BODY_TEXT_BOLD_FONT);
            paragraph.add(this.getText("summaries.project.partner.partnerPerson"));
            this.addCustomTableCell(table, paragraph, Element.ALIGN_LEFT, BODY_TEXT_BOLD_FONT, Color.WHITE,
                    table.getNumberOfColumns(), 0, false);

            // ***** Header Partner persons

            // Person type
            paragraph = new Paragraph();
            paragraph.setFont(TABLE_HEADER_FONT);
            paragraph.add(this.getText("summaries.project.partner.persontype"));
            this.addTableHeaderCell(table, paragraph);

            // contact person
            paragraph = new Paragraph();
            paragraph.setFont(TABLE_HEADER_FONT);
            paragraph.add(this.getText("summaries.project.partner.contactperson"));
            this.addTableHeaderCell(table, paragraph);

            // responsabities
            paragraph = new Paragraph();
            paragraph.setFont(TABLE_HEADER_FONT);
            paragraph.setAlignment(Element.ALIGN_JUSTIFIED);
            paragraph.add(this.getText("summaries.project.partner.responsibilities"));
            this.addTableHeaderCell(table, paragraph);

            paragraph.setFont(TABLE_BODY_FONT);

            for (PartnerPerson partnerPerson : partner.getPartnerPersons()) {

                // type
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_FONT);
                if (partnerPerson.getType() == null) {
                    paragraph.add(this.getText("summary.project.empty"));
                } else if (partnerPerson.getType().equals("PL")) {
                    paragraph.add(this.getText("planning.projectPartners.types.PL"));
                } else if (partnerPerson.getType().equals("PC")) {
                    paragraph.add(this.getText("planning.projectPartners.types.PC"));
                } else {
                    // is CP
                    paragraph.add(this.getText("planning.projectPartners.types.CP"));
                }
                this.addTableColSpanCell(table, paragraph, Element.ALIGN_CENTER, 1, 1);

                // contact person
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_FONT);
                paragraph.add(this.messageReturn(partnerPerson.getComposedName()));
                this.addTableColSpanCell(table, paragraph, Element.ALIGN_CENTER, 1, 1);

                // Responsabilities
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_FONT);
                paragraph.add(this.messageReturn(partnerPerson.getResponsibilities()));
                this.addTableColSpanCell(table, paragraph, Element.ALIGN_JUSTIFIED, 1, 1);

            }

            document.add(table);
            paragraph = new Paragraph();
            paragraph.add(Chunk.NEWLINE);
            paragraph.add(Chunk.NEWLINE);
            document.add(paragraph);

        } catch (DocumentException e) {
            LOG.error(
                    "-- generatePdf() > There was an error adding the table with content for case study summary. ",
                    e);
        }
    }
}

From source file:org.cgiar.ccafs.ap.summaries.projects.pdf.ProjectSummaryPDF.java

License:Open Source License

private void addProjectContributions() {
    try {/*from  ww  w.j  a va2 s.  c  om*/
        PdfPTable table = new PdfPTable(2);

        // Set table widths
        table.setLockedWidth(true);
        table.setTotalWidth(480);
        table.setWidths(new int[] { 7, 3 });

        Paragraph cell;
        StringBuffer projectFocuses = new StringBuffer();

        // ************************ Adding flagships and regions **********************************
        List<IPProgram> listIPFlagship = project.getFlagships();
        List<IPProgram> listIPRegions = project.getRegions();

        if (listIPFlagship.isEmpty() && listIPRegions.isEmpty()) {

            cell = new Paragraph(this.getText("summaries.project.ipContributions"), BODY_TEXT_BOLD_FONT);
            cell.setFont(BODY_TEXT_BOLD_FONT);
            cell.add(": ");
            projectFocuses.append(this.getText("summaries.project.empty"));
            cell.setFont(BODY_TEXT_FONT);
            cell.add(projectFocuses.toString());
            document.add(cell);
            document.add(Chunk.NEWLINE);

        } else {

            cell = new Paragraph(this.getText("summaries.project.ipContributions"), BODY_TEXT_BOLD_FONT);
            this.addCustomTableCell(table, cell, Element.ALIGN_LEFT, BODY_TEXT_FONT, Color.WHITE,
                    table.getNumberOfColumns(), 0, false);

            cell = new Paragraph("", TABLE_HEADER_FONT);
            cell.setAlignment(Element.ALIGN_LEFT);
            cell.add(this.getText("summaries.project.ipContributions.flagship"));

            this.addTableHeaderCell(table, cell);

            cell = new Paragraph("", TABLE_HEADER_FONT);
            cell.setAlignment(Element.ALIGN_LEFT);
            cell.add(this.getText("summaries.project.ipContributions.region"));
            this.addTableHeaderCell(table, cell);

            int sizeFlaships = listIPFlagship.size();
            int sizeRegions = listIPRegions.size();

            if (sizeFlaships < sizeRegions) {
                this.addEmptyFlashigAndRegion(listIPFlagship, sizeRegions);
            } else if (sizeFlaships > sizeRegions) {
                this.addEmptyFlashigAndRegion(listIPRegions, sizeFlaships);
            }

            IPProgram program;
            for (int a = 0; a < listIPRegions.size(); a++) {

                // Flashing
                program = listIPFlagship.get(a);
                if (program.getComposedName() == null || program.getComposedName().isEmpty()) {

                    cell = new Paragraph("", TABLE_BODY_FONT);
                } else {
                    cell = new Paragraph(program.getComposedName(), TABLE_BODY_FONT);
                }

                this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);

                // Regions
                program = listIPRegions.get(a);

                if (program.getComposedName() == null || program.getComposedName().isEmpty()) {
                    cell = new Paragraph("", TABLE_BODY_FONT);
                } else {
                    cell = new Paragraph(program.getComposedName(), TABLE_BODY_FONT);
                }
                this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);
            }
            document.add(table);
            document.add(Chunk.NEWLINE);

        }

        // ******************** Adding Bilateral ********************************************
        List<Project> listLinkageProject = project.getLinkedProjects();
        cell = new Paragraph();
        projectFocuses = new StringBuffer();

        if (project.isBilateralProject()) {
            projectFocuses
                    .append(this.getText("summaries.project.ipContributions.project", new String[] { "Core" }));
        } else {
            projectFocuses.append(
                    this.getText("summaries.project.ipContributions.project", new String[] { "Bilateral" }));
        }

        if (listLinkageProject != null && !listLinkageProject.isEmpty()) {
            table = new PdfPTable(1);

            // Set table widths
            table.setLockedWidth(true);
            table.setTotalWidth(480);

            cell.setFont(TABLE_HEADER_FONT);
            cell.add(projectFocuses.toString());
            table.setWidths(new int[] { 5 });

            // Adding Header
            this.addTableHeaderCell(table, cell);

            for (Project projectContribution : project.getLinkedProjects()) {
                projectFocuses = new StringBuffer();
                projectFocuses.append(projectContribution.getId());
                projectFocuses.append(" - ");
                projectFocuses.append(projectContribution.getTitle());
                cell = new Paragraph(projectFocuses.toString(), TABLE_BODY_FONT);
                this.addTableBodyCell(table, cell, Element.ALIGN_JUSTIFIED, 1);
            }
            document.add(table);
            document.add(Chunk.NEWLINE);
        } else {
            cell.setFont(BODY_TEXT_BOLD_FONT);
            cell.add(projectFocuses.toString());
            cell.add(Chunk.NEWLINE);
            cell.setFont(BODY_TEXT_FONT);
            projectFocuses = new StringBuffer();

            if (project.isBilateralProject()) {
                projectFocuses.append(
                        this.getText("summaries.project.ipContributions.noproject", new String[] { "Core" }));
            } else {
                projectFocuses.append(this.getText("summaries.project.ipContributions.noproject",
                        new String[] { "Bilateral" }));
            }
            cell.add(projectFocuses.toString());
            document.add(cell);
            document.add(Chunk.NEWLINE);
        }

        /*
         * if (project.isBilateralProject()) {
         * projectFocuses = new StringBuffer();
         * cell = new Paragraph();
         * cell.setFont(BODY_TEXT_BOLD_FONT);
         * projectFocuses.append(this.getText("summaries.project.ipContributions.proposal"));
         * cell.add(projectFocuses.toString());
         * cell.setFont(BODY_TEXT_FONT);
         * cell.add(this.messageReturn(project.getBilateralContractProposalName()));
         * document.add(cell);
         * document.add(Chunk.NEWLINE);
         * }
         */

    } catch (DocumentException e) {
        LOG.error("There was an error trying to add the project focuses to the project summary pdf", e);
    }

}

From source file:org.cgiar.ccafs.ap.summaries.projects.pdf.ProjectSummaryPDF.java

License:Open Source License

/**
 * This method is used for add Outcomes in the project summary
 *///from  w  w w  .  j a v a 2 s  .c  om
private void addProjectOutcomes(String number) {
    Paragraph outcomesBlock = new Paragraph();
    outcomesBlock.setAlignment(Element.ALIGN_JUSTIFIED);
    Paragraph title = new Paragraph(number + ". " + this.getText("summaries.project.outcome"), HEADING2_FONT);
    outcomesBlock.add(title);
    outcomesBlock.add(Chunk.NEWLINE);
    ;
    title = new Paragraph();
    title.setFont(HEADING3_FONT);
    title.add(number + ".1 " + this.getText("summaries.project.outcomeNarrative"));
    outcomesBlock.add(title);
    outcomesBlock.add(Chunk.NEWLINE);
    ;

    // Project outcome statement
    Paragraph body = new Paragraph();
    body.setFont(BODY_TEXT_BOLD_FONT);
    body.add(this.getText("summaries.project.outcomeStatement"));

    // body.setFont(BODY_TEXT_FONT);
    if (project.getOutcomes() == null || project.getOutcomes().get(String.valueOf(midOutcomeYear)) == null
            || project.getOutcomes().get(String.valueOf(midOutcomeYear)).getStatement() == null
            || project.getOutcomes().get(String.valueOf(midOutcomeYear)).getStatement().equals("")) {
        body.add(": ");
        body.setFont(BODY_TEXT_FONT);
        body.add(this.getText("summaries.project.empty"));
    } else {
        body.setFont(BODY_TEXT_FONT);
        body.add(Chunk.NEWLINE);
        body.add(this.messageReturn(project.getOutcomes().get(String.valueOf(midOutcomeYear)).getStatement()));

    }
    body.add(Chunk.NEWLINE);
    ;
    outcomesBlock.add(body);

    try {
        document.newPage();
        document.add(outcomesBlock);
    } catch (DocumentException e) {
        LOG.error("There was an error trying to add the project focuses to the project summary pdf", e);
    }

    Anchor anchor;
    currentPlanningYear--;
    ////////////////// Reporting
    PdfPTable table;
    if (project.isReporting()) {
        for (int year = currentPlanningYear; year < midOutcomeYear; year++) {

            // Annual progress towards
            outcomesBlock = new Paragraph();
            outcomesBlock.setAlignment(Element.ALIGN_JUSTIFIED);
            outcomesBlock.setFont(BODY_TEXT_BOLD_FONT);
            outcomesBlock.add(this.getText("summaries.project.outcomeAnnualProgress",
                    new String[] { String.valueOf(year) }));
            outcomesBlock.setFont(BODY_TEXT_FONT);

            if (project.getOutcomes() == null || project.getOutcomes().get(String.valueOf(year)) == null) {
                outcomesBlock.add(this.getText("summaries.project.empty"));
            } else {
                outcomesBlock.add(
                        this.messageReturn(project.getOutcomes().get(String.valueOf(year)).getStatement()));
            }
            outcomesBlock.add(Chunk.NEWLINE);
            outcomesBlock.add(Chunk.NEWLINE);

            try {
                document.add(outcomesBlock);
            } catch (DocumentException e) {
                LOG.error("There was an error trying to add the project focuses to the project summary pdf", e);
            }

            if (year == this.currentPlanningYear) {
                table = new PdfPTable(1);
                table.setLockedWidth(true);
                table.setTotalWidth(500);

                ///// outcome toward in reporting cycle
                outcomesBlock = new Paragraph();
                outcomesBlock.setFont(TABLE_BODY_BOLD_FONT);
                outcomesBlock.add(this.getText("summaries.project.outcomeAnnualTowards",
                        new String[] { String.valueOf(year) }));

                outcomesBlock.setFont(TABLE_BODY_FONT);

                if (project.getOutcomes() == null || project.getOutcomes().get(String.valueOf(year)) == null) {
                    outcomesBlock.add(this.getText("summaries.project.empty"));
                } else {
                    outcomesBlock.add(this
                            .messageReturn(project.getOutcomes().get(String.valueOf(year)).getAnualProgress()));
                }

                this.addTableBodyCell(table, outcomesBlock, Element.ALIGN_JUSTIFIED, 1);

                ///// outcome communication
                outcomesBlock = new Paragraph();
                outcomesBlock.setFont(TABLE_BODY_BOLD_FONT);
                outcomesBlock.add(this.getText("summaries.project.outcomeAnnualCommunication"));
                outcomesBlock.setFont(TABLE_BODY_FONT);

                if (project.getOutcomes() == null || project.getOutcomes().get(String.valueOf(year)) == null) {
                    outcomesBlock.add(this.getText("summaries.project.empty"));
                } else {
                    outcomesBlock.add(this
                            .messageReturn(project.getOutcomes().get(String.valueOf(year)).getComunication()));
                }
                this.addTableBodyCell(table, outcomesBlock, Element.ALIGN_JUSTIFIED, 1);

                // Any evendence
                outcomesBlock = new Paragraph();
                outcomesBlock.setFont(TABLE_BODY_BOLD_FONT);
                outcomesBlock.add(this.getText("summaries.project.outcomeAnnualEvidence"));
                outcomesBlock.setFont(TABLE_BODY_FONT);

                if (project.getOutcomes() == null || project.getOutcomes().get(String.valueOf(year)) == null
                        || project.getOutcomes().get(String.valueOf(year)).getFile() == null
                        || project.getOutcomes().get(String.valueOf(year)).getFile().equals("")) {
                    outcomesBlock.add(this.getText("summaries.project.empty"));
                } else {

                    anchor = new Anchor(project.getOutcomes().get(String.valueOf(year)).getFile(),
                            TABLE_BODY_FONT_LINK);
                    anchor.setReference(config.getDownloadURL() + "/projects/" + project.getId()
                            + "/project_outcome/" + project.getOutcomes().get(String.valueOf(year)).getFile());
                    outcomesBlock.add(anchor);
                }
                this.addTableBodyCell(table, outcomesBlock, Element.ALIGN_LEFT, 1);
                try {
                    document.add(table);
                    outcomesBlock = new Paragraph();
                    outcomesBlock.add(Chunk.NEWLINE);
                    document.add(outcomesBlock);
                } catch (DocumentException e) {
                    LOG.error("There was an error trying to add the project focuses to the project summary pdf",
                            e);
                }
            }
        }

    }
    ////////////////// Planning
    else {
        String outcomeProgress = new String();
        for (int year = currentPlanningYear; year < midOutcomeYear; year++) {
            // Annual progress towards
            outcomesBlock = new Paragraph();
            outcomesBlock.setAlignment(Element.ALIGN_JUSTIFIED);
            outcomesBlock.setFont(BODY_TEXT_BOLD_FONT);
            outcomesBlock.add(this.getText("summaries.project.outcomeAnnualProgress",
                    new String[] { String.valueOf(year) }));

            if (project.getOutcomes() == null || project.getOutcomes().get(String.valueOf(year)) == null
                    || project.getOutcomes().get(String.valueOf(year)).getStatement() == null
                    || project.getOutcomes().get(String.valueOf(year)).getStatement().equals("")) {
                outcomesBlock.add(": ");
                outcomesBlock.setFont(BODY_TEXT_FONT);
                outcomeProgress = this.getText("summaries.project.empty");
            } else {
                outcomesBlock.add(Chunk.NEWLINE);
                outcomeProgress = this
                        .messageReturn(project.getOutcomes().get(String.valueOf(year)).getStatement());
                outcomesBlock.setFont(BODY_TEXT_FONT);
            }
            outcomesBlock.add(outcomeProgress);
            outcomesBlock.add(Chunk.NEWLINE);
            ;
            outcomesBlock.add(Chunk.NEWLINE);
            ;

            try {
                document.add(outcomesBlock);
            } catch (DocumentException e) {
                LOG.error("There was an error trying to add the project focuses to the project summary pdf", e);
            }
        }

    }

    // Lesson regardins
    outcomesBlock = new Paragraph();
    outcomesBlock.setAlignment(Element.ALIGN_JUSTIFIED);
    outcomesBlock.setFont(BODY_TEXT_BOLD_FONT);
    if (project.isReporting()) {
        outcomesBlock.add(this.getText("summaries.project.outcome.reporting.lessonRegarding"));
    } else {
        outcomesBlock.add(this.getText("summaries.project.outcome.lessonRegarding"));
    }
    outcomesBlock.setFont(BODY_TEXT_FONT);
    if (project.getComponentLesson("outcomes") != null) {
        outcomesBlock.add(this.messageReturn(project.getComponentLesson("outcomes").getLessons()));
    } else {
        outcomesBlock.add(this.messageReturn(null));
    }
    try {
        document.add(outcomesBlock);
    } catch (DocumentException e) {
        LOG.error("There was an error trying to add the project focuses to the project summary pdf", e);
    }
    // ******************* CCAFS Outcomes***************/
    this.addProjectCCAFSOutcomes(number);

    // **********************************************************************************
    // ******************* Other contributions***************/
    // **********************************************************************************

    OtherContribution otherContribution = project.getIpOtherContribution();

    try {
        outcomesBlock = new Paragraph();
        outcomesBlock.setAlignment(Element.ALIGN_JUSTIFIED);

        title = new Paragraph(
                number + ".3 " + this.getText("summaries.project.outcome.ccafs.outcomes.other.contributions"),
                HEADING3_FONT);
        outcomesBlock.add(Chunk.NEWLINE);
        outcomesBlock.add(Chunk.NEWLINE);
        outcomesBlock.add(title);
        outcomesBlock.add(Chunk.NEWLINE);

        // Contribution to other Impact Pathways:
        outcomesBlock.setFont(BODY_TEXT_BOLD_FONT);
        if (project.isReporting()) {
            outcomesBlock.add(this.getText(
                    "summaries.project.outcome.ccafs.outcomes.reporting.other.contributions.pathways"));
        } else {

            outcomesBlock
                    .add(this.getText("summaries.project.outcome.ccafs.outcomes.other.contributions.pathways"));
        }
        outcomesBlock.setFont(BODY_TEXT_FONT);

        if (otherContribution == null || otherContribution.getContribution() == null
                || otherContribution.getContribution().equals("")) {
            outcomesBlock.add(": " + this.getText("summaries.project.empty"));
        } else {
            outcomesBlock.add(Chunk.NEWLINE);
            outcomesBlock.add(otherContribution.getContribution());
        }

        outcomesBlock.add(Chunk.NEWLINE);
        outcomesBlock.add(Chunk.NEWLINE);

        document.add(outcomesBlock);
        document.add(Chunk.NEWLINE);

        Paragraph cell;

        if (project.isReporting()) {

            if (project.getOtherContributions().isEmpty()) {

            } else {
                table = new PdfPTable(4);
                table.setWidths(new int[] { 2, 4, 4, 4 });
                table.setLockedWidth(true);
                table.setTotalWidth(500);

                // adding headers
                cell = new Paragraph(this.getText("summaries.project.reporting.ccafs.outcomes.region"),
                        TABLE_HEADER_FONT);
                this.addTableHeaderCell(table, cell);

                cell = new Paragraph(this.getText("summaries.project.reporting.ccafs.outcomes.indicator"),
                        TABLE_HEADER_FONT);
                this.addTableHeaderCell(table, cell);

                cell = new Paragraph(this.getText("summaries.project.reporting.ccafs.outcomes.describe",
                        new String[] { String.valueOf(this.currentReportingYear) }), TABLE_HEADER_FONT);
                this.addTableHeaderCell(table, cell);

                cell = new Paragraph(this.getText("summaries.project.reporting.ccafs.outcomes.ablequantily"),
                        TABLE_HEADER_FONT);
                this.addTableHeaderCell(table, cell);

                // Adding contain
                for (ProjecteOtherContributions projectOther : project.getOtherContributions()) {
                    cell = new Paragraph(projectOther.getRegion(), TABLE_BODY_FONT);
                    this.addTableBodyCell(table, cell, Element.ALIGN_JUSTIFIED, 1);

                    cell = new Paragraph(projectOther.getIndicators(), TABLE_BODY_FONT);
                    this.addTableBodyCell(table, cell, Element.ALIGN_JUSTIFIED, 1);

                    cell = new Paragraph(projectOther.getDescription(), TABLE_BODY_FONT);
                    this.addTableBodyCell(table, cell, Element.ALIGN_JUSTIFIED, 1);

                    cell = new Paragraph(String.valueOf(projectOther.getTarget()), TABLE_BODY_FONT);
                    this.addTableBodyCell(table, cell, Element.ALIGN_JUSTIFIED, 1);

                }
                document.add(table);
                document.add(Chunk.NEWLINE);
            }
            // // Collaboration with other CRPs
            cell = new Paragraph(this.getText("summaries.project.reporting.ccafs.outcomes.collaborating"),
                    BODY_TEXT_BOLD_FONT);

            if (project.getListCRPContributions().isEmpty()) {
                cell.add(": ");
                cell.setFont(BODY_TEXT_FONT);
                cell.add(this.messageReturn(null));
                cell.add(Chunk.NEWLINE);
                document.add(cell);
            } else {
                document.add(cell);
                document.add(Chunk.NEWLINE);

                for (CRPContribution crpContribution : project.getListCRPContributions()) {
                    table = new PdfPTable(1);
                    table.setLockedWidth(true);
                    table.setTotalWidth(500);

                    cell = new Paragraph(this.messageReturn(crpContribution.getCrp().getName()),
                            TABLE_BODY_BOLD_FONT);
                    cell.setAlignment(Element.ALIGN_LEFT);
                    this.addTableBodyCell(table, cell, Element.ALIGN_CENTER, 1);

                    cell = new Paragraph(
                            this.getText("summaries.project.reporting.ccafs.outcomes.natureCollaboration"),
                            TABLE_BODY_BOLD_FONT);
                    cell.setFont(TABLE_BODY_FONT);
                    cell.add(this.messageReturn(crpContribution.getNatureCollaboration()));
                    this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);

                    cell = new Paragraph(
                            this.getText("summaries.project.reporting.ccafs.outcomes.achievedOutcome"),
                            TABLE_BODY_BOLD_FONT);
                    cell.setFont(TABLE_BODY_FONT);
                    cell.add(this.messageReturn(crpContribution.getExplainAchieved()));
                    this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);

                    document.add(table);
                    document.add(Chunk.NEWLINE);
                }

            }
        }

        else {
            outcomesBlock = new Paragraph();
            // Contribution to another Center activity:
            outcomesBlock.setFont(BODY_TEXT_BOLD_FONT);
            outcomesBlock
                    .add(this.getText("summaries.project.outcome.ccafs.outcomes.other.contributions.center"));
            outcomesBlock.setFont(BODY_TEXT_FONT);
            if (otherContribution == null || otherContribution.getAdditionalContribution() == null
                    || otherContribution.getAdditionalContribution().equals("")) {
                outcomesBlock.add(": " + this.getText("summaries.project.empty"));
            } else {
                outcomesBlock.add(otherContribution.getAdditionalContribution());
                outcomesBlock.add(Chunk.NEWLINE);
                outcomesBlock.add(Chunk.NEWLINE);

            }

            boolean addParagraph = false;
            cell = new Paragraph();
            ;
            cell.setFont(BODY_TEXT_BOLD_FONT);

            table = new PdfPTable(2);

            cell.add(this.getText("summaries.project.outcome.ccafs.outcomes.other.contributions.covered"));
            if (otherContribution != null)

            {
                List<CRPContribution> listCRP = otherContribution.getCrpContributions();
                if (listCRP.isEmpty()) {
                    cell.setFont(BODY_TEXT_FONT);
                    cell.add(this.getText("summaries.project.empty"));
                    addParagraph = true;
                } else {
                    table.setWidths(new int[] { 4, 6 });
                    table.setLockedWidth(true);
                    table.setTotalWidth(500);

                    this.addCustomTableCell(table, cell, Element.ALIGN_LEFT, BODY_TEXT_FONT, Color.WHITE,
                            table.getNumberOfColumns(), 0, false);

                    // adding headers
                    this.addTableHeaderCell(table,
                            new Paragraph(
                                    this.getText(
                                            "summaries.project.outcome.ccafs.outcomes.other.contributions.crp"),
                                    TABLE_HEADER_FONT));

                    this.addTableHeaderCell(table,
                            new Paragraph(this.getText(
                                    "summaries.project.outcome.ccafs.outcomes.other.contributions.nature"),
                                    TABLE_HEADER_FONT));

                    for (CRPContribution CRPContribution : listCRP) {
                        if (CRPContribution != null && CRPContribution.getCrp() != null) {
                            cell = new Paragraph();
                            cell.setFont(TABLE_BODY_FONT);
                            cell.add(CRPContribution.getCrp().getName());
                            this.addTableBodyCell(table, cell, Element.ALIGN_CENTER, 1);

                            cell = new Paragraph();
                            cell.setFont(TABLE_BODY_FONT);
                            cell.add(CRPContribution.getNatureCollaboration());
                            this.addTableBodyCell(table, cell, Element.ALIGN_JUSTIFIED, 1);
                        }
                    }
                }
            } else

            {
                cell.add(": ");
                cell.setFont(BODY_TEXT_FONT);
                cell.add(this.getText("summaries.project.empty"));
                addParagraph = true;
            }
            document.add(outcomesBlock);
            // Add paragraphs to document
            if (addParagraph) {
                document.add(cell);
            } else

            {
                document.add(table);
            }

            document.add(Chunk.NEWLINE);

            // Lesson regardins Other contributions
            outcomesBlock = new Paragraph();
            outcomesBlock.setAlignment(Element.ALIGN_JUSTIFIED);
            outcomesBlock.setFont(BODY_TEXT_BOLD_FONT);
            outcomesBlock.add(this
                    .getText("summaries.project.outcome.ccafs.outcomes.other.contributions.lessonRegarding"));
            outcomesBlock.setFont(BODY_TEXT_FONT);
            if (project.getComponentLesson("otherContributions") != null)

            {
                outcomesBlock
                        .add(this.messageReturn(project.getComponentLesson("otherContributions").getLessons()));
            } else

            {
                outcomesBlock.add(this.messageReturn(null));
            }
            document.add(outcomesBlock);
        }
        // **********************************************************************************
        // *************************** Outcome Case Studies *************************************
        // **********************************************************************************
        int counter = 0;
        if (project.isReporting()) {
            document.newPage();
            title = new Paragraph(
                    number + ".4 " + this.getText("summaries.project.reporting.outcome.case.studies"),
                    HEADING3_FONT);
            document.add(title);

            if (project.getCaseStudies().isEmpty()) {
                document.add(
                        new Paragraph(this.getText("summaries.project.reporting.outcome.not.case.studies")));
            } else {
                title = new Paragraph();
                title.add(Chunk.NEWLINE);
                document.add(title);

                for (CasesStudies caseStudy : project.getCaseStudies()) {

                    counter++;
                    table = new PdfPTable(1);
                    table.setLockedWidth(true);
                    table.setTotalWidth(500);

                    // case study
                    cell = new Paragraph(
                            this.getText("summaries.project.reporting.outcome.case.study") + " #" + counter,
                            TABLE_HEADER_FONT);
                    this.addTableHeaderCell(table, cell);
                    // this.addCustomTableCell(table, cell, Element.ALIGN_LEFT, BODY_TEXT_FONT, Color.WHITE,
                    // table.getNumberOfColumns(), 0, false);

                    // Title
                    cell = new Paragraph(this.getText("summaries.project.reporting.outcome.casestudy.title"),
                            TABLE_BODY_BOLD_FONT);
                    cell.setFont(TABLE_BODY_FONT);
                    cell.add(caseStudy.getTitle());
                    this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);

                    // Outcome statement
                    cell = new Paragraph(
                            this.getText("summaries.project.reporting.outcome.casestudy.outcomestatement"),
                            TABLE_BODY_BOLD_FONT);
                    cell.setFont(TABLE_BODY_FONT);
                    cell.add(caseStudy.getOutcomeStatement());
                    this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);

                    // Research outputs
                    cell = new Paragraph(
                            this.getText("summaries.project.reporting.outcome.casestudy.researchoutputs"),
                            TABLE_BODY_BOLD_FONT);
                    cell.setFont(TABLE_BODY_FONT);
                    cell.add(caseStudy.getResearchOutputs());
                    this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);

                    // Research partners
                    cell = new Paragraph(
                            this.getText("summaries.project.reporting.outcome.casestudy.researchPartners"),
                            TABLE_BODY_BOLD_FONT);
                    cell.setFont(TABLE_BODY_FONT);
                    cell.add(caseStudy.getResearchPartners());
                    this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);

                    // activities Contributed
                    cell = new Paragraph(
                            this.getText("summaries.project.reporting.outcome.casestudy.activitiesContributed"),
                            TABLE_BODY_BOLD_FONT);
                    cell.setFont(TABLE_BODY_FONT);
                    cell.add(caseStudy.getActivities());
                    this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);

                    // Non Research Partners
                    cell = new Paragraph(
                            this.getText("summaries.project.reporting.outcome.casestudy.nonResearchPartners"),
                            TABLE_BODY_BOLD_FONT);
                    cell.setFont(TABLE_BODY_FONT);
                    cell.add(caseStudy.getNonResearchPartneres());
                    this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);

                    // Output Users
                    cell = new Paragraph(
                            this.getText("summaries.project.reporting.outcome.casestudy.outputUsers"),
                            TABLE_BODY_BOLD_FONT);
                    cell.setFont(TABLE_BODY_FONT);
                    cell.add(caseStudy.getOutputUsers());
                    this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);

                    // Output Used
                    cell = new Paragraph(
                            this.getText("summaries.project.reporting.outcome.casestudy.outputWasUsed"),
                            TABLE_BODY_BOLD_FONT);
                    cell.setFont(TABLE_BODY_FONT);
                    cell.add(caseStudy.getOutputUsed());
                    this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);

                    // Evidence
                    cell = new Paragraph(
                            this.getText("summaries.project.reporting.outcome.casestudy.evidenceOutcome"),
                            TABLE_BODY_BOLD_FONT);
                    cell.setFont(TABLE_BODY_FONT);
                    cell.add(caseStudy.getEvidenceOutcome());
                    this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);

                    // References
                    cell = new Paragraph(
                            this.getText("summaries.project.reporting.outcome.casestudy.references"),
                            TABLE_BODY_BOLD_FONT);
                    cell.setFont(TABLE_BODY_FONT);
                    cell.add(caseStudy.getReferencesCase());
                    this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);

                    // Outcome indicators
                    cell = new Paragraph(
                            this.getText("summaries.project.reporting.outcome.casestudy.primaryOutcome",
                                    new String[] { String.valueOf(this.midOutcomeYear) }),
                            TABLE_BODY_BOLD_FONT);
                    cell.setFont(TABLE_BODY_FONT);
                    cell.add("\n");
                    for (IPIndicator ipIndicator : caseStudy.getCaseStudyIndicators()) {
                        if (ipIndicator.getOutcome() != null) {
                            cell.add(ipIndicator.getOutcome().getDescription());
                        }
                        cell.add(" " + ipIndicator.getDescription() + "\n");
                    }
                    this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);

                    // Explain link
                    cell = new Paragraph(
                            this.getText("summaries.project.reporting.outcome.casestudy.explainLink"),
                            TABLE_BODY_BOLD_FONT);
                    cell.setFont(TABLE_BODY_FONT);
                    cell.add(caseStudy.getExplainIndicatorRelation());
                    this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);

                    // year
                    cell = new Paragraph(this.getText("summaries.project.reporting.outcome.casestudy.year"),
                            TABLE_BODY_BOLD_FONT);
                    cell.setFont(TABLE_BODY_FONT);
                    cell.add(String.valueOf(caseStudy.getYear()));
                    this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);

                    // upload
                    cell = new Paragraph(this.getText("summaries.project.reporting.outcome.casestudy.upload"),
                            TABLE_BODY_BOLD_FONT);
                    cell.setFont(TABLE_BODY_FONT);
                    if (caseStudy.getFile() == null || caseStudy.getFile().equals("")) {
                        cell.add(this.messageReturn(null));
                    } else {
                        anchor = new Anchor(caseStudy.getFile(), TABLE_BODY_FONT_LINK);
                        anchor.setReference(config.getDownloadURL() + "/projects/" + project.getId()
                                + "/caseStudy/" + caseStudy.getFile());
                        cell.add(anchor);
                    }
                    this.addTableBodyCell(table, cell, Element.ALIGN_LEFT, 1);

                    document.add(table);
                    document.add(new Paragraph(Chunk.NEWLINE));
                }
            }
        }

    } catch (DocumentException e) {
        LOG.error("There was an error trying to add the project focuses to the project summary pdf", e);
    }

}

From source file:org.cgiar.ccafs.ap.summaries.projects.pdf.ProjectSummaryPDF.java

License:Open Source License

/**
 * Entering the project outputs in the summary
 */// w  w  w.j  a  v  a  2 s  .  c  o  m
private void addProjectOutputs(String number) {

    // **********************************************************************************
    // *************************** Overview By Mog *************************************
    // **********************************************************************************
    try {
        Paragraph overview_title = new Paragraph();
        overview_title.setFont(HEADING2_FONT);
        overview_title.add(number + ". " + this.getText("summaries.project.projectOutput"));
        overview_title.add(Chunk.NEWLINE);
        overview_title.add(Chunk.NEWLINE);

        document.newPage();
        document.add(overview_title);

        overview_title = new Paragraph();
        overview_title.setFont(HEADING3_FONT);
        overview_title.add(number + ".1 " + this.getText("summaries.project.overviewbymogs"));
        document.add(overview_title);

    } catch (DocumentException e) {
        LOG.error("There was an error trying to add the project title to the project summary pdf", e);
    }

    int[] years = { midOutcomeYear,
            project.isReporting() ? this.currentReportingYear - 1 : this.currentReportingYear - 1,
            project.isReporting() ? this.currentReportingYear : this.currentPlanningYear,
            project.isReporting() ? this.currentReportingYear + 1 : this.currentReportingYear + 1 };

    Paragraph paragraph = new Paragraph();

    List<IPElement> mogs = project.getOutputs();
    try {
        if (mogs.isEmpty()) {
            paragraph.add(this.getText("summaries.project.empty"));
            document.add(paragraph);

        } else {
            // year
            PdfPTable table;
            for (int a = 0; a < years.length; a++) {
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_HEADER_FONT);
                paragraph.add(this.getText("summaries.project.overviewbymogs.text") + "- " + years[a]);
                table = new PdfPTable(1);
                table.setLockedWidth(true);
                table.setTotalWidth(480);
                this.addTableHeaderCell(table, paragraph);
                // Mog
                for (int b = 0; b < mogs.size(); b++) {
                    this.addOverview(table, mogs.get(b), years[a]);
                }
                paragraph = new Paragraph();
                paragraph.add(Chunk.NEWLINE);
                document.add(paragraph);
                document.add(table);
            }

            // Leason regardins
            paragraph = new Paragraph();
            paragraph.add(Chunk.NEWLINE);
            paragraph.setAlignment(Element.ALIGN_JUSTIFIED);
            paragraph.setFont(BODY_TEXT_BOLD_FONT);
            if (!project.isReporting()) {
                paragraph.add(this.getText("summaries.project.output.lessonRegarding"));
            } else {
                paragraph.add(this.getText("summaries.project.overviewbymogs.reporting.lesson"));
            }
            paragraph.setFont(BODY_TEXT_FONT);
            if (project.getComponentLesson("outputs") != null) {
                paragraph.add(this.messageReturn(project.getComponentLesson("outputs").getLessons()));
            } else {
                paragraph.add(this.messageReturn(null));
            }
            paragraph.add(Chunk.NEWLINE);
            paragraph.add(Chunk.NEWLINE);
            document.add(paragraph);
        }

    } catch (DocumentException e) {
        LOG.error("There was an error trying to add the project title to the project summary pdf", e);
    }

    // **********************************************************************************
    // *************************** Deliverables.****************************************
    // **********************************************************************************

    int counter = 1;
    try {
        document.newPage();
        paragraph = new Paragraph();
        paragraph.setFont(HEADING3_FONT);
        paragraph.add(number + ".2 " + this.getText("summaries.project.deliverable.title"));
        document.add(paragraph);
        paragraph = new Paragraph();

        List<Deliverable> listDeliverables = project.getDeliverables();
        if (listDeliverables.isEmpty()) {
            paragraph.add(this.getText("summaries.project.empty"));
            document.add(paragraph);
        } else {
            paragraph.add(Chunk.NEWLINE);
            document.add(paragraph);
            for (Deliverable deliverable : listDeliverables) {
                if (!project.isReporting()) {
                    if (deliverable.getYear() == config.getPlanningCurrentYear()) {
                        this.addDelivable(deliverable, counter);
                        counter++;

                    }
                }
            }
        }

        // **********************************************************************************
        // *************************** Next users.****************************************
        // **********************************************************************************

        if (project.isReporting()) {

            counter = 1;
            document.newPage();
            paragraph = new Paragraph();
            paragraph.setFont(HEADING3_FONT);
            paragraph.add(number + ".3 " + this.getText("summaries.project.reporting.nextuser.title"));
            document.add(paragraph);

            PdfPTable table;

            if (project.getNextUsers().isEmpty()) {

                paragraph = new Paragraph();
                paragraph.add(this.messageReturn(null));
                paragraph.add(Chunk.NEWLINE);
                document.add(paragraph);

            } else {
                paragraph = new Paragraph();
                paragraph.add(Chunk.NEWLINE);
                document.add(paragraph);

                for (ProjectNextUser projectNextUser : project.getNextUsers()) {

                    paragraph = new Paragraph();
                    paragraph.setFont(TABLE_HEADER_FONT);
                    paragraph.setAlignment(Element.ALIGN_LEFT);

                    table = new PdfPTable(1);
                    table.setLockedWidth(true);
                    table.setTotalWidth(480);

                    paragraph.add(this.getText("summaries.project.reporting.nextuser",
                            new String[] { String.valueOf(counter) }));
                    this.addTableHeaderCell(table, paragraph);

                    // Next users key
                    paragraph = new Paragraph();
                    paragraph.setFont(TABLE_BODY_BOLD_FONT);
                    paragraph.add(this.getText("summaries.project.reporting.nextuser.currentPeriod"));
                    paragraph.setFont(TABLE_BODY_FONT);

                    if (projectNextUser != null) {
                        paragraph.add(this.messageReturn(projectNextUser.getKeyNextUser()));
                    } else {
                        paragraph.add(this.messageReturn(null));
                    }
                    this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1);

                    // Strategies
                    paragraph = new Paragraph();
                    paragraph.setFont(TABLE_BODY_BOLD_FONT);
                    paragraph.add(this.getText("summaries.project.reporting.nextuser.strategies"));
                    paragraph.setFont(TABLE_BODY_FONT);

                    if (projectNextUser != null) {
                        paragraph.add(this.messageReturn(projectNextUser.getStrategies()));
                    } else {
                        paragraph.add(this.messageReturn(null));
                    }
                    this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1);

                    // reported
                    paragraph = new Paragraph();
                    paragraph.setFont(TABLE_BODY_BOLD_FONT);
                    paragraph.add(this.getText("summaries.project.reporting.nextuser.reported"));
                    paragraph.setFont(TABLE_BODY_FONT);

                    if (projectNextUser != null) {
                        paragraph.add(this.messageReturn(projectNextUser.getReportedDeliverables()));
                    } else {
                        paragraph.add(this.messageReturn(null));
                    }
                    this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1);

                    // lessons
                    paragraph = new Paragraph();
                    paragraph.setFont(TABLE_BODY_BOLD_FONT);
                    paragraph.add(this.getText("summaries.project.reporting.nextuser.lessons"));
                    paragraph.setFont(TABLE_BODY_FONT);

                    if (projectNextUser != null) {
                        paragraph.add(this.messageReturn(projectNextUser.getLessonsImplications()));
                    } else {
                        paragraph.add(this.messageReturn(null));
                    }
                    this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1);

                    counter++;
                    document.add(table);
                    paragraph = new Paragraph();
                    paragraph.add(Chunk.NEWLINE);
                    document.add(paragraph);
                }
            }

            // **********************************************************************************
            // *************************** Project HighLights****************************************
            // **********************************************************************************
            counter = 1;
            document.newPage();
            paragraph = new Paragraph();
            paragraph.setFont(HEADING3_FONT);
            paragraph.add(number + ".4 " + this.getText("summaries.project.reporting.highlight.principal"));
            document.add(paragraph);

            paragraph = new Paragraph();
            paragraph.add(Chunk.NEWLINE);
            document.add(paragraph);

            for (ProjectHighligths projectHighLigth : project.getHighlights()) {
                table = new PdfPTable(2);
                table.setLockedWidth(true);
                table.setTotalWidth(480);

                paragraph = new Paragraph();
                paragraph.setFont(TABLE_HEADER_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight",
                        new String[] { String.valueOf(counter) }));
                this.addTableHeaderCellColspan(table, paragraph, 2);

                // title
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.title"));
                paragraph.setFont(TABLE_BODY_FONT);
                if (projectHighLigth != null) {
                    paragraph.add(this.messageReturn(projectHighLigth.getTitle()));
                } else {
                    paragraph.add(this.messageReturn(null));
                }
                this.addTableColSpanCell(table, paragraph, Element.ALIGN_LEFT, 1, 2);

                // author
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.author"));
                paragraph.setFont(TABLE_BODY_FONT);
                if (projectHighLigth != null) {
                    paragraph.add(this.messageReturn(projectHighLigth.getAuthor()));
                } else {
                    paragraph.add(this.messageReturn(null));
                }
                this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1);

                // subject
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.subject"));
                paragraph.setFont(TABLE_BODY_FONT);
                if (projectHighLigth != null) {
                    paragraph.add(this.messageReturn(projectHighLigth.getSubject()));
                } else {
                    paragraph.add(this.messageReturn(null));
                }
                this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1);

                // publisher
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.publisher"));
                paragraph.setFont(TABLE_BODY_FONT);
                if (projectHighLigth != null) {
                    paragraph.add(this.messageReturn(projectHighLigth.getPublisher()));
                } else {
                    paragraph.add(this.messageReturn(null));
                }
                this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1);

                // year
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.year"));
                paragraph.setFont(TABLE_BODY_FONT);
                if (projectHighLigth != null) {
                    paragraph.add(this.messageReturn(String.valueOf(projectHighLigth.getYear())));
                } else {
                    paragraph.add(this.messageReturn(null));
                }
                this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1);

                // project highlight types
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.types"));
                paragraph.setFont(TABLE_BODY_FONT);
                if (projectHighLigth != null) {
                    for (ProjectHighligthsTypes projectHighLigthTypes : projectHighLigth
                            .getProjectHighligthsTypeses()) {
                        paragraph.add(this.messageReturn("\n" + ProjectHighlightsType
                                .getEnum(String.valueOf(projectHighLigthTypes.getIdType())).getDescription()));
                    }
                } else {
                    paragraph.add(this.messageReturn(null));
                }
                this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1);

                // project images
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add("Image");

                if (projectHighLigth != null) {
                    Image global;
                    try {
                        if (projectHighLigth.getPhoto() != null) {
                            String urlImage = config.getDownloadURL() + "/" + this.getHighlightsImagesUrlPath()
                                    + projectHighLigth.getPhoto();
                            urlImage = urlImage.replace(" ", "%20");
                            global = Image.getInstance(urlImage);

                        } else {
                            global = null;
                        }

                        if (global != null) {

                            float documentWidth = document.getPageSize().getWidth() - document.leftMargin()
                                    - document.rightMargin();
                            float documentHeight = document.getPageSize().getHeight() - document.topMargin()
                                    - document.bottomMargin();
                            global.scaleToFit((float) (documentWidth * 0.4), global.getHeight());
                            global.setAlignment(Element.ALIGN_CENTER);

                            this.addTableBodyCell(table, global, Element.ALIGN_LEFT, 1);

                        }

                    } catch (MalformedURLException e) {

                        e.printStackTrace();
                    } catch (IOException e) {
                        e.printStackTrace();

                    }

                } else {
                    paragraph.add(this.messageReturn(null));
                }

                // project start date
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.startDate"));
                paragraph.setFont(TABLE_BODY_FONT);
                if (projectHighLigth != null) {
                    paragraph.add(this.messageReturn(String.valueOf(projectHighLigth.getStartDate())));
                } else {
                    paragraph.add(this.messageReturn(null));
                }
                this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1);

                // project end date
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.endDate"));
                paragraph.setFont(TABLE_BODY_FONT);
                if (projectHighLigth != null) {
                    paragraph.add(this.messageReturn(String.valueOf(projectHighLigth.getEndDate())));
                } else {
                    paragraph.add(this.messageReturn(null));
                }
                this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1);

                // Its Global
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.itsglobal"));
                paragraph.setFont(TABLE_BODY_FONT);
                if (projectHighLigth != null) {
                    if (projectHighLigth.isIsGlobal()) {
                        paragraph.add("Yes");
                    } else {
                        paragraph.add("No");
                    }
                    ;
                } else {
                    paragraph.add(this.messageReturn(null));
                }
                this.addTableColSpanCell(table, paragraph, Element.ALIGN_LEFT, 1, 2);

                // Country
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.country"));
                paragraph.setFont(TABLE_BODY_FONT);
                if (projectHighLigth != null && projectHighLigth.getProjectHighligthsCountries() != null) {
                    for (ProjectHighligthsCountry country : projectHighLigth.getProjectHighligthsCountries()) {
                        paragraph.add(locationManager.getCountry(country.getIdCountry()).getName() + "\n");
                    }
                } else {
                    paragraph.add(this.messageReturn(null));
                }
                this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1);
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.keywords"));
                paragraph.setFont(TABLE_BODY_FONT);
                if (projectHighLigth != null) {
                    paragraph.add(this.messageReturn(projectHighLigth.getKeywords()));
                } else {
                    paragraph.add(this.messageReturn(null));
                }
                this.addTableColSpanCell(table, paragraph, Element.ALIGN_LEFT, 1, 2);

                // description
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.description"));
                paragraph.setFont(TABLE_BODY_FONT);
                if (projectHighLigth != null) {
                    paragraph.add(this.messageReturn(projectHighLigth.getDescription()));
                } else {
                    paragraph.add(this.messageReturn(null));
                }
                this.addTableColSpanCell(table, paragraph, Element.ALIGN_LEFT, 1, 2);

                // Introduction / Objectives
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.introduction"));
                paragraph.setFont(TABLE_BODY_FONT);
                if (projectHighLigth != null) {
                    paragraph.add(this.messageReturn(projectHighLigth.getObjectives()));
                } else {
                    paragraph.add(this.messageReturn(null));
                }
                this.addTableColSpanCell(table, paragraph, Element.ALIGN_LEFT, 1, 2);

                // Results
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.results"));
                paragraph.setFont(TABLE_BODY_FONT);
                if (projectHighLigth != null) {
                    paragraph.add(this.messageReturn(projectHighLigth.getResults()));
                } else {
                    paragraph.add(this.messageReturn(null));
                }
                this.addTableColSpanCell(table, paragraph, Element.ALIGN_LEFT, 1, 2);

                // Partners
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.partners"));
                paragraph.setFont(TABLE_BODY_FONT);
                if (projectHighLigth != null) {
                    paragraph.add(this.messageReturn(projectHighLigth.getPartners()));
                } else {
                    paragraph.add(this.messageReturn(null));
                }
                this.addTableColSpanCell(table, paragraph, Element.ALIGN_LEFT, 1, 2);

                // Links

                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.links"));
                paragraph.setFont(TABLE_BODY_FONT);
                paragraph.add(this.messageReturn(projectHighLigth.getLinks()));

                this.addTableColSpanCell(table, paragraph, Element.ALIGN_LEFT, 1, 2);

                document.add(table);
                document.newPage();
            }

        }
    } catch (DocumentException e) {
        LOG.error("There was an error trying to add the project title to the project summary pdf", e);
    }
}