Example usage for com.lowagie.text Paragraph add

List of usage examples for com.lowagie.text Paragraph add

Introduction

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

Prototype

public boolean add(Object o) 

Source Link

Document

Adds an Object to the Paragraph.

Usage

From source file:org.posterita.businesslogic.performanceanalysis.POSReportManager.java

License:Open Source License

public static String getShipmentPDFReport(Properties ctx, int minoutId, String trxName)
        throws OperationException {
    String docStatus = null;/*from  w w w . jav a  2s  . co  m*/
    String dateOrdered = null;
    String docType = null;
    String orgName = null;
    String orgAddress = null;
    String salesRep = null;
    String phone = "      ";
    String fax = "       ";

    String customerName = null;
    String customerAddress = null;
    String documentNo = null;

    MInOut minout = MinOutManager.loadMInOut(ctx, minoutId, trxName);

    // getting orgInfo
    MOrg org = new MOrg(ctx, minout.getAD_Org_ID(), trxName);
    int location_id = org.getInfo().getC_Location_ID();
    MLocation location = new MLocation(ctx, location_id, trxName);
    MBPartner orgPartner = new MBPartner(ctx, org.getLinkedC_BPartner_ID(trxName), trxName);
    MBPartnerLocation meLocation[] = MBPartnerLocation.getForBPartner(ctx, orgPartner.get_ID());

    if (meLocation.length != 1)
        throw new OperationException("Should have only 1 location for organisation business partner!!");

    MBPartnerLocation orgLocation = meLocation[0];

    if (orgLocation.getPhone() != null)
        phone = orgLocation.getPhone();

    if (orgLocation.getFax() != null)
        fax = orgLocation.getFax();
    ;

    orgName = org.getName();

    String address1 = (location.getAddress1() == null) ? " " : location.getAddress1();
    String address2 = (location.getAddress2() == null) ? " " : location.getAddress2();
    orgAddress = (address1 + " " + address2).trim();

    // getting order type
    MDocType doctype = MDocType.get(ctx, minout.getC_DocType_ID());
    docType = doctype.getName();

    // getting orderInfo
    docStatus = minout.getDocStatusName();
    documentNo = minout.getDocumentNo();

    Date d = new Date(minout.getCreated().getTime());
    SimpleDateFormat s = new SimpleDateFormat(TimestampConvertor.DEFAULT_DATE_PATTERN1);
    dateOrdered = s.format(d);

    // getting salesrep
    int saleRep_id = minout.getSalesRep_ID();
    MUser user = new MUser(ctx, saleRep_id, trxName);
    salesRep = user.getName();

    // getting customer info
    int bpartner_id = minout.getC_BPartner_ID();
    BPartnerBean bean = BPartnerManager.getBpartner(ctx, bpartner_id, trxName);

    String name1 = (bean.getPartnerName() == null) ? " " : bean.getPartnerName();
    String name2 = (bean.getName2() == null) ? " " : bean.getName2();
    customerName = (name1 + " " + name2).trim();

    address1 = (bean.getAddress1() == null) ? " " : bean.getAddress1();
    address2 = (bean.getAddress2() == null) ? " " : bean.getAddress2();
    customerAddress = (address1 + " " + address2).trim();

    ArrayList<WebMinOutLineBean> orderLineList = MinOutManager.getWebMinOutLines(ctx, minout);

    // ----------------------------------- generating pdf
    // --------------------------------------
    String reportName = RandomStringGenerator.randomstring() + ".pdf";
    String reportPath = ReportManager.getReportPath(reportName);

    Font titleFont = new Font(Font.TIMES_ROMAN, 18, Font.BOLD);
    Font subtitleFont = new Font(Font.TIMES_ROMAN, 14, Font.BOLD);

    Font headerFont = new Font(Font.TIMES_ROMAN, 11, Font.BOLD);
    Font simpleFont = new Font(Font.TIMES_ROMAN, 10);

    float cellBorderWidth = 0.0f;

    // step 1: creation of a document-object
    Document document = new Document(PageSize.A4, 30, 30, 20, 40);// l,r,t,b
    // document.getPageSize().set;

    System.out.println(document.leftMargin());

    try {
        // step 2:
        // we create a writer that listens to the document
        // and directs a PDF-stream to a file
        PdfWriter.getInstance(document, new FileOutputStream(reportPath));

        // step 3: we open the document
        document.open();
        // step 4: we add a paragraph to the document

        Image logo = null;

        // TODO: make this part dynamic <------------------------------
        // IMPORTANT !!!!!!!!!!!!!!!!!!!!!!!!!!!
        String imageURI = PathInfo.PROJECT_HOME + "images/pos/openBLUE_POS_Logo.gif";
        logo = Image.getInstance(imageURI);

        // MAttachment attachment = new
        // MAttachment(ctx,MOrg.Table_ID,org.getID(),null);
        // logo = Image.getInstance(attachment.getEntries()[0].getData());

        try {
            byte logoData[] = OrganisationManager.getLogo(ctx, null);
            logo = Image.getInstance(logoData);
        } catch (LogoException ex) {
            logo = Image.getInstance(imageURI);
        }

        logo.setAbsolutePosition(document.left(), document.top() - logo.getHeight());
        document.add(logo);

        PdfPTable table = new PdfPTable(2);
        PdfPCell cell = null;

        //
        table.getDefaultCell().setPadding(5.0f);
        table.setWidthPercentage(100.0f);

        // header cell
        Paragraph title = new Paragraph();
        title.add(new Chunk(orgName, subtitleFont));
        title.add(new Chunk("\n"));
        title.add(new Chunk(orgAddress, subtitleFont));
        title.add(new Chunk("\n"));
        title.add(new Chunk("Phone: " + phone, subtitleFont));
        title.add(new Chunk("\n"));
        title.add(new Chunk("Fax: " + fax, subtitleFont));

        // cell = new PdfPCell(new Paragraph(new
        // Chunk("Title1",titleFont)));
        cell = new PdfPCell(title);

        cell.setColspan(2);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        cell.setFixedHeight(logo.getHeight());
        cell.setBorderWidth(cellBorderWidth);
        table.addCell(cell);

        cell = new PdfPCell(new Paragraph(""));
        cell.setBorderWidth(cellBorderWidth);
        cell.setFixedHeight(10);
        cell.setColspan(2);
        table.addCell(cell);

        // doc type
        cell = new PdfPCell(new Paragraph(new Chunk(docType, titleFont)));

        cell.setColspan(2);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        cell.setBorderWidth(cellBorderWidth);
        table.addCell(cell);

        // spacing
        cell = new PdfPCell(new Paragraph(""));
        cell.setBorderWidth(cellBorderWidth);
        cell.setFixedHeight(10);
        cell.setColspan(2);
        table.addCell(cell);

        // row 1
        cell = new PdfPCell(new Paragraph(new Chunk(customerName, headerFont)));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        cell.setBorderWidth(cellBorderWidth);
        table.addCell(cell);

        cell = new PdfPCell(new Paragraph(new Chunk("Sales Rep: " + salesRep, headerFont)));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        cell.setBorderWidth(cellBorderWidth);
        table.addCell(cell);

        // row 2
        cell = new PdfPCell(new Paragraph(new Chunk(customerAddress, headerFont)));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        cell.setBorderWidth(cellBorderWidth);
        table.addCell(cell);

        // spacing
        cell = new PdfPCell(new Paragraph(""));
        cell.setBorderWidth(cellBorderWidth);
        cell.setFixedHeight(10);
        cell.setColspan(2);
        table.addCell(cell);

        // row 3
        cell = new PdfPCell(new Paragraph(new Chunk("No: " + documentNo, headerFont)));
        cell.setColspan(2);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        cell.setBorderWidth(cellBorderWidth);
        table.addCell(cell);

        // row 4
        cell = new PdfPCell(new Paragraph(new Chunk("Doc Status: " + docStatus, headerFont)));
        cell.setColspan(2);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        cell.setBorderWidth(cellBorderWidth);
        table.addCell(cell);

        /*
         * //row 5 cell = new PdfPCell(new Paragraph(new Chunk("Payment By:
         * "+paymentBy,headerFont))); cell.setColspan(2);
         * cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
         * cell.setBorderWidth(cellBorderWidth); table.addCell(cell);
         */

        // row 6
        cell = new PdfPCell(new Paragraph(new Chunk("Date: " + dateOrdered, headerFont)));
        cell.setColspan(2);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        cell.setBorderWidth(cellBorderWidth);
        table.addCell(cell);

        // spacing
        cell = new PdfPCell(new Paragraph(""));
        cell.setColspan(2);
        cell.setFixedHeight(10);
        cell.setBorderWidth(cellBorderWidth);
        table.addCell(cell);

        // spacing
        cell = new PdfPCell(new Paragraph(""));
        cell.setColspan(2);
        cell.setFixedHeight(10);
        cell.setBorderWidth(cellBorderWidth);
        table.addCell(cell);

        // ------------------------------------------------------
        cell = new PdfPCell();
        cell.setColspan(2);
        cell.setBorderWidth(cellBorderWidth);

        PdfPTable t = new PdfPTable(3);
        t.getDefaultCell().setPadding(3.0f);
        t.setWidthPercentage(100.0f);

        int[] widths = { 1, 10, 1 };
        t.setWidths(widths);

        // setting headers
        t.addCell(new Paragraph(new Chunk("SerNo", headerFont)));
        t.addCell(new Paragraph(new Chunk("Name", headerFont)));
        t.addCell(new Paragraph(new Chunk("Qty", headerFont)));

        // setting table data
        // --------------------------------writing table
        // data------------------------------
        int serNo = 0;

        BigDecimal qty = null;

        for (WebMinOutLineBean orderlineBean : orderLineList) {
            serNo++;
            qty = orderlineBean.getQtyOrdered();

            t.addCell(new Paragraph(new Chunk(serNo + "", simpleFont)));
            t.addCell(new Paragraph(new Chunk(orderlineBean.getProductName(), simpleFont)));
            t.addCell(new Paragraph(new Chunk(qty.intValue() + "", simpleFont)));
        }
        // -----------------------------------------------------------------------------------

        // table.addCell(cell);
        table.setSplitRows(true);

        document.add(table);
        document.add(t);

    } catch (Exception e) {
        throw new OperationException(e);
    }

    // step 5: we close the document
    document.close();

    return reportName;
}

From source file:org.posterita.core.PDFReportGenerator.java

License:Open Source License

public String getPDFReport(Properties ctx, ArrayList dataSource) throws OperationException {
    String filename = RandomStringGenerator.randomstring() + ".pdf";
    String dir = UDIFilePropertiesManager.getProperty().get(ctx, PropertiesConstant.UDI_HOME)
            + "/config/reports/pdf/";
    String filepath = dir + filename;

    //Generatting report

    //Initialising the datasource
    this.dataSource = dataSource;

    if (dataSource == null)
        throw new OperationException("Cannot generate report! Cause: empty datasource");

    Rectangle dimension = getDocumentDimension();
    Document document = new Document(dimension, MARGIN, MARGIN, MARGIN, MARGIN);

    try {/*from  w w w  .  jav  a 2 s . c  o m*/
        writer = PdfWriter.getInstance(document, new FileOutputStream(filepath));
        writer.setPageEvent(new PDFReportPageEventHelper());

        document.open();

        //Add the title part
        Paragraph title = new Paragraph();
        Paragraph subTitle = new Paragraph();

        if (reportTitle != null) {
            title.add(new Chunk(reportTitle, TITLE_FONT));
            title.setAlignment(Element.ALIGN_CENTER);
            document.add(title);
        }

        if (reportSubTitle != null) {
            subTitle.add(new Chunk(reportSubTitle, SUBTITLE_FONT));
            subTitle.setAlignment(Element.ALIGN_CENTER);
            document.add(subTitle);
        }

        if ((reportSubTitle != null) || (reportTitle != null)) {
            document.add(new Paragraph(" "));
        }

        writeDocument(document);

        document.close();
        writer.close();

        return "config/report/pdf/" + filename;
    } catch (Exception e) {
        throw new OperationException(e);
    }

}

From source file:org.primefaces.component.export.PDFExporter.java

License:Open Source License

protected void addEmptyLine(Paragraph paragraph, int number) {
    for (int i = 0; i < number; i++) {
        paragraph.add(new Paragraph(" "));
    }//from   w ww  .  j  a  va 2s .  co  m
}

From source file:org.pz.platypus.plugin.pdf.commands.PdfCodeOff.java

License:Open Source License

public int process(final IOutputContext context, final Token tok, final int tokNum) {
    if (context == null || tok == null) {
        throw new IllegalArgumentException();
    }/*  w w  w  .  j  a v  a  2s .com*/

    PdfData pdd = (PdfData) context;
    if (!pdd.inCodeSection()) {
        return 0; //not currently in a code section
    }

    int addlTokensToSkip = 0;
    TokenList tokens = pdd.getGdd().getInputTokens();

    // must output the paragraph manually for listing, because the [-code] command after a
    // listing implies an end of a paragraph and adds a CR/LF to the listing.
    if (pdd.isInCodeListing()) {
        pdd.setInCodeListing(false);
        PdfOutfile outfile = pdd.getOutfile();
        if (outfile != null) {
            Paragraph para = outfile.getItPara();
            if (para != null && para.size() > 0) {
                if (nextTokenIsEol(tokens, tokNum) && !justBeforeEndOfParagraph(tokens, tokNum)) {
                    para.add(new Chunk(Chunk.NEWLINE));
                    addlTokensToSkip += 1;
                }
                //                    outfile.addParagraph( para, outfile.getItColumn() );
                //                    outfile.setItPara( new Paragraph( pdd.getLeading() ));
            }
        }
    }

    PdfRestoreFormat.restore(pdd, tok.getSource());
    pdd.setInCodeSection(false, tok.getSource());
    return (addlTokensToSkip);
}

From source file:org.pz.platypus.plugin.pdf.commands.PdfCodeWithOptions.java

License:Open Source License

/**
 * Emits a CR or CR/LF to the PDF outfile.
 * @param outfile to which newLine is written
 *//* w w  w.  j  av  a 2  s  . com*/
private void emitNewLine(final PdfOutfile outfile) {
    Paragraph para = outfile.getItPara();
    para.add(new Chunk(Chunk.NEWLINE));
}

From source file:org.pz.platypus.plugin.pdf.commands.PdfEol.java

License:Open Source License

public int process(final IOutputContext context, final Token tok, final int tokNum) {
    if (context == null) {
        throw new IllegalArgumentException();
    }/*from  w ww. ja v a  2s .c o m*/

    PdfData pdf = (PdfData) context;
    PdfOutfile outfile = pdf.getOutfile();
    TokenList tl = pdf.getGdd().getInputTokens();
    Token nextTok = tl.getNextToken(tokNum);

    // if we're at the last input token, then do nothing
    if (nextTok == null) {
        return 0;
    }

    // if the [cr] occurs at the end of a line that consisted entirely of commands,
    // then ignore it (so that the following text does not have an unwanted leading character).
    // so with a line consisting entirely of [fsize:12pt] simply changes font size, but
    // adds no character to the ouput stream
    if (!tl.lineSoFarEmitsText(tokNum)) {
        return 0;
    }

    // if EolTreatment = hard, issue CR/LF
    if (!new EolTreatment().isSoft(pdf.getEolTreatment())) {
        Paragraph para = outfile.getItPara();
        if (para != null) {
            para.add(new Chunk(Chunk.NEWLINE));
        }
        return 0;
    }

    outfile.emitText(" ");
    return 0;
}

From source file:org.pz.platypus.plugin.pdf.commands.PdfEoParagraph.java

License:Open Source License

public int process(final IOutputContext context, final Token tok, final int tokNum) {
    if (context == null) {
        throw new IllegalArgumentException();
    }//from w  ww .  j av a 2  s. c  o m

    PdfData pdf = (PdfData) context;

    // if we're in an paragraph with content, then close it and start a new one.
    // If we're not, it's likely because someone has inserted multiple blank lines,
    // so we just skip a line.
    Paragraph currPar = pdf.getOutfile().getItPara();
    //        if( currPar == null || ! currPar.isEmpty() ) {
    if (currPar == null || currPar.size() > 0) {
        pdf.getOutfile().startNewParagraph();
    } else {
        currPar.add(new Chunk(Chunk.NEWLINE));
    }
    return 0;

}

From source file:org.pz.platypus.plugin.pdf.commands.PdfHardCR.java

License:Open Source License

public int process(final IOutputContext context, final Token tok, final int tokNum) {
    if (context == null || tok == null) {
        throw new IllegalArgumentException();
    }/*from  ww w  .  j  av  a  2 s. c o m*/

    PdfData pdd = (PdfData) context;
    PdfOutfile outfile = pdd.getOutfile();
    if (outfile == null) {
        return (0); //TODO: Error message, though effectively an impossible error.
    }

    // a [] marks the end of a bullet entry. If the entry is a paragraph, (almost always the case)
    // then add it to the current list and return.
    Paragraph currPar = pdd.getOutfile().getItPara();
    if (outfile.inABulletList()) {
        if (currPar != null && !currPar.isEmpty()) {
            outfile.addParagraphToList(currPar);
            return (0);
        }
    }

    currPar.add(new Chunk(Chunk.NEWLINE));

    // if it's the first token in line, it = a blank line, so an additional
    // NEWLINE needs to be emitted, unless it's right after an end of listing command,
    // which has already emitted the extra CR/LF.

    if (isFirstTokenInLine(context, tok, tokNum) && !isAfterCodeListing(context, tokNum) && currPar != null) {
        currPar.add(new Chunk(Chunk.NEWLINE));
    }
    return 0;
}

From source file:org.pz.platypus.plugin.pdf.PdfOutfile.java

License:Open Source License

/**
 * Implement the line spacing before the paragraph, if any.
 *
 * Note: We do this manually rather than call Paragraph.setSpacingBefore() in iText
 * because setSpacingBefore() in iText affects the current paragraph. So is [paraskip=0]
 * occurs midway in a paragraph, that pargraph will have 0 spacing before it, rather than
 * the previous paraskip value, which was in effect when the paragraph was started. 2009-01-31
 *
 * @param para the paragraph to align// w  ww  .  j av a  2 s . c o  m
 * @param pData the PdfData container holding the current settings of the PDF output
 */
void doParagraphSpaceBefore(final Paragraph para, final PdfData pData) {
    float skipLines = pData.getParagraphSkip();

    // add 1, as you need 2 NEWLINES for the first line's skip.
    skipLines++;
    while (skipLines-- > 0) {
        para.add(new Chunk(Chunk.NEWLINE));
    }
}

From source file:org.revager.export.ProtocolPDFExporter.java

License:Open Source License

/**
 * Write the title page of the protocol.
 * /*from w w  w.  ja v a2  s  .c  om*/
 * @param meetings
 *            the meetings
 * @param attachProdExtRefs
 *            true, if the external reference of the product should be part
 *            of the protocol
 * 
 * @throws ExportException
 *             If an error occurs while writing the title page
 */
protected void writeTitlePage(List<Meeting> meetings, boolean attachProdExtRefs) throws ExportException {
    try {
        Font plainFont = new Font(BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED),
                10);

        Font plainFontSmall = new Font(
                BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED), 8);

        Font boldFont = new Font(
                BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, BaseFont.EMBEDDED), 11);

        Font italicFont = new Font(
                BaseFont.createFont(BaseFont.HELVETICA_OBLIQUE, BaseFont.CP1252, BaseFont.EMBEDDED), 10);

        Font italicFontSmall = new Font(
                BaseFont.createFont(BaseFont.HELVETICA_OBLIQUE, BaseFont.CP1252, BaseFont.EMBEDDED), 8);

        Font boldItalicFont = new Font(
                BaseFont.createFont(BaseFont.HELVETICA_BOLDOBLIQUE, BaseFont.CP1252, BaseFont.EMBEDDED), 11);

        Font boldItalicFontSmall = new Font(
                BaseFont.createFont(BaseFont.HELVETICA_BOLDOBLIQUE, BaseFont.CP1252, BaseFont.EMBEDDED), 8);

        Font protocolFontTitle = new Font(
                BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, BaseFont.EMBEDDED), 20);

        Font reviewFontTitle = new Font(
                BaseFont.createFont(BaseFont.HELVETICA_OBLIQUE, BaseFont.CP1252, BaseFont.EMBEDDED), 15);

        Font meetingFontTitle = new Font(
                BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED), 13);

        /*
         * Title of the protocol
         */
        PdfPTable tableTitlePage = new PdfPTable(new float[] { 0.6f, 0.4f });
        tableTitlePage.setWidthPercentage(100);
        tableTitlePage.setSplitRows(false);
        tableTitlePage.getDefaultCell().setBorder(0);
        tableTitlePage.getDefaultCell().setPadding(0);

        String protocolTitle = translate("Findings List of the Review");

        if (meetings.size() == 1) {
            protocolTitle = translate("Findings List of the Review Meeting");
        }

        PdfPCell cellProtocol = new PdfPCell(new Phrase(protocolTitle, protocolFontTitle));
        cellProtocol.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellProtocol.setColspan(2);
        cellProtocol.setBorderWidth(0);
        cellProtocol.setPaddingTop(PDFTools.cmToPt(0.4f));
        cellProtocol.setPaddingBottom(PDFTools.cmToPt(0.2f));

        tableTitlePage.addCell(cellProtocol);

        /*
         * Name of the review
         */
        PdfPCell cellRevName = new PdfPCell(
                new Phrase(Application.getInstance().getReviewMgmt().getReviewName(), reviewFontTitle));
        cellRevName.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellRevName.setColspan(2);
        cellRevName.setBorderWidth(0);
        cellRevName.setPaddingBottom(PDFTools.cmToPt(1.6f));

        tableTitlePage.addCell(cellRevName);

        /*
         * Review meeting date and location
         */
        if (meetings.size() == 1) {
            sdfDate.setTimeZone(meetings.get(0).getProtocol().getDate().getTimeZone());
            sdfTime.setTimeZone(meetings.get(0).getProtocol().getDate().getTimeZone());

            String meetingDate = sdfDate.format(meetings.get(0).getProtocol().getDate().getTime());

            String meetingTime = sdfTime.format(meetings.get(0).getProtocol().getStart().getTime()) + " - "
                    + sdfTime.format(meetings.get(0).getProtocol().getEnd().getTime()) + " ["
                    + meetings.get(0).getProtocol().getEnd().getTimeZone().getDisplayName() + "]";

            Phrase phraseMeeting = new Phrase(meetingDate + " (" + meetingTime + ")", meetingFontTitle);

            PdfPCell cellMeeting = new PdfPCell(phraseMeeting);
            cellMeeting.setColspan(2);
            cellMeeting.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellMeeting.setPadding(0);
            cellMeeting.setBorderWidth(0);

            tableTitlePage.addCell(cellMeeting);

            String location = meetings.get(0).getProtocol().getLocation();

            if (location.trim().equals("")) {
                location = "--";
            }
            cellMeeting = new PdfPCell(new Phrase(translate("Location") + ": " + location, meetingFontTitle));
            cellMeeting.setColspan(2);
            cellMeeting.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellMeeting.setPadding(0);
            cellMeeting.setBorderWidth(0);
            cellMeeting.setPaddingTop(PDFTools.cmToPt(0.15f));
            cellMeeting.setPaddingBottom(PDFTools.cmToPt(1.9f));

            tableTitlePage.addCell(cellMeeting);
        }

        /*
         * Review description and comments
         */
        PdfPCell cellRevDesc = new PdfPCell(new Phrase(translate("Review Description:"), boldItalicFont));
        cellRevDesc.setBorderWidth(0);
        cellRevDesc.setPadding(padding);

        tableTitlePage.addCell(cellRevDesc);

        cellRevDesc = new PdfPCell(new Phrase(translate("Review Comments"), boldFont));
        cellRevDesc.setBorderWidth(0);
        cellRevDesc.setPadding(padding);
        cellRevDesc.setBackgroundColor(cellBackground);

        tableTitlePage.addCell(cellRevDesc);

        String revDesc = Application.getInstance().getReviewMgmt().getReviewDescription();
        if (revDesc.trim().equals("")) {
            revDesc = "--";
        }

        Phrase phrDesc = new Phrase(revDesc, plainFont);
        phrDesc.setLeading(leading);
        cellRevDesc = new PdfPCell();
        cellRevDesc.addElement(phrDesc);
        cellRevDesc.setBorderWidth(0);
        cellRevDesc.setPadding(padding);
        cellRevDesc.setPaddingBottom(padding * 1.8f);

        tableTitlePage.addCell(cellRevDesc);

        String revComm = Application.getInstance().getReviewMgmt().getReviewComments();
        if (revComm.trim().equals("")) {
            revComm = "--";
        }

        Phrase phrComm = new Phrase(revComm, italicFont);
        phrComm.setLeading(leading);
        cellRevDesc = new PdfPCell();
        cellRevDesc.addElement(phrComm);
        cellRevDesc.setBorderWidth(0);
        cellRevDesc.setPadding(padding);
        cellRevDesc.setPaddingBottom(padding * 1.8f);
        cellRevDesc.setBackgroundColor(cellBackground);

        tableTitlePage.addCell(cellRevDesc);

        tableTitlePage.addCell(createVerticalStrut(PDFTools.cmToPt(1.0f), 2));

        /*
         * Product title
         */
        PdfPTable tableProduct = new PdfPTable(new float[] { 0.07f, 0.93f });
        tableProduct.setWidthPercentage(100);
        tableProduct.setSplitRows(false);
        tableProduct.getDefaultCell().setBorderWidth(0);
        tableProduct.getDefaultCell().setPadding(0);

        PdfPCell cellProdTitle = new PdfPCell(new Phrase(translate("Reviewed Product:"), boldItalicFont));
        cellProdTitle.setColspan(2);
        cellProdTitle.setPadding(padding);
        cellProdTitle.setBorder(0);

        tableProduct.addCell(cellProdTitle);

        /*
         * List point used for lists
         */
        Phrase phraseListPoint = new Phrase("", boldFont);
        phraseListPoint.setLeading(leading);

        PdfPCell cellListPoint = new PdfPCell();
        cellListPoint.addElement(phraseListPoint);
        cellListPoint.setBorderWidth(0);
        cellListPoint.setPadding(padding);
        cellListPoint.setPaddingLeft(padding * 2);
        cellListPoint.setPaddingBottom(0);

        /*
         * Write name and version of the reviewed product
         */
        String prodName = Data.getInstance().getResiData().getReview().getProduct().getName();

        if (prodName.trim().equals("")) {
            prodName = "--";
        }

        Phrase phrName = new Phrase(translate("Product Name") + ": " + prodName, plainFont);
        phrName.setLeading(leading);

        PdfPCell cellName = new PdfPCell();
        cellName.addElement(phrName);
        cellName.setBorderWidth(0);
        cellName.setPadding(padding);
        cellName.setPaddingBottom(0);

        tableProduct.addCell(cellListPoint);

        tableProduct.addCell(cellName);

        String prodVersion = Data.getInstance().getResiData().getReview().getProduct().getVersion();

        if (prodVersion.trim().equals("")) {
            prodVersion = "--";
        }

        Phrase phrVersion = new Phrase(translate("Product Version") + ": " + prodVersion, plainFont);
        phrVersion.setLeading(leading);

        PdfPCell cellVersion = new PdfPCell();
        cellVersion.addElement(phrVersion);
        cellVersion.setBorderWidth(0);
        cellVersion.setPadding(padding);
        cellVersion.setPaddingBottom(0);

        tableProduct.addCell(cellListPoint);

        tableProduct.addCell(cellVersion);

        if (Application.getInstance().getReviewMgmt().getNumberOfProdRefs() > 0) {
            /*
             * Table of product references
             */
            PdfPCell cellRefTitle = new PdfPCell(new Phrase(translate("Product References:"), boldItalicFont));
            cellRefTitle.setBorderWidth(0);
            cellRefTitle.setPadding(padding);
            cellRefTitle.setPaddingTop(padding * 4);
            cellRefTitle.setColspan(2);

            tableProduct.addCell(cellRefTitle);

            /*
             * Textual references
             */
            for (String ref : Application.getInstance().getReviewMgmt().getProductReferences()) {
                Phrase phraseRef = new Phrase(ref, plainFont);
                phraseRef.setLeading(leading);

                PdfPCell cellRef = new PdfPCell();
                cellRef.addElement(phraseRef);
                cellRef.setBorderWidth(0);
                cellRef.setPadding(padding);
                cellRef.setPaddingBottom(0);

                tableProduct.addCell(cellListPoint);

                tableProduct.addCell(cellRef);
            }

            /*
             * External file references
             */
            for (File ref : Application.getInstance().getReviewMgmt().getExtProdReferences()) {
                Phrase phraseRef = new Phrase();
                phraseRef.add(new Chunk(ref.getName(), plainFont));
                phraseRef.add(new Chunk(" (" + translate("File Attachment") + ")", italicFont));
                phraseRef.setFont(plainFont);
                phraseRef.setLeading(leading);

                PdfPCell cellRef = new PdfPCell();
                cellRef.addElement(phraseRef);
                cellRef.setBorderWidth(0);
                cellRef.setPadding(padding);
                cellRef.setPaddingBottom(0);

                tableProduct.addCell(cellListPoint);

                if (attachProdExtRefs) {
                    cellRef.setCellEvent(new PDFCellEventExtRef(pdfWriter, ref));
                }

                tableProduct.addCell(cellRef);
            }
        }

        /*
         * Add the product table to the base table
         */
        PdfPCell cellProduct = new PdfPCell(tableProduct);
        cellProduct.setBorder(0);
        cellProduct.setPadding(0);

        tableTitlePage.addCell(cellProduct);

        /*
         * List the meetings of this review
         */
        PdfPCell cellInfos = new PdfPCell();
        cellInfos.setBorder(0);
        cellInfos.setPadding(0);

        /*
         * meeting list title or meeting info title
         */
        PdfPTable tableInfos = new PdfPTable(new float[] { 0.09f, 0.91f });
        tableInfos.setWidthPercentage(100);
        tableInfos.setSplitRows(false);
        tableInfos.getDefaultCell().setBorderWidth(0);
        tableInfos.getDefaultCell().setPadding(0);

        String title = translate("Meeting Information:");

        if (meetings.size() > 1) {
            title = translate("Findings Lists of the Review Meetings:");
        }

        PdfPCell cellInfosTitle = new PdfPCell(new Phrase(title, boldFont));
        cellInfosTitle.setColspan(2);
        cellInfosTitle.setPadding(padding);
        cellInfosTitle.setBorder(0);

        tableInfos.addCell(cellInfosTitle);

        if (meetings.size() > 1) {
            /*
             * list the meetings of this review (for review protocols)
             */
            for (Meeting m : meetings) {
                Protocol protocol = m.getProtocol();
                if (protocol != null) {
                    String meetingDate = sdfDate.format(protocol.getDate().getTime());

                    String meetingTime = sdfTime.format(protocol.getStart().getTime()) + " - "
                            + sdfTime.format(protocol.getEnd().getTime()) + " ["
                            + protocol.getEnd().getTimeZone().getDisplayName() + "]";
                    String protLoc = protocol.getLocation();
                    if (protLoc.trim().equals("")) {
                        protLoc = "--";
                    }

                    Phrase phraseMeet = new Phrase(
                            translate("Date") + ": " + meetingDate + "\n" + translate("Time") + ": "
                                    + meetingTime + "\n" + translate("Location") + ": " + protLoc,
                            italicFont);

                    Paragraph paraMeet = new Paragraph();
                    paraMeet.setLeading(leading);

                    Anchor anchor = new Anchor(phraseMeet);
                    anchor.setReference("#" + Long.toString(
                            protocol.getDate().getTimeInMillis() + protocol.getStart().getTimeInMillis()));

                    paraMeet.add(anchor);

                    PdfPCell cellMeet = new PdfPCell();
                    cellMeet.addElement(paraMeet);
                    cellMeet.setBorderWidth(0);
                    cellMeet.setPadding(padding);

                    tableInfos.addCell(cellListPoint);

                    tableInfos.addCell(cellMeet);
                }
            }
        } else {
            Protocol prot = meetings.get(0).getProtocol();
            Duration meetDur = DatatypeFactory.newInstance()
                    .newDuration(prot.getEnd().getTimeInMillis() - prot.getStart().getTimeInMillis());

            Phrase phraseMeetInfo = new Phrase(
                    translate("Duration of the meeting") + ":\n" + meetDur.getHours() + " "
                            + translate("Hour(s)") + ", " + meetDur.getMinutes() + " " + translate("Minute(s)"),
                    italicFont);
            phraseMeetInfo.setLeading(leading);

            PdfPCell cellMeetInfo = new PdfPCell();
            cellMeetInfo.addElement(phraseMeetInfo);
            cellMeetInfo.setBorderWidth(0);
            cellMeetInfo.setPadding(padding);

            tableInfos.addCell(cellListPoint);

            tableInfos.addCell(cellMeetInfo);

            /*
             * meeting number of findings
             */
            phraseMeetInfo = new Phrase(translate("Number of findings") + ": " + prot.getFindings().size(),
                    italicFont);
            phraseMeetInfo.setLeading(leading);

            cellMeetInfo = new PdfPCell();
            cellMeetInfo.addElement(phraseMeetInfo);
            cellMeetInfo.setBorderWidth(0);
            cellMeetInfo.setPadding(padding);

            tableInfos.addCell(cellListPoint);

            tableInfos.addCell(cellMeetInfo);

            /*
             * meeting number of attendees
             */
            phraseMeetInfo = new Phrase(
                    translate("Number of attendees") + ": " + protMgmt.getAttendees(prot).size(), italicFont);
            phraseMeetInfo.setLeading(leading);

            cellMeetInfo = new PdfPCell();
            cellMeetInfo.addElement(phraseMeetInfo);
            cellMeetInfo.setBorderWidth(0);
            cellMeetInfo.setPadding(padding);

            tableInfos.addCell(cellListPoint);

            tableInfos.addCell(cellMeetInfo);
        }

        cellInfos.addElement(tableInfos);
        cellInfos.setBackgroundColor(cellBackground);
        cellInfos.setPaddingBottom(padding);

        tableTitlePage.addCell(cellInfos);

        /*
         * Insert vertical strut
         */
        tableTitlePage.addCell(createVerticalStrut(PDFTools.cmToPt(1.0f), 2));

        /*
         * Write general impression and recommendation
         */
        PdfPTable tableRevInfo = new PdfPTable(new float[] { 0.5f, 0.5f });
        tableRevInfo.setWidthPercentage(100);
        tableRevInfo.setSplitRows(false);
        tableRevInfo.getDefaultCell().setBorderWidth(0);
        tableRevInfo.getDefaultCell().setPadding(0);

        /*
         * Insert vertical strut
         */
        tableRevInfo.addCell(createVerticalStrut(PDFTools.cmToPt(0.5f), 2));

        PdfPCell cellImpr = new PdfPCell(
                new Phrase(translate("General impressions of the product:"), boldFont));
        cellImpr.setBorderWidth(0);
        cellImpr.setPadding(padding);
        cellImpr.setBorderColor(verticalBorderColor);
        cellImpr.setBorderWidthLeft(verticalBorderWidth);

        tableRevInfo.addCell(cellImpr);

        PdfPCell cellReco = new PdfPCell(
                new Phrase(translate("Final recommendation for the product:"), boldFont));
        cellReco.setBorderWidth(0);
        cellReco.setPadding(padding);
        cellReco.setBorderColor(verticalBorderColor);
        cellReco.setBorderWidthLeft(verticalBorderWidth);

        tableRevInfo.addCell(cellReco);

        String impression = Application.getInstance().getReviewMgmt().getImpression();
        if (impression.trim().equals("")) {
            impression = "--";
        }

        Phrase phrImpr = new Phrase(impression, italicFont);
        phrImpr.setLeading(leading);
        cellImpr = new PdfPCell();
        cellImpr.addElement(phrImpr);
        cellImpr.setBorderWidth(0);
        cellImpr.setPadding(padding);
        cellImpr.setPaddingBottom(padding * 1.8f);
        cellImpr.setBorderColor(verticalBorderColor);
        cellImpr.setBorderWidthLeft(verticalBorderWidth);

        tableRevInfo.addCell(cellImpr);

        String recommendation = Application.getInstance().getReviewMgmt().getRecommendation();
        if (recommendation.trim().equals("")) {
            recommendation = "--";
        }

        Phrase phrReco = new Phrase(recommendation, italicFont);
        phrReco.setLeading(leading);
        cellReco = new PdfPCell();
        cellReco.addElement(phrReco);
        cellReco.setBorderWidth(0);
        cellReco.setPadding(padding);
        cellReco.setPaddingBottom(padding * 1.8f);
        cellReco.setBorderColor(verticalBorderColor);
        cellReco.setBorderWidthLeft(verticalBorderWidth);

        tableRevInfo.addCell(cellReco);

        /*
         * Add vertical strut
         */
        tableRevInfo.addCell(createVerticalStrut(PDFTools.cmToPt(0.8f), 2));

        /*
         * Write possible severities for this review
         */
        String severities = "";
        String separator = "";
        for (String sev : Application.getInstance().getSeverityMgmt().getSeverities()) {
            severities = severities + separator + sev;
            separator = "; ";
        }

        Phrase phrSeverities = new Phrase();
        phrSeverities.add(new Chunk(
                translate("The severities of the findings in this review (descending order of importance):"),
                italicFontSmall));
        phrSeverities.add(new Chunk(" " + severities, boldItalicFontSmall));
        phrSeverities.setLeading(leading);
        PdfPCell cellSevs = new PdfPCell();
        cellSevs.setColspan(2);
        cellSevs.addElement(phrSeverities);
        cellSevs.setBorderWidth(0);
        cellSevs.setPadding(padding);

        tableRevInfo.addCell(cellSevs);

        /*
         * Short review statistics
         */
        if (meetings.size() > 1) {
            Phrase phrRevStat = new Phrase(MessageFormat.format(translate(
                    "This review consists of {0} attendees, {1} findings, {2} meetings and {3} aspects."),
                    Application.getInstance().getReviewMgmt().getNumberOfAttendees(),
                    Application.getInstance().getReviewMgmt().getNumberOfFindings(),
                    Application.getInstance().getReviewMgmt().getNumberOfMeetings(),
                    Application.getInstance().getReviewMgmt().getNumberOfAspects()), italicFontSmall);
            phrRevStat.setLeading(leading);
            PdfPCell cellRevStat = new PdfPCell();
            cellRevStat.setColspan(2);
            cellRevStat.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellRevStat.addElement(phrRevStat);
            cellRevStat.setBorderWidth(0);
            cellRevStat.setPadding(padding);
            cellRevStat.setPaddingTop(0);

            tableRevInfo.addCell(cellRevStat);
        }

        /*
         * Write the date of creation
         */
        String creationDate = sdfDate.format(new Date().getTime());

        Phrase phrCreationDate = new Phrase(
                translate("This finding has been created with RevAger on") + " " + creationDate,
                plainFontSmall);
        phrCreationDate.setLeading(leading);
        PdfPCell cellCrDate = new PdfPCell();
        cellCrDate.setColspan(2);
        cellCrDate.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellCrDate.addElement(phrCreationDate);
        cellCrDate.setBorderWidth(0);
        cellCrDate.setPadding(0);
        cellCrDate.setPaddingLeft(padding);
        cellCrDate.setPaddingRight(padding);

        tableRevInfo.addCell(cellCrDate);

        /*
         * Add content to the base table
         */
        PdfPCell cellRevInfo = new PdfPCell();
        cellRevInfo.setColspan(2);
        cellRevInfo.setBorder(0);
        cellRevInfo.setPadding(0);
        cellRevInfo.addElement(tableRevInfo);

        tableTitlePage.addCell(cellRevInfo);

        pdfDoc.add(tableTitlePage);
    } catch (Exception e) {
        /*
         * Not part of unit testing because this exception is only thrown if
         * an internal error occurs.
         */
        throw new ExportException(translate("Cannot generate front page of the PDF document."));
    }
}