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

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

Introduction

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

Prototype

public void addElement(Element element) 

Source Link

Document

Adds an iText element to the cell.

Usage

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  a2 s. c  om

                    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:eu.geopaparazzi.plugins.pdfexport.PdfExportDialogFragment.java

License:Open Source License

public void processNote(Document document, Note note, int count) throws Exception {
    String name = Utilities.makeXmlSafe(note.getName());
    String form = note.getForm();

    DaoImages daoImages = new DaoImages();
    if (form != null && form.length() > 0) {
        JSONObject sectionObject = new JSONObject(form);
        if (!sectionObject.has(FormUtilities.ATTR_SECTIONNAME)) {
            return;
        }/*  ww w  .  j  av  a 2s . co  m*/
        String sectionName = sectionObject.getString(FormUtilities.ATTR_SECTIONNAME);
        Anchor anchor = new Anchor(sectionName);
        anchor.setName(sectionName);
        Chapter currentChapter = new Chapter(new Paragraph(anchor), count);
        addEmptyLine(currentChapter, 3);

        PdfPTable infoTable = new PdfPTable(2);
        infoTable.setHeaderRows(0);
        infoTable.setWidthPercentage(90);
        currentChapter.add(infoTable);

        addKeyValueToTableRow(infoTable, "Timestamp", new Date(note.getTimeStamp()).toString());
        addKeyValueToTableRow(infoTable, "Latitude", note.getLat() + "");
        addKeyValueToTableRow(infoTable, "Longitude", note.getLon() + "");

        addEmptyLine(currentChapter, 3);

        List<String> formsNames = TagsManager.getFormNames4Section(sectionObject);
        for (String formName : formsNames) {
            Paragraph section = new Paragraph(formName);
            currentChapter.addSection(section);
            addEmptyLine(currentChapter, 3);

            PdfPTable currentTable = new PdfPTable(2);
            currentTable.setHeaderRows(1);
            currentTable.setWidthPercentage(90);
            currentChapter.add(currentTable);

            JSONObject form4Name = TagsManager.getForm4Name(formName, sectionObject);
            JSONArray formItems = TagsManager.getFormItems(form4Name);
            for (int i = 0; i < formItems.length(); i++) {
                JSONObject formItem = formItems.getJSONObject(i);
                if (!formItem.has(FormUtilities.TAG_KEY)) {
                    continue;
                }

                String type = formItem.getString(FormUtilities.TAG_TYPE);
                String key = formItem.getString(FormUtilities.TAG_KEY);
                String value = formItem.getString(FormUtilities.TAG_VALUE);

                String label = key;
                if (formItem.has(FormUtilities.TAG_LABEL)) {
                    label = formItem.getString(FormUtilities.TAG_LABEL);
                }

                if (type.equals(FormUtilities.TYPE_PICTURES)) {
                    if (value.trim().length() == 0) {
                        continue;
                    }
                    String[] imageIdsSplit = value.split(Note.IMAGES_SEPARATOR);
                    for (String imageId : imageIdsSplit) {
                        Image image = daoImages.getImage(Long.parseLong(imageId));
                        String imgName = image.getName();
                        byte[] imageData = daoImages.getImageData(Long.parseLong(imageId));
                        com.itextpdf.text.Image itextImage = com.itextpdf.text.Image.getInstance(imageData);
                        Paragraph caption = new Paragraph(imgName);
                        caption.setAlignment(Element.ALIGN_CENTER);

                        PdfPCell keyCell = new PdfPCell(new Phrase(label));
                        keyCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                        keyCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                        keyCell.setPadding(10);
                        currentTable.addCell(keyCell);
                        PdfPCell valueCell = new PdfPCell();
                        valueCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                        valueCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                        valueCell.setPadding(10);
                        valueCell.addElement(itextImage);
                        valueCell.addElement(caption);
                        currentTable.addCell(valueCell);
                    }
                } else if (type.equals(FormUtilities.TYPE_MAP)) {
                    if (value.trim().length() == 0) {
                        continue;
                    }
                    String imageId = value.trim();
                    Image image = daoImages.getImage(Long.parseLong(imageId));
                    String imgName = image.getName();
                    byte[] imageData = daoImages.getImageData(Long.parseLong(imageId));
                    com.itextpdf.text.Image itextImage = com.itextpdf.text.Image.getInstance(imageData);
                    Paragraph caption = new Paragraph(imgName);
                    caption.setAlignment(Element.ALIGN_CENTER);

                    PdfPCell keyCell = new PdfPCell(new Phrase(label));
                    keyCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                    keyCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                    keyCell.setPadding(10);
                    currentTable.addCell(keyCell);
                    PdfPCell valueCell = new PdfPCell();
                    valueCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                    valueCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                    valueCell.setPadding(10);
                    valueCell.addElement(itextImage);
                    valueCell.addElement(caption);
                    currentTable.addCell(valueCell);
                } else if (type.equals(FormUtilities.TYPE_SKETCH)) {
                    if (value.trim().length() == 0) {
                        continue;
                    }
                    String[] imageIdsSplit = value.split(Note.IMAGES_SEPARATOR);
                    for (String imageId : imageIdsSplit) {
                        Image image = daoImages.getImage(Long.parseLong(imageId));
                        String imgName = image.getName();
                        byte[] imageData = daoImages.getImageData(Long.parseLong(imageId));
                        com.itextpdf.text.Image itextImage = com.itextpdf.text.Image.getInstance(imageData);
                        Paragraph caption = new Paragraph(imgName);
                        caption.setAlignment(Element.ALIGN_CENTER);

                        PdfPCell keyCell = new PdfPCell(new Phrase(label));
                        keyCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                        keyCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                        keyCell.setPadding(10);
                        currentTable.addCell(keyCell);
                        PdfPCell valueCell = new PdfPCell();
                        valueCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                        valueCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                        valueCell.setPadding(10);
                        valueCell.addElement(itextImage);
                        valueCell.addElement(caption);
                        currentTable.addCell(valueCell);
                    }
                } else {
                    addKeyValueToTableRow(currentTable, label, value);
                }
            }
        }

        document.add(currentChapter);
        document.newPage();

    }

}

From source file:Export.CertificadoCargaMaritima.java

public String criarDoc(String numApolice, String numCliente, Contrato c, CargaMaritimaBean cm, String user,
        String moeda, String arquivo) {
    try {//from ww w.  j  a  v  a  2  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:Export.CertificadoMaritimo.java

public String criarDoc(String numApolice, String numCliente, MaritimoBean mb, Contrato c, String user,
        String moeda, String arquivo) {
    try {/* www  . j  a v  a  2 s  .  c  om*/
        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);

        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 Maritimo".toUpperCase(), fontCorpoNG);
        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);
        Paragraph pCorpoUm2 = new Paragraph("Abimto de Cortura: ".toUpperCase(), fontCorpoN);
        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);

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

        Paragraph pCorpoDois11 = new Paragraph("Taxa Maritima: ", fontCorpo);
        Paragraph pCorpoDois12 = new Paragraph("Taxa Guerra: ", fontCorpo);
        cellCorpopDois1.addElement(pCorpoDois11);
        cellCorpopDois1.addElement(pCorpoDois12);
        pTableCorpoDois.addCell(cellCorpopDois1);

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

        Paragraph pCorpoDois21 = new Paragraph("Nota de Bebito: ", fontCorpo);
        Paragraph pCorpoDois22 = new Paragraph("Total de Prmio: ", fontCorpo);
        cellCorpopDois2.addElement(pCorpoDois21);
        cellCorpopDois2.addElement(pCorpoDois22);
        pTableCorpoDois.addCell(cellCorpopDois2);

        Paragraph pCorpoTres1 = new Paragraph("Taxa Superintendente: ", fontCorpo);
        Paragraph pCorpoTres2 = new Paragraph("Taxa Interna de Trnsito: ", fontCorpo);
        Paragraph pCorpoTres3 = new Paragraph("Taxa Total: ", fontCorpo);
        Paragraph pCorpoTres4 = new Paragraph("Segurado: ", fontCorpo);
        Paragraph pCorpoTres5 = new Paragraph("Meio de Transporte: ", fontCorpo);
        Paragraph pCorpoTres6 = new Paragraph("De   Para: ", fontCorpo);
        Paragraph pCorpoTres7 = new Paragraph("Juros: ", fontCorpo);
        Paragraph pCorpoTres8 = new Paragraph("Valor Segurado: ", fontCorpo);
        Paragraph pCorpoTres9 = new Paragraph(
                "CONDIES: Sujeitas as seguintes clsulas e garantias (Ver anexo A)", fontCorpoN);
        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);
        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);
        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);
        pCorpoTres12.add(p1);
        pCorpoTres12.add(p2);

        cellCorpopTres.addElement(pCorpoTres1);
        cellCorpopTres.addElement(pCorpoTres2);
        cellCorpopTres.addElement(pCorpoTres3);
        cellCorpopTres.addElement(pCorpoTres4);
        cellCorpopTres.addElement(pCorpoTres5);
        cellCorpopTres.addElement(pCorpoTres6);
        cellCorpopTres.addElement(pCorpoTres7);
        cellCorpopTres.addElement(pCorpoTres8);
        cellCorpopTres.addElement(cellNull.getPhrase());
        cellCorpopTres.addElement(pCorpoTres9);
        cellCorpopTres.addElement(cellNull.getPhrase());
        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 });
        PdfPCell cellAssinatora = new PdfPCell(new Phrase("Assinaturas e Carimbo".toUpperCase(), fontCorpoN));
        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);

        PdfPCell celllinha11 = new PdfPCell(new Phrase("para nicon Seguro sa stp".toUpperCase(), fontCorpoP));
        celllinha11.setBorder(0);
        celllinha11.setHorizontalAlignment(Element.ALIGN_CENTER);
        PdfPCell celllinha21 = new PdfPCell(new Phrase("o segurado ".toUpperCase(), fontCorpoP));
        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("Documentos\\"+user+"\\Seguro Maritimo\\");
        //            f.mkdirs();
        //            f =new File(f.getAbsoluteFile()+"\\"+"Certificado Seguro Maritimo "+sdf.format(new Date())+".pdf");

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

        reString = "../Documentos/" + user + "/Seguro Maritimo/" + "Certificado Seguro Maritimo " + 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:Export.CertificadoViatura.java

public String criarDoc(String numApolice, String numCliente, Contrato c, VeiculoBean vf, String user,
        String moeda, String arquivo) {
    SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH'.'mm'.'ss");
    SimpleDateFormat sdfPT = new SimpleDateFormat("dd/MM/yyyy");

    try {//from w w w  . j  ava 2 s.  co m
        Document documento = new Document();
        documento.setPageSize(PageSize.A4);
        documento.setMargins(2f, 2f, 35f, 5f);

        //            File ff= new File("Documentos\\"+user+"\\Seguro Automovel\\");
        //            ff.mkdirs();
        //            ff =new File(ff.getAbsoluteFile()+"\\"+"Certificado Seguro Automovel "+sdf.format(new Date())+".pdf");
        File ff = new File(arquivo + "/" + user + "/Seguro Automovel/");
        ff.mkdirs();
        String Ddata = sdf.format(new Date());
        ff = new File(ff.getAbsoluteFile() + "/" + "Certificado Seguro Automovel " + Ddata + ".pdf");

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

        OutputStream outputStraem = new FileOutputStream(ff);
        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);
        }

        //            MyFooter event = new MyFooter();
        //            writer.setPageEvent(event);

        Font fontCabecalhoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 10.5f);
        Font fontCorpo = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
        Font fontCorpoP = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 7f);
        Font fontCorpoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 7.5f);
        Font fontCorpoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 11f);
        Font fontCabecalhoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 16f,
                Font.UNDERLINE);
        Font fontUK = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 5f, Font.ITALIC);

        documento.open();
        int total = vf.getInfo().size();
        int i = 0;
        for (Veiculo v : vf.getInfo()) {
            i++;
            PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 25f, 75f });
            pTableEmpresaPricipal.setWidthPercentage(93f);
            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(190f, 100f);

            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);

            Paragraph PTitulo = new Paragraph(new Phrase("", fontCorpo));
            Phrase pTitulo = new Phrase("Certificado Seguro de automvel".toUpperCase(), fontCorpoNG);
            Phrase pTituloUK = new Phrase("\nCertificate of motor insurance".toUpperCase(), fontUK);
            PTitulo.add(pTitulo);
            PTitulo.add(pTituloUK);

            PdfPCell cellTitulo = new PdfPCell(PTitulo);
            cellTitulo.setBorder(0);
            cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableTitulo.addCell(cellTitulo);

            PdfPTable pTableDetalhes = new PdfPTable(new float[] { 55, 45 });
            pTableDetalhes.setWidthPercentage(93f);

            Paragraph pNunCetificado = new Paragraph(new Phrase("", fontCorpo));
            pNunCetificado.add(new Phrase("1. Certificado: ", fontCorpo));
            pNunCetificado.add(new Phrase(v.getCertificado() == null || v.getCertificado().equals("") ? ""
                    : v.getCertificado().toUpperCase(), fontCorpoN));
            pNunCetificado.add(new Phrase("\n1. Certificate NO".toUpperCase(), fontUK));
            pNunCetificado.setPaddingTop(0f);

            ClienteI ci = new ClienteI(numCliente);
            Paragraph pNomeSegurado = new Paragraph(new Phrase("", fontCorpo));
            pNomeSegurado.add(new Phrase("3. Segurado: ", fontCorpo));
            pNomeSegurado.add(new Phrase(ci.getNOME_().toUpperCase(), fontCorpoN));
            pNomeSegurado.add(new Phrase("\n3. Insured".toUpperCase(), fontUK));
            pNomeSegurado.setPaddingTop(0f);

            Paragraph pMarca = new Paragraph(new Phrase("", fontCorpo));
            pMarca.add(new Phrase("5. Marca do Veiculo: ", fontCorpo));
            pMarca.add(new Phrase((v.getMarca() == null) ? " " : v.getMarca().toUpperCase(), fontCorpoN));
            pMarca.add(new Phrase("\n5. vehicle mark".toUpperCase(), fontUK));
            //                pMarca.setPaddingTop(1f);

            Paragraph pModelo = new Paragraph(new Phrase("", fontCorpo));
            pModelo.add(new Phrase("7. Modelo do Veiculo: ", fontCorpo));
            pModelo.add(new Phrase((v.getModelo() == null) ? " " : v.getModelo().toUpperCase(), fontCorpoN));
            pModelo.add(new Phrase("\n7. Model Vehicle".toUpperCase(), fontUK));
            pModelo.setPaddingTop(0f);

            Paragraph pPeriodo = new Paragraph(new Phrase("", fontCorpo));
            pPeriodo.add(new Phrase("9. Perodo de Seguro - De: ", fontCorpo));
            pPeriodo.add(new Phrase(
                    (sdfPT.format(c.getDataInicio()) + "  " + sdfPT.format(c.getDataFim())).toUpperCase(),
                    fontCorpoN));
            pPeriodo.add(new Phrase("\n9. period of insurance - from  to".toUpperCase(), fontUK));
            pPeriodo.setPaddingTop(0f);

            Paragraph pCategoria = new Paragraph(new Phrase("", fontCorpo));
            pCategoria.add(new Phrase("11. Categoria/Uso do Veculo: ", fontCorpo));
            pCategoria.add(new Phrase(" ", fontCorpoN));
            pCategoria.add(new Phrase("\n11. category/use of vehicle".toUpperCase(), fontUK));
            pCategoria.setPaddingTop(0f);

            PdfPCell cellDetalhesRi = new PdfPCell();
            cellDetalhesRi.addElement(pNunCetificado);
            cellDetalhesRi.addElement(pNomeSegurado);
            cellDetalhesRi.addElement(pMarca);
            cellDetalhesRi.addElement(pModelo);
            cellDetalhesRi.addElement(pPeriodo);
            cellDetalhesRi.addElement(pCategoria);

            Paragraph pNumApolice = new Paragraph(new Phrase("", fontCorpo));
            pNumApolice.add(new Phrase("2. Aplice N ", fontCorpo));
            pNumApolice.add(new Phrase(numApolice, fontCorpoN));
            pNumApolice.add(new Phrase("\n2. policy no".toUpperCase(), fontUK));
            pNumApolice.setPaddingTop(0f);

            Paragraph pOcupacaoSegurado = new Paragraph(new Phrase("", fontCorpo));
            pOcupacaoSegurado.add(new Phrase("4. Ocupao do Seguros: ", fontCorpo));
            pOcupacaoSegurado.add(new Phrase(ci.getPROFISSAO_().toUpperCase(), fontCorpoN));
            pOcupacaoSegurado.add(new Phrase("\n4. insured's occupation".toUpperCase(), fontUK));
            pOcupacaoSegurado.setPaddingTop(0f);

            Paragraph pNumChassi = new Paragraph(new Phrase("", fontCorpo));
            pNumChassi.add(new Phrase("6. N de Chassi/Motor: ", fontCorpo));
            pNumChassi.add(new Phrase(v.getChassi()
                    + ((v.getNumMotor() == null || v.getNumMotor().isEmpty()) ? " " : "/" + v.getNumMotor()),
                    fontCorpoN));
            pNumChassi.add(new Phrase("\n6 EnGINE", fontUK));
            pNumChassi.setPaddingTop(0f);

            Paragraph pDataFabrico = new Paragraph(new Phrase("", fontCorpo));
            pDataFabrico.add(new Phrase("8. Data de Fabrico: ", fontCorpo));
            pDataFabrico.add(new Phrase(((v.getAnoFabrico() == null) ? " " : v.getAnoFabrico()), fontCorpo));
            pDataFabrico.add(new Phrase("\n8. Date of manofacturing", fontUK));
            pDataFabrico.setPaddingTop(0f);

            Paragraph pTipoCobertura = new Paragraph(new Phrase("", fontCorpo));
            pTipoCobertura.add(new Phrase("10. Tipo de Cobertura: ", fontCorpo));
            pTipoCobertura
                    .add(new Phrase(
                            ((v.getTipoCobertura() != null) ? (vf.getVeiculo().getTipoCobertura().equals("41")
                                    ? "Contra Terceiros".toUpperCase()
                                    : (vf.getVeiculo().getTipoCobertura().equals("42")
                                            ? "CONTRA Todos os riscos".toUpperCase()
                                            : (vf.getVeiculo().getTipoCobertura().equals("43")
                                                    ? "Compreensivo limitado".toUpperCase()
                                                    : vf.getVeiculo().getTipoCobertura())))
                                    : " "),
                            fontCorpoN));
            pTipoCobertura.add(new Phrase("\n10. Tipo of Cover".toUpperCase(), fontUK));
            pTipoCobertura.setPaddingTop(0f);

            PdfPCell cellDetalhesLe = new PdfPCell();
            cellDetalhesLe.addElement(pNumApolice);
            cellDetalhesLe.addElement(pOcupacaoSegurado);
            cellDetalhesLe.addElement(pNumChassi);
            cellDetalhesLe.addElement(pDataFabrico);
            cellDetalhesLe.addElement(pTipoCobertura);

            pTableDetalhes.addCell(cellDetalhesRi);
            pTableDetalhes.addCell(cellDetalhesLe);
            String f = "";

            Paragraph para = new Paragraph(new Phrase("", fontCorpo));
            para.add(new Phrase("12. Pessoas ou Classe de Pessoas Habilitadas Para Conduzir", fontCorpoN));
            para.add(new Phrase("\n12. Persons or Class of Persons Entitled to Drive", fontUK));
            pTableDetalhes.addCell(new PdfPCell(para));

            para = new Paragraph(new Phrase("", fontCorpo));
            para.add(new Phrase("14. Categorias/Uso de Veculos", fontCorpoN));
            para.add(new Phrase("\n14. Categories / Use of Vehicles", fontUK));
            pTableDetalhes.addCell(new PdfPCell(para));

            Paragraph p11 = new Paragraph(new Phrase("", fontCorpo));
            p11.add(new Phrase(
                    "Qualquer pessoa que conduza sob a ordem do detentor da aplice ou com a sua permisso:",
                    fontCorpo));
            p11.add(new Phrase("\nAny person who is driving on the policy holder's or with his permission",
                    fontUK));
            p11.setPaddingTop(0f);

            Paragraph p12 = new Paragraph(new Phrase("", fontCorpo));
            p12.add(new Phrase(
                    "Desde que o/a condutor/a esteja habilitado/a para conduzir de acordo com a licena/normas que regulam "
                            + "a conduo de veculos a motor ou instrues para conduo lhe tenha sido passada e no esteja impedido de conduzir por"
                            + " ordem do tribunal ou por alguma outra razo.",
                    fontCorpo));
            p12.add(new Phrase(
                    "\nProvided that the person diving is permitted in accodance with the licensing or outher laws or regulations to dive the"
                            + "motor vehicles or has been premitted and is not disiqualified by order of a court of law or reason of any enactment or regulation in that behalf from diving such motor vehice",
                    fontUK));
            p12.setPaddingTop(0f);

            Paragraph p13 = new Paragraph(new Phrase("", fontCorpo));
            p13.add(new Phrase("13. Limite para uso:", fontCorpoN));
            p13.add(new Phrase("\n13. Limitation as to use", fontUK));
            p13.setPaddingTop(0f);

            Paragraph p14 = new Paragraph(new Phrase("", fontCorpo));
            p14.add(new Phrase("  - Usado apenas como descrito na categoria aqui indicada.", fontCorpo));
            p14.add(new Phrase("\n  - Used only as prescribed under the applicable category stated there in.",
                    fontUK));
            p14.setPaddingTop(0f);

            Paragraph p15 = new Paragraph(new Phrase("", fontCorpo));
            p15.add(new Phrase(
                    "  - Em todo caso, a aplice no cobre corridas, prova de segurana teste de velocidade, nem para qualquer outro propsito relacionado com a venda do automvel.",
                    fontCorpo));
            p15.add(new Phrase(
                    "\n  - In all cases, the policy does not cover racing, pace-making, reliability trial, speed testing, nor use for any purpose in connection with the trade",
                    fontUK));
            p15.setPaddingTop(0f);

            cellDetalhesRi = new PdfPCell();
            cellDetalhesRi.addElement(p11);
            cellDetalhesRi.addElement(p12);
            cellDetalhesRi.addElement(p13);
            cellDetalhesRi.addElement(p14);
            cellDetalhesRi.addElement(p15);

            Paragraph p21 = new Paragraph(new Phrase("", fontCorpo));
            p21.add(new Phrase("CATEGORIA 1 ", fontCorpoN));
            p21.add(new Paragraph(
                    "- Veculos usados para actividade social, domstica e de lazer e do segurado incluindo uso comercial.",
                    fontCorpo));
            p21.add(new Phrase(
                    "Vehicles used for social, domestic and pleasure including business use of the insured.",
                    fontUK));
            p21.setPaddingTop(0f);

            Paragraph p22 = new Paragraph(new Phrase("", fontCorpo));
            p22.add(new Phrase("CATEGORIA 2 ", fontCorpoN));
            p22.add(new Paragraph("- Veculo pertence ao segurado e usado no transporte de mercadorias.",
                    fontCorpo));
            p22.add(new Phrase("Vehicle used for transportation of good and belonging to the insured", fontUK));
            p22.setPaddingTop(0f);

            Paragraph p23 = new Paragraph(new Phrase("", fontCorpo));
            p23.add(new Phrase("CATEGORIA 3 ", fontCorpoN));
            p23.add(new Paragraph(
                    "- Veculos alugados utilizados no transporte Comercial de mercadorias pertencente  terceiros.",
                    fontCorpo));
            p23.add(new Phrase(
                    "Vehicles used for commercial transportation of good belonging to third parteis fare paying.",
                    fontUK));
            p23.setPaddingTop(0f);

            Paragraph p24 = new Paragraph(new Phrase("", fontCorpo));
            p24.add(new Phrase("CATEGORIA 5 ", fontCorpoN));
            p24.add(new Paragraph(
                    "- Veculos a motor com duas ou trs rodas para o transporte pblico de passageiro (mediante pagamento de bilhetes).",
                    fontCorpo));
            p24.add(new Phrase("Motor vehicles with two or three wheels for carrying fare paying pessengers.",
                    fontUK));
            p24.setPaddingTop(0f);

            Paragraph p25 = new Paragraph(new Phrase("", fontCorpo));
            p25.add(new Phrase("CATEGORIA 6-10 ", fontCorpoN));
            p25.add(new Paragraph(
                    "- Veculos para fins especiais: Garagem (6), Escola de Conduo (7), Para Aluguer sem motorista (8), Veculo Pesado (9) e Ambulncia, Transporte de distribuio de mercadoria, etc. (10).",
                    fontCorpo));
            p25.add(new Phrase(
                    "To special purposes vehicles: Garage (6) Driving School (7) Haring without driver ( 8) , Heavy trucks ( 9) and ambulance, refuse disposal vans etc. ( 10).",
                    fontUK));
            p25.setPaddingTop(0f);

            cellDetalhesLe = new PdfPCell();
            cellDetalhesLe.addElement(p21);
            cellDetalhesLe.addElement(p22);
            cellDetalhesLe.addElement(p23);
            cellDetalhesLe.addElement(p24);
            cellDetalhesLe.addElement(p25);

            pTableDetalhes.addCell(cellDetalhesRi);
            pTableDetalhes.addCell(cellDetalhesLe);

            PdfPTable pTableArtigo = new PdfPTable(1);
            pTableArtigo.setWidthPercentage(93f);
            Paragraph pArtigoCetificado = new Paragraph(new Phrase("", fontCorpo));
            pArtigoCetificado.add(new Phrase(
                    "O Contrato de seguro cessa, nos termos da legislao em vigor, os efeitos s 24 horas do dia da alienao do veculo.",
                    fontCorpo));
            pArtigoCetificado.add(new Phrase(
                    "\nThe insurance contract ceases, according to law in force, from its effects from 24 hours from the date of alienation of the vehicle.",
                    fontUK));
            PdfPCell cellArtigoCetificado = new PdfPCell(pArtigoCetificado);
            cellArtigoCetificado.setBorder(0);

            Paragraph pLeis = new Paragraph(new Phrase("", fontCorpo));
            pLeis.add(new Phrase(
                    "Este certificado foi emitido em conformidade com os Artigos 1 a 36, lei n 30/2000 da Repblica Democrtica de So Tom e Prncipe e que institui a existncia de uma cobertura pelo seguro",
                    fontCorpo));
            pLeis.add(new Phrase(
                    "\nThis certificate is issurd in pursuat to the prevision of Articles 1 to 36 , Law No. 30/2000 of the Democratic Republic of Sao Tome and Principe and it constitutes the existence of an insurance cover",
                    fontUK));
            PdfPCell cellLeis = new PdfPCell(pLeis);
            cellLeis.setBorder(0);

            pTableArtigo.addCell(cellArtigoCetificado);
            pTableArtigo.addCell(cellLeis);

            PdfPTable pTableAssinaturaTitulo = new PdfPTable(1);
            PdfPTable pTableAssinatura = new PdfPTable(new float[] { 50f, 50f });
            PdfPCell cellAssinatora = new PdfPCell(
                    new Phrase("Assinaturas e Carimbo".toUpperCase(), fontCorpoN));
            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);

            PdfPCell celllinha11 = new PdfPCell(new Phrase("Nicon Seguros sa STP".toUpperCase(), fontCorpoP));
            celllinha11.setBorder(0);
            celllinha11.setHorizontalAlignment(Element.ALIGN_CENTER);
            PdfPCell celllinha21 = new PdfPCell(new Phrase("o segurado ".toUpperCase(), fontCorpoP));
            celllinha21.setBorder(0);
            celllinha21.setHorizontalAlignment(Element.ALIGN_CENTER);

            PdfPCell assinaturaUK = new PdfPCell(
                    new Phrase("Signature of Insurer and stamp".toUpperCase(), fontUK));
            assinaturaUK.setBorder(0);
            assinaturaUK.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            assinaturaUK.setColspan(2);

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

            documento.add(pTableEmpresaPricipal);
            documento.add(pTableNull);
            documento.add(pTableTitulo);
            documento.add(pTableNull);
            documento.add(pTableNull);
            documento.add(pTableDetalhes);
            documento.add(pTableNull);
            documento.add(pTableArtigo);
            documento.add(pTableNull);
            documento.add(pTableAssinaturaTitulo);
            documento.add(pTableNull);
            documento.add(pTableNull);
            documento.add(pTableAssinatura);
            if (i != total)
                documento.newPage();
        }
        documento.close();

        //           PrintPdf printPdf = new PrintPdf(ff.getAbsolutePath(), ff.getAbsolutePath(), 0, 595f,842f,"Enviar Para o OneNote 2013",1); 
        //           //PrintPdf printPdf = new PrintPdf(ff.getAbsolutePath(), ff.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:Export.DocNotaCredito.java

@SuppressWarnings("CallToPrintStackTrace")
private void docSeguros(String nomeSeguro, String interCod, String user, String arquivo, int idResseguro,
        TypeNotaCredito tnc) {/*w  ww.  ja  v a 2 s  . c  o m*/
    String reString;
    try {

        Font fontCabecalhoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9.2f);
        Font fontLinha = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 0.000000358f);
        Font fontCabecalhoS = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9.2f);
        Font fontCorpo = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
        Font fontCorpoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
        Font fontNull = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 4f);
        Font fontMenor = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 3f);

        PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 80, 20 });
        pTableEmpresaPricipal.setWidthPercentage(95);
        PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1);
        PdfPTable pTableEmpresaInforImpres2 = new PdfPTable(1);
        PdfPTable pTableEmpresaInforImpres3 = new PdfPTable(2);
        PdfPTable pTableEmpresaInforImpres4 = new PdfPTable(2);
        PdfPTable pTableEmpresaInforImpres5 = new PdfPTable(1);

        DataResseguro resS = new DataResseguro();
        HashMap<String, Object> map = new LinkedHashMap<>();
        if (tnc == TypeNotaCredito.RESEGURO) {
            resS = DataReseguro.getDadosReseguro(idResseguro);
        } else {
            map = loadNotaConta();
        }

        PdfPTable pTableFatura = new PdfPTable(new float[] { 80, 20 });

        PdfPCell pCellNomeEmpresa = new PdfPCell(new Phrase(Empresa.NOME, fontCabecalhoN));
        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 pCellCapital = new PdfPCell(new Phrase(Empresa.CAPITALSOCIAL, fontCabecalhoN));
        pCellCapital.setBorder(0);

        PdfPCell pCellPolice = new PdfPCell(new Phrase(
                Empresa.APOLICE + ((TypeNotaCredito.RESEGURO == tnc) ? resS.getAPOLICE() : map.get(APOLICE)),
                fontCabecalhoN));
        pCellPolice.setBorder(0);

        PdfPCell pCellDebNF = new PdfPCell(new Phrase("Cre. N", fontCabecalhoS));
        pCellDebNF.setHorizontalAlignment(Element.ALIGN_RIGHT);
        pCellDebNF.setBorder(0);

        PdfPCell pCellDebN = new PdfPCell(new Phrase(
                ((TypeNotaCredito.RESEGURO == tnc) ? resS.getIDSEGURO() : map.get(ID) + ""), fontCabecalhoS));
        pCellDebN.setHorizontalAlignment(Element.ALIGN_CENTER);
        pCellDebN.setBorder(0);

        PdfPCell pCellInterCoF = new PdfPCell(new Phrase("Inter COD:", fontCabecalhoS));
        pCellInterCoF.setHorizontalAlignment(Element.ALIGN_RIGHT);
        pCellInterCoF.setBorder(0);

        PdfPCell pCellInterCo = new PdfPCell(new Phrase(interCod, fontCabecalhoS));
        pCellInterCo.setHorizontalAlignment(Element.ALIGN_CENTER);
        pCellInterCo.setBorder(0);

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

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

        pTableEmpresaInforImpres2.addCell(pCellCapital);
        pTableEmpresaInforImpres2.addCell(pCellPolice);

        pTableEmpresaInforImpres3.addCell(pCellDebNF);
        pTableEmpresaInforImpres3.addCell(pCellDebN);
        pTableEmpresaInforImpres3.addCell(pCellInterCoF);
        pTableEmpresaInforImpres3.addCell(pCellInterCo);

        PdfPCell cellTabela1 = new PdfPCell(pTableEmpresaInforImpres2);
        cellTabela1.setBorder(0);

        pTableEmpresaInforImpres4.addCell(cellTabela1);

        PdfPCell cellTabela2 = new PdfPCell(pTableEmpresaInforImpres3);
        cellTabela2.setBorder(0);

        pTableEmpresaInforImpres4.addCell(cellTabela2);

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

        pTableEmpresaInforImpres5.addCell(cellTabela3);

        PdfPCell cellTabela4 = new PdfPCell(pTableEmpresaInforImpres4);
        cellTabela4.setBorder(0);

        pTableEmpresaInforImpres5.addCell(cellTabela4);

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

        pTableEmpresaPricipal.addCell(cellTabela5);

        PdfPCell cellTabela6 = new PdfPCell(imageEmpresa);
        cellTabela6.setBorder(0);
        cellTabela6.setHorizontalAlignment(Element.ALIGN_RIGHT);

        pTableEmpresaPricipal.addCell(cellTabela6);

        //
        PdfPTable pTableLinha = new PdfPTable(1);
        pTableLinha.setWidthPercentage(95);
        PdfPCell linha = new PdfPCell(new Phrase(" ", fontLinha));
        linha.setBorderWidthTop(0.5f);
        linha.setBorderWidthBottom(0);
        linha.setBorderWidthLeft(0);
        linha.setBorderWidthRight(0);
        pTableLinha.addCell(linha);

        PdfPTable pTableCorpoEndTitile = new PdfPTable(new float[] { 100 });
        pTableCorpoEndTitile.setWidthPercentage(95);
        PdfPCell cellCorpoEndTitile = new PdfPCell();
        Paragraph paragraphCorpoEndTitile = new Paragraph();

        Paragraph titile = new Paragraph("NOTA DE CREDITO", fontCabecalhoN);
        titile.setAlignment(Paragraph.ALIGN_CENTER);

        PdfPTable pTableNumNota = new PdfPTable(new float[] { 100f });

        Paragraph titileSub = new Paragraph(nomeSeguro, fontCabecalhoN);
        titileSub.setAlignment(Paragraph.ALIGN_CENTER);
        paragraphCorpoEndTitile.add(titile);

        if (tnc == TypeNotaCredito.ANULACAO) {
            PdfPCell titileNum = new PdfPCell(new Paragraph("Deb. N " + map.get(NOTADEBITO), fontCabecalhoN));
            titileNum.setBorder(PdfPCell.NO_BORDER);
            titileNum.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);

            pTableNumNota.addCell(titileNum);
            paragraphCorpoEndTitile.add(pTableNumNota);
        }

        paragraphCorpoEndTitile.add(titileSub);

        paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpo));
        paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpo));

        ArrayList<DataReseguro.DataEmpresa> listaDataEmpresas = new ArrayList<>();

        ClienteI ci = null;
        if (tnc == TypeNotaCredito.RESEGURO) {
            listaDataEmpresas = DataReseguro.getDadosEmpresa(idResseguro);
        } else {
            ci = new ClienteI(map.get(IDCLIENTE) + "");
        }

        Phrase pCr = new Phrase("BENEFICI?RIO: ", fontCabecalhoN);
        paragraphCorpoEndTitile.add(pCr);
        @SuppressWarnings("null")
        Phrase pCrTex = new Phrase(
                ((tnc == TypeNotaCredito.RESEGURO) ? resS.getCLIENTE() : map.get(BENEFICIARIO) + "\n"),
                fontCabecalhoS);
        paragraphCorpoEndTitile.add(pCrTex);

        Phrase pEndereco = new Phrase("Endereo: ".toUpperCase(), fontCabecalhoN);
        paragraphCorpoEndTitile.add(pEndereco);
        Phrase pEnderecoTex = new Phrase(
                ((tnc == TypeNotaCredito.RESEGURO) ? ConfigDoc.Empresa.ENDERECO : ci.getENDERECO_()) + "\n",
                fontCabecalhoS);
        paragraphCorpoEndTitile.add(pEnderecoTex);

        Phrase pPolice = new Phrase("Apolice: ".toUpperCase(), fontCabecalhoN);
        paragraphCorpoEndTitile.add(pPolice);
        Phrase pPoliceTex = new Phrase(
                ((tnc == TypeNotaCredito.RESEGURO) ? resS.getAPOLICE() : map.get(APOLICE)) + "\n",
                fontCabecalhoS);
        paragraphCorpoEndTitile.add(pPoliceTex);

        //                Phrase pInterCod = new Phrase("intermediry Code".toUpperCase(), fontCabecalhoN);
        //                paragraphCorpoEndTitile.add(pInterCod);
        //                Phrase pInterCodTex = new Phrase(/*SessionUtil.getUserlogado().getResidencia()*/"In ----\n", fontCabecalhoS);
        //                paragraphCorpoEndTitile.add(pInterCodTex);

        Phrase pDate = new Phrase("DATA: ".toUpperCase(), fontCabecalhoN);
        paragraphCorpoEndTitile.add(pDate);
        Phrase pDateTex = new Phrase(((TypeNotaCredito.ANULACAO != tnc) ? resS.getINICIO() + " " + resS.getFIM()
                : map.get(DATAINICIO) + " " + map.get(DATAFIM)) + "\n", fontCabecalhoS);
        paragraphCorpoEndTitile.add(pDateTex);

        Phrase pSegurado = new Phrase("Segurado: ".toUpperCase(), fontCabecalhoN);
        paragraphCorpoEndTitile.add(pSegurado);
        Phrase pSeguradoTex = new Phrase(
                ((tnc == TypeNotaCredito.RESEGURO) ? ConfigDoc.Empresa.NOME + "(" + resS.getCLIENTE() + ")"
                        : ci.getNOME_()),
                fontCabecalhoS);
        paragraphCorpoEndTitile.add(pSeguradoTex);

        paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpo));
        paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpo));

        //Tabela Principal
        PdfPTable pTableNotaCredito = new PdfPTable(new float[] { 21.5f, 21.5f, 22f, 27f, 7f });
        //            PdfPTable pTableNotaCreditos = new PdfPTable(new float[]{70f, 30f});
        pTableNotaCredito.setWidthPercentage(100f);
        //            pTableNotaCreditos.setWidthPercentage(100f);

        PdfPCell cellParticular = new PdfPCell(new Phrase("Particular".toUpperCase(), fontCorpoN));
        cellParticular.setBorderWidth(1);
        pTableNotaCredito.addCell(cellParticular);

        PdfPCell cellPremioGrosso = new PdfPCell(new Phrase("Prmio Grosso".toUpperCase(), fontCorpoN));
        cellPremioGrosso.setBorderWidth(1);
        pTableNotaCredito.addCell(cellPremioGrosso);

        PdfPCell cellComissaoDedutivel = new PdfPCell(
                new Phrase("Comisso Dedutvel".toUpperCase(), fontCorpoN));
        cellComissaoDedutivel.setBorderWidth(1);
        pTableNotaCredito.addCell(cellComissaoDedutivel);

        PdfPCell cellValorLiquidoD = new PdfPCell(new Phrase("Valor Liqudo Devido", fontCorpoN));
        cellValorLiquidoD.setBorderWidth(1);
        cellValorLiquidoD.setBorderWidthRight(0);
        pTableNotaCredito.addCell(cellValorLiquidoD);

        PdfPCell cellNull = new PdfPCell(new Phrase(" ", fontCorpoN));
        PdfPCell cellNull1 = new PdfPCell(new Phrase("(NET)", fontCorpoN));
        cellNull.setBorder(0);

        cellNull1.setBorderWidthTop(1);
        cellNull1.setBorderWidthRight(1);
        cellNull1.setBorderWidthLeft(0);
        cellNull1.setBorderWidthBottom(1);
        cellNull1.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);

        pTableNotaCredito.addCell(cellNull1);

        cellParticular = new PdfPCell(
                new Phrase(((TypeNotaCredito.RESEGURO == tnc) ? resS.getDESCRICAO().toUpperCase()
                        : map.get(DESCRICAO) + ""), fontCorpo));
        cellParticular.setBorderWidth(1);
        pTableNotaCredito.addCell(cellParticular);

        cellPremioGrosso = new PdfPCell(new Phrase(
                ((TypeNotaCredito.RESEGURO == tnc) ? Moeda.format(Double.valueOf(resS.getPREMIOGROSSO()))
                        : Moeda.format(Double.valueOf(map.get(PREMIOGROSSO) + ""))),
                fontCorpo));
        cellPremioGrosso.setBorderWidth(1);
        cellPremioGrosso.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellPremioGrosso.setPaddingTop(30f);
        pTableNotaCredito.addCell(cellPremioGrosso);

        cellComissaoDedutivel = new PdfPCell(new Phrase(
                ((TypeNotaCredito.RESEGURO == tnc) ? resS.getDEDUCAO() + "%" : map.get(DECUCAO) + "%"),
                fontCorpo));
        cellComissaoDedutivel.setBorderWidth(1);
        cellComissaoDedutivel.setPaddingTop(30f);
        cellComissaoDedutivel.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pTableNotaCredito.addCell(cellComissaoDedutivel);

        cellValorLiquidoD = new PdfPCell(new Phrase(
                Moeda.format(Double
                        .valueOf(((TypeNotaCredito.RESEGURO == tnc) ? resS.getTOTAL() : map.get(TOTAL) + ""))),
                fontCorpo));
        cellValorLiquidoD.setBorderWidth(1);
        cellValorLiquidoD.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellValorLiquidoD.setPaddingTop(30f);
        cellValorLiquidoD.setPaddingBottom(75f);
        pTableNotaCredito.addCell(cellValorLiquidoD);

        pTableNotaCredito.addCell(cellNull);

        PdfPCell cellTotalDebito = new PdfPCell(new Phrase("TOTAL ", fontCorpoN));
        cellTotalDebito.setBorder(PdfPCell.NO_BORDER);
        cellTotalDebito.setColspan(3);
        pTableNotaCredito.addCell(cellTotalDebito);

        PdfPCell cellTotalDebitoV = new PdfPCell(new Phrase(
                Moeda.format(Double
                        .valueOf(((TypeNotaCredito.RESEGURO == tnc) ? resS.getTOTAL() : map.get(TOTAL) + ""))),
                fontCorpo));
        cellTotalDebitoV.setBorderWidth(1);
        cellTotalDebitoV.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pTableNotaCredito.addCell(cellTotalDebitoV);

        pTableNotaCredito.addCell(cellNull);

        double cambio;
        double totalSTD = 0;
        if (!((TypeNotaCredito.RESEGURO == tnc) ? resS.getMOEDA() : map.get(SIGLADAMOEDA)).equals("STD")) {
            PdfPCell cellCambio = new PdfPCell(new Phrase(
                    "CAMBIO " + ((TypeNotaCredito.RESEGURO == tnc) ? resS.getMOEDA() : map.get(SIGLADAMOEDA)),
                    fontCorpoN));
            cellCambio.setBorder(PdfPCell.NO_BORDER);
            cellCambio.setColspan(3);
            pTableNotaCredito.addCell(cellCambio);

            cambio = valorCompra(
                    ((TypeNotaCredito.RESEGURO == tnc) ? resS.getMOEDA() : map.get(SIGLADAMOEDA) + ""),
                    ((TypeNotaCredito.RESEGURO == tnc) ? new Date() : map.get(CTT_DTREG)));

            PdfPCell cellCambioV = new PdfPCell(new Phrase(Moeda.format(cambio), fontCorpo));
            cellCambioV.setBorderWidth(1);
            cellCambioV.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            pTableNotaCredito.addCell(cellCambioV);

            pTableNotaCredito.addCell(cellNull);

            PdfPCell cellValorDobras = new PdfPCell(new Phrase("VALOR EM DOBRAS", fontCorpoN));
            cellValorDobras.setBorder(PdfPCell.NO_BORDER);
            cellValorDobras.setColspan(3);
            pTableNotaCredito.addCell(cellValorDobras);

            totalSTD = cambio
                    * Double.valueOf((TypeNotaCredito.RESEGURO == tnc) ? resS.getTOTAL() : map.get(TOTAL) + "");
            PdfPCell cellValorDobrasV = new PdfPCell(new Phrase(Moeda.format(totalSTD), fontCorpo));
            cellValorDobrasV.setBorderWidth(1);
            cellValorDobrasV.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            pTableNotaCredito.addCell(cellValorDobrasV);

            pTableNotaCredito.addCell(cellNull);
        }

        paragraphCorpoEndTitile.add(pTableNotaCredito);
        JTextPane jtp = new JTextPane();
        Moeda.EscreverEstenso(totalSTD, jtp, "Dobras");
        paragraphCorpoEndTitile.add(new Phrase("POR EXTENSO: ", fontCorpoN));
        paragraphCorpoEndTitile.add(new Phrase(jtp.getText().toUpperCase().trim() + "\n", fontCorpo));

        paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpoN));
        paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpoN));

        paragraphCorpoEndTitile.add(new Phrase("NOTA: ZERO PRMIO, ZERO COBERTURA", fontCorpoN));

        paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpoN));
        paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpoN));

        PdfPTable pTableRodape = new PdfPTable(new float[] { 33.333333333f, 33.333333333f, 33.333333333f });
        pTableRodape.setWidthPercentage(100.0f);

        PdfPCell cellRodapeData = new PdfPCell(
                new Phrase(".......................................................", fontCorpo));
        cellRodapeData.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellRodapeData.setBorder(PdfPCell.NO_BORDER);
        pTableRodape.addCell(cellRodapeData);

        PdfPCell cellRodapeVerificado = new PdfPCell(
                new Phrase(".......................................................", fontCorpoN));
        cellRodapeVerificado.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellRodapeVerificado.setBorder(PdfPCell.NO_BORDER);
        pTableRodape.addCell(cellRodapeVerificado);

        PdfPCell cellAssinatura = new PdfPCell(
                new Phrase(".......................................................", fontCorpo));
        cellAssinatura.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellAssinatura.setBorder(PdfPCell.NO_BORDER);
        pTableRodape.addCell(cellAssinatura);

        cellRodapeData = new PdfPCell(new Phrase(" ", fontCorpo));
        cellRodapeData.setBorder(PdfPCell.NO_BORDER);
        pTableRodape.addCell(cellRodapeData);

        cellRodapeVerificado = new PdfPCell(new Phrase("VERIFICADO POR", fontCorpoN));
        cellRodapeVerificado.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellRodapeVerificado.setBorder(PdfPCell.NO_BORDER);
        pTableRodape.addCell(cellRodapeVerificado);

        cellAssinatura = new PdfPCell(new Phrase("ASSINATURA", fontCorpo));
        cellAssinatura.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellAssinatura.setBorder(PdfPCell.NO_BORDER);
        pTableRodape.addCell(cellAssinatura);

        paragraphCorpoEndTitile.add(pTableRodape);

        cellCorpoEndTitile.addElement(paragraphCorpoEndTitile);

        cellCorpoEndTitile.setBorder(PdfPCell.NO_BORDER);

        pTableCorpoEndTitile.addCell(cellCorpoEndTitile);

        SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss");

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

        String f1 = (arquivo + "/" + interCod + "/Seguro " + nomeSeguro + "/");
        File f = new File(f1);
        String Ddata = sdf1.format(new Date());
        f.mkdirs();
        f = new File(f.getAbsoluteFile() + "/" + "Nota de Credito " + Ddata + ".pdf");

        reString = "../Documentos/" + interCod + "/Seguro " + nomeSeguro + "/" + "Nota de Credito " + Ddata
                + ".pdf";
        OutputStream outputStraem = new FileOutputStream(f);
        PdfWriter writer = PdfWriter.getInstance(documento, outputStraem);

        documento.open();
        documento.add(pTableEmpresaPricipal);
        documento.add(pTableLinha);
        documento.add(pTableLinha);
        documento.add(pTableCorpoEndTitile);
        documento.close();

        RequestContext.getCurrentInstance().execute("openAllDocument('" + reString + "')");
    } catch (FileNotFoundException | DocumentException e) {
        e.printStackTrace();
    } catch (IOException ex) {
        Logger.getLogger(DocNotaCredito.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:Export.ExportMapaProducao__.java

public String criarDoc(String user, Date dataInicio, Date dataFim) {
    try {// w w  w.  j  a va  2s  .  c  om
        SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss");
        SimpleDateFormat sdfPT = new SimpleDateFormat("dd-MM-yyyy");

        Font fontCabecalhoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 10f);
        Font fontCorpo = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        Font fontCorpoTable = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
        Font fontCorpoBP = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
        Font fontCorpoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8.5f);
        Font fontCorpoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9.5f);
        Font fontCabecalhoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 16f,
                Font.UNDERLINE);

        Document documento = new Document();
        documento.setPageSize(PageSize.A4.rotate());
        documento.setMargins(10f, 10f, 35f, 80f);

        File ff = new File(getDiretorio() + "/" + user + "/Relatorio/");
        ff.mkdirs();

        String stringData = sdf.format(new Date());

        ff = new File(ff.getAbsoluteFile() + "/" + "Export Mapa Producao " + stringData + ".pdf");

        String reString = "../Documentos/" + user + "/Relatorio/" + "Export Mapa Producao " + stringData
                + ".pdf";

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

        MyFooter event = new MyFooter();
        writer.setPageEvent(event);
        documento.open();

        PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 10f, 90f });
        PdfPTable pTableEmpresaInforImpres1 = 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);

        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);

        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.setWidthPercentage(95);
        pTableEmpresaPricipal.addCell(cellTabela6);
        pTableEmpresaPricipal.addCell(cellTabela5);

        documento.add(pTableEmpresaPricipal);
        documento.add(pTableNull);

        PdfPTable pptTitileMapa = new PdfPTable(new float[] { 100 });
        pptTitileMapa.setWidthPercentage(95);
        PdfPCell cellTitileMapa = new PdfPCell(new Phrase("Mapa de produo de ".toUpperCase()
                + ((dataInicio != null) ? sdfPT.format(dataInicio) + "  "
                        : " dos Ultimos anos te hoje".toUpperCase())
                + ((dataFim == null) ? "" : sdfPT.format(dataFim)), fontCorpoNG));
        cellTitileMapa.setBorder(0);
        cellTitileMapa.setHorizontalAlignment(Element.ALIGN_CENTER);
        pptTitileMapa.addCell(cellTitileMapa);
        documento.add(pptTitileMapa);
        documento.add(pTableNull);

        ResultSet rs = ud.relatorioSeguroForImpresao(dataInicio, dataFim);
        Consumer<HashMap<String, Object>> act = (map) -> {
            list = new ArrayList<>();
            putNewDado(map, dataInicio, dataFim);
        };
        Call.forEchaResultSet(act, rs);

        int f = 0;
        for (Map.Entry<String, ArrayList<Producao>> al : hasList.entrySet()) {
            if (f > 0) {
                documento.add(pTableNull);
                documento.add(pTableNull);
            }
            f++;
            PdfPTable pptTitulo = new PdfPTable(new float[] { 100 });
            pptTitulo.setWidthPercentage(95);

            PdfPCell cellTitulo = new PdfPCell(new Phrase(al.getKey().toUpperCase(), fontCorpoNG));
            cellTitulo.setBorder(0);
            pptTitulo.addCell(cellTitulo);

            documento.add(pptTitulo);
            documento.add(pTableNull);

            PdfPTable pTableDate = HeadTablePrincipal();
            documento.add(pTableDate);

            for (Producao pro : al.getValue()) {
                pTableDate = new PdfPTable(new float[] { 9.7f, 28.8f, 14.7f, 10.7f, 10.7f, 10.7f, 14.7f });
                pTableDate.setWidthPercentage(95);
                if (!pro.DATA.equals("SOMATORIO")) {
                    newDado(pro.NUMAPOLICE, fontCorpoTable, pTableDate, documento, Element.ALIGN_LEFT, 0.5f);
                    newDado(pro.CLIENTESEGURO, fontCorpoTable, pTableDate, documento, Element.ALIGN_LEFT, 0.5f);
                    priencherTable(pro, fontCorpoTable, pTableDate, documento, 0.5f);
                } else {
                    PdfPTable pTableDate2 = rodapeTabelaPrincipal();
                    newDado(("TOTAL " + al.getKey()).toUpperCase(), fontCorpoN, pTableDate2, documento,
                            Element.ALIGN_LEFT, 1.5f);
                    priencherTable(pro, fontCorpoBP, pTableDate2, documento, 1.5f);
                }
            }
        }

        PdfPTable pTableAssinatura = new PdfPTable(new float[] { 50f, 50f });
        pTableAssinatura.setTotalWidth(700f);

        PdfPCell cellAssinatura = new PdfPCell();
        cellAssinatura.setBorder(0);
        Paragraph assinatora = new Paragraph("DIRETOR TECNICO", fontCorpoN);
        assinatora.setAlignment(Element.ALIGN_CENTER);
        Paragraph espaco = new Paragraph(" ", fontCorpoN);
        Paragraph linha = new Paragraph("______________________________________", fontCorpoN);
        linha.setAlignment(Element.ALIGN_CENTER);

        cellAssinatura.addElement(assinatora);
        cellAssinatura.addElement(espaco);
        cellAssinatura.addElement(linha);

        pTableAssinatura.addCell(cellAssinatura);

        cellAssinatura = new PdfPCell();
        cellAssinatura.setBorder(0);
        assinatora = new Paragraph("DIRETORA GERAL", fontCorpoN);
        assinatora.setAlignment(Element.ALIGN_CENTER);
        linha.setAlignment(Element.ALIGN_CENTER);

        cellAssinatura.addElement(assinatora);
        cellAssinatura.addElement(espaco);
        cellAssinatura.addElement(linha);

        pTableAssinatura.addCell(cellAssinatura);

        pTableAssinatura.writeSelectedRows(-1, 2, 70, 80, writer.getDirectContent());
        documento.close();

        //           PrintPdf printPdf = new PrintPdf(ff.getAbsolutePath(), ff.getAbsolutePath(), 0, 595f,842f,"Enviar Para o OneNote 2013",0); 
        //PrintPdf printPdf = new PrintPdf(ff.getAbsolutePath(), ff.getAbsolutePath(), 0, 595f,842f,"Hewlett-Packard HP LaserJet P2035",0); 
        //            printPdf.print();
        return reString;
    } 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 null;
}

From source file:Export.FuncPagamento.java

private String folhaPagamento(String numPagamento, String user, String nomeUser, int j)
        throws NumberFormatException {
    try {//  w  w  w .  j  a  v  a 2  s . c  om

        SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss");

        Font fontCabecalhoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                9.5f);
        Font fontCorpo = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        Font fontCorpoP = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
        Font fontCorpoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        Font fontCorpoNU = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f,
                Font.UNDERLINE);
        Font fontCorpoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                11.5f);
        Font fontCorpoNGT = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                13f, Font.UNDERLINE);
        Font fontCabecalhoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                16f, Font.UNDERLINE);

        ArrayList<HashMap<String, Object>> mapList = getObj(numPagamento);

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

        String Ddata = sdf1.format(new Date());

        int size = mapList.size(), i = 0;

        File ff = new File(ConfigDoc.Fontes.getDiretorio() + "/" + user + "/Pagamentos/");

        ff.mkdirs();
        ff = new File(ff.getAbsoluteFile() + "/" + "Pagamentos Func " + Ddata + ".pdf");

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

        MyFooter event = new MyFooter();
        writer.setPageEvent(event);

        documento.open();

        for (HashMap<String, Object> hashMap : mapList) {
            i++;

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

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

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

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

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

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

            PdfPCell pCellSociedade = new PdfPCell(new Phrase(ConfigDoc.Empresa.SOCIEDADE, fontCabecalhoN));
            pCellSociedade.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);

            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);

            documento.add(pTableEmpresaPricipal);

            documento.add(pTableNull);
            documento.add(pTableNull);

            PdfPTable pTableTitulo = new PdfPTable(new float[] { 50, 50 });
            pTableTitulo.setWidthPercentage(90f);
            PdfPCell cellTitulo = new PdfPCell(new Phrase("Comprovativo de Pagamento", fontCorpoNGT));
            cellTitulo.setBorder(0);
            cellTitulo.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cellTitulo.setPaddingRight(-80f);
            cellTitulo.setPaddingTop(-26f);
            pTableTitulo.addCell(cellTitulo);
            cellTitulo = new PdfPCell(new Phrase("N: " + hashMap.get(PAGAMENTO), fontCorpoNGT));
            cellTitulo.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cellTitulo.setBorder(0);
            cellTitulo.setPaddingBottom(5f);
            pTableTitulo.addCell(cellTitulo);

            documento.add(pTableTitulo);

            PdfPTable pTableAno = new PdfPTable(new float[] { 100 });
            pTableAno.setWidthPercentage(90f);
            PdfPCell cellAno = new PdfPCell(new Phrase(toData(hashMap.get(REGISTRO), j), fontCorpoNGT));
            cellAno.setBorder(0);
            cellAno.setPaddingBottom(20f);
            pTableAno.addCell(cellAno);

            documento.add(pTableAno);

            PdfPTable pTableDetalhesPagamento = new PdfPTable(new float[] { 100 });
            pTableDetalhesPagamento.setWidthPercentage(90f);
            PdfPCell cellDetalhesPagamento = new PdfPCell();

            Paragraph pDetalhesPagamento = new Paragraph();
            pDetalhesPagamento.add(new Paragraph("\nDetalhes de Pagamento ", fontCorpoNG));

            pDetalhesPagamento.add(new Phrase("Beneficirio: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(toString(hashMap.get(BENEFICIARIO)) + "\n", fontCorpo));
            pDetalhesPagamento.add(new Phrase("Descrio do pagamento: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(toString(hashMap.get(DESCRICAOPAGAMENTO)), fontCorpo));
            pDetalhesPagamento.add(new Paragraph("CONFORME APROVADO\n\n", fontCorpoN));

            pDetalhesPagamento.add(new Paragraph("Valor Pagamento", fontCorpoNG));
            pDetalhesPagamento.add(new Phrase("Valor Numerico: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(
                    toMoeda(hashMap.get(VALORPAGAMENTO), toString(hashMap.get(SIGLA))) + "\n", fontCorpo));
            System.err.println(toString(hashMap.get(RETENCAOFONTE)) + " hfhfh retensao");
            if (toString(hashMap.get(RETENCAOFONTE)).trim().equals("1")) {
                double ret = getValorImportRetensao();
                pDetalhesPagamento.add(new Phrase("Valor Retensao Fonte: ", fontCorpoN));
                pDetalhesPagamento.add(new Phrase(toMoeda(ret, "%") + "\n", fontCorpo));
                pDetalhesPagamento.add(new Phrase("Valor Retido: ", fontCorpoN));
                double valret = toDouble(hashMap.get(VALORPAGAMENTO)) * ret;
                pDetalhesPagamento
                        .add(new Phrase(toMoeda(valret, toString(hashMap.get(SIGLA))) + "\n", fontCorpo));
            }

            JTextPane jtp = new JTextPane();
            Double valor = Double.valueOf((hashMap.get(VALORPAGAMENTO) + ""));
            Moeda.EscreverEstenso(valor, jtp, toString(hashMap.get(MOEDA)));

            pDetalhesPagamento.add(new Phrase("Valor por Extenso: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(jtp.getText().trim() + " \n\n", fontCorpo));

            pDetalhesPagamento.add(new Paragraph("Descrio da Conta", fontCorpoNG));
            pDetalhesPagamento.add(new Phrase("Cod Conta: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(hashMap.get(CODIGOCONTAPAGAMENTO) + "\n", fontCorpo));
            pDetalhesPagamento.add(new Phrase("Titulo da Conta: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(hashMap.get(TITULOCONTAPAGAMENTO) + "\n", fontCorpo));

            /**
             * For alter
             */
            pDetalhesPagamento.add(new Phrase("Forma de Pagamento: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(hashMap.get(FORMAPAGAMENTO) + " \n", fontCorpo));
            pDetalhesPagamento.add(new Phrase("Documento de Pagamento: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(toString(hashMap.get(DESCRICAOCONTABANCO)) + " - "
                    + toString(hashMap.get(DOCFORMAPAGAMENTO)) + "\n\n", fontCorpo));
            pDetalhesPagamento.add(new Paragraph(" ", fontCorpoN));

            cellDetalhesPagamento.addElement(pDetalhesPagamento);
            pTableDetalhesPagamento.addCell(cellDetalhesPagamento);

            cellDetalhesPagamento = new PdfPCell();
            pDetalhesPagamento = new Paragraph();

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpo));
            pDetalhesPagamento.add(new Phrase("Preparado por: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(nomeUser + " ", fontCorpoP));
            pDetalhesPagamento.add(new Phrase("            Examinado por", fontCorpoN));
            pDetalhesPagamento.add(new Phrase("____________________\n", fontCorpo));

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpoN));
            pDetalhesPagamento.add(new Paragraph("Pagamento Autorizado por:", fontCorpoNG));

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase("Assinatura: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(" ____________________________________________", fontCorpo));
            pDetalhesPagamento.add(new Phrase("    Data ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(" ______________________\n\n", fontCorpo));

            pDetalhesPagamento.add(new Phrase("Assinatura: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(" ____________________________________________", fontCorpo));
            pDetalhesPagamento.add(new Phrase("    Data ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(" ______________________\n", fontCorpo));

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpo));
            pDetalhesPagamento.add(new Paragraph(
                    "............................................................................."
                            + "...........................................................................",
                    fontCorpoN));

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpo));
            Paragraph pReceip = new Paragraph("RECIBO", fontCorpoN);
            pReceip.setAlignment(Element.ALIGN_CENTER);
            pDetalhesPagamento.add(pReceip);

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpo));
            pDetalhesPagamento.add(new Phrase("Recebi o valor de: ", fontCorpo));
            pDetalhesPagamento.add(new Phrase(jtp.getText() + " \n", fontCorpoNU));

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpoN));

            PdfPTable pTableNumCheque = new PdfPTable(
                    new float[] { 33.3333333333f, 33.3333333333f, 33.3333333333f });
            pTableNumCheque.setWidthPercentage(90f);
            pTableNumCheque.setWidthPercentage(100f);

            PdfPCell cellNumCheque = new PdfPCell(new Phrase("_______________________", fontCorpo));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);
            cellNumCheque = new PdfPCell(new Phrase("_______________________", fontCorpo));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);
            cellNumCheque = new PdfPCell(new Phrase("_______________________", fontCorpo));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);

            cellNumCheque = new PdfPCell(new Phrase("Cheque No.", fontCorpoN));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);
            cellNumCheque = new PdfPCell(new Phrase("Data", fontCorpoN));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);
            cellNumCheque = new PdfPCell(new Phrase("Receiver Name & Signature", fontCorpoN));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);

            pDetalhesPagamento.add(pTableNumCheque);

            pDetalhesPagamento.add(new Phrase(
                    "\nNOTA: Um recibo oficial pode ser obtido por um pagamento e informado na parte inversa deste comprovativo. \n\n",
                    fontCorpo));

            cellDetalhesPagamento.addElement(pDetalhesPagamento);

            pTableDetalhesPagamento.addCell(cellDetalhesPagamento);

            documento.add(pTableDetalhesPagamento);

            if (i != size) {
                documento.newPage();
            }
        }

        documento.close();

        reString = "../Documentos/" + user + "/Pagamentos/" + "Pagamentos Func " + Ddata + ".pdf";
        return reString;
    } catch (BadElementException | IOException ex) {
        Logger.getLogger(FuncPagamento.class.getName()).log(Level.SEVERE, null, ex);
    } catch (DocumentException ex) {
        Logger.getLogger(FuncPagamento.class.getName()).log(Level.SEVERE, null, ex);
    }
    return reString;
}

From source file:Export.FuncPagamento.java

private String pequenoPagamento(String numPagamento, String user, String nomeUser, int i) {
    OutputStream outputStraem;/*from   ww w  . j a  v  a 2  s . co  m*/
    try {
        SimpleDateFormat sdf = new SimpleDateFormat("MMMM yyyy - dd", new Locale("pt", "BR"));
        SimpleDateFormat sdf3 = new SimpleDateFormat("dd-MM-yyyy");
        SimpleDateFormat sdf2 = new SimpleDateFormat("dd 'de' MMMM 'de' yyyy", new Locale("pt", "BR"));
        SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss");

        Font fontCabecalhoN = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED,
                14f);
        Font fontCorpo = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8.5f);
        Font fontCorpoU = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f,
                Font.UNDERLINE);
        //            Font fontCorpoP= FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED ,8f );
        Font fontCorpoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        Font fontCorpoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                8.5f);
        //            Font fontCorpoNGT= FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED , 13f ,Font.UNDERLINE);
        Font fontCabecalhoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                16f, Font.UNDERLINE);

        Document documento = new Document();
        documento.setPageSize(PageSize.A4);
        documento.setMargins(20f, 20f, 10f, 5f);
        String Ddata = sdf1.format(new Date());

        ArrayList<HashMap<String, Object>> mapList = getObj(numPagamento);
        int total = mapList.size();

        File ff = new File(ConfigDoc.Fontes.getDiretorio() + "/" + user + "/Pagamentos/");
        ff.mkdirs();
        ff = new File(ff.getAbsoluteFile() + "/" + "Pagamentos Func " + Ddata + ".pdf");

        outputStraem = new FileOutputStream(ff);
        PdfWriter writer = PdfWriter.getInstance(documento, outputStraem);
        MyFooterA5 event = new MyFooterA5();
        writer.setPageEvent(event);

        documento.open();

        PdfPTable pTableTitile = new PdfPTable(new float[] { 100 });
        pTableTitile.setWidthPercentage(95f);
        PdfPCell cellTitile = new PdfPCell();
        cellTitile.setBorder(0);

        Paragraph pTitile = new Paragraph();

        pTitile.add(new Phrase(ConfigDoc.Empresa.NOME.toUpperCase(), fontCabecalhoNG));
        pTitile.setAlignment(Element.ALIGN_CENTER);

        PdfPTable pTableSubTitile = new PdfPTable(new float[] { 80, 20 });
        pTableSubTitile.setWidthPercentage(101f);

        PdfPCell cellSubTitile = new PdfPCell(
                new Phrase("Petty cash voucher no.".toUpperCase(), fontCabecalhoN));
        cellSubTitile.setBorder(0);
        cellSubTitile.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cellSubTitile.setPaddingBottom(20);
        cellSubTitile.setPaddingRight(67);
        cellSubTitile.setPaddingTop(10);
        pTableSubTitile.addCell(cellSubTitile);

        cellSubTitile = new PdfPCell(
                new Phrase(toData((mapList.size() > 0) ? mapList.get(0).get(REGISTRO) : " ", i).toUpperCase(),
                        fontCabecalhoN));
        cellSubTitile.setHorizontalAlignment(Element.ALIGN_LEFT);
        cellSubTitile.setBorder(0);
        cellSubTitile.setPaddingBottom(20);
        cellSubTitile.setPaddingTop(10);
        pTableSubTitile.addCell(cellSubTitile);
        //            pTitile.add(cellSubTitile);

        pTitile.add(pTableSubTitile);

        cellTitile.addElement(pTitile);
        pTableTitile.addCell(cellTitile);

        documento.add(pTableTitile);

        PdfPTable pTableDados = new PdfPTable(new float[] { 5.6f, 6.05f, 53.5f, 17.95f, 19f });
        pTableDados.setWidthPercentage(95f);

        PdfPCell cellDados = new PdfPCell(new Phrase("S/N", fontCorpoNG));
        cellDados.setHorizontalAlignment(Element.ALIGN_CENTER);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Qty", fontCorpoNG));
        cellDados.setHorizontalAlignment(Element.ALIGN_CENTER);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Detail Description", fontCorpoNG));
        cellDados.setHorizontalAlignment(Element.ALIGN_CENTER);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Unit price", fontCorpoNG));
        cellDados.setHorizontalAlignment(Element.ALIGN_CENTER);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("AMT (STD)", fontCorpoNG));
        cellDados.setHorizontalAlignment(Element.ALIGN_CENTER);
        pTableDados.addCell(cellDados);

        Double toPa = 0.0;
        for (int j = 0; j < total; j++) {
            int tLinha = toString(mapList.get(j).get(DESCRICAOPAGAMENTO)).split("\n").length;

            float pad = setPadding(total, tLinha);

            cellDados = new PdfPCell(new Phrase((j + 1) + "", fontCorpo));
            cellDados.setPaddingBottom(pad);
            cellDados.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellDados.setPaddingTop(pad);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(toInt(mapList.get(j).get(QUANTIDADE)) + "", fontCorpo));
            cellDados.setPaddingBottom(pad);
            cellDados.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellDados.setPaddingTop(pad);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(toString(mapList.get(j).get(DESCRICAOPAGAMENTO)), fontCorpo));
            cellDados.setPaddingBottom(pad);
            cellDados.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellDados.setPaddingTop(pad);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(toMoeda(
                    (toDouble(mapList.get(j).get(VALORPAGAMENTO))
                            / (float) toInt(mapList.get(j).get(QUANTIDADE))),
                    toString(mapList.get(j).get(SIGLA))), fontCorpo));
            cellDados.setPaddingBottom(pad);
            cellDados.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellDados.setPaddingTop(pad);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(
                    toMoeda(toDouble(mapList.get(j).get(VALORPAGAMENTO)), toString(mapList.get(j).get(SIGLA))),
                    fontCorpo));
            cellDados.setPaddingBottom(pad);
            cellDados.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellDados.setPaddingTop(pad);
            pTableDados.addCell(cellDados);

            toPa += toDouble(mapList.get(j).get(VALORPAGAMENTO));
        }
        //            5.6f,5.6f,53.5f,17.95f,19.45f
        PdfPTable pTableRodape = new PdfPTable(new float[] { 5.6f, 6.05f, 19.795f, 33.705f, 17.95f, 19f });
        pTableRodape.setWidthPercentage(95f);

        cellDados = new PdfPCell(new Phrase(" ", fontCorpoNG));
        pTableRodape.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("CODE", fontCorpoNG));
        pTableRodape.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase(toString(mapList.get(0).get(DOCFORMAPAGAMENTO)), fontCorpoNG));
        pTableRodape.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase(toString(mapList.get(0).get(DESCRICAOCONTABANCO)), fontCorpoNG));
        pTableRodape.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("TOTAL", fontCorpoNG));
        pTableRodape.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase(toMoeda(toPa, toString(mapList.get(0).get(SIGLA))), fontCorpoNG));
        pTableRodape.addCell(cellDados);

        documento.add(pTableDados);
        documento.add(pTableRodape);

        PdfPTable pTableAssiEstenso = new PdfPTable(new float[] { 100f });

        pTableAssiEstenso.setWidthPercentage(95f);

        PdfPCell cellAssiEstenso = new PdfPCell();
        Paragraph pAssiEstenso = new Paragraph();

        PdfPTable pTableResposavel = new PdfPTable(new float[] { 70, 30 });
        pTableResposavel.setWidthPercentage(100f);

        PdfPCell cellResposavel = new PdfPCell();
        cellResposavel
                .addElement(new Phrase("Requested by:_________________________________________", fontCorpoN));
        cellResposavel.setPaddingTop(10f);
        cellResposavel.setPaddingBottom(20f);
        cellResposavel.setBorder(0);
        pTableResposavel.addCell(cellResposavel);

        cellResposavel = new PdfPCell();
        cellResposavel.addElement(new Phrase(" HOD:___________________", fontCorpoN));
        cellResposavel.setPaddingTop(10f);
        cellResposavel.setPaddingBottom(20f);
        cellResposavel.setBorder(0);
        pTableResposavel.addCell(cellResposavel);

        cellResposavel = new PdfPCell();
        cellResposavel
                .addElement(new Phrase("Approveds by:_________________________________________", fontCorpoN));
        cellResposavel.setPaddingTop(-5f);
        cellResposavel.setPaddingBottom(20f);
        cellResposavel.setBorder(0);
        pTableResposavel.addCell(cellResposavel);

        cellResposavel = new PdfPCell();
        cellResposavel.addElement(new Phrase(" Date:___________________", fontCorpoN));
        cellResposavel.setPaddingTop(-5f);
        cellResposavel.setPaddingBottom(20f);
        cellResposavel.setBorder(0);
        pTableResposavel.addCell(cellResposavel);

        pAssiEstenso.add(pTableResposavel);
        cellAssiEstenso.addElement(pAssiEstenso);

        PdfPTable pTableExteso = new PdfPTable(new float[] { 25f, 75f });
        pTableExteso.setWidthPercentage(100f);

        JTextPane jtp = new JTextPane();
        Moeda.EscreverEstenso(toPa, jtp, ((mapList.size() > 0) ? toString(mapList.get(0).get(MOEDA)) : ""));

        PdfPCell cellExteso = new PdfPCell(new Phrase("Recived the sum of", fontCorpoN));
        cellExteso.setBorder(0);
        pTableExteso.addCell(cellExteso);
        cellExteso = new PdfPCell(new Phrase(jtp.getText().toUpperCase().trim(), fontCorpoU));
        cellExteso.setBorder(0);
        pTableExteso.addCell(cellExteso);

        pAssiEstenso.add(pTableExteso);

        PdfPTable pTableAss = new PdfPTable(new float[] { 45f, 55f });
        pTableAss.setWidthPercentage(100f);

        PdfPCell cellAss = new PdfPCell(new Phrase(" ______________", fontCorpoN));
        cellAss.setPaddingTop(15f);
        cellAss.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellAss.setBorder(0);
        cellAss.setPaddingBottom(0f);
        pTableAss.addCell(cellAss);

        cellAss = new PdfPCell(new Phrase(" ____________________________________________", fontCorpoN));
        cellAss.setPaddingTop(15f);
        cellAss.setPaddingBottom(0f);
        cellAss.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellAss.setBorder(0);
        pTableAss.addCell(cellAss);

        cellAss = new PdfPCell(new Phrase("Date", fontCorpoN));
        cellAss.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellAss.setBorder(0);
        pTableAss.addCell(cellAss);

        cellAss = new PdfPCell(new Phrase("Receiver name & signature", fontCorpoN));
        cellAss.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellAss.setBorder(0);
        pTableAss.addCell(cellAss);
        pTableAss.setHorizontalAlignment(Element.ALIGN_CENTER);

        pAssiEstenso.add(pTableAss);
        pAssiEstenso.setAlignment(Element.ALIGN_CENTER);
        pAssiEstenso.add(new Phrase(
                "NOTA: Um recibo oficial pode ser obtido por um pagamento e informado na parte inversa deste comprovativo.\n\n",
                fontCorpoN));
        cellAssiEstenso = new PdfPCell();
        cellAssiEstenso.addElement(pAssiEstenso);

        pTableAssiEstenso.addCell(cellAssiEstenso);

        documento.add(pTableAssiEstenso);

        documento.close();
        reString = "../Documentos/" + user + "/Pagamentos/" + "Pagamentos Func " + Ddata + ".pdf";
        return reString;
    } catch (FileNotFoundException | DocumentException ex) {
        Logger.getLogger(FuncPagamento.class.getName()).log(Level.SEVERE, null, ex);
    }
    return reString;
}

From source file:Export.FuncPagamento.java

public static String folhaPagamentoOnlyMovCre(String numPagamento, String user, String nomeUser, Object ob)
        throws NumberFormatException {
    try {/*  ww  w  .  j  a v  a2  s .c  o m*/

        SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss");

        Font fontCabecalhoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                9.5f);
        Font fontCorpo = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        Font fontCorpoP = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
        Font fontCorpoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        Font fontCorpoNU = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f,
                Font.UNDERLINE);
        Font fontCorpoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                11.5f);
        Font fontCorpoNGT = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                13f, Font.UNDERLINE);
        Font fontCabecalhoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                16f, Font.UNDERLINE);

        ArrayList<HashMap<String, Object>> mapList = setObj(numPagamento, ob);

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

        String Ddata = sdf1.format(new Date());

        int size = mapList.size(), i = 0;

        File ff = new File(ConfigDoc.Fontes.getDiretorio() + "/" + user + "/Pagamentos/");

        ff.mkdirs();
        ff = new File(ff.getAbsoluteFile() + "/" + "Pagamentos Func " + Ddata + ".pdf");

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

        MyFooter event = new MyFooter();
        writer.setPageEvent(event);

        documento.open();

        for (HashMap<String, Object> hashMap : mapList) {
            i++;

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

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

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

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

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

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

            PdfPCell pCellSociedade = new PdfPCell(new Phrase(ConfigDoc.Empresa.SOCIEDADE, fontCabecalhoN));
            pCellSociedade.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);

            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);

            documento.add(pTableEmpresaPricipal);

            documento.add(pTableNull);
            documento.add(pTableNull);

            PdfPTable pTableTitulo = new PdfPTable(new float[] { 50, 50 });
            pTableTitulo.setWidthPercentage(90f);
            PdfPCell cellTitulo = new PdfPCell(new Phrase("Comprovativo de Pagamento", fontCorpoNGT));
            cellTitulo.setBorder(0);
            cellTitulo.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cellTitulo.setPaddingRight(-80f);
            cellTitulo.setPaddingTop(-26f);
            pTableTitulo.addCell(cellTitulo);
            cellTitulo = new PdfPCell(new Phrase("N: " + hashMap.get(PAGAMENTO), fontCorpoNGT));
            cellTitulo.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cellTitulo.setBorder(0);
            cellTitulo.setPaddingBottom(5f);
            pTableTitulo.addCell(cellTitulo);

            documento.add(pTableTitulo);

            PdfPTable pTableAno = new PdfPTable(new float[] { 100 });
            pTableAno.setWidthPercentage(90f);

            SimpleDateFormat sdfVeiw = new SimpleDateFormat("MMMM '('dd/MM/yyyy')'", new Locale("pt", "BR"));
            PdfPCell cellAno = new PdfPCell(new Phrase(sdfVeiw.format(new Date()), fontCorpoNGT));
            cellAno.setBorder(0);
            cellAno.setPaddingBottom(20f);
            pTableAno.addCell(cellAno);

            documento.add(pTableAno);

            PdfPTable pTableDetalhesPagamento = new PdfPTable(new float[] { 100 });
            pTableDetalhesPagamento.setWidthPercentage(90f);
            PdfPCell cellDetalhesPagamento = new PdfPCell();

            Paragraph pDetalhesPagamento = new Paragraph();
            pDetalhesPagamento.add(new Paragraph("\nDetalhes de Pagamento ", fontCorpoNG));

            pDetalhesPagamento.add(new Phrase("Beneficirio: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(toString(hashMap.get(BENEFICIARIO)) + "\n", fontCorpo));
            pDetalhesPagamento.add(new Phrase("Descrio do pagamento: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(toString(hashMap.get(DESCRICAOPAGAMENTO)), fontCorpo));
            pDetalhesPagamento.add(new Paragraph("CONFORME APROVADO\n\n", fontCorpoN));

            pDetalhesPagamento.add(new Paragraph("Valor Pagamento", fontCorpoNG));
            pDetalhesPagamento.add(new Phrase("Valor Numerico: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(
                    toMoeda(hashMap.get(VALORPAGAMENTO), toString(hashMap.get(SIGLA))) + "\n", fontCorpo));
            System.err.println(toString(hashMap.get(RETENCAOFONTE)) + " hfhfh retensao");
            if (toString(hashMap.get(RETENCAOFONTE)).trim().equals("1")) {
                double ret = getValorImportRetensao();
                pDetalhesPagamento.add(new Phrase("Valor Retensao Fonte: ", fontCorpoN));
                pDetalhesPagamento.add(new Phrase(toMoeda(ret, "%") + "\n", fontCorpo));
                pDetalhesPagamento.add(new Phrase("Valor Retido: ", fontCorpoN));
                double valret = toDouble(hashMap.get(VALORPAGAMENTO)) * ret;
                pDetalhesPagamento
                        .add(new Phrase(toMoeda(valret, toString(hashMap.get(SIGLA))) + "\n", fontCorpo));
            }

            JTextPane jtp = new JTextPane();
            Double valor = Double.valueOf((hashMap.get(VALORPAGAMENTO) + ""));
            Moeda.EscreverEstenso(valor, jtp, toString(hashMap.get(MOEDA)));

            pDetalhesPagamento.add(new Phrase("Valor por Extenso: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(jtp.getText().trim() + " \n\n", fontCorpo));

            pDetalhesPagamento.add(new Paragraph("Descrio da Conta", fontCorpoNG));
            pDetalhesPagamento.add(new Phrase("Cod Conta: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(hashMap.get(CODIGOCONTAPAGAMENTO) + "\n", fontCorpo));
            pDetalhesPagamento.add(new Phrase("Titulo da Conta: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(hashMap.get(TITULOCONTAPAGAMENTO) + "\n", fontCorpo));

            /**
             * For alter
             */
            //                pDetalhesPagamento.add(new Phrase("Forma de Pagamento: ", fontCorpoN));
            //                pDetalhesPagamento.add(new Phrase(hashMap.get(FORMAPAGAMENTO) + " \n", fontCorpo));
            pDetalhesPagamento.add(new Phrase("Documento de Pagamento: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(toString(hashMap.get(DESCRICAOCONTABANCO)) + " - "
                    + toString(hashMap.get(DOCFORMAPAGAMENTO)) + "\n\n", fontCorpo));
            pDetalhesPagamento.add(new Paragraph(" ", fontCorpoN));

            cellDetalhesPagamento.addElement(pDetalhesPagamento);
            pTableDetalhesPagamento.addCell(cellDetalhesPagamento);

            cellDetalhesPagamento = new PdfPCell();
            pDetalhesPagamento = new Paragraph();

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpo));
            pDetalhesPagamento.add(new Phrase("Preparado por: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(nomeUser + " ", fontCorpoP));
            pDetalhesPagamento.add(new Phrase("            Examinado por", fontCorpoN));
            pDetalhesPagamento.add(new Phrase("____________________\n", fontCorpo));

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpoN));
            pDetalhesPagamento.add(new Paragraph("Pagamento Autorizado por:", fontCorpoNG));

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase("Assinatura: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(" ____________________________________________", fontCorpo));
            pDetalhesPagamento.add(new Phrase("    Data ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(" ______________________\n\n", fontCorpo));

            pDetalhesPagamento.add(new Phrase("Assinatura: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(" ____________________________________________", fontCorpo));
            pDetalhesPagamento.add(new Phrase("    Data ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(" ______________________\n", fontCorpo));

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpo));
            pDetalhesPagamento.add(new Paragraph(
                    "............................................................................."
                            + "...........................................................................",
                    fontCorpoN));

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpo));
            Paragraph pReceip = new Paragraph("RECIBO", fontCorpoN);
            pReceip.setAlignment(Element.ALIGN_CENTER);
            pDetalhesPagamento.add(pReceip);

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpo));
            pDetalhesPagamento.add(new Phrase("Recebi o valor de: ", fontCorpo));
            pDetalhesPagamento.add(new Phrase(jtp.getText() + " \n", fontCorpoNU));

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpoN));

            PdfPTable pTableNumCheque = new PdfPTable(
                    new float[] { 33.3333333333f, 33.3333333333f, 33.3333333333f });
            pTableNumCheque.setWidthPercentage(90f);
            pTableNumCheque.setWidthPercentage(100f);

            PdfPCell cellNumCheque = new PdfPCell(new Phrase("_______________________", fontCorpo));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);
            cellNumCheque = new PdfPCell(new Phrase("_______________________", fontCorpo));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);
            cellNumCheque = new PdfPCell(new Phrase("_______________________", fontCorpo));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);

            cellNumCheque = new PdfPCell(new Phrase("Cheque No.", fontCorpoN));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);
            cellNumCheque = new PdfPCell(new Phrase("Data", fontCorpoN));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);
            cellNumCheque = new PdfPCell(new Phrase("Receiver Name & Signature", fontCorpoN));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);

            pDetalhesPagamento.add(pTableNumCheque);

            pDetalhesPagamento.add(new Phrase(
                    "\nNOTA: Um recibo oficial pode ser obtido por um pagamento e informado na parte inversa deste comprovativo. \n\n",
                    fontCorpo));

            cellDetalhesPagamento.addElement(pDetalhesPagamento);

            pTableDetalhesPagamento.addCell(cellDetalhesPagamento);

            documento.add(pTableDetalhesPagamento);

            if (i != size) {
                documento.newPage();
            }
        }

        documento.close();
        String ret = "../Documentos/" + user + "/Pagamentos/" + "Pagamentos Func " + Ddata + ".pdf";

        RequestContext.getCurrentInstance().execute("openAllDocument('" + ret + "')");

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