Example usage for com.itextpdf.text.pdf PdfPTable setWidths

List of usage examples for com.itextpdf.text.pdf PdfPTable setWidths

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfPTable setWidths.

Prototype

public void setWidths(final int relativeWidths[]) throws DocumentException 

Source Link

Document

Sets the relative widths of the table.

Usage

From source file:org.sharegov.cirm.utils.PDFExportUtil.java

License:Apache License

private static void createTable(Section subCatPart, Json allData) throws DocumentException {

    Json metaData = allData.at("metaData");
    PdfPTable table = null;
    PdfPCell c1 = null;//from w  w w . j  a  v a 2 s  .c o  m

    int columns = metaData.at("columns").asInteger();
    table = new PdfPTable(columns);
    table.setWidthPercentage(100);
    if (columns == 9) {
        int[] widths = { 10, 20, 12, 12, 4, 6, 6, 8, 8 };
        table.setWidths(widths);
    } else {
        int[] widths = { 10, 25, 12, 12, 4, 6, 6, 8 };
        table.setWidths(widths);
    }
    // t.setBorderColor(BaseColor.GRAY);
    // t.setPadding(4);
    // t.setSpacing(4);
    // t.setBorderWidth(1);

    c1 = new PdfPCell(new Phrase(metaData.at("boid").asString(), smallBold));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
    table.addCell(c1);
    c1 = new PdfPCell(new Phrase(metaData.at("type").asString(), smallBold));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
    table.addCell(c1);
    c1 = new PdfPCell(new Phrase(metaData.at("fullAddress").asString(), smallBold));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
    table.addCell(c1);
    c1 = new PdfPCell(new Phrase(metaData.at("city").asString(), smallBold));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
    table.addCell(c1);
    c1 = new PdfPCell(new Phrase(metaData.at("zip").asString(), smallBold));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
    table.addCell(c1);
    c1 = new PdfPCell(new Phrase(metaData.at("hasStatus").asString(), smallBold));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
    table.addCell(c1);
    c1 = new PdfPCell(new Phrase(metaData.at("createdDate").asString(), smallBold));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
    table.addCell(c1);
    c1 = new PdfPCell(new Phrase(metaData.at("lastActivityUpdatedDate").asString(), smallBold));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
    table.addCell(c1);
    if (columns == 9) {
        c1 = new PdfPCell(new Phrase(metaData.at("gisColumn").asString(), smallBold));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
        table.addCell(c1);
    }
    table.setHeaderRows(1);

    List<Json> data = allData.at("data").asJsonList();
    for (Json dataValue : data) {
        if (!dataValue.at("hasCaseNumber").asString().isEmpty())
            c1 = new PdfPCell(new Phrase(dataValue.at("hasCaseNumber").asString(), smallFont));
        else
            c1 = new PdfPCell(new Phrase(GenUtils.makeCaseNumber(dataValue.at("boid").asLong()), smallFont));
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase(dataValue.at("label").asString(), smallFont));
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase(dataValue.at("fullAddress").asString(), smallFont));
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase(dataValue.at("Street_Address_City").asString(), smallFont));
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase(dataValue.at("Zip_Code").asString(), smallFont));
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase(dataValue.at("hasStatus").asString(), smallFont));
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase(dataValue.at("hasDateCreated").asString(), smallFont));
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase(dataValue.at("lastActivityUpdatedDate").asString(), smallFont));
        table.addCell(c1);
        if (columns == 9) {
            c1 = new PdfPCell(new Phrase(dataValue.at("gisColumn").asString(), smallFont));
            table.addCell(c1);
        }
    }

    subCatPart.add(table);
}

From source file:org.sharegov.cirm.utils.PDFViewReport.java

License:Apache License

private void addTopTable(Section subCatPart, Json data) throws DocumentException {
    PdfPTable table = new PdfPTable(4);
    table.setWidthPercentage(100);/*from   w w w  .j  a  v  a2 s .c om*/
    int[] widths = { 12, 55, 15, 20 };
    table.setWidths(widths);

    PdfPCell cell = null;

    OWLNamedIndividual typeInd = individual(legacyPrefix + data.at("type").asString());
    addCell(cell, table, "Type:", Element.ALIGN_RIGHT, boldFont, null);
    addCell(cell, table, getEntityLabel(typeInd), Element.ALIGN_LEFT, normalFont, null);
    addCell(cell, table, "SR #:", Element.ALIGN_RIGHT, boldFont, null);
    if (data.at("properties").has("hasCaseNumber"))
        addCell(cell, table, data.at("properties").at("hasCaseNumber").asString(), Element.ALIGN_LEFT,
                normalFont, null);
    else
        addCell(cell, table, GenUtils.makeCaseNumber(data.at("boid").asLong()), Element.ALIGN_LEFT, normalFont,
                null);
    //02-20-2014 - Syed add providedby to report
    addCell(cell, table, "Area:", Element.ALIGN_RIGHT, boldFont, null);
    addCell(cell, table, getArea(typeInd), Element.ALIGN_LEFT, normalFont, null);
    addCell(cell, table, "Priority:", Element.ALIGN_RIGHT, boldFont, null);
    addCell(cell, table, data.at("properties").at("hasPriority").at("label").asString(), Element.ALIGN_LEFT,
            normalFont, null);
    addCell(cell, table, "Group:", Element.ALIGN_RIGHT, boldFont, null);
    addCell(cell, table, getGroup(typeInd), Element.ALIGN_LEFT, normalFont, null);
    addCell(cell, table, "Status:", Element.ALIGN_RIGHT, boldFont, null);
    addCell(cell, table, getEntityLabel(individual(data.at("properties"), "hasStatus")), Element.ALIGN_LEFT,
            normalFont, null);

    addCell(cell, table, "Jurisdiction:", Element.ALIGN_RIGHT, boldFont, null);
    OWLLiteral jurisdiction = dataProperty(typeInd, legacyPrefix + "hasJurisdictionDescription");
    addCell(cell, table, jurisdiction != null ? jurisdiction.getLiteral() : emptyField, Element.ALIGN_LEFT,
            normalFont, null);
    addCell(cell, table, "Status Date:", Element.ALIGN_RIGHT, boldFont, null);
    String modifiedDate = data.at("properties").has("hasDateLastModified")
            ? data.at("properties").at("hasDateLastModified").asString()
            : "";
    addCell(cell, table, formatDate(modifiedDate, true, false), Element.ALIGN_LEFT, normalFont, null);

    addCell(cell, table, "Input By:", Element.ALIGN_RIGHT, boldFont, null);
    String inputBy = data.at("properties").has("isCreatedBy")
            ? data.at("properties").at("isCreatedBy").asString()
            : emptyField;
    addCell(cell, table, inputBy, Element.ALIGN_LEFT, normalFont, null);
    addCell(cell, table, "Created Date:", Element.ALIGN_RIGHT, boldFont, null);
    String createdDate = data.at("properties").has("hasDateCreated")
            ? data.at("properties").at("hasDateCreated").asString()
            : "";
    addCell(cell, table, formatDate(createdDate, true, false), Element.ALIGN_LEFT, normalFont, null);

    addCell(cell, table, "CC Groups:", Element.ALIGN_RIGHT, boldFont, null);
    addCell(cell, table, blankField, Element.ALIGN_LEFT, normalFont, null);
    addCell(cell, table, "Created By:", Element.ALIGN_RIGHT, boldFont, null);
    addCell(cell, table, getEmployeeName(inputBy), Element.ALIGN_LEFT, normalFont, null);

    addCell(cell, table, "Location:", Element.ALIGN_RIGHT, boldFont, null);
    addCell(cell, table,
            data.at("properties").has("atAddress") ? buildAddress(data.at("properties").at("atAddress"))
                    : blankField,
            Element.ALIGN_LEFT, normalFont, null);
    addCell(cell, table, "Method Received:", Element.ALIGN_RIGHT, boldFont, null);
    addCell(cell, table, data.at("properties").at("hasIntakeMethod").at("label").asString(), Element.ALIGN_LEFT,
            normalFont, null);

    subCatPart.add(table);
    subCatPart.add(new Chunk(new LineSeparator()));
}

From source file:org.sharegov.cirm.utils.PDFViewReport.java

License:Apache License

private void addDescription(Section subCatPart, Json data) throws DocumentException {
    PdfPTable table = new PdfPTable(2);
    table.setWidthPercentage(100);/*w  ww.j  av a 2 s . co m*/
    int[] widths = { 15, 85 };
    table.setWidths(widths);

    PdfPCell cell = null;

    addCell(cell, table, "Description:", Element.ALIGN_LEFT, bigBoldFont, null);
    if (data.at("properties").has("hasDetails"))
        addCell(cell, table, data.at("properties").at("hasDetails").asString(), Element.ALIGN_LEFT, normalFont,
                null);

    subCatPart.add(table);
    subCatPart.add(new Chunk(new LineSeparator()));
}

From source file:org.sharegov.cirm.utils.PDFViewReport.java

License:Apache License

private void addQuestions(Section subCatPart, Json data)
        throws DocumentException, UnsupportedEncodingException {
    PdfPTable table = new PdfPTable(2);
    table.setWidthPercentage(100);/*from   w  w  w .j  a v a2  s .c o  m*/
    int[] widths = { 65, 35 };
    table.setWidths(widths);

    PdfPCell cell = null;

    addCell(cell, table, "SR Questions", Element.ALIGN_LEFT, bigBoldFont, null);
    addCell(cell, table, "Answers", Element.ALIGN_LEFT, bigBoldFont, null);

    subCatPart.add(table);
    //subCatPart.add(Chunk.NEWLINE);
    //subCatPart.add(new Chunk(new LineSeparator()));

    table = new PdfPTable(2);
    table.setWidthPercentage(100);
    table.setWidths(widths);

    OWLNamedIndividual typeInd = individual(legacyPrefix + data.at("type").asString());
    List<Json> allServiceAnswers = new ArrayList<Json>();
    LegacyEmulator.getAllServiceFields(typeInd, allServiceAnswers, true);

    List<Json> saList = getAllServiceAnswers(data);

    for (int k = 0; k < allServiceAnswers.size(); k++) {
        Json serviceAnswer = allServiceAnswers.get(k);
        BaseColor color = addColor(k);
        int counter = 0;
        addCell(cell, table, serviceAnswer.at("hasServiceField").at("label").asString(), Element.ALIGN_LEFT,
                normalFont, color);
        for (Json sa : saList) {
            if (sa.at("hasServiceField").at("iri").asString()
                    .equals(serviceAnswer.at("hasServiceField").at("iri").asString())) {
                OWLIndividual qtn = individual(sa.at("hasServiceField").at("iri").asString());
                OWLObjectProperty cvl = objectProperty(legacyPrefix + "hasChoiceValueList");

                if (sa.has("hasAnswerValue")) {
                    if (sa.at("hasAnswerValue").at("literal").isArray()) {
                        List<Json> literalList = sa.at("hasAnswerValue").at("literal").asJsonList();
                        for (int i = 0; i < literalList.size(); i++) {
                            String eachAns = literalList.get(i).asString();
                            addCell(cell, table, eachAns, Element.ALIGN_LEFT, normalFont, color);
                            if (i != literalList.size() - 1)
                                addCell(cell, table, blankField, Element.ALIGN_LEFT, normalFont, color);
                        }
                    } else {
                        String ans = sa.at("hasAnswerValue").at("literal").asString();
                        if (serviceAnswer.at("hasDataType").asString().equals("NUMBER"))
                            ans = Long.toString(new BigDecimal(ans).longValue());
                        if (serviceAnswer.at("hasDataType").asString().equals("DATE"))
                            ans = formatDate(ans, false, false);
                        addCell(cell, table, ans, Element.ALIGN_LEFT, normalFont, color);

                    }
                } else if (sa.has("hasAnswerObject")) {
                    if (sa.at("hasAnswerObject").isArray()) {
                        List<Json> answerObjectList = sa.at("hasAnswerObject").asJsonList();
                        for (int i = 0; i < answerObjectList.size(); i++) {
                            Json eachAnswerObject = answerObjectList.get(i);
                            //OWL.objectProperties(qtn, cvl.getIRI().toString());
                            if (!OWL.collectObjectProperties(qtn, cvl).isEmpty()
                                    && !containsWhiteSpace(eachAnswerObject.at("iri").asString())) {
                                addCell(cell, table,
                                        getEntityLabel(individual(eachAnswerObject.at("iri").asString())),
                                        Element.ALIGN_LEFT, normalFont, color);
                                if (i != answerObjectList.size() - 1)
                                    addCell(cell, table, blankField, Element.ALIGN_LEFT, normalFont, color);
                            }
                        }
                    } else {
                        String ans = sa.at("hasAnswerObject").at("iri").asString();
                        if (!OWL.collectObjectProperties(qtn, cvl).isEmpty() && !containsWhiteSpace(ans)) {
                            addCell(cell, table, getEntityLabel(individual(ans)), Element.ALIGN_LEFT,
                                    normalFont, color);
                        } else
                            addCell(cell, table, ans, Element.ALIGN_LEFT, normalFont, color);
                    }
                }
                ++counter;
            } else
                continue;
        }
        if (counter == 0)
            addCell(cell, table, emptyField, Element.ALIGN_LEFT, normalFont, color);
    }
    subCatPart.add(table);
    subCatPart.add(new Chunk(new LineSeparator()));
}

From source file:org.sharegov.cirm.utils.PDFViewReport.java

License:Apache License

private void addActors(Section subCatPart, Json data) throws DocumentException {
    if (data.at("properties").has("hasServiceCaseActor")) {
        int iActorHeaderColumns = 5;
        int iActorColumns = 6;
        PdfPTable table = new PdfPTable(iActorHeaderColumns);
        table.setWidthPercentage(100);/*from www  .j  a  v a2 s .  com*/
        int[] headerWidths = { 15, 15, 25, 18, 22 };
        int[] widths = { 15, 15, 25, 18, 5, 17 };
        table.setWidths(headerWidths);
        PdfPCell cell = null;

        addCell(cell, table, "Customer", Element.ALIGN_LEFT, bigBoldFont, null);
        addCell(cell, table, "Name", Element.ALIGN_LEFT, bigBoldFont, null);
        addCell(cell, table, "Address", Element.ALIGN_LEFT, bigBoldFont, null);
        addCell(cell, table, "e-Mail", Element.ALIGN_LEFT, bigBoldFont, null);
        addCell(cell, table, "Contact No", Element.ALIGN_LEFT, bigBoldFont, null);

        subCatPart.add(table);
        //subCatPart.add(Chunk.NEWLINE);
        //subCatPart.add(new Chunk(new LineSeparator()));

        table = new PdfPTable(iActorColumns);
        table.setWidthPercentage(100);
        table.setWidths(widths);

        if (!data.at("properties").at("hasServiceCaseActor").isArray()) {
            data.at("properties").set("hasServiceCaseActor",
                    Json.array().add(data.at("properties").at("hasServiceCaseActor")));
        }

        for (int k = 0; k < data.at("properties").at("hasServiceCaseActor").asJsonList().size(); k++) {
            Json actor = data.at("properties").at("hasServiceCaseActor").at(k);
            BaseColor color = addColor(k);
            OWLNamedIndividual act = individual(actor, "hasServiceActor");
            String actorType = getEntityLabel(act);

            StringBuilder actorName = new StringBuilder();
            if (actor.has("Name"))
                actorName.append(actor.at("Name").asString());
            if (actor.has("LastName")) {
                if (actorName.toString().isEmpty())
                    actorName.append(actor.at("LastName").asString());
                else
                    actorName.append(" ").append(actor.at("LastName").asString());
            }
            if (actorName.toString().isEmpty())
                actorName.append(blankField);

            StringBuilder actorAddr = new StringBuilder();
            if (actor.has("atAddress")) {
                Json addr = actor.at("atAddress");
                if (addr.has("fullAddress"))
                    actorAddr.append(addr.at("fullAddress").asString());
                if (addr.has("Street_Unit_Number"))
                    actorAddr.append(", #").append(addr.at("Street_Unit_Number").asString());
                if (addr.has("Street_Address_City")) {
                    OWLNamedIndividual cityInd = individual(addr, "Street_Address_City");
                    OWLLiteral city = dataProperty(cityInd, "Name");
                    if (city == null)
                        city = dataProperty(cityInd, "Alias");
                    if (city != null)
                        actorAddr.append(", ").append(city.getLiteral());
                }
                if (addr.has("fullAddress") && addr.has("Street_Address_State")) {
                    OWLNamedIndividual stateInd = individual(addr, "Street_Address_State");
                    OWLLiteral state = dataProperty(stateInd, "USPS_Abbreviation");
                    if (state != null)
                        actorAddr.append(", ").append(state.getLiteral());
                }
                if (addr.has("Zip_Code"))
                    actorAddr.append(" - ").append(addr.at("Zip_Code").asString());
            } else
                actorAddr.append(blankField);

            String eMail = actor.has("hasEmailAddress") ? actor.at("hasEmailAddress").isObject()
                    ? actor.at("hasEmailAddress").at("iri").asString().split(":")[1]
                    : actor.at("hasEmailAddress").asString().split(":")[1] : blankField;

            addCell(cell, table, actorType, Element.ALIGN_LEFT, normalFont, color);
            addCell(cell, table, actorName.toString(), Element.ALIGN_LEFT, normalFont, color);
            addCell(cell, table, actorAddr.toString(), Element.ALIGN_LEFT, normalFont, color);
            addCell(cell, table, eMail, Element.ALIGN_LEFT, normalFont, color);

            boolean isFirstContactNo = true;
            String actorHmPh = actor.has("HomePhoneNumber") ? actor.at("HomePhoneNumber").asString() : null;
            String actorCellNo = actor.has("CellPhoneNumber") ? actor.at("CellPhoneNumber").asString() : null;
            String actorBizNo = actor.has("BusinessPhoneNumber") ? actor.at("BusinessPhoneNumber").asString()
                    : null;
            String actorFaxNo = actor.has("FaxNumber") ? actor.at("FaxNumber").asString() : null;
            String actorOtherNo = actor.has("OtherPhoneNumber") ? actor.at("OtherPhoneNumber").asString()
                    : null;

            if (actorHmPh != null)
                isFirstContactNo = addActorsContactNumbers(table, cell, actorHmPh, "Home ", iActorColumns,
                        color, isFirstContactNo);
            if (actorCellNo != null)
                isFirstContactNo = addActorsContactNumbers(table, cell, actorCellNo, "Cell ", iActorColumns,
                        color, isFirstContactNo);
            if (actorBizNo != null)
                isFirstContactNo = addActorsContactNumbers(table, cell, actorBizNo, "Biz ", iActorColumns,
                        color, isFirstContactNo);
            if (actorFaxNo != null)
                isFirstContactNo = addActorsContactNumbers(table, cell, actorFaxNo, "Fax ", iActorColumns,
                        color, isFirstContactNo);
            if (actorOtherNo != null)
                isFirstContactNo = addActorsContactNumbers(table, cell, actorOtherNo, "Other ", iActorColumns,
                        color, isFirstContactNo);
            if (actorHmPh == null && actorCellNo == null && actorBizNo == null && actorFaxNo == null
                    && actorOtherNo == null) {
                addCell(cell, table, blankField, Element.ALIGN_LEFT, normalFont, color);
                addCell(cell, table, blankField, Element.ALIGN_LEFT, normalFont, color);
            }
        }
        subCatPart.add(table);
        subCatPart.add(new Chunk(new LineSeparator()));
    }
}

From source file:org.sharegov.cirm.utils.PDFViewReport.java

License:Apache License

private void addActivities(Section subCatPart, Json data) throws DocumentException {
    if (data.at("properties").has("hasServiceActivity")) {
        if (!data.at("properties").at("hasServiceActivity").isArray()) {
            data.at("properties").set("hasServiceActivity",
                    Json.array().add(data.at("properties").at("hasServiceActivity")));
        }/*from ww w . j av a 2s  .  c  o m*/
        Json filteredActivities = Json.array();
        //Do not add any StatusChangeActivity Activities to the report
        for (Json act : data.at("properties").at("hasServiceActivity").asJsonList()) {
            OWLNamedIndividual actInd = individual(act, "hasActivity");
            if (!actInd.getIRI().getFragment().equals("StatusChangeActivity"))
                filteredActivities.add(act);
        }

        if (filteredActivities.asJsonList().size() > 0) {
            //PdfPTable table = new PdfPTable(7);
            PdfPTable table = new PdfPTable(6);
            table.setWidthPercentage(100);
            //int[] widths = {17, 13, 12, 12, 13, 13, 20};
            int[] widths = { 25, 20, 13, 12, 13, 17 };
            table.setWidths(widths);
            PdfPCell cell = null;

            addCell(cell, table, "Activity", Element.ALIGN_LEFT, bigBoldFont, null);
            addCell(cell, table, "Assigned To", Element.ALIGN_LEFT, bigBoldFont, null);
            addCell(cell, table, "Created Date", Element.ALIGN_LEFT, bigBoldFont, null);
            addCell(cell, table, "Due Date", Element.ALIGN_LEFT, bigBoldFont, null);
            addCell(cell, table, "Completed Date", Element.ALIGN_LEFT, bigBoldFont, null);
            addCell(cell, table, "Outcome", Element.ALIGN_LEFT, bigBoldFont, null);
            //addCell(cell, table, "Details", Element.ALIGN_LEFT, bigBoldFont);

            subCatPart.add(table);
            //subCatPart.add(Chunk.NEWLINE);
            //subCatPart.add(new Chunk(new LineSeparator()));

            //table = new PdfPTable(7);
            //table = new PdfPTable(6);
            //table.setWidthPercentage(100);
            //table.setWidths(widths);

            //Store all outcome iris(key), labels(value).
            //Because in case of duplicate outcomes all outcome values (except the first) will be a string and not object
            Map<String, String> outcomeMap = new HashMap<String, String>(10);

            //for (int k = 0; k < data.at("properties").at("hasServiceActivity").asJsonList().size(); k++)
            for (int k = 0; k < filteredActivities.asJsonList().size(); k++) {
                Json activity = filteredActivities.at(k);
                BaseColor color = addColor(k);
                OWLIndividual act = individual(activity, "hasActivity");
                OWLLiteral typeLabel = null;
                for (OWLAnnotation ann : OWL.annotations(act.asOWLNamedIndividual())) {
                    if (ann.getProperty().isLabel())
                        typeLabel = (OWLLiteral) ann.getValue();
                }

                String activityType = typeLabel == null ? "" : typeLabel.getLiteral();
                String assignedTo = activity.has("isAssignedTo") ? activity.at("isAssignedTo").asString()
                        : blankField;
                String createdDate = activity.has("hasDateCreated") ? activity.at("hasDateCreated").asString()
                        : blankField;
                String dueDate = activity.has("hasDueDate") ? activity.at("hasDueDate").asString() : blankField;
                String completedDate = activity.has("hasCompletedTimestamp")
                        ? activity.at("hasCompletedTimestamp").asString()
                        : blankField;
                String details = activity.has("hasDetails") ? activity.at("hasDetails").asString() : blankField;
                StringBuilder outcome = new StringBuilder("");
                if (activity.has("hasOutcome")) {
                    if (activity.at("hasOutcome").isObject()) {
                        if (!outcomeMap.containsKey(activity.at("hasOutcome").at("iri").asString())) {
                            outcomeMap.put(activity.at("hasOutcome").at("iri").asString(),
                                    activity.at("hasOutcome").at("label").asString());
                            outcome.append(activity.at("hasOutcome").at("label").asString());
                        }
                    } else if (activity.at("hasOutcome").isString()) {
                        if (outcomeMap.containsKey(activity.at("hasOutcome").asString()))
                            outcome.append(outcomeMap.get(activity.at("hasOutcome").asString()));
                        else
                            outcome.append(OWL.fullIri(activity.at("hasOutcome").asString()).getFragment());
                    }
                }

                //table = new PdfPTable(7);
                table = new PdfPTable(6);
                table.setWidthPercentage(100);
                table.setWidths(widths);

                addCell(cell, table, activityType, Element.ALIGN_LEFT, normalFont, color);
                addCell(cell, table, getEmployeeName(assignedTo), Element.ALIGN_LEFT, normalFont, color);
                addCell(cell, table, formatDate(createdDate, false, false), Element.ALIGN_LEFT, normalFont,
                        color);
                addCell(cell, table, formatDate(dueDate, false, false), Element.ALIGN_LEFT, normalFont, color);
                addCell(cell, table, formatDate(completedDate, true, false), Element.ALIGN_LEFT, normalFont,
                        color);
                addCell(cell, table, outcome.toString(), Element.ALIGN_LEFT, normalFont, color);
                subCatPart.add(table);
                if (!details.equals(blankField)) {
                    table = new PdfPTable(2);
                    table.setWidthPercentage(100);
                    int[] detailsWitdh = { 10, 90 };
                    table.setWidths(detailsWitdh);
                    addCell(cell, table, "Details: ", Element.ALIGN_LEFT, normalFont, color);
                    addCell(cell, table, details, Element.ALIGN_LEFT, normalFont, color);
                    subCatPart.add(table);
                }
            }
            //subCatPart.add(table);
            subCatPart.add(new Chunk(new LineSeparator()));
        }
    }
}

From source file:org.sharegov.cirm.utils.PDFViewReport.java

License:Apache License

private void addWASDHeader(Chapter chapter) throws DocumentException {
    try {// ww  w .  jav a  2  s. c  o m
        String img = StartUp.config.at("workingDir").asString() + "/src/html/images/md-logo.png";
        Image logo = Image.getInstance(img);
        logo.scalePercent(67);

        PdfPTable table = new PdfPTable(2);
        table.setWidthPercentage(100);
        int[] widths = { 50, 50 };
        table.setWidths(widths);
        //table.addCell(logo); //This exactly fits the image to the size of the cell.
        PdfPCell cell = new PdfPCell(logo);
        cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);
        String str1 = "Miami-Dade Water and Sewer Department";
        String str2 = "P.O.Box 33016 . 3071 SW 38 Ave";
        String str3 = "Miami, Florida 33146";
        String str4 = "T: 786-552-8974";
        String str5 = "www.miamidade.gov";
        PdfPTable wasdTable = new PdfPTable(1);
        addCell(wasdTable, str1, Element.ALIGN_RIGHT, boldFont, null);
        addCell(wasdTable, str2, Element.ALIGN_RIGHT, normalFont, null);
        addCell(wasdTable, str3, Element.ALIGN_RIGHT, normalFont, null);
        addCell(wasdTable, str4, Element.ALIGN_RIGHT, normalFont, null);
        addCell(wasdTable, str5, Element.ALIGN_RIGHT, boldFont, null);
        cell = new PdfPCell(wasdTable);
        cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);
        addSection(chapter).add(table);
    } catch (Exception e) {
        e.printStackTrace();
        throw new RuntimeException(e.getMessage());
    }
}

From source file:org.techytax.report.helper.PdfReportHelper.java

License:Open Source License

private void addJournalsOut(VatReportData vatReportData, PdfPTable table) throws DocumentException {
    PdfPCell cell;/*from w  ww  .  j a  v a 2 s  .co m*/
    Paragraph chunk;
    PdfPTable subTable;
    PdfPCell tableCell;
    Paragraph chunkMoney;
    for (VatJournal vatJournal : vatReportData.getVatJournalsOut().getVatJournals()) {
        subTable = new PdfPTable(4);
        chunk = new Paragraph("btw uit post: " + vatJournal.getCostType(), headerFont);
        cell = new PdfPCell(chunk);
        cell.setColspan(4);
        subTable.addCell(cell);

        subTable.setWidths(new int[] { 1, 1, 8, 1 });
        createTableHeader(headerFont, subTable);
        for (Cost cost : vatJournal.getJournalCosts()) {
            createTableRow(cost, font, subTable);
        }

        cell = new PdfPCell(new Paragraph("Totaal", headerFont));
        subTable.addCell(cell);
        cell = new PdfPCell();
        cell.setBorder(PdfPCell.NO_BORDER);
        subTable.addCell(cell);
        chunkMoney = new Paragraph(AmountHelper.formatDecimal(vatJournal.getTotalAmount()), totalAmountFont);
        cell = new PdfPCell(chunkMoney);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setColspan(2);
        subTable.addCell(cell);

        tableCell = new PdfPCell(subTable);
        table.addCell(tableCell);

        addSpace(table);
    }
}

From source file:org.techytax.report.helper.PdfReportHelper.java

License:Open Source License

private void addJournalsIn(VatReportData vatReportData, PdfPTable table) throws DocumentException {
    PdfPCell cell;/*from  www.ja v a2s.co m*/
    Paragraph chunk;
    PdfPTable subTable;
    PdfPCell tableCell;
    Paragraph chunkMoney;
    for (VatJournal vatJournal : vatReportData.getVatJournalsIn().getVatJournals()) {
        subTable = new PdfPTable(4);
        chunk = new Paragraph("btw in post: " + vatJournal.getCostType(), headerFont);
        cell = new PdfPCell(chunk);
        cell.setColspan(4);
        subTable.addCell(cell);

        subTable.setWidths(new int[] { 1, 1, 8, 1 });
        createTableHeader(headerFont, subTable);
        for (Cost cost : vatJournal.getJournalCosts()) {
            createTableRow(cost, font, subTable);
        }

        cell = new PdfPCell(new Paragraph("Totaal", headerFont));
        subTable.addCell(cell);
        cell = new PdfPCell();
        cell.setBorder(PdfPCell.NO_BORDER);
        subTable.addCell(cell);
        chunkMoney = new Paragraph(AmountHelper.formatDecimal(vatJournal.getTotalAmount()), totalAmountFont);
        cell = new PdfPCell(chunkMoney);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        cell.setBorder(PdfPCell.NO_BORDER);
        cell.setColspan(2);
        subTable.addCell(cell);

        tableCell = new PdfPCell(subTable);
        table.addCell(tableCell);

        addSpace(table);

    }
}

From source file:org.techytax.report.helper.PdfReportHelper.java

License:Open Source License

private void addTotalsIn(VatReportData vatReportData, PdfPTable table) throws DocumentException {
    PdfPCell cell;// w w w  . j  a  v  a 2 s .c o  m

    PdfPTable subTable = new PdfPTable(2);
    subTable.setWidths(new int[] { 8, 2 });

    Paragraph chunk = new Paragraph("btw in overzicht", headerFont);
    cell = new PdfPCell(chunk);
    cell.setBorder(PdfPCell.NO_BORDER);
    cell.setColspan(2);
    subTable.addCell(cell);
    Paragraph headerChunk = new Paragraph("Omschrijving", headerFont);
    cell = new PdfPCell(headerChunk);
    subTable.addCell(cell);
    headerChunk = new Paragraph("Subtotaal", headerFont);
    cell = new PdfPCell(headerChunk);
    subTable.addCell(cell);
    PdfPCell tableCell = new PdfPCell(subTable);
    for (VatJournal vatJournal : vatReportData.getVatJournalsIn().getVatJournals()) {
        cell = new PdfPCell(new Paragraph(vatJournal.getCostType(), font));
        subTable.addCell(cell);
        Paragraph chunkMoney = new Paragraph(AmountHelper.formatDecimal(vatJournal.getTotalAmount()), font);
        cell = new PdfPCell(chunkMoney);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        subTable.addCell(cell);
    }

    cell = new PdfPCell(new Paragraph("Totaal in", headerFont));
    subTable.addCell(cell);
    Paragraph chunkMoney = new Paragraph(
            AmountHelper.formatDecimal(
                    vatReportData.getVatDeclarationData().getValueAddedTaxSuppliesServicesGeneralTariff()),
            totalAmountFont);
    cell = new PdfPCell(chunkMoney);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
    cell.setBorder(PdfPCell.NO_BORDER);
    subTable.addCell(cell);
    tableCell = new PdfPCell(subTable);
    table.addCell(tableCell);
}