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

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

Introduction

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

Prototype

public void setPhrase(Phrase phrase) 

Source Link

Document

Sets the Phrase for this cell.

Usage

From source file:edu.cornell.mannlib.vitro.webapp.visualization.visutils.PDFDocument.java

License:Open Source License

private PdfPTable createTable(Map<String, Integer> yearToPublicationCount) {

    Font normalContentStyle = FontFactory.getFont(FontFactory.TIMES_ROMAN, 11);
    Font summaryContentStyle = FontFactory.getFont(FontFactory.TIMES_ROMAN, 11, Font.BOLDITALIC);
    BaseColor summaryBackgroundColor = new BaseColor(0xEE, 0xEE, 0xEE);
    BaseColor headerBackgroundColor = new BaseColor(0xC3, 0xD9, 0xFF);
    BaseColor bodyBackgroundColor = new BaseColor(Color.white);

    PdfPTable table = new PdfPTable(2);
    table.setWidthPercentage(36.0f);/*w  w w.ja v  a 2s. c  o  m*/

    table.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.getDefaultCell().setBorderWidth(0.0f);
    table.setHeaderRows(2);

    PdfPCell cell;
    cell = new PdfPCell(new Phrase("Publications per year", normalContentStyle));
    setTableCaptionStyle(summaryBackgroundColor, cell);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("Year", normalContentStyle));
    setTableHeaderStyle(headerBackgroundColor, cell);
    table.addCell(cell);

    cell.setPhrase(new Phrase("Publications", normalContentStyle));
    table.addCell(cell);

    setTableBodyStyle(bodyBackgroundColor, cell);
    int totalPublications = 0;

    for (Entry<String, Integer> currentEntry : yearToPublicationCount.entrySet()) {

        cell.setPhrase(new Phrase(currentEntry.getKey(), normalContentStyle));
        table.addCell(cell);

        cell.setPhrase(new Phrase(currentEntry.getValue().toString(), normalContentStyle));
        table.addCell(cell);

        totalPublications += currentEntry.getValue();
    }

    setTableFooterStyle(summaryBackgroundColor, cell);
    cell.setPhrase(new Phrase("Total", summaryContentStyle));
    table.addCell(cell);

    cell.setPhrase(new Phrase(String.valueOf(totalPublications), summaryContentStyle));
    table.addCell(cell);

    return table;
}

From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.AbstractContentFactory.java

License:Open Source License

protected PdfPCell getContentCell(String phrase, Font font) {

    PdfPCell cell = getContentCell();
    cell.setPhrase(new Phrase(phrase, font));
    return cell;/*  w w w.ja va  2 s . c om*/
}

From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.AbstractContentFactory.java

License:Open Source License

protected PdfPCell getContentCell(String[] phrases, Font font) {

    PdfPCell cell = getContentCell();
    Phrase p = new Phrase(phrases[0], font);
    for (int i = 1; i < phrases.length; i++) {
        p.add(Chunk.NEWLINE);/* w w  w  .j a v a 2  s  .com*/
        p.add(new Phrase(phrases[i], font));
    }
    cell.setPhrase(p);
    return cell;
}

From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java

License:Open Source License

private void buildSectionGoalDelegations(Section section) {

    String sectionIntro = "Stakeholders interact with others to achieve some of their goals by means of goal delegations. Goal delegations are graphically represented as a relation that starts from a delegator actor to a delegatee actor (following the direction of the arrow), having a rounded corner rectangle representing the goal being delegated. Security needs are graphically specified as labels that appear below the delegated goal "
            + socialDiagRef() + ".";
    section.add(createParagraph(sectionIntro));

    List<Actor> selActor = getGoalDelegationsActors();
    List<Paragraph> phrases = new ArrayList<Paragraph>();

    for (Actor a : selActor) {

        for (Delegation d : a.getOutgoingDelegations()) {
            Paragraph par = createParagraph("%b" + a.getName() + "% delegates goal %i"
                    + d.getSourceGoal().getName() + "% to %b" + d.getTarget().getName() + "%.");
            List<String> secNeeds = buildDelegationSecNeedList(d);
            if (secNeeds.size() > 0) {
                par.add(new Phrase(" The following security needs apply to this delegation:"));
                par.add(Chunk.NEWLINE);// w  w w . j  a v  a 2  s  .  c  om
                par.add(new Phrase(separateListOfString(secNeeds) + "."));
            }
            phrases.add(par);
        }

        /*
         * StringBuilder sbInc = new StringBuilder(); sbInc.append("%b" +
         * a.getName() + "% is delegated by ");
         * 
         * int incCount = 0; for (Delegation d : a.getIncomingDelegations())
         * { if (incCount > 0) sbInc.append(", and is delegated by ");
         * sbInc.append("%i" + d.getSource().getName() + "% goal %i" +
         * d.getSourceGoal().getName() + "%"); List<String> secNeed1 =
         * buildSecNeedString(d, false, 'i'); List<String> secNeed2 =
         * buildSecNeedString(d, true, 'i');
         * 
         * if (secNeed2.size() > 0) { switch (secNeed2.size()) { case 1:
         * sbInc.append(" and is required to comply with the " +
         * separateListOfString(secNeed2) + " security need"); break;
         * default: sbInc.append(" and is required to comply with the " +
         * separateListOfString(secNeed2) + " security needs"); break; } }
         * if (secNeed1.size() > 0) { switch (secNeed1.size()) { case 1:
         * sbInc.append(" and requires it to comply with the " +
         * separateListOfString(secNeed1) + " security need"); break;
         * default: sbInc.append(" and requires it to comply with the " +
         * separateListOfString(secNeed1) + " security needs"); break; }
         * 
         * } List<String> parmSecNeed = buildParamterizedSecNeedString(d,
         * 'i'); if (parmSecNeed.size() > 0) {
         * sbInc.append(" and is required for a level of " +
         * separateListOfString(parmSecNeed)); } if (secNeed1.size() == 0 &&
         * secNeed2.size() == 0 && parmSecNeed.size() == 0) {
         * sbInc.append(": no security need is speccified"); } incCount++; }
         * 
         * 
         * StringBuilder sbOut = new StringBuilder(); int outCount = 0; for
         * (Delegation d : a.getOutgoingDelegations()) { if (outCount > 0)
         * sbOut.append(", and delegates to "); sbOut.append("%i" +
         * d.getTarget().getName() + "% goal %i" +
         * d.getSourceGoal().getName() + "%"); List<String> secNeed1 =
         * buildSecNeedString(d, true, 'i'); List<String> secNeed2 =
         * buildSecNeedString(d, false, 'i');
         * 
         * if (secNeed1.size() > 0) { switch (secNeed1.size()) { case 1:
         * sbOut.append(" and requires it to comply with the " +
         * separateListOfString(secNeed1) + " security need"); break;
         * default: sbOut.append(" and requires it to comply with the " +
         * separateListOfString(secNeed1) + " security needs"); break; } }
         * if (secNeed2.size() > 0) { switch (secNeed2.size()) { case 1:
         * sbOut.append(" and is required to comply with the " +
         * separateListOfString(secNeed2) + " security need"); break;
         * default: sbOut.append(" and is required to comply with the " +
         * separateListOfString(secNeed2) + " security needs"); break; } }
         * List<String> parmSecNeed = buildParamterizedSecNeedString(d,
         * 'i'); if (parmSecNeed.size() > 0) {
         * sbOut.append(" and requires a level of " +
         * separateListOfString(parmSecNeed)); } if (secNeed1.size() == 0 &&
         * secNeed2.size() == 0 && parmSecNeed.size() == 0) {
         * sbOut.append(": no security need is speccified"); }
         * 
         * outCount++; }
         * 
         * StringBuilder sb = new StringBuilder(); if (incCount > 0) { if
         * (outCount > 0) { sb.append(sbInc.toString() +
         * " while it delegates to " + sbOut.toString() + "."); } else {
         * sb.append(sbInc.toString() + "."); } } else { if (outCount > 0) {
         * sb.append("%b" + a.getName() + "% delegates to " +
         * sbOut.toString() + "."); } } if (sb.length() > 0) {
         * phrases.add(createParagraph(sb.toString())); }
         */
    }

    if (phrases.size() != 0) {
        sectionIntro = "The following description enlists all the delegations from one role/agent to the others. When applicable, security needs expressed over the delegations are enumerated.";
        section.add(createParagraph(sectionIntro));

        String t = "In the " + getProjectName() + " project" + socialDiagRef()
                + ", we have the following goal delegations:";
        section.add(createParagraph(t));
        section.add(listParagraphs(phrases));

        section.add(createParagraph(ftc.getTable(FigureConstant.DELEGATION_TABLE)
                + " summarises %igoal delegations%, together with the eventual %isecurity needs%, and the possible %ipreconditions% and %ipostconditions%, which determine when the delegation can take place, and the expected outcome of the delegation, respectively."));

        List<String[]> headers = new ArrayList<String[]>();
        headers.add(new String[] { "Delegator" });
        headers.add(new String[] { "Goal" });
        headers.add(new String[] { "Delegatee" });
        headers.add(new String[] { "Security", "Needs" });
        headers.add(new String[] { "Delegation", "Description" });
        headers.add(new String[] { "Pre-", "conditions" });
        headers.add(new String[] { "Post-", "conditions" });

        PdfPTable table = createTable(headers);

        for (Actor a : selActor) {

            if (a.getOutgoingDelegations().size() > 0) {

                PdfPCell cell = getContentCell();
                cell.setPhrase(new Phrase(a.getName(), TABLE_CONTENT));
                cell.setRowspan(a.getOutgoingDelegations().size());
                table.addCell(cell);

                for (Delegation d : a.getOutgoingDelegations()) {
                    table.addCell(getContentCell(d.getSourceGoal().getName()));
                    table.addCell(getContentCell(d.getTarget().getName()));

                    List<String> sn = buildDelegationSecNeedList(d);

                    Phrase p = null;
                    for (int i = 0; i < sn.size(); i++) {
                        if (i == 0)
                            p = new Phrase(sn.get(i), TABLE_CONTENT_SMALL);
                        else {
                            p.add(Chunk.NEWLINE);
                            p.add(new Phrase(sn.get(i), TABLE_CONTENT_SMALL));
                        }
                    }

                    PdfPCell c = getContentCell();
                    c.addElement(p);
                    table.addCell(c);

                    table.addCell(getContentCell(d.getDescription()));
                    table.addCell(getContentCell(d.getPreConditions()));
                    table.addCell(getContentCell(d.getPostConditions()));
                }
            }
        }
        addTableCaption(table,
                ftc.getTable(FigureConstant.DELEGATION_TABLE) + " - Goal Delegations and Security Needs");
        section.add(table);
        table.setComplete(true);

    } else {
        section.add(createParagraph("In the " + getProjectName()
                + " project there are no goal delegations taking place for the given agents/roles."));
    }
    section.setComplete(true);
}

From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java

License:Open Source License

private void buildSectionDocumentProvisions(Section section) {

    String sectionIntro = "Stakeholders exchange information by means of documents with other stakeholders. The following description enlists all the provisions from one role/agent representing the stakeholder, to other roles/agents. %iDocument provision% is represented as an arrow from the provider to the providee, with a rectangle representing the document. The security needs expressed over the provisions are described, if applicable. Security needs are specified with the help of labels that appear below the document.";
    section.add(createParagraph(sectionIntro));

    List<Actor> selActor = getDocumentProvisionsActors();
    List<Paragraph> phrases = new ArrayList<Paragraph>();

    for (Actor a : selActor) {

        for (Provision p : a.getOutgoingProvisions()) {
            Paragraph par = createParagraph("%b" + a.getName() + "% provides document %i"
                    + p.getSourceResource().getName() + "% to %b" + p.getTarget().getName() + "%.");
            List<String> secNeeds = buildProvisionSecNeedList(p);
            if (secNeeds.size() > 0) {
                par.add(new Phrase(" The following security needs apply to this provision:"));
                par.add(Chunk.NEWLINE);//from w ww .  ja va  2s .  com
                par.add(new Phrase(separateListOfString(secNeeds) + "."));
            }
            phrases.add(par);
        }
    }

    /*
     * for (Actor a : selActor) { StringBuilder sbInc = new StringBuilder();
     * sbInc.append("%b" + a.getName() + "% is provided by "); int incCount
     * = 0; for (Provision p : a.getIncomingProvisions()) { if (incCount >
     * 0) sbInc.append(", and is provided by "); sbInc.append("%i" +
     * p.getSource().getName() + "% document %i" +
     * p.getSourceResource().getName() + "%"); if (p.isIntegrity()) {
     * sbInc.append(" and requires %b" + p.getSource().getName() +
     * "% to ensure %iintegrity of transmission% over the provision of this document"
     * ); }
     * 
     * incCount++; }
     * 
     * StringBuilder sbOut = new StringBuilder(); int outCount = 0; for
     * (Provision p : a.getOutgoingProvisions()) { if (outCount > 0)
     * sbOut.append(", and it provides to "); sbOut.append("%i" +
     * p.getTarget().getName() + "% document %i" +
     * p.getSourceResource().getName() + "%"); if (p.isIntegrity()) {
     * sbInc.append(" and requires %iAvailability% level of " +
     * p.getAvailabilityValue() + "%"); } outCount++; }
     * 
     * StringBuilder sb = new StringBuilder(); if (incCount > 0) { if
     * (outCount > 0) { sb.append(sbInc.toString() +
     * " while it provides to " + sbOut.toString() + "."); } else {
     * sb.append(sbInc.toString() + "."); } } else { if (outCount > 0) {
     * sb.append("%b" + a.getName() + "% provides to " + sbOut.toString() +
     * "."); } }
     * 
     * if (sb.length() > 0) { phrases.add(createParagraph(sb.toString())); }
     * }
     */

    if (phrases.size() != 0) {
        String s = "In the " + getProjectName() + " project " + socialDiagRef()
                + ", we have the following %idocument provisions%:";
        section.add(createParagraph(s));
        section.add(listParagraphs(phrases));

        section.add(createParagraph(ftc.getTable(FigureConstant.PROVISION_TABLE)
                + " summarises the %idocument provisions% for the " + getProjectName() + " project."));

        List<String[]> headers = new ArrayList<String[]>();
        headers.add(new String[] { "Providor" });
        headers.add(new String[] { "Document" });
        headers.add(new String[] { "Providee" });
        headers.add(new String[] { "Security", "Needs" });
        headers.add(new String[] { "Provision", "Descr." });

        PdfPTable table = createTable(headers);

        for (Actor a : selActor) {

            if (a.getOutgoingProvisions().size() > 0) {

                PdfPCell cell = getContentCell();
                cell.setPhrase(new Phrase(a.getName(), TABLE_CONTENT));
                cell.setRowspan(a.getOutgoingProvisions().size());
                table.addCell(cell);

                for (Provision p : a.getOutgoingProvisions()) {
                    table.addCell(getContentCell(p.getSourceResource().getName()));
                    table.addCell(getContentCell(p.getTarget().getName()));

                    List<String> sn = buildProvisionSecNeedList(p);

                    Phrase pr = null;
                    for (int i = 0; i < sn.size(); i++) {
                        if (i == 0)
                            pr = new Phrase(sn.get(i), TABLE_CONTENT_SMALL);
                        else {
                            pr.add(Chunk.NEWLINE);
                            pr.add(new Phrase(sn.get(i), TABLE_CONTENT_SMALL));
                        }
                    }

                    PdfPCell c = getContentCell();
                    c.addElement(pr);
                    table.addCell(c);

                    table.addCell(getContentCell(p.getDescription()));
                }
            }
        }
        addTableCaption(table, ftc.getTable(FigureConstant.PROVISION_TABLE) + " - Document Provisions");
        section.add(table);
        table.setComplete(true);
    } else {
        section.add(createParagraph("In the " + getProjectName()
                + " project there are no document provisions taking place for the given agents/roles."));
    }
    section.setComplete(true);
}

From source file:fc.extensions.itext.Writer.java

License:MIT License

public void addCell(PdfPTable table, String content, int fontSize, float borderWidth, int columnSpan) {
    PdfPCell pCell = new PdfPCell();
    if (columnSpan > 1) {
        pCell.setColspan(columnSpan);/*  w  w  w. j  a va 2s  .c o m*/
    }
    pCell.setBorderWidth(borderWidth);
    pCell.setPhrase(new Phrase(content, getFont(fontSize)));
    pCell.setNoWrap(false);
    pCell.setHorizontalAlignment(PdfContentByte.ALIGN_LEFT);
    pCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(pCell);
}

From source file:fc.extensions.itext.Writer.java

License:MIT License

public void addAnsiCell(PdfPTable table, String content, int fontSize, float borderWidth, int columnSpan) {
    PdfPCell pCell = new PdfPCell();
    if (columnSpan > 1) {
        pCell.setColspan(columnSpan);//from  ww  w  . ja  v  a2  s.  c  o m
    }
    pCell.setBorderWidth(borderWidth);
    pCell.setPhrase(new Phrase(content, getAnsiFont(fontSize)));
    pCell.setNoWrap(false);
    pCell.setHorizontalAlignment(PdfContentByte.ALIGN_LEFT);
    pCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(pCell);
}

From source file:fc.extensions.itext.Writer.java

License:MIT License

public void addCell(PdfPTable table, Cell cell) {
    PdfPCell pCell = cell.getPdfPCell();
    if (cell.getFontType() == Cell.FontType.DBCS) {
        pCell.setPhrase(new Phrase(cell.getContent(), getFont(cell.getFontSize())));
    } else {/*from w w w .j  a va2s  .co  m*/
        pCell.setPhrase(new Phrase(cell.getContent(), getAnsiFont(cell.getFontSize())));
    }
    table.addCell(pCell);
}

From source file:Functions.pdf_Export.java

private void createFooter(Document doc, HoaDon hoaDon, NhanVien nv, KhachHang kh) {
    try {//from w ww.ja  v a 2  s.  c om
        String total = new DecimalFormat("#,###").format(hoaDon.getTongTien());
        Paragraph paragraph = new Paragraph();
        paragraph.add(new Phrase("Total: " + total + " (VND)", smallFont));
        paragraph.setAlignment(Element.ALIGN_RIGHT);
        addEmptyLine(paragraph, 3);
        doc.add(paragraph);

        PdfPTable table = new PdfPTable(2);
        PdfPCell cell = new PdfPCell(new Phrase("Sale Staff", subFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        table.addCell(cell);
        cell.setPhrase(new Phrase("Customer", subFont));
        table.addCell(cell);
        // add 3 blank row
        for (Integer i = 0; i < 10; i++) {
            cell.setPhrase(new Phrase(" "));
            table.addCell(cell);
        }
        cell.setPhrase(new Phrase(nv.getHoTenNhanVien(), smallFont));
        table.addCell(cell);
        cell.setPhrase(new Phrase(kh.getHoTenKH(), smallFont));
        table.addCell(cell);
        doc.add(table);

        paragraph = new Paragraph();
        addEmptyLine(paragraph, 5);
        paragraph.add(new Phrase(
                "Bill generated by: " + nv.getHoTenNhanVien() + " - " + nv.getMaNhanVien() + ", " + new Date(),
                italicFont));
        doc.add(paragraph);
    } catch (DocumentException ex) {
        Logger.getLogger(pdf_Export.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:generators.InvoiceGenerator.java

/**
 * Generate Invoice pdf file/*from   w ww.  j  a  v a  2 s .c om*/
 *
 * @param order the order
 * @throws DocumentException the document exception
 * @throws IOException       the io exception
 */
public void generate(Order order) throws DocumentException, IOException {
    Date invoiceDate = order.getDate();
    SimpleDateFormat sdf = new SimpleDateFormat("dd MMMM YYYY");
    //        User guest = order.getGuest();
    User guest = new UserDAO().get(order.getUserId());
    guest.setOrder(order);
    System.out.println("invoice generator orderID: " + order.getId());
    Document document = new Document();
    Font defaultFont = new Font(Font.FontFamily.TIMES_ROMAN, 12);
    System.out.println(System.getProperty("user.dir"));
    PdfWriter writer = PdfWriter.getInstance(document,
            new FileOutputStream(System.getProperty("user.dir") + "/src/main/java/nl/ipsen3/invoice/"
                    + new SimpleDateFormat("dd-MM-yyyy").format(invoiceDate) + " - " + order.getId() + ".pdf"));
    document.setMargins(30, 30, 30, 65);
    writer.setPageEvent(new InvoiceEventListener());
    document.open();
    Paragraph header = new Paragraph("Lionsclub Oegstgeest/Warmond",
            new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.BOLD));
    header.setAlignment(Element.ALIGN_CENTER);
    document.add(header);
    AddressDAO addressDAO = new AddressDAO();
    Address userAddress = addressDAO.get(guest.getAddressId());
    Paragraph address = new Paragraph(guest.getFirstName() + " " + guest.getPrefixLastName() + " "
            + guest.getLastName() + "\n" + userAddress.getStreet() + " " + userAddress.getHouseNumber() + "\n"
            + userAddress.getZipCode() + " " + userAddress.getCity(), defaultFont);
    address.setSpacingBefore(35);
    address.setSpacingAfter(25);
    address.setLeading(15);
    document.add(address);

    Paragraph invoiceDetails = new Paragraph("Factuurdatum: " + sdf.format(invoiceDate) + "\n"
            + "FactuurNummer: " + order.getId() + " \n" + "Debiteurennummer: " + guest.getId(), defaultFont);

    invoiceDetails.setSpacingAfter(15);
    invoiceDetails.setLeading(15);
    document.add(invoiceDetails);

    Paragraph subject = new Paragraph("Betreft: Onderwerp factuur", defaultFont);
    subject.setSpacingAfter(30);
    document.add(subject);

    PdfPTable orderTable = new PdfPTable(10);
    PdfPCell wineCell = new PdfPCell(new Paragraph("Wijn", defaultFont));
    wineCell.setColspan(5);
    wineCell.setBorder(Rectangle.BOTTOM);
    orderTable.getDefaultCell().setPaddingBottom(10);
    orderTable.getDefaultCell().setBorder(Rectangle.BOTTOM);
    ;

    orderTable.addCell(new Paragraph("Code", defaultFont));
    orderTable.addCell(new Paragraph("Aantal", defaultFont));
    orderTable.addCell(wineCell);
    orderTable.addCell(new Paragraph("Jaar", defaultFont));
    orderTable.addCell(new Paragraph("Per Fles", defaultFont));
    orderTable.addCell(new Paragraph("Bedrag", defaultFont));

    orderTable.getDefaultCell().setPaddingBottom(0);
    orderTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    wineCell.setBorder(Rectangle.NO_BORDER);

    NumberFormat numberFormat = NumberFormat.getCurrencyInstance(Locale.GERMANY);

    for (WineOrder wineOrder : order.getWineOrders()) {
        orderTable.addCell(new Paragraph("" + wineOrder.getWine().getId(), defaultFont));
        orderTable.addCell(new Paragraph("" + wineOrder.getAmount(), defaultFont));
        wineCell.setPhrase(new Phrase(wineOrder.getWine().getName(), defaultFont));
        orderTable.addCell(wineCell);
        orderTable.addCell(new Paragraph("" + wineOrder.getWine().getYear(), defaultFont));
        orderTable.addCell(new Paragraph(
                " " + numberFormat.format(wineOrder.getWine().getPrice()).replace(" ", ""), defaultFont));
        orderTable.addCell(new Paragraph(" " + numberFormat
                .format(wineOrder.getAmount() * wineOrder.getWine().getPrice()).replace(" ", ""),
                defaultFont));

        orderTable.completeRow();
    }

    orderTable.addCell(" ");
    orderTable.completeRow();
    Font totalFont = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD);
    PdfPCell totalAmount = new PdfPCell(
            new Paragraph(" " + numberFormat.format(order.getTotalAmount()).replace(" ", ""), totalFont));
    totalAmount.setBorder(Rectangle.TOP);
    totalAmount.setPaddingTop(10);
    PdfPCell totalCell = new PdfPCell(new Paragraph("Totaal", totalFont));
    totalCell.setPaddingTop(10);
    totalCell.setBorder(Rectangle.NO_BORDER);
    orderTable.addCell(totalCell);
    PdfPCell fillerCell = new PdfPCell(new Paragraph(""));
    fillerCell.setColspan(8);
    fillerCell.setBorder(Rectangle.NO_BORDER);
    orderTable.addCell(fillerCell);
    orderTable.addCell(totalAmount);

    orderTable.setSpacingBefore(15);
    orderTable.setSpacingAfter(30);
    orderTable.setWidthPercentage(95);
    orderTable.setHorizontalAlignment(Element.ALIGN_CENTER);
    document.add(orderTable);

    Paragraph retrievalDetails = new Paragraph(
            "Wij verzoeken u vriendelijk het totaalbedrag binnen 7 dagen na factuurdatum over te maken op bankrekening <bankAccountNr> t.n.v <bankAccountName> onder vermelding van het factuurnummer",
            defaultFont);
    retrievalDetails.setLeading(15);
    retrievalDetails.setSpacingAfter(20);
    document.add(retrievalDetails);

    //        document.add(new Paragraph("U kunt uw wijnen ophalen op " +  sdf.format(invoiceDate) , defaultFont));
    //        document.add(new Paragraph("Adres:", defaultFont));
    //
    //        PdfPTable addressTable = new PdfPTable(1);
    //        addressTable.setSpacingBefore(5);
    //        addressTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    //        addressTable.getDefaultCell().setPaddingLeft(35);
    //        MerchantService merchantService = new MerchantService();
    //        Merchant merchant = merchantService.find(merchantService.all().get(0).getId());
    //        addressTable.addCell(new Paragraph(merchant.getName(), defaultFont));
    //        addressTable.addCell(new Paragraph(merchant.getAddress().getStreet()
    //                + " " + merchant.getAddress().getHouseNumber(), defaultFont));
    //        addressTable.addCell(new Paragraph(merchant.getAddress().getZipCode() + " " +
    //                merchant.getAddress().getCity(), defaultFont));
    //        addressTable.setHorizontalAlignment(Element.ALIGN_LEFT);
    //        document.add(addressTable);

    document.close();
    System.out.println(
            "Succesfully generated IPSEN2.invoice: " + order.getId() + " on Date: " + sdf.format(invoiceDate));
}