Example usage for com.itextpdf.text Phrase add

List of usage examples for com.itextpdf.text Phrase add

Introduction

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

Prototype

@Override
public boolean add(final Element element) 

Source Link

Document

Adds a Chunk, Anchor or another Phrase to this Phrase.

Usage

From source file:de.extra.xtt.util.pdf.PdfCreatorImpl.java

License:Apache License

/**
 * Fr die angegebenen Kindlemente wird ein Listeneintrag fr das PDF
 * erzeugt.// w  w w.  j  a  va 2s .  c  o  m
 * 
 * @param childs
 *            Kindelemente
 * @param schemaQueues
 *            Queues mit allen Elementen fr die einzelnen Schemas
 * @param strBullet
 *            Zeichen, das als Aufzhlunsgzeichen fr die Liste verwendet
 *            wird
 * @return PDF-Liste mit den Kindelementen
 */
private List erzeugeListeFuerKindElemente(XSParticle[] childs, Map<String, Queue<XSElementDecl>> schemaQueues,
        String strBullet) {

    List currList = new List(false, 12);
    currList.setListSymbol(strBullet);

    for (XSParticle currChild : childs) {

        if (currChild.getTerm() instanceof ElementDecl) {
            // Elemente von sequence bzw. choice abarbeiten
            XSElementDecl currElement = currChild.getTerm().asElementDecl();

            Phrase currPhrase = new Phrase();

            // Name, inkl. Referenz auf das Element
            currPhrase.add(getChunkTextBoldWithReference(getNameWithPrefix(currElement),
                    getReferenceForElement(currElement)));

            // Auftreten (direkt hinter dem Namen)
            currPhrase.add(getChunkText(" (" + getMinMaxStr(currChild) + ")\n"));

            // Beschreibung
            XSAnnotation currAnn = currChild.getAnnotation();
            if ((currAnn == null) && currElement.isLocal() && (currElement.getAnnotation() != null)) {
                currAnn = currElement.getAnnotation();
            }
            if (currAnn != null) {
                currPhrase.add(getChunkTextItalic(currAnn.getAnnotation().toString() + "\n"));
            }

            currList.add(new ListItem(currPhrase));

            // Element in Queue einfgen
            String currPrefix = getNsPref(currElement.getTargetNamespace());
            schemaQueues.get(currPrefix).add(currElement);

        } else if (currChild.getTerm() instanceof XSModelGroup) {
            // Element von sequence/choice kann wieder eine ModelGroup
            // (sequence/choice) sein
            XSModelGroup mg = currChild.getTerm().asModelGroup();
            XSParticle[] childChilds = mg.getChildren();
            if ((childChilds != null) && (childChilds.length > 0)) {

                // Art der Gruppe
                String strCompositor = "";
                Compositor compositor = mg.getCompositor();
                if (compositor.equals(com.sun.xml.xsom.XSModelGroup.Compositor.SEQUENCE)) {
                    strCompositor = "Sequence:";
                } else if (compositor.equals(com.sun.xml.xsom.XSModelGroup.Compositor.CHOICE)) {
                    strCompositor = "Choice:";
                }
                currList.add(new ListItem(getPhraseTextBold(strCompositor)));

                // neue Liste fr aktuelle Kindelemente erzeugen
                List subList = erzeugeListeFuerKindElemente(childChilds, schemaQueues, bulletSub);

                // Als Subliste hinzufgen
                currList.add(subList);
            }

        } else if (currChild.getTerm() instanceof XSWildcard) {
            // Element von sequence/choice kann ein Wildcard-Objekt sein,
            // z.B. 'xs:any'
            XSWildcard wildCard = currChild.getTerm().asWildcard();
            String currNamespaceStr = wildCard.apply(MySchemaWriter.WILDCARD_NS);

            Phrase currPhrase = new Phrase();
            currPhrase.add(getChunkTextBold("any"));
            currPhrase.add(getChunkText(" (" + getMinMaxStr(currChild) + ")\n"));
            if (currNamespaceStr.length() > 0) {
                currPhrase.add(getChunkText(currNamespaceStr));
            }
            currList.add(new ListItem(currPhrase));
        }
    }
    return currList;
}

From source file:EplanPrinter.PDFPrint.java

License:Open Source License

public Phrase composePhrase(String str, BaseFont normalFont, BaseFont boldFont)
        throws DocumentException, IOException {
    ArrayList<Chunk> chunks = new ArrayList();

    // unescape all HTML encode i.e &lt; = <
    str = HtmlDecoder.unescapeHTML(str);

    // replace all <li> with bullet symbol
    str = Pattern.compile("\\<li*?\\>", Pattern.CASE_INSENSITIVE).matcher(str)
            .replaceAll(new Character('\u2022') + " ");

    String words[] = str.split(" ");
    for (int i = 0; i < words.length; i++) {
        String noHtml = words[i];
        BaseFont font = boldFont;//from  w w  w .j  av a  2  s  .c  o m
        if (hasHtmlTag(noHtml, REGEX_B)) {
            noHtml = removeHtmlTag(words[i]);
        } else if (hasHtmlTag(noHtml, REGEX_I)) {
            noHtml = removeHtmlTag(words[i]);
        } else if (hasHtmlTag(noHtml, REGEX_EM)) {
            noHtml = removeHtmlTag(words[i]);
        } else if (hasHtmlTag(noHtml, REGEX_STRONG)) {
            noHtml = removeHtmlTag(words[i]);
        } else if (hasHtmlTag(noHtml, REGEX_LI)) {
            noHtml = new Character('\u2022') + " " + removeHtmlTag(words[i]);
            font = normalFont;
        } else if (hasHtmlTag(noHtml, REGEX_DT)) {
            noHtml = new Character('\u2022') + " " + removeHtmlTag(words[i]);
            font = normalFont;
        } else if (hasHtmlTag(noHtml, REGEX_DD)) {
            noHtml = new Character('\u2022') + " " + removeHtmlTag(words[i]);
            font = normalFont;
        } else {
            noHtml = removeHtmlTag(words[i]);
            font = normalFont;
        }

        chunks.add(new Chunk(noHtml + " ", new Font(font, fontSize)));
    }

    Phrase phrase = new Phrase();
    for (Chunk chunk : chunks) {
        phrase.add(chunk);
    }

    return phrase;
}

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

License:Open Source License

protected PdfPCell getHeaderCell(String[] header) {

    Phrase p = new Phrase();
    p.setFont(TABLE_HEADER);/* w ww .ja  v a  2 s. c om*/
    for (String s : header) {
        p.add(new Chunk(s));
        p.add(Chunk.NEWLINE);
    }
    PdfPCell cell = new PdfPCell(p);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorder(Rectangle.BOTTOM | Rectangle.TOP);
    cell.setBorderWidthTop(1.5f);
    cell.setBorderWidthBottom(1.5f);
    cell.setPaddingBottom(7);
    cell.setPaddingTop(2);
    return cell;
}

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();// www .  j a v a 2  s .c  o m
    Phrase p = new Phrase(phrases[0], font);
    for (int i = 1; i < phrases.length; i++) {
        p.add(Chunk.NEWLINE);
        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);//from www  . j av  a  2s .co m
                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  w  w. j a  va 2  s .c o m
                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:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java

License:Open Source License

private void buildSecurityRequirementsChapterContentTable(Chapter chapter) {

    List<Actor> selActors = getSecurityRequirementsActors();

    List<String[]> headers = new ArrayList<String[]>();//
    headers.add(new String[] { "Responsible" });
    headers.add(new String[] { "Security Requirement" });
    headers.add(new String[] { "Requester" });
    headers.add(new String[] { "Description" });
    PdfPTable table = createTable(headers);

    for (Actor act : selActors) {

        List<PdfPCell> cells = new ArrayList<PdfPCell>();

        for (Delegation d : act.getIncomingDelegations()) {
            if (selActors.contains(d.getSource()) && (d.getTimesTransferable() >= 0
                    || d.getRepudiationType() != RepudiationType.NO_REPUDIATION
                    || d.getRedundancyType() != RedundancyType.NO_REDUNDANCY || d.isAvailability())) {
                if (d.getRedundancyType() != RedundancyType.NO_REDUNDANCY) {
                    String red = "";
                    switch (d.getRedundancyType()) {
                    case TRUE_SINGLE:
                        red = "single-actor-true-redundancy";
                        break;
                    case TRUE_MULTI:
                        red = "multi-actor-true-redundancy";
                        break;
                    case FALLBACK_SINGLE:
                        red = "single-actor-fallback-redundancy";
                        break;
                    case FALLBACK_MULTI:
                        red = "single-actor-fallback-redundancy";
                        break;
                    }/*w w w. j av  a 2 s.c  o m*/

                    cells.add(getContentCell(new String[] { red, "(" + d.getSourceGoal().getName() + ")" }));
                    cells.add(getContentCell(d.getSource().getName()));

                    StringBuilder sb = new StringBuilder();
                    sb.append(d.getTarget().getName() + " requires " + red + " for goal "
                            + d.getSourceGoal().getName() + ",");
                    sb.append("when delegating " + d.getSourceGoal().getName() + " to "
                            + d.getTarget().getName() + ".");
                    cells.add(getContentCell(sb.toString()));
                }
                if (d.getTimesTransferable() >= 0) {
                    String s = "no-delegation";
                    cells.add(getContentCell(new String[] { s, "(" + d.getSourceGoal().getName() + ")" }));
                    cells.add(getContentCell(d.getSource().getName()));

                    StringBuilder sb = new StringBuilder();
                    sb.append(d.getTarget().getName() + " requires " + s + " for goal "
                            + d.getSourceGoal().getName() + ",");
                    sb.append("when delegating " + d.getSourceGoal().getName() + " to "
                            + d.getTarget().getName() + ".");
                    cells.add(getContentCell(sb.toString()));
                }
                if (d.getRepudiationType() == RepudiationType.DUAL_REPUDIATION
                        || d.getRepudiationType() == RepudiationType.DELEGATEEE_REPUDIATION) {
                    cells.add(getContentCell(new String[] { "non-repudiation-of-acceptance",
                            "(delegated(" + d.getSource().getName() + "," + d.getTarget().getName() + ","
                                    + d.getSourceGoal().getName() + "))" }));
                    cells.add(getContentCell(d.getSource().getName()));

                    StringBuilder sb = new StringBuilder();
                    sb.append(d.getSource().getName() + " require non-repudiation-of-acceptance for goal "
                            + d.getSourceGoal().getName() + ",");
                    sb.append("when delegating " + d.getSourceGoal().getName() + " to "
                            + d.getTarget().getName() + ".");
                    cells.add(getContentCell(sb.toString()));
                }
                if (d.isAvailability()) {
                    cells.add(getContentCell(new String[] { "availability",
                            "(" + d.getSourceGoal().getName() + "," + d.getAvailabilityValue() + "%)" }));

                    cells.add(getContentCell(d.getSource().getName()));
                    StringBuilder sb = new StringBuilder();
                    sb.append(d.getSource().getName() + " require " + d.getTarget().getName()
                            + " to assure an availability level of " + d.getAvailabilityValue() + "% for goal "
                            + d.getSourceGoal().getName() + ".");
                    cells.add(getContentCell(sb.toString()));
                }
            }
        }

        for (Delegation d : act.getOutgoingDelegations()) {
            if (selActors.contains(d.getTarget())
                    && (d.getRepudiationType() != RepudiationType.NO_REPUDIATION || d.isTrustworthiness())) {

                if (d.getRepudiationType() == RepudiationType.DUAL_REPUDIATION
                        || d.getRepudiationType() == RepudiationType.DELEGATOR_REPUDIATION) {
                    cells.add(getContentCell(new String[] { "non-repudiation-of-delegation",
                            "(delegated(" + d.getSource().getName() + "," + d.getTarget().getName() + ","
                                    + d.getSourceGoal().getName() + "))" }));
                    cells.add(getContentCell(d.getTarget().getName()));

                    StringBuilder sb = new StringBuilder();
                    sb.append(d.getTarget().getName() + " require non-repudiation-of-delegation for goal "
                            + d.getSourceGoal().getName() + ",");
                    sb.append("when delegated " + d.getSourceGoal().getName() + " by " + d.getSource().getName()
                            + ".");
                    cells.add(getContentCell(sb.toString()));
                }
                if (d.isTrustworthiness()) {
                    cells.add(getContentCell(
                            new String[] { "trustworthiness", "(delegatedTo(" + d.getTarget().getName()
                                    + ", trustworthiness level: " + d.getTrustworthinessValue() + "))" }));

                    cells.add(getContentCell(d.getSource().getName()));
                    StringBuilder sb = new StringBuilder();
                    sb.append(d.getSource().getName() + " will delegate to " + d.getTarget().getName()
                            + " that have trustwhorthiness level only grater than "
                            + d.getTrustworthinessValue());
                    cells.add(getContentCell(sb.toString()));
                }
            }
        }

        for (Provision p : act.getIncomingProvisions()) {
            if (selActors.contains(p.getTarget()) && (p.isAvailability())) {

                if (p.isAvailability()) {
                    cells.add(getContentCell(new String[] { "availability",
                            "(" + p.getSourceResource().getName() + "," + p.getAvailabilityValue() + "%)" }));

                    cells.add(getContentCell(p.getSource().getName()));
                    StringBuilder sb = new StringBuilder();
                    sb.append(p.getSource().getName() + " require " + p.getTarget().getName()
                            + " to assure an availability level of " + p.getAvailabilityValue()
                            + "% for document " + p.getSourceResource().getName() + ".");
                    cells.add(getContentCell(sb.toString()));
                }
            }
        }

        for (Provision p : act.getOutgoingProvisions()) {
            if (selActors.contains(p.getTarget()) && (p.isIntegrity() || p.isConfidentiality())) {

                if (p.isIntegrity()) {
                    cells.add(
                            getContentCell(new String[] {
                                    "integrity", "(provided(" + p.getSource().getName() + ","
                                            + p.getTarget().getName() + "," + p.getSourceResource().getName(),
                                    "))" }));

                    cells.add(getContentCell(p.getSource().getName()));
                    StringBuilder sb = new StringBuilder();
                    String a = p.getTarget().getName();
                    String b = p.getSource().getName();
                    String d = p.getSourceResource().getName();
                    sb.append(a + " requires " + b
                            + " to ensure integrity of transmission over the provision of document " + d
                            + ", when " + b + " provides " + d + " to " + a + ".");
                    cells.add(getContentCell(sb.toString()));
                }

                if (p.isConfidentiality()) {
                    cells.add(
                            getContentCell(new String[] {
                                    "confidentiality", "(provided(" + p.getSource().getName() + ","
                                            + p.getTarget().getName() + "," + p.getSourceResource().getName(),
                                    "))" }));

                    cells.add(getContentCell(p.getSource().getName()));
                    StringBuilder sb = new StringBuilder();
                    String a = p.getTarget().getName();
                    String b = p.getSource().getName();
                    String d = p.getSourceResource().getName();
                    sb.append(a + " requires " + b
                            + " to ensure confidentiality of transmission over the provision of document " + d
                            + ", when " + b + " provides " + d + " to " + a + ".");
                    cells.add(getContentCell(sb.toString()));
                }
            }
        }

        for (Authorisation a : act.getIncomingAuthorisations()) {
            if (selActors.contains(a.getSource()) && a.getResources().size() > 0
                    && (a.isDistribution() || a.isModification() || a.isUsage() || a.isProduce())) {

                List<String> res = new ArrayList<String>();
                List<String> goal = new ArrayList<String>();
                for (IResource r : a.getResources()) {
                    res.add(r.getName());
                }
                for (Goal g : a.getGoals()) {
                    goal.add(g.getName());
                }

                if (!a.isUsage()) {
                    String s = "non-usage";
                    cells.add(getContentCell(
                            new String[] { s, "(" + separateListOfString(res, ",", ",") + ")" }));
                    cells.add(getContentCell(a.getSource().getName()));

                    StringBuilder sb = new StringBuilder();
                    sb.append(a.getSource().getName() + " requires " + a.getTarget().getName() + " " + s
                            + " of Information ");
                    sb.append(separateListOfString(res) + ".");
                    cells.add(getContentCell(sb.toString()));
                }
                if (!a.isModification()) {
                    String s = "non-modification";
                    cells.add(getContentCell(
                            new String[] { s, "(" + separateListOfString(res, ",", ",") + ")" }));
                    cells.add(getContentCell(a.getSource().getName()));

                    StringBuilder sb = new StringBuilder();
                    sb.append(a.getSource().getName() + " requires " + a.getTarget().getName() + " " + s
                            + " of Information ");
                    sb.append(separateListOfString(res) + ".");
                    cells.add(getContentCell(sb.toString()));
                }
                if (!a.isProduce()) {
                    String s = "non-production";
                    cells.add(getContentCell(
                            new String[] { s, "(" + separateListOfString(res, ",", ",") + ")" }));
                    cells.add(getContentCell(a.getSource().getName()));

                    StringBuilder sb = new StringBuilder();
                    sb.append(a.getSource().getName() + " requires " + a.getTarget().getName() + " " + s
                            + " of Information ");
                    sb.append(separateListOfString(res) + ".");
                    cells.add(getContentCell(sb.toString()));
                }
                if (!a.isDistribution()) {
                    String s = "non-disclosure";
                    cells.add(getContentCell(
                            new String[] { s, "(" + separateListOfString(res, ",", ",") + ")" }));
                    cells.add(getContentCell(a.getSource().getName()));

                    StringBuilder sb = new StringBuilder();
                    sb.append(a.getSource().getName() + " requires " + a.getTarget().getName() + " " + s
                            + " of Information ");
                    sb.append(separateListOfString(res) + ".");
                    cells.add(getContentCell(sb.toString()));
                }
                if (a.getGoals().size() > 0) {
                    String s = "need-to-know";
                    cells.add(getContentCell(new String[] { s, "(" + separateListOfString(res, ",", ",") + ")",
                            "(" + separateListOfString(goal, ",", ",") + ")" }));
                    cells.add(getContentCell(a.getSource().getName()));

                    StringBuilder sb = new StringBuilder();
                    sb.append(a.getSource().getName() + " requires " + a.getTarget().getName() + " " + s
                            + " of Information ");
                    sb.append(separateListOfString(res) + ", in the scope of goal " + separateListOfString(goal)
                            + ".");
                    cells.add(getContentCell(sb.toString()));
                }
            }
        }

        PdfPCell respCell = getContentCell(act.getName());
        if (cells.size() > 0) {
            if (cells.size() >= 3) {
                respCell.setRowspan(cells.size() / 3);
            }
            table.addCell(respCell);
            for (PdfPCell c : cells) {
                table.addCell(c);
            }
        }
    }

    List<PdfPCell> cells = new ArrayList<PdfPCell>();
    for (Actor act : selActors) {

        if (act instanceof Role) {
            Role r = (Role) act;

            for (IncompatibleDuties id : r.getIncompatibleDutiesIn()) {
                cells.add(getContentCell(new String[] { "not-play-both", "(" + ((Role) id.getSource()).getName()
                        + "," + ((Role) id.getTarget()).getName() + ")" }));
                cells.add(getContentCell(
                        "Any agent that play " + r.getName() + " or " + ((Role) id.getSource()).getName()
                                + ", is required not to play (adopt) the other role too."));

            }
        }

        for (Goal g : act.getGoals()) {
            for (IncompatibleDuties id : g.getIncompatibleDutiesIn()) {
                cells.add(getContentCell(new String[] { "not-achieve-both",
                        "(" + g.getName() + "," + ((Goal) id.getSource()).getName() + ")" }));
                cells.add(getContentCell(
                        "Any agent that achieves " + g.getName() + " or " + ((Goal) id.getSource()).getName()
                                + ", is required not to achieve the other goal too."));

            }
            for (CompatibleDuties cd : g.getCompatibleDutiesIn()) {
                cells.add(getContentCell(new String[] { "achieve-in-combination",
                        "(" + g.getName() + "," + ((Goal) cd.getSource()).getName() + ")" }));
                cells.add(getContentCell("Any agent that achieves one of " + g.getName() + " or "
                        + ((Goal) cd.getSource()).getName() + ", is required to achieve the other goal too."));

            }
        }
        /*
         * for(Goal g:act.getGoals()){ for (IncompatibleDuties id :
         * g.getIncompatibleDutiesIn()) { cells.add(getContentCell(new
         * String[] {"achieves(a,"+g.getName()+")",
         * "then not achieve(a,"+((Goal)id.getSource()).getName()+")"}));
         * cells
         * .add(getContentCell("Org requires any agent a that achieves "
         * +g.getName
         * ()+" not to achieve "+((Goal)id.getSource()).getName())); } for
         * (IncompatibleDuties id : g.getIncompatibleDutiesOut()) {
         * cells.add(getContentCell(new String[]
         * {"achieves(a,"+g.getName()+")",
         * "then not achieve(a,"+((Goal)id.getTarget()).getName()+")"}));
         * cells
         * .add(getContentCell("Org requires any agent a that achieves "
         * +g.getName
         * ()+" not to achieve "+((Goal)id.getTarget()).getName())); }
         * 
         * for (CompatibleDuties cd : g.getCompatibleDutiesIn()) {
         * cells.add(getContentCell(new String[]
         * {"achieves(a,"+g.getName()+")",
         * "then achieve(a,"+((Goal)cd.getSource()).getName()+")"}));
         * cells.add
         * (getContentCell("Org requires any agent a that achieves "
         * +g.getName
         * ()+" to achieve "+((Goal)cd.getSource()).getName()+" as well"));
         * } for (CompatibleDuties cd : g.getCompatibleDutiesOut()) {
         * cells.add(getContentCell(new String[]
         * {"achieves(a,"+g.getName()+")",
         * "then achieve(a,"+((Goal)cd.getTarget()).getName()+")"}));
         * cells.add
         * (getContentCell("Org requires any agent a that achieves "
         * +g.getName
         * ()+" to achieve "+((Goal)cd.getTarget()).getName()+" as well"));
         * } }
         */
    }
    PdfPCell respCell = getContentCell("\"Any agents\"");
    if (cells.size() > 0) {
        if (cells.size() >= 2) {
            respCell.setRowspan(cells.size() / 2);
        }
        table.addCell(respCell);
        for (int i = 0; i < cells.size(); i++) {
            table.addCell(cells.get(i));
            table.addCell(getContentCell("-"));
            table.addCell(cells.get(++i));
        }
    }

    addTableCaption(table, ftc.getTable(FigureConstant.COMM_TABLE) + " - Security Requirements for the "
            + getProjectName() + " Project");
    chapter.add(table);
    table.setComplete(true);

    boolean addAuthTable = false;

    // Chapter section = chapter;
    List<String[]> headers2 = new ArrayList<String[]>();
    headers2.add(new String[] { "Authorisor" });
    headers2.add(new String[] { "Information" });
    headers2.add(new String[] { "Goal" });
    headers2.add(new String[] { "Operation" });
    headers2.add(new String[] { "Authorisee" });
    headers2.add(new String[] { "Description" });
    PdfPTable table2 = createTable(headers2);

    for (Actor a : selActors) {

        List<Authorisation> validAuth = new ArrayList<Authorisation>();
        for (Authorisation au : a.getOutgoingAuthorisations()) {
            if (isValidAuth(au))
                validAuth.add(au);
        }

        if (validAuth.size() > 0) {
            addAuthTable = true;
            PdfPCell actorCell = getContentCell(a.getName());
            actorCell.setRowspan(validAuth.size());
            table2.addCell(actorCell);
            for (Authorisation au : validAuth) {

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

                /*
                 * com.itextpdf.text.List resList = new
                 * com.itextpdf.text.List(com.itextpdf.text.List.ORDERED,
                 * com.itextpdf.text.List.NUMERICAL); for (IResource r :
                 * au.getResources()) { ListItem listItem = new ListItem(new
                 * Phrase(r.getName(), TABLE_CONTENT));
                 * resList.add(listItem); }
                 */
                PdfPCell c = getContentCell();
                c.addElement(p);
                table2.addCell(c);
                // -------------------------------------//
                if (au.getGoals().size() > 0) {

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

                    /*
                     * com.itextpdf.text.List goalList = new
                     * com.itextpdf.text
                     * .List(com.itextpdf.text.List.ORDERED,
                     * com.itextpdf.text.List.NUMERICAL); for (Goal g :
                     * au.getGoals()) { ListItem listItem = new ListItem(new
                     * Phrase(g.getName(), TABLE_CONTENT));
                     * goalList.add(listItem); }
                     */
                    PdfPCell c1 = getContentCell();
                    c1.addElement(p1);
                    table2.addCell(c1);
                } else {
                    table2.addCell(getContentCell(""));
                }
                // -------------------------------------//
                table2.addCell(getContentCell(getOperationsTable(au)));

                // -------------------------------------//
                table2.addCell(getContentCell(au.getTarget().getName()));
                if (au.getTimesTransferable() == 0) {
                    table2.addCell(getContentCell("Non-transferable authority"));
                } else {
                    table2.addCell(getContentCell("Transferable authority"));
                }
            }
        }
    }
    if (addAuthTable) {
        chapter.add(createParagraph(""));
        chapter.add(createParagraph(
                ftc.getTable(FigureConstant.AUTH_TABLE) + " summarises the authorisations actors in the "
                        + getProjectName() + " project grant to one another."));
        chapter.add(table2);
        addTableCaption(table2, ftc.getTable(FigureConstant.AUTH_TABLE) + " - Authorisations in the "
                + getProjectName() + " project");
        table2.setComplete(true);
    }

}

From source file:Export.CertificadoCargaMaritima.java

public String criarDoc(String numApolice, String numCliente, Contrato c, CargaMaritimaBean cm, String user,
        String moeda, String arquivo) {
    try {/*ww w  . jav a2 s .c o  m*/
        SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss");

        Font fontCabecalhoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9.5f);
        Font fontCorpo = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        Font fontCorpoP = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
        Font fontCorpoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        Font fontCorpoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 10f);
        Font fontCabecalhoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 16f,
                Font.UNDERLINE);
        Font fontUK = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 5.5f, Font.ITALIC);

        PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 25f, 75f });
        PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1);
        PdfPTable pTableEmpresaInforImpres2 = new PdfPTable(1);
        PdfPTable pTableEmpresaInforImpres5 = new PdfPTable(1);

        PdfPTable pTableNull = new PdfPTable(1);
        PdfPCell cellNull = new PdfPCell(new Phrase(" ", fontCorpo));
        cellNull.setBorder(0);
        pTableNull.addCell(cellNull);

        PdfPCell pCellNomeEmpresa = new PdfPCell(new Phrase(Empresa.NOME, fontCabecalhoNG));
        pCellNomeEmpresa.setBorder(0);

        PdfPCell pCellNomeEndereco = new PdfPCell(new Phrase(Empresa.ENDERECO, fontCabecalhoN));
        pCellNomeEndereco.setBorder(0);

        PdfPCell pCellCaixaPostal = new PdfPCell(new Phrase(Empresa.CAIXAPOSTAL, fontCabecalhoN));
        pCellCaixaPostal.setBorder(0);

        PdfPCell pCellTeleFax = new PdfPCell(
                new Phrase(Empresa.TELEFAX + " " + ConfigDoc.Empresa.EMAIL, fontCabecalhoN));
        pCellTeleFax.setBorder(0);

        PdfPCell pCellSociedade = new PdfPCell(new Phrase(Empresa.SOCIEDADE, fontCabecalhoN));
        pCellSociedade.setBorder(0);

        PdfPCell pCellPolice = new PdfPCell(new Phrase(Empresa.APOLICE + numApolice, fontCabecalhoN));
        pCellPolice.setBorder(0);

        Image imageEmpresa = Image.getInstance("logo.png");
        imageEmpresa.scaleToFit(120f, 85f);

        pTableEmpresaInforImpres1.addCell(pCellNomeEmpresa);
        pTableEmpresaInforImpres1.addCell(pCellNomeEndereco);
        pTableEmpresaInforImpres1.addCell(pCellCaixaPostal);
        pTableEmpresaInforImpres1.addCell(pCellTeleFax);
        pTableEmpresaInforImpres1.addCell(pCellSociedade);

        pTableEmpresaInforImpres1.addCell(pCellPolice);

        PdfPCell cellTabela3 = new PdfPCell(pTableEmpresaInforImpres1);
        cellTabela3.setBorder(0);

        pTableEmpresaInforImpres5.addCell(cellTabela3);

        PdfPCell cellTabela5 = new PdfPCell(pTableEmpresaInforImpres5);
        cellTabela5.setBorder(0);

        PdfPCell cellTabela6 = new PdfPCell(imageEmpresa);
        cellTabela6.setBorder(0);

        pTableEmpresaPricipal.addCell(cellTabela6);
        pTableEmpresaPricipal.addCell(cellTabela5);

        PdfPTable pTableTitulo = new PdfPTable(1);
        Phrase pTitulo = new Phrase("CErtificado Seguro de Carga Maritima".toUpperCase(), fontCorpoNG);
        pTitulo.add(new Phrase("\nMARINE CARGO CERTIFICATE", fontUK));
        PdfPCell cellTitulo = new PdfPCell(pTitulo);
        cellTitulo.setBorder(0);
        cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER);
        pTableTitulo.addCell(cellTitulo);

        PdfPTable pTableCorpoUm = new PdfPTable(new float[] { 100 });
        PdfPTable pTableCorpoDois = new PdfPTable(new float[] { 50, 50 });
        PdfPTable pTableCorpoTres = new PdfPTable(new float[] { 100 });

        PdfPCell cellCorpopUm = new PdfPCell();
        cellCorpopUm.setBorder(0);
        PdfPCell cellCorpopDois1 = new PdfPCell();
        cellCorpopDois1.setBorder(0);
        PdfPCell cellCorpopDois2 = new PdfPCell();
        cellCorpopDois2.setBorder(0);
        PdfPCell cellCorpopTres = new PdfPCell();
        cellCorpopTres.setBorder(0);

        Paragraph pCorpoUm1 = new Paragraph(
                "Certificado de seguro emitido sob contracto aberto n".toUpperCase(), fontCorpoN);
        pCorpoUm1.add(
                new Phrase("\ncertificate OF insurance issued under contract open No.".toUpperCase(), fontUK));
        Paragraph pCorpoUm2 = new Paragraph("mbito da cobertura: ".toUpperCase(), fontCorpoN);
        pCorpoUm2.add(new Phrase("\nSCOPE OF COVER", fontUK));
        Paragraph pCorpoUm3 = new Paragraph(
                "Este certificado atesta que a Companhia tem as mencionadas, sob seguro para viagem (s) e valore (s) declarados em favor de",
                fontCorpo);
        pCorpoUm3.add(new Phrase(
                "\nTHIS IS TO CERTIFY THAT THE COMPANY HAS INSURED THE UNDER MENTIONED GOODS FOR THE VOYGE (S) AND VALUE (S) STATED ON BEHALF OF",
                fontUK));

        cellCorpopUm.addElement(pCorpoUm1);
        cellCorpopUm.addElement(pCorpoUm2);
        cellCorpopUm.addElement(pCorpoUm3);
        pTableCorpoUm.addCell(cellCorpopUm);

        Paragraph pCorpoDois11 = new Paragraph("Taxa Maritima: ", fontCorpo);
        pCorpoDois11.add(new Phrase("\nMARINE RATE", fontUK));
        Paragraph pCorpoDois12 = new Paragraph("Taxa Guerra: ", fontCorpo);
        pCorpoDois12.add(new Phrase("\nWAR RATE", fontUK));

        cellCorpopDois1.addElement(pCorpoDois11);
        cellCorpopDois1.addElement(pCorpoDois12);
        pTableCorpoDois.addCell(cellCorpopDois1);

        cellCorpopUm.addElement(pCorpoUm1);
        cellCorpopUm.addElement(pCorpoUm2);

        Paragraph pCorpoDois21 = new Paragraph("Nota de Bebito: ", fontCorpo);
        pCorpoDois21.add(new Phrase("\nDEBIT NOTE NO", fontUK));
        Paragraph pCorpoDois22 = new Paragraph("Total de Prmio: ", fontCorpo);
        pCorpoDois22.add(new Phrase("\nGROSS PREMIUM", fontUK));

        cellCorpopDois2.addElement(pCorpoDois21);
        cellCorpopDois2.addElement(pCorpoDois22);
        pTableCorpoDois.addCell(cellCorpopDois2);

        Paragraph pCorpoTres1 = new Paragraph("Taxa Superintendente: ", fontCorpo);
        pCorpoTres1.add(new Phrase("\nSuperintendent RATE".toUpperCase(), fontUK));
        Paragraph pCorpoTres2 = new Paragraph("Taxa Interna de Trnsito: ", fontCorpo);
        pCorpoTres2.add(new Phrase("\nINLANDTraffic Rate", fontUK));
        Paragraph pCorpoTres3 = new Paragraph("Taxa Total: ", fontCorpo);
        pCorpoTres3.add(new Phrase("\nTOTAL RATE", fontUK));
        Paragraph pCorpoTres4 = new Paragraph("Segurado: ", fontCorpo);
        pCorpoTres4.add(new Phrase("\nInsured".toUpperCase(), fontUK));
        Paragraph pCorpoTres5 = new Paragraph("Meio de Transporte: " + cm.getCargaMaritima().getFormaEnvio(),
                fontCorpo);
        pCorpoTres5.add(new Phrase("\nMODE OF CONVEYANCE", fontUK));

        //Paragraph pCorpoTres6_1 = new Paragraph("Medadoria Assegurada: ",fontCorpo);
        Paragraph pCorpoTres6 = new Paragraph("De " + cm.getCargaMaritima().getPaisOrigem() + " Para: "
                + cm.getCargaMaritima().getPaisDestino(), fontCorpo);
        pCorpoTres6.add(new Phrase("\nFROM                         TO", fontUK));
        Paragraph pCorpoTres7 = new Paragraph("Juros: ", fontCorpo);
        pCorpoTres7.add(new Phrase("\nINTEREST", fontUK));
        Paragraph pCorpoTres8 = new Paragraph("Valor Segurado: ", fontCorpo);
        pCorpoTres8.add(new Phrase("\nINSURED VALUE", fontUK));
        Paragraph pCorpoTres9 = new Paragraph(
                "CONDIES: Sujeitas as seguintes clsulas e garantias (Ver anexo A)", fontCorpoN);
        pCorpoTres9.add(new Phrase(
                "\nCONDITIONS : Subject to the following clsulas and warranteis (SEE APPENDICIX A)", fontUK));
        Paragraph pCorpoTres10 = new Paragraph(
                "No caso de perda ou dano que se presume a companhia ser reponsvel, deve-se comunicar de imediato  NICOM SEGUROS STP"
                        + " para ser feita a vistoria (Por favor volte).",
                fontCorpo);
        pCorpoTres10.add(new Phrase(
                "\nIn the event of loss or damage for which company is presumed to be liable, immediate resquest for survey must be made to  NICON SEGUROS STP (PLEASE TURN OVER).",
                fontUK));

        Paragraph pCorpoTres11 = new Paragraph(
                "No caso de perda ou dano este certificado, depois de autenticado, deve ser anexo a reclamao acompanhado"
                        + " de relatrio de auditoria e da factura original do desembarque, a cpia autenticada ou original da factura e uaisquer outros documentos relativo.",
                fontCorpo);
        pCorpoTres10.add(new Phrase(
                "\nIn case of loss or damage this certificate, must be annexed to the claim note accompaneid by the repost, original bill of landing, true copy"
                        + " or original invoice and any other relevant documenent.",
                fontUK));

        Paragraph pCorpoTres12 = new Paragraph();
        Phrase p1 = new Phrase("Nota: ", fontCorpoN);
        Phrase p2 = new Phrase(
                "A Empresa compromete-se a emitir uma aplice que cobre as mercadorias descritas no pedido",
                fontCorpo);
        Phrase p3 = new Phrase(
                "\nThe Company undertakes to issue a policy covering the good described herein on request.",
                fontUK);
        pCorpoTres12.add(p1);
        pCorpoTres12.add(p2);
        pCorpoTres12.add(p3);

        cellCorpopTres.addElement(pCorpoTres1);
        cellCorpopTres.addElement(pCorpoTres2);
        cellCorpopTres.addElement(pCorpoTres3);
        cellCorpopTres.addElement(pCorpoTres4);
        cellCorpopTres.addElement(pCorpoTres5);
        //cellCorpopTres.addElement(pCorpoTres6_1);
        cellCorpopTres.addElement(pCorpoTres6);
        cellCorpopTres.addElement(pCorpoTres7);
        cellCorpopTres.addElement(pCorpoTres8);
        cellCorpopTres.addElement(cellNull.getPhrase());
        cellCorpopTres.addElement(pCorpoTres9);
        cellCorpopTres.addElement(pCorpoTres10);
        cellCorpopTres.addElement(cellNull.getPhrase());
        cellCorpopTres.addElement(pCorpoTres11);
        cellCorpopTres.addElement(cellNull.getPhrase());
        cellCorpopTres.addElement(pCorpoTres12);
        pTableCorpoTres.addCell(cellCorpopTres);

        PdfPTable pTableAssinaturaTitulo = new PdfPTable(1);
        PdfPTable pTableAssinatura = new PdfPTable(new float[] { 50f, 50f });

        Paragraph pUK = new Paragraph("", fontCorpo);
        pUK.add(new Phrase("Assinaturas", fontCorpoN));
        pUK.add(new Phrase("Signature", fontUK));
        PdfPCell cellAssinatora = new PdfPCell(pUK);
        cellAssinatora.setBorder(0);
        cellAssinatora.setHorizontalAlignment(Element.ALIGN_CENTER);
        PdfPCell celllinha1 = new PdfPCell(
                new Phrase("___________________________________".toUpperCase(), fontCorpo));
        celllinha1.setBorder(0);
        celllinha1.setHorizontalAlignment(Element.ALIGN_CENTER);
        PdfPCell celllinha2 = new PdfPCell(
                new Phrase("___________________________________".toUpperCase(), fontCorpo));
        celllinha2.setBorder(0);
        celllinha2.setHorizontalAlignment(Element.ALIGN_CENTER);

        pUK = new Paragraph("", fontCorpo);
        pUK.add(new Phrase("Pela NICON SEGUROS STP", fontCorpoN));
        pUK.add(new Phrase("For NICON SEGUROS STP", fontUK));
        PdfPCell celllinha11 = new PdfPCell(pUK);
        celllinha11.setBorder(0);
        celllinha11.setHorizontalAlignment(Element.ALIGN_CENTER);

        pUK = new Paragraph("", fontCorpo);
        pUK.add(new Phrase("O Segurado", fontCorpoN));
        pUK.add(new Phrase("Insured", fontUK));
        PdfPCell celllinha21 = new PdfPCell(pUK);
        celllinha21.setBorder(0);
        celllinha21.setHorizontalAlignment(Element.ALIGN_CENTER);

        pTableAssinaturaTitulo.addCell(cellAssinatora);
        pTableAssinatura.addCell(celllinha1);
        pTableAssinatura.addCell(celllinha2);
        pTableAssinatura.addCell(celllinha11);
        pTableAssinatura.addCell(celllinha21);

        Document documento = new Document();
        documento.setPageSize(PageSize.A4);
        documento.setMargins(20f, 20f, 35f, 5f);

        File f = new File(arquivo + "/" + user + "/Seguro Carga Maritima/");
        f.mkdirs();
        String Ddata = sdf.format(new Date());
        f = new File(f.getAbsoluteFile() + "/" + "Certificado Carga Maritima " + Ddata + ".pdf");

        reString = "../Documentos/" + user + "/Seguro Carga Maritima/" + "Certificado Carga Maritima " + Ddata
                + ".pdf";

        OutputStream outputStraem = new FileOutputStream(f);
        PdfWriter writer = PdfWriter.getInstance(documento, outputStraem);

        if (MarcaDAgua.isSimulation) {
            MarcaDAgua.SimulacaoVertical v = new MarcaDAgua.SimulacaoVertical();
            writer.setPageEvent(v);
        }

        if (MarcaDAgua.isCanceled) {
            MarcaDAgua.AnulacaoVertical v = new MarcaDAgua.AnulacaoVertical();
            writer.setPageEvent(v);
        }

        documento.open();
        documento.add(pTableEmpresaPricipal);
        documento.add(pTableNull);
        documento.add(pTableTitulo);
        documento.add(pTableNull);
        documento.add(pTableNull);
        documento.add(pTableCorpoUm);
        documento.add(pTableNull);
        documento.add(pTableCorpoDois);
        documento.add(pTableCorpoTres);
        documento.add(pTableNull);
        documento.add(pTableNull);
        documento.add(pTableAssinaturaTitulo);
        documento.add(pTableNull);
        documento.add(pTableNull);
        documento.add(pTableNull);
        documento.add(pTableAssinatura);
        documento.close();

        //           PrintPdf printPdf = new PrintPdf(f.getAbsolutePath(), f.getAbsolutePath(), 0, 595f,842f,"Enviar Para o OneNote 2013",1); 
        //           //PrintPdf printPdf = new PrintPdf(f.getAbsolutePath(), f.getAbsolutePath(), 0, 595f,842f,"Hewlett-Packard HP LaserJet P2035",1); 
        //             
        //            printPdf.print();

    } catch (BadElementException | IOException ex) {
        Logger.getLogger(SeguroAPG.class.getName()).log(Level.SEVERE, null, ex);
    } catch (DocumentException ex) {
        Logger.getLogger(SeguroAPG.class.getName()).log(Level.SEVERE, null, ex);
    }
    return reString;
}

From source file:femr.ui.controllers.PDFController.java

License:Open Source License

private Phrase getStyledPhrase(String title, String value) {
    Phrase phrase = new Phrase();
    phrase.add(new Chunk(title, getTitleFont()));
    phrase.add(new Chunk(value, getValueFont()));
    return phrase;
}

From source file:file.PDFWriter.java

License:Open Source License

/**
 * Add the page number and line to the PDF
 * @param splitLines the array of line segments to print
 * @param page the page number the line was on
 * @throws DocumentException /*  w w  w. j av  a2  s  .  co  m*/
 */
private void addLineTableToPDF(String[] splitLines, String page) throws DocumentException {
    PdfPTable lineTable = new PdfPTable(2);
    PdfPCell pageCell = new PdfPCell(new Paragraph("Page: " + page, lineFont));
    pageCell.setPadding(20);
    pageCell.setPaddingLeft(0);
    pageCell.setBorder(PdfPCell.NO_BORDER);
    Chunk lineSegment1 = new Chunk(splitLines[0]);
    lineSegment1.setFont(lineFont);
    Chunk error1 = new Chunk(splitLines[1]);
    error1.setFont(lineFontBold);
    Chunk lineSegment2 = new Chunk(splitLines[2]);
    lineSegment2.setFont(lineFont);
    Chunk error2 = new Chunk(splitLines[3]);
    error2.setFont(lineFontBold);
    Chunk lineSegment3 = new Chunk(splitLines[4]);
    lineSegment3.setFont(lineFont);

    Phrase line = new Phrase(lineSegment1);
    line.add(error1);
    line.add(lineSegment2);
    line.add(error2);
    line.add(lineSegment3);

    PdfPCell lineCell = new PdfPCell(line);
    lineCell.setPadding(20);
    lineCell.setBorder(PdfPCell.NO_BORDER);
    lineTable.setWidthPercentage(100);
    lineTable.setWidths(new int[] { 2, 10 });
    lineTable.setSpacingBefore(1f);
    lineTable.setSpacingAfter(1f);

    lineTable.addCell(pageCell);
    lineTable.addCell(lineCell);
    document.add(lineTable);
    document.add(Chunk.NEWLINE);
}