Example usage for com.lowagie.text.pdf PdfPCell PdfPCell

List of usage examples for com.lowagie.text.pdf PdfPCell PdfPCell

Introduction

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

Prototype

public PdfPCell(PdfPCell cell) 

Source Link

Document

Constructs a deep copy of a PdfPCell.

Usage

From source file:org.cgiar.ccafs.ap.summaries.projects.pdf.ProjectSummaryPDF.java

License:Open Source License

/**
 * @param deliverable deliverable to add in the summary
 * @param counter number of deliverable/*  www  .j a  v a  2s.  co  m*/
 **/
private void addDelivable(Deliverable deliverable, int counter) {
    try {
        if (deliverable != null) {

            PdfPTable table = new PdfPTable(2);
            table.setTotalWidth(480);
            table.setLockedWidth(true);

            StringBuilder stringBuilder = new StringBuilder();
            PdfPCell cell_new;

            // **** Expected Deliverable #*********
            Paragraph deliverableBlock = new Paragraph();
            deliverableBlock.setFont(HEADING4_FONT);
            if (project.isReporting()) {
                deliverableBlock.add(this.getText("summaries.project.deliverable") + " #" + counter);
            } else {
                if (deliverable.getYear() < config.getPlanningCurrentYear()) {
                    deliverableBlock.add(this.getText("summaries.project.deliverable") + " #" + counter);
                } else {
                    deliverableBlock
                            .add(this.getText("summaries.project.deliverable.expected") + " #" + counter);
                }

            }

            deliverableBlock.add(Chunk.NEWLINE);
            deliverableBlock.add(Chunk.NEWLINE);
            document.add(deliverableBlock);

            // **** Deliverable Information *********
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(BODY_TEXT_BOLD_FONT);
            deliverableBlock.setAlignment(Element.ALIGN_LEFT);
            deliverableBlock.setFont(TABLE_HEADER_FONT);
            deliverableBlock.add(this.getText("summaries.project.deliverable.information"));

            cell_new = new PdfPCell(deliverableBlock);
            cell_new.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell_new.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell_new.setBackgroundColor(TABLE_HEADER_BACKGROUND);
            cell_new.setUseBorderPadding(true);
            cell_new.setPadding(3);
            cell_new.setBorderColor(TABLE_CELL_BORDER_COLOR);
            cell_new.setColspan(2);

            this.addTableHeaderCell(table, cell_new);

            // Title
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.deliverable.information.title") + ": ");

            deliverableBlock.setFont(TABLE_BODY_FONT);
            deliverableBlock.add(this.messageReturn(deliverable.getTitle()));
            deliverableBlock.add(Chunk.NEWLINE);
            ;
            // document.add(deliverableBlock);
            this.addTableColSpanCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1, 2);

            // MOG

            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            if (deliverable.getOutput() != null) {
                stringBuilder = new StringBuilder();
                if (deliverable.getOutput().getProgram() != null
                        && deliverable.getOutput().getProgram().getAcronym() != null) {
                    stringBuilder.append(deliverable.getOutput().getProgram().getAcronym());
                    stringBuilder.append(" - MOG # ");
                } else {
                    stringBuilder.append("MOG # ");
                }
                stringBuilder.append(this.getMOGIndex(deliverable.getOutput()));
                stringBuilder.append(": ");
                deliverableBlock.add(stringBuilder.toString());
                deliverableBlock.setFont(TABLE_BODY_FONT);
                stringBuilder = new StringBuilder();
                stringBuilder.append(deliverable.getOutput().getDescription());
            } else {
                deliverableBlock.add("MOG :");
                stringBuilder.append(this.getText("summaries.project.empty"));
            }
            deliverableBlock.add(stringBuilder.toString());
            deliverableBlock.add(Chunk.NEWLINE);
            // document.add(deliverableBlock);
            this.addTableColSpanCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1, 2);

            // Main Type
            deliverableBlock = new Paragraph();
            stringBuilder = new StringBuilder();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            stringBuilder.append(this.getText("summaries.project.deliverable.information.main"));
            stringBuilder.append(": ");
            deliverableBlock.add(stringBuilder.toString());

            deliverableBlock.setFont(TABLE_BODY_FONT);
            stringBuilder = new StringBuilder();
            if (deliverable.getType() != null && deliverable.getType().getCategory() != null) {
                stringBuilder.append(this.messageReturn(deliverable.getType().getCategory().getName()));
            } else {
                stringBuilder.append(this.messageReturn(""));
            }
            deliverableBlock.add(stringBuilder.toString());
            deliverableBlock.add(Chunk.NEWLINE);
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1);

            // Sub Type
            deliverableBlock = new Paragraph();
            stringBuilder = new StringBuilder();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            stringBuilder.append(this.getText("summaries.project.deliverable.information.sub"));
            stringBuilder.append(": ");
            deliverableBlock.add(stringBuilder.toString());
            deliverableBlock.setFont(TABLE_BODY_FONT);
            stringBuilder = new StringBuilder();
            if (deliverable.getType() == null) {
                stringBuilder.append(this.messageReturn(this.getText("summaries.project.empty")));
            } else if (deliverable.getType().getId() == 38) {
                stringBuilder.append(this.getText("summaries.project.deliverable.other.expected"));
                stringBuilder.append("(");
                stringBuilder.append(this.messageReturn(deliverable.getTypeOther()));
                stringBuilder.append(")");
            } else {
                stringBuilder.append(this.messageReturn(deliverable.getType().getName()));
            }

            deliverableBlock.add(this.messageReturn(stringBuilder.toString()));
            deliverableBlock.add(Chunk.NEWLINE);
            ;
            // document.add(deliverableBlock);
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

            // Year
            deliverableBlock = new Paragraph();
            stringBuilder = new StringBuilder();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            stringBuilder.append(this.getText("summaries.project.deliverable.information.year"));
            stringBuilder.append(": ");
            deliverableBlock.add(stringBuilder.toString());

            deliverableBlock.setFont(TABLE_BODY_FONT);
            stringBuilder = new StringBuilder();
            stringBuilder.append(deliverable.getYear());
            deliverableBlock.add(stringBuilder.toString());
            deliverableBlock.add(Chunk.NEWLINE);
            // document.add(deliverableBlock);
            this.addTableColSpanCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1, 2);

            // Status
            deliverableBlock = new Paragraph();
            stringBuilder = new StringBuilder();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            stringBuilder.append(this.getText("summaries.project.deliverable.information.statuts"));
            deliverableBlock.add(stringBuilder.toString());

            deliverableBlock.setFont(TABLE_BODY_FONT);
            stringBuilder = new StringBuilder();
            if (deliverable.getStatus() != 0) {
                if (deliverable.getStatus() == Integer.parseInt(ProjectStatusEnum.Cancelled.getStatusId())) {

                    deliverableBlock.setFont(TABLE_BODY_FONT_RED);
                }
                stringBuilder.append(this.statuses.get(String.valueOf(deliverable.getStatus())));
            } else {
                stringBuilder.append(this.messageReturn(null));
            }
            deliverableBlock.add(stringBuilder.toString());
            deliverableBlock.add(Chunk.NEWLINE);
            // document.add(deliverableBlock);

            if (deliverable.isStatusCancelled() || deliverable.isStatusExtended()
                    || deliverable.isStatusOnGoing()) {
                this.addTableColSpanCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1, 1);

                // Justification
                deliverableBlock = new Paragraph();
                stringBuilder = new StringBuilder();
                deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
                stringBuilder.append(this.getText("summaries.project.deliverable.information.justification"));
                deliverableBlock.add(stringBuilder.toString());

                deliverableBlock.setFont(TABLE_BODY_FONT);
                deliverableBlock.add(this.messageReturn(deliverable.getStatusDescription()));
                deliverableBlock.add(Chunk.NEWLINE);

                this.addTableColSpanCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1, 1);

            } else {
                this.addTableColSpanCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1, 2);
            }

            document.add(table);
            deliverableBlock = new Paragraph();
            deliverableBlock.add(Chunk.NEWLINE);
            document.add(deliverableBlock);

            // ********** Next Users**************************************

            counter = 1;
            List<NextUser> nextUsers = deliverable.getNextUsers();
            for (NextUser nextUser : nextUsers) {
                if (nextUser != null) {

                    table = new PdfPTable(1);
                    table.setTotalWidth(480);
                    table.setLockedWidth(true);

                    // Next user title
                    deliverableBlock = new Paragraph();
                    deliverableBlock.setAlignment(Element.ALIGN_LEFT);
                    deliverableBlock.setFont(TABLE_HEADER_FONT);
                    if (nextUsers.size() == 1) {
                        deliverableBlock.add(this.getText("summaries.project.deliverable.next.user"));
                    } else {
                        deliverableBlock
                                .add(this.getText("summaries.project.deliverable.next.user") + " #" + counter);
                    }

                    this.addTableHeaderCell(table, deliverableBlock);

                    // Next user
                    stringBuilder = new StringBuilder();
                    deliverableBlock = new Paragraph();
                    deliverableBlock.setFont(TABLE_BODY_FONT);
                    stringBuilder.append(nextUser.getUser());
                    deliverableBlock.add(this.messageReturn(stringBuilder.toString()));
                    this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1);

                    // Expected Changes
                    stringBuilder = new StringBuilder();
                    deliverableBlock = new Paragraph();
                    deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
                    deliverableBlock
                            .add(this.getText("summaries.project.deliverable.next.user.expected.change"));
                    deliverableBlock.setFont(TABLE_BODY_FONT);
                    stringBuilder.append(this.messageReturn(nextUser.getExpectedChanges()));
                    deliverableBlock.add(stringBuilder.toString());
                    // document.add(deliverableBlock);
                    this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1);

                    // Strategies
                    stringBuilder = new StringBuilder();
                    deliverableBlock = new Paragraph();
                    deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
                    deliverableBlock.add(this.getText("summaries.project.deliverable.next.user.strategies"));
                    deliverableBlock.setFont(TABLE_BODY_FONT);
                    stringBuilder.append(this.messageReturn(nextUser.getStrategies()));
                    deliverableBlock.add(stringBuilder.toString());
                    // document.add(deliverableBlock);
                    this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1);

                    document.add(table);
                    deliverableBlock = new Paragraph();
                    deliverableBlock.add(Chunk.NEWLINE);
                    document.add(deliverableBlock);

                    counter++;
                }

            }
            // ********** Deliverable partnership****************************

            // ******************Partner contributing
            counter = 1;

            table = new PdfPTable(1);
            table.setLockedWidth(true);
            table.setTotalWidth(480);

            // Title partners contributing
            deliverableBlock = new Paragraph();
            deliverableBlock.setAlignment(Element.ALIGN_LEFT);
            deliverableBlock.setFont(TABLE_HEADER_FONT);
            deliverableBlock.add(this.getText("summaries.project.deliverable.partnership"));
            deliverableBlock.setFont(TABLE_HEADER_FONT);
            this.addTableHeaderCell(table, deliverableBlock);

            // Organization
            stringBuilder = new StringBuilder();
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.deliverable.partnership.organization") + " #"
                    + counter + " (Responsible)" + ": ");
            deliverableBlock.setFont(TABLE_BODY_FONT);
            DeliverablePartner deliverableResponsiblePartner = deliverable.getResponsiblePartner();
            PartnerPerson partnerPersonResponsible = null;
            if (deliverableResponsiblePartner != null) {
                partnerPersonResponsible = deliverableResponsiblePartner.getPartner();
            }
            if (deliverableResponsiblePartner != null && partnerPersonResponsible != null) {
                stringBuilder.append(this.messageReturn(partnerPersonResponsible.getComposedName()));
                stringBuilder.append(", ");
                stringBuilder
                        .append(this.mapPartnerPersons.get(String.valueOf(partnerPersonResponsible.getId())));
            } else {
                stringBuilder.append(this.getText("summaries.project.empty"));
            }
            deliverableBlock.add(stringBuilder.toString());
            deliverableBlock.add(Chunk.NEWLINE);
            ;
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1);
            counter = 1;
            // ************** Other Partners
            List<DeliverablePartner> listOtherPartner = deliverable.getOtherPartners();

            PartnerPerson otherResponsiblepartnerPerson = null;

            if (!listOtherPartner.isEmpty()) {
                for (DeliverablePartner deliverablePartner : listOtherPartner) {
                    if (deliverablePartner != null) {
                        counter++;

                        // Title partners contributing
                        deliverableBlock = new Paragraph();
                        deliverableBlock.setAlignment(Element.ALIGN_LEFT);
                        deliverableBlock.setFont(BODY_TEXT_BOLD_FONT);
                        if (listOtherPartner.size() == 1) {
                            deliverableBlock.add(this.getText("summaries.project.deliverable.partnership"));
                        } else {
                            deliverableBlock.add(
                                    this.getText("summaries.project.deliverable.partnership") + " #" + counter);
                        }

                        // Organization
                        stringBuilder = new StringBuilder();
                        deliverableBlock = new Paragraph();
                        deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);

                        deliverableBlock
                                .add(this.getText("summaries.project.deliverable.partnership.organization")
                                        + " #" + counter + ": ");
                        deliverableBlock.add("");

                        deliverableBlock.setFont(TABLE_BODY_FONT);

                        otherResponsiblepartnerPerson = deliverablePartner.getPartner();
                        if (otherResponsiblepartnerPerson != null) {
                            stringBuilder.append(
                                    this.messageReturn(otherResponsiblepartnerPerson.getComposedName()));
                            stringBuilder.append(", ");
                            stringBuilder.append(this.mapPartnerPersons
                                    .get(String.valueOf(otherResponsiblepartnerPerson.getId())));
                        } else {
                            stringBuilder.append(this.getText("summaries.project.empty"));
                        }

                        deliverableBlock.add(stringBuilder.toString());
                        deliverableBlock.add(Chunk.NEWLINE);
                        ;
                        this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_JUSTIFIED, 1);
                    }
                }
            }

            document.add(table);
            deliverableBlock = new Paragraph();
            deliverableBlock.add(Chunk.NEWLINE);
            document.add(deliverableBlock);

        }

        // ********** Ranking**************************************
        PdfPCell cell_new;
        if (project.isReporting()) {

            PdfPTable table = new PdfPTable(2);
            table.setLockedWidth(true);
            table.setTotalWidth(480);
            table.setWidths(new int[] { 7, 3 });
            DeliverablesRanking deliverableRanking = deliverable.getRanking();

            // summaries.project.reporting.deliverable.ranking
            Paragraph deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_HEADER_FONT);
            deliverableBlock.setAlignment(Element.ALIGN_LEFT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.ranking"));

            cell_new = new PdfPCell(deliverableBlock);
            cell_new.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell_new.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell_new.setBackgroundColor(TABLE_HEADER_BACKGROUND);
            cell_new.setUseBorderPadding(true);
            cell_new.setPadding(3);
            cell_new.setBorderColor(TABLE_CELL_BORDER_COLOR);
            cell_new.setColspan(2);

            this.addTableHeaderCell(table, cell_new);

            // address gender
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.addres.gender"));
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_FONT);
            if (deliverableRanking != null && deliverableRanking.getAddress() != null) {
                deliverableBlock.add(this.messageReturn(deliverableRanking.getAddress().toString()));
            } else {
                deliverableBlock.add(this.messageReturn(null));
            }
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_CENTER, 1);

            // Get Potential
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.contribution.outcome"));
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_FONT);
            if (deliverableRanking != null && deliverableRanking.getPotential() != null) {
                deliverableBlock.add(this.messageReturn(deliverableRanking.getPotential().toString()));
            } else {
                deliverableBlock.add(this.messageReturn(null));
            }
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_CENTER, 1);

            // Level
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.shared.ownership"));
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_FONT);
            if (deliverableRanking != null && deliverableRanking.getLevel() != null) {
                deliverableBlock.add(this.messageReturn(deliverableRanking.getLevel().toString()));
            } else {
                deliverableBlock.add(this.messageReturn(null));
            }
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_CENTER, 1);

            // Personal perspective
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.personal.prespective"));
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_FONT);
            if (deliverableRanking != null && deliverableRanking.getPersonalPerspective() != null) {
                deliverableBlock
                        .add(this.messageReturn(String.valueOf(deliverableRanking.getPersonalPerspective())));
            } else {
                deliverableBlock.add(this.messageReturn(null));
            }
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_CENTER, 1);

            document.add(table);
            deliverableBlock = new Paragraph();
            deliverableBlock.add(Chunk.NEWLINE);
            document.add(deliverableBlock);

            // ********** Deliverable Dissemination**************************************
            DeliverableDissemination deliverableDissemination = deliverable.getDissemination();
            table = new PdfPTable(1);
            table.setLockedWidth(true);
            table.setTotalWidth(480);

            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_HEADER_FONT);
            deliverableBlock.setAlignment(Element.ALIGN_LEFT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.dissemination"));
            this.addTableHeaderCell(table, deliverableBlock);

            // Open access
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.dissemination.open"));
            deliverableBlock.setFont(TABLE_BODY_FONT);

            if (deliverableDissemination != null) {
                if (deliverableDissemination.getIsOpenAccess() != null
                        && deliverableDissemination.getIsOpenAccess().booleanValue()) {
                    deliverableBlock.add("Yes");
                } else if (deliverableDissemination.getIntellectualProperty() != null
                        && deliverableDissemination.getIntellectualProperty().booleanValue()) {
                    deliverableBlock.add(
                            this.getText("summaries.project.reporting.deliverable.dissemination.intellectual"));
                } else if (deliverableDissemination.getLimitedExclusivity() != null
                        && deliverableDissemination.getLimitedExclusivity().booleanValue()) {
                    deliverableBlock
                            .add(this.getText("summaries.project.reporting.deliverable.dissemination.limited"));
                } else if (deliverableDissemination.getRestrictedUseAgreement() != null
                        && deliverableDissemination.getRestrictedUseAgreement().booleanValue()) {

                    deliverableBlock.add(
                            this.getText("summaries.project.reporting.deliverable.dissemination.restricted"));
                    this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

                    deliverableBlock = new Paragraph();
                    deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
                    deliverableBlock
                            .add(this.getText("summaries.project.reporting.deliverable.dissemination.access"));
                    deliverableBlock.setFont(TABLE_BODY_FONT);
                    deliverableBlock.add(deliverableDissemination.getRestrictedAccessUntilText());

                } else if (deliverableDissemination.getEffectiveDateRestriction() != null
                        && deliverableDissemination.getEffectiveDateRestriction().booleanValue()) {
                    deliverableBlock.add(
                            this.getText("summaries.project.reporting.deliverable.dissemination.effective"));
                    this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

                    deliverableBlock = new Paragraph();
                    deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
                    deliverableBlock.add(
                            this.getText("summaries.project.reporting.deliverable.dissemination.embargoed"));
                    deliverableBlock.setFont(TABLE_BODY_FONT);
                    deliverableBlock.add(deliverableDissemination.getRestrictedEmbargoedText());

                } else {
                    deliverableBlock.add(this.messageReturn(null));
                }
            } else {
                deliverableBlock.add(this.messageReturn(null));
            }
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

            // License adopted

            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.dissemination.license"));
            deliverableBlock.setFont(TABLE_BODY_FONT);

            if (deliverableDissemination != null) {
                if (deliverable
                        .getMetadataValueByEncondedName(APConstants.DELIVERABLE_ENCONDING_LICENSE) != null) {
                    deliverableBlock.add(this.messageReturn(deliverable
                            .getMetadataValueByEncondedName(APConstants.DELIVERABLE_ENCONDING_LICENSE)));
                } else {
                    deliverableBlock.add("No");
                }
            } else {
                deliverableBlock.add(this.messageReturn(null));
            }
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

            // // Dissemination channel
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.dissemination.channel"));
            deliverableBlock.setFont(TABLE_BODY_FONT);

            if (deliverableDissemination != null) {
                deliverableBlock.add(this.messageReturn(deliverableDissemination.getDisseminationChannel()));
            } else {
                deliverableBlock.add(this.messageReturn(null));
            }
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

            // Dissemination URL
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.dissemination.url"));
            deliverableBlock.setFont(TABLE_BODY_FONT_LINK);

            if (deliverableDissemination != null) {
                deliverableBlock.add(this.messageReturn(deliverableDissemination.getDisseminationUrl()));
            } else {
                deliverableBlock.add(this.messageReturn(null));
            }
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

            document.add(table);
            deliverableBlock = new Paragraph();
            deliverableBlock.add(Chunk.NEWLINE);
            document.add(deliverableBlock);

            // ********** Deliverable Metadata**************************************
            DeliverablePublicationMetadata deliverableMetadata = deliverable.getPublicationMetadata();
            table = new PdfPTable(1);
            table.setLockedWidth(true);
            table.setTotalWidth(480);

            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_HEADER_FONT);
            deliverableBlock.setAlignment(Element.ALIGN_LEFT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.metadata"));
            this.addTableHeaderCell(table, deliverableBlock);

            // Description
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.metadata.description"));
            deliverableBlock.setFont(TABLE_BODY_FONT);

            if (deliverableMetadata != null) {
                deliverableBlock.add(this.messageReturn(deliverable
                        .getMetadataValueByEncondedName(APConstants.DELIVERABLE_ENCONDING_DESCRIPTION)));
            } else {
                deliverableBlock.add(this.messageReturn(null));
            }
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

            // creator
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.metadata.creator"));
            deliverableBlock.setFont(TABLE_BODY_FONT);

            if (deliverableMetadata != null) {
                deliverableBlock.add(this.messageReturn(
                        deliverable.getMetadataValueByEncondedName(APConstants.DELIVERABLE_ENCONDING_CREATOR)));
            } else {
                deliverableBlock.add(this.messageReturn(null));
            }
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

            // authorID
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.metadata.authorID"));
            deliverableBlock.setFont(TABLE_BODY_FONT);

            if (deliverableMetadata != null) {
                deliverableBlock.add(this.messageReturn(deliverable
                        .getMetadataValueByEncondedName(APConstants.DELIVERABLE_ENCONDING_CREATOR_ID)));
            } else {
                deliverableBlock.add(this.messageReturn(null));
            }
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

            // Creation
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.metadata.creation"));
            deliverableBlock.setFont(TABLE_BODY_FONT);

            if (deliverableMetadata != null) {
                deliverableBlock.add(this.messageReturn(deliverable
                        .getMetadataValueByEncondedName(APConstants.DELIVERABLE_ENCONDING_PUBLICATION)));
            } else {
                deliverableBlock.add(this.messageReturn(null));
            }
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

            // Language
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.metadata.language"));
            deliverableBlock.setFont(TABLE_BODY_FONT);

            if (deliverableMetadata != null) {
                deliverableBlock.add(this.messageReturn(this.messageReturn(deliverable
                        .getMetadataValueByEncondedName(APConstants.DELIVERABLE_ENCONDING_LANGUAGE))));
            } else {
                deliverableBlock.add(this.messageReturn(null));
            }
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);

            // Coverage
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.metadata.coverage"));
            deliverableBlock.setFont(TABLE_BODY_FONT);

            if (deliverableMetadata != null) {
                deliverableBlock.add(this.messageReturn(deliverable
                        .getMetadataValueByEncondedName(APConstants.DELIVERABLE_ENCONDING_COVERAGE)));
            } else {
                deliverableBlock.add(this.messageReturn(null));
            }
            this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);
            document.add(table);
            deliverableBlock = new Paragraph();
            deliverableBlock.add(Chunk.NEWLINE);
            document.add(deliverableBlock);

            // ********** Deliverable Data Sharing**************************************
            table = new PdfPTable(1);
            table.setLockedWidth(true);
            table.setTotalWidth(480);

            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_HEADER_FONT);
            deliverableBlock.setAlignment(Element.ALIGN_LEFT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.datasharing"));
            this.addTableHeaderCell(table, deliverableBlock);

            // Files
            deliverableBlock = new Paragraph();
            deliverableBlock.setFont(TABLE_BODY_BOLD_FONT);
            deliverableBlock.add(this.getText("summaries.project.reporting.deliverable.datasharing.files"));
            deliverableBlock.add("\n");
            deliverableBlock.setFont(TABLE_BODY_FONT);

            List<DeliverableDataSharingFile> deliverableDataSharingFileList = deliverable.getDataSharingFile();

            cell_new = new PdfPCell(deliverableBlock);
            cell_new.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell_new.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell_new.setBackgroundColor(TABLE_BODY_ODD_ROW_BACKGROUND);
            cell_new.setUseBorderPadding(true);
            cell_new.setPadding(3);
            cell_new.setBorderColor(TABLE_CELL_BORDER_COLOR);
            cell_new.setColspan(2);
            Anchor anchor;
            Phrase myurl;
            counter = 0;
            if (deliverableDataSharingFileList != null) {
                for (DeliverableDataSharingFile deliverableDataSharingFile : deliverableDataSharingFileList) {
                    if (deliverableDataSharingFile != null) {

                        anchor = new Anchor(deliverableDataSharingFile.getFile(), TABLE_BODY_FONT_LINK);
                        anchor.setReference(config.getDownloadURL() + "/projects/" + project.getId()
                                + "/deliverableDataSharing/" + deliverableDataSharingFile.getFile());
                        myurl = new Phrase();
                        myurl.add(anchor);
                        myurl.setFont(TABLE_BODY_FONT_LINK);

                        cell_new.addElement(myurl);
                        if (counter > 1) {
                            cell_new.addElement(new Paragraph("\n"));
                        }
                        counter++;
                    }
                }
                table.addCell(cell_new);
            } else {
                deliverableBlock.setFont(TABLE_BODY_FONT);
                deliverableBlock.add(this.messageReturn(null));
                this.addTableBodyCell(table, deliverableBlock, Element.ALIGN_LEFT, 1);
            }
            document.add(table);
            deliverableBlock = new Paragraph();
            deliverableBlock.add(Chunk.NEWLINE);
            deliverableBlock.add(Chunk.NEWLINE);
            document.add(deliverableBlock);
        }

    } catch (DocumentException e) {
        LOG.error(
                "-- generatePdf() > There was an error adding the table with content for case study summary. ",
                e);
    }
}

From source file:org.cgiar.ccafs.ap.summaries.projects.pdf.ProjectSummaryPDF.java

License:Open Source License

private void addProjectCCAFSOutcomes(String number) {
    PdfPTable table = new PdfPTable(3);

    Paragraph cell = new Paragraph();
    Paragraph indicatorsBlock = new Paragraph();
    indicatorsBlock.setAlignment(Element.ALIGN_JUSTIFIED);
    indicatorsBlock.setKeepTogether(true);

    Paragraph title = new Paragraph(number + ".2 " + this.getText("summaries.project.indicatorsContribution"),
            HEADING3_FONT);/*from  ww w.  j  a  v  a 2 s . c om*/
    indicatorsBlock.add(Chunk.NEWLINE);
    indicatorsBlock.add(title);

    try {
        document.add(indicatorsBlock);
        List<IPElement> listIPElements = this.getMidOutcomesPerIndicators();
        if (!listIPElements.isEmpty()) {

            if (project.isReporting()) {

                for (IPElement outcome : listIPElements) {
                    Paragraph outcomeBlock = new Paragraph();
                    int indicatorIndex = 1;

                    outcomeBlock.add(Chunk.NEWLINE);
                    outcomeBlock.setAlignment(Element.ALIGN_JUSTIFIED);
                    outcomeBlock.setFont(BODY_TEXT_BOLD_FONT);
                    outcomeBlock.add(outcome.getProgram().getAcronym());
                    outcomeBlock.add(" - " + this.getText("summaries.project.midoutcome"));

                    outcomeBlock.setFont(BODY_TEXT_FONT);
                    outcomeBlock.add(outcome.getDescription());
                    outcomeBlock.add(Chunk.NEWLINE);
                    outcomeBlock.add(Chunk.NEWLINE);

                    document.add(outcomeBlock);

                    for (IPIndicator outcomeIndicator : outcome.getIndicators()) {
                        outcomeIndicator = outcomeIndicator.getParent() != null ? outcomeIndicator.getParent()
                                : outcomeIndicator;
                        List<IPIndicator> indicators = project.getIndicatorsByParent(outcomeIndicator.getId());
                        if (indicators.isEmpty()) {
                            continue;
                        }

                        Paragraph indicatorDescription = new Paragraph();
                        indicatorDescription.setFont(BODY_TEXT_BOLD_FONT);
                        indicatorDescription.add(this.getText("summaries.project.indicators"));
                        indicatorDescription.add(String.valueOf(indicatorIndex) + ": ");

                        indicatorDescription.setFont(BODY_TEXT_FONT);
                        indicatorDescription.setAlignment(Element.ALIGN_JUSTIFIED);
                        indicatorDescription.add(outcomeIndicator.getDescription());
                        document.add(indicatorDescription);
                        document.add(Chunk.NEWLINE);
                        ;

                        PdfPCell cell_new;
                        for (IPIndicator indicator : indicators) {

                            table = new PdfPTable(3);
                            table.setLockedWidth(true);
                            table.setTotalWidth(480);
                            table.setWidths(new int[] { 3, 3, 3 });
                            table.setHeaderRows(1);

                            if (indicator.getOutcome().getId() != outcome.getId()) {
                                continue;
                            }

                            cell = new Paragraph(this.messageReturn(String.valueOf(indicator.getYear())),
                                    TABLE_HEADER_FONT);

                            cell_new = new PdfPCell(cell);
                            // Set alignment
                            cell_new.setHorizontalAlignment(Element.ALIGN_CENTER);
                            cell_new.setVerticalAlignment(Element.ALIGN_MIDDLE);
                            cell_new.setBackgroundColor(TABLE_HEADER_BACKGROUND);

                            // Set padding
                            cell_new.setUseBorderPadding(true);
                            cell_new.setPadding(3);

                            // Set border color
                            cell_new.setBorderColor(TABLE_CELL_BORDER_COLOR);
                            cell_new.setColspan(3);

                            this.addTableHeaderCell(table, cell_new);
                            // Target value
                            cell = new Paragraph(this.getText("summaries.project.indicator.targetValue"),
                                    TABLE_BODY_BOLD_FONT);
                            cell.setFont(TABLE_BODY_FONT);
                            cell.add(this.messageReturn(indicator.getTarget()));

                            this.addTableBodyCell(table, cell, Element.ALIGN_JUSTIFIED, 1);

                            // Cumulative target to date
                            // TODO
                            cell = new Paragraph(this.getText("summaries.project.indicator.cumulative"),
                                    TABLE_BODY_BOLD_FONT);
                            cell.setFont(TABLE_BODY_FONT);
                            cell.add(this.messageReturn(
                                    project.calculateAcumulativeTarget(indicator.getYear(), indicator)));
                            if (indicator.getYear() <= this.currentReportingYear) {
                                this.addTableBodyCell(table, cell, Element.ALIGN_JUSTIFIED, 1);
                                // achieved
                                cell = new Paragraph(this.getText("summaries.project.indicator.archieved"),
                                        TABLE_BODY_BOLD_FONT);
                                cell.setFont(TABLE_BODY_FONT);
                                if (indicator.getArchived() == null) {
                                    cell.add(this.messageReturn(null));
                                } else {
                                    cell.add(this.messageReturn(String.valueOf(indicator.getArchived())));
                                }
                                this.addTableBodyCell(table, cell, Element.ALIGN_JUSTIFIED, 1);
                            } else {
                                this.addTableColSpanCell(table, cell, Element.ALIGN_JUSTIFIED, 1, 2);
                            }
                            // target narrative
                            cell = new Paragraph(this.getText("summaries.project.indicator.targetNarrative"),
                                    TABLE_BODY_BOLD_FONT);
                            cell.setFont(TABLE_BODY_FONT);
                            cell.add(this.messageReturn(indicator.getDescription()));
                            this.addTableColSpanCell(table, cell, Element.ALIGN_JUSTIFIED, 1, 3);

                            // targets achieved
                            if (indicator.getYear() <= this.currentReportingYear) {
                                cell = new Paragraph(
                                        this.getText("summaries.project.indicator.targetsAchieved"),
                                        TABLE_BODY_BOLD_FONT);
                                cell.setFont(TABLE_BODY_FONT);
                                cell.add(this.messageReturn(indicator.getNarrativeTargets()));
                                this.addTableColSpanCell(table, cell, Element.ALIGN_JUSTIFIED, 1, 3);
                            }

                            // Target gender
                            cell = new Paragraph(this.getText("summaries.project.indicator.targetGender"),
                                    TABLE_BODY_BOLD_FONT);
                            cell.setFont(TABLE_BODY_FONT);
                            cell.add(this.messageReturn(indicator.getGender()));
                            this.addTableColSpanCell(table, cell, Element.ALIGN_JUSTIFIED, 1, 3);

                            // Target achieved gender
                            if (indicator.getYear() <= this.currentReportingYear) {
                                cell = new Paragraph(this.getText("summaries.project.indicator.genderAchieved"),
                                        TABLE_BODY_BOLD_FONT);
                                cell.setFont(TABLE_BODY_FONT);
                                cell.add(this.messageReturn(indicator.getNarrativeGender()));
                                this.addTableColSpanCell(table, cell, Element.ALIGN_JUSTIFIED, 1, 3);
                            }

                            document.add(table);
                            document.add(Chunk.NEWLINE);

                        }
                        indicatorIndex++;

                    }
                }

                //////////// Planning
            } else {

                for (IPElement outcome : listIPElements) {
                    Paragraph outcomeBlock = new Paragraph();
                    int indicatorIndex = 1;

                    outcomeBlock.add(Chunk.NEWLINE);
                    outcomeBlock.setAlignment(Element.ALIGN_JUSTIFIED);
                    outcomeBlock.setFont(BODY_TEXT_BOLD_FONT);
                    outcomeBlock.add(outcome.getProgram().getAcronym());
                    outcomeBlock.add(" - " + this.getText("summaries.project.midoutcome"));

                    outcomeBlock.setFont(BODY_TEXT_FONT);
                    outcomeBlock.add(outcome.getDescription());
                    outcomeBlock.add(Chunk.NEWLINE);
                    outcomeBlock.add(Chunk.NEWLINE);

                    document.add(outcomeBlock);

                    for (IPIndicator outcomeIndicator : outcome.getIndicators()) {
                        outcomeIndicator = outcomeIndicator.getParent() != null ? outcomeIndicator.getParent()
                                : outcomeIndicator;
                        List<IPIndicator> indicators = project.getIndicatorsByParent(outcomeIndicator.getId());
                        if (indicators.isEmpty()) {
                            continue;
                        }

                        Paragraph indicatorDescription = new Paragraph();
                        indicatorDescription.setFont(BODY_TEXT_BOLD_FONT);
                        indicatorDescription.add(this.getText("summaries.project.indicators"));
                        indicatorDescription.add(String.valueOf(indicatorIndex) + ": ");

                        indicatorDescription.setFont(BODY_TEXT_FONT);
                        indicatorDescription.setAlignment(Element.ALIGN_JUSTIFIED);
                        indicatorDescription.add(outcomeIndicator.getDescription());
                        document.add(indicatorDescription);
                        document.add(Chunk.NEWLINE);
                        ;

                        table = new PdfPTable(4);
                        table.setLockedWidth(true);
                        table.setTotalWidth(480);
                        table.setWidths(new int[] { 1, 3, 3, 3 });
                        table.setHeaderRows(1);

                        // Headers
                        cell = new Paragraph(this.getText("summaries.project.indicator.year"),
                                TABLE_HEADER_FONT);
                        this.addTableHeaderCell(table, cell);
                        cell = new Paragraph(this.getText("summaries.project.indicator.targetValue"),
                                TABLE_HEADER_FONT);
                        this.addTableHeaderCell(table, cell);
                        cell = new Paragraph(this.getText("summaries.project.indicator.targetNarrative"),
                                TABLE_HEADER_FONT);
                        this.addTableHeaderCell(table, cell);
                        cell = new Paragraph(this.getText("summaries.project.indicator.targetGender"),
                                TABLE_HEADER_FONT);
                        this.addTableHeaderCell(table, cell);

                        for (IPIndicator indicator : indicators) {

                            if (indicator.getOutcome().getId() != outcome.getId()) {
                                continue;
                            }
                            cell = new Paragraph(this.messageReturn(String.valueOf(indicator.getYear())),
                                    TABLE_BODY_FONT);
                            this.addTableBodyCell(table, cell, Element.ALIGN_CENTER, 1);

                            cell = new Paragraph(this.messageReturn(indicator.getTarget()), TABLE_BODY_FONT);
                            this.addTableBodyCell(table, cell, Element.ALIGN_CENTER, 1);

                            cell = new Paragraph(this.messageReturn(indicator.getDescription()),
                                    TABLE_BODY_FONT);
                            this.addTableBodyCell(table, cell, Element.ALIGN_JUSTIFIED, 1);

                            cell = new Paragraph(this.messageReturn(indicator.getGender()), TABLE_BODY_FONT);
                            this.addTableBodyCell(table, cell, Element.ALIGN_JUSTIFIED, 1);

                        }
                        indicatorIndex++;
                        document.add(table);
                        document.add(Chunk.NEWLINE);
                    }
                }
            }

            // When there isn't elements in indicators
        } else {
            cell = new Paragraph(this.getText("summaries.project.empty"));
            document.add(cell);
        }
    } catch (

    DocumentException e)

    {
        LOG.error("There was an error trying to add the project focuses to the project summary pdf", e);
    }

}

From source file:org.cocktail.superplan.server.gestionimpression.TabularEdtReport.java

License:CeCILL license

public void ecrireCreneau(NSDictionary creneau, PdfPTable pdfTable) {

    NSTimestamp debut = (NSTimestamp) creneau.valueForKey("debut");
    NSTimestamp fin = (NSTimestamp) creneau.valueForKey("fin");
    NSArray texte = (NSArray) creneau.valueForKey("texte");
    // String ccolor = (String)creneau.valueForKey("ccolor");
    EOGlobalID idResa = (EOGlobalID) creneau.valueForKey("reservation");

    String type;//from ww  w.j a  va  2 s  .c  om
    Reservation resa = null;
    if (idResa != null) {
        resa = (Reservation) editingContext.faultForGlobalID(idResa, editingContext);
        type = resa.typeLocation().tlocLibelle();
    } else {
        type = "autre";
    }

    pdfTable.addCell(
            FormatHandler.dateToStr(debut, FORMAT_HOUR) + " - " + FormatHandler.dateToStr(fin, FORMAT_HOUR));
    pdfTable.addCell(type);

    PdfPCell cell = new PdfPCell(new Phrase(texte.componentsJoinedByString(" - ")));
    cell.setColspan(2);
    pdfTable.addCell(cell);
}

From source file:org.cyberoam.iview.charts.Chart.java

License:Open Source License

/**
 * Function to write a given ChartID to pdf file
 * @param pdfFileName specifies the pdf where chart is written.Please specify full path with the filename.
 * @param reportGroup id specifies the chart to be generated
 * @param startdate specifies start date 
 * @param enddate specifies end date/*w  w  w.  j  av  a 2s  . c o  m*/
 * @param limit specifies number of records per record to be written in report
 */
public static void generatePDFReportGroup(OutputStream out, int reportGroupID, String applianceID,
        String startDate, String endDate, String limit, int[] deviceIDs, HttpServletRequest request,
        LinkedHashMap paramMap) throws Exception {
    float width = 768;
    float height = 1024;
    float rec_hieght = 470;
    Rectangle pagesize = new Rectangle(768, 1024);
    Document document = new Document(pagesize, 30, 30, 30, 30);

    JFreeChart chart = null;
    SqlReader sqlReader = new SqlReader(false);
    //CyberoamLogger.sysLog.debug("pdf:"+pdfFileName);
    CyberoamLogger.sysLog.debug("reportGroupID:" + reportGroupID);
    CyberoamLogger.sysLog.debug("applianceID:" + applianceID);
    CyberoamLogger.sysLog.debug("startDate:" + startDate);
    CyberoamLogger.sysLog.debug("endDate:" + endDate);
    CyberoamLogger.sysLog.debug("limit:" + limit);
    try {
        //PdfWriter writer = PdfWriter.getInstance(document, response!=null ? response.getOutputStream():new FileOutputStream(pdfFileName));
        PdfWriter writer = PdfWriter.getInstance(document, out);
        writer.setPageEvent(new Chart());
        document.addAuthor("iView");
        document.addSubject("iView Report");
        document.open();
        PdfContentByte contentByte = writer.getDirectContent();
        ReportGroupBean reportGroupBean = ReportGroupBean.getRecordbyPrimarykey(reportGroupID);
        ArrayList reportList = reportGroupBean.getReportIdByReportGroupId(reportGroupID);
        ReportBean reportBean;
        ResultSetWrapper rsw = null;

        String seperator = System.getProperty("file.separator");

        //String path=System.getProperty("catalina.home") +seperator+"webapps" +seperator+"ROOT" + seperator + "images" + seperator + "iViewPDF.jpg";
        String path = InitServlet.contextPath + seperator + "images" + seperator + "iViewPDF.jpg";

        Image iViewImage = Image.getInstance(path);
        iViewImage.scaleAbsolute(750, 900);
        //iViewImage.scaleAbsolute(600,820);
        iViewImage.setAbsolutePosition(10, 10);
        document.add(iViewImage);

        document.add(new Paragraph("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"));

        /*
         *   Generating Table on the First Page of Report providing summary of Content 
         */
        PdfPTable frontPageTable = new PdfPTable(2);
        PdfPCell dataCell;
        ReportGroupRelationBean reportGroupRelationBean;
        String reportName = "";

        Color tableHeadBackColor = new Color(150, 174, 190);
        Color tableContentBackColor = new Color(229, 232, 237);
        Color tableBorderColor = new Color(229, 232, 237);

        dataCell = new PdfPCell(new Phrase(new Chunk("Report Profile",
                FontFactory.getFont(FontFactory.HELVETICA_BOLD, 16, Font.PLAIN, new Color(255, 255, 255)))));
        dataCell.setBackgroundColor(tableHeadBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);

        /**
         * Getting dynamic title.
         */
        String title = "";
        if (paramMap != null) {
            title = paramMap.get("title").toString();

            paramMap.remove("title");
        }
        if (request != null)
            title = getFormattedTitle(request, reportGroupBean, true);

        dataCell = new PdfPCell(new Phrase(new Chunk(title,
                FontFactory.getFont(FontFactory.HELVETICA_BOLD, 16, Font.PLAIN, new Color(255, 255, 255)))));
        dataCell.setBackgroundColor(tableHeadBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);

        dataCell = new PdfPCell(new Phrase(new Chunk("Start Date",
                FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(0, 0, 0)))));
        dataCell.setBackgroundColor(tableContentBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);

        dataCell = new PdfPCell(new Phrase(startDate));
        dataCell.setBackgroundColor(tableContentBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);

        dataCell = new PdfPCell(new Phrase(new Chunk("End Date",
                FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(0, 0, 0)))));
        dataCell.setBackgroundColor(tableContentBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);

        dataCell = new PdfPCell(new Phrase(endDate));
        dataCell.setBackgroundColor(tableContentBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);

        dataCell = new PdfPCell(new Phrase(new Chunk("iView Server Time",
                FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(0, 0, 0)))));
        dataCell.setBackgroundColor(tableContentBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);

        java.util.Date currentDate = new java.util.Date();
        dataCell = new PdfPCell(new Phrase(currentDate.toString()));
        dataCell.setBackgroundColor(tableContentBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);

        dataCell = new PdfPCell(new Phrase(new Chunk("Reports",
                FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(0, 0, 0)))));
        dataCell.setBackgroundColor(tableContentBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);

        int len = reportList.size();
        for (int k = 0; k < len; k++) {
            reportGroupRelationBean = (ReportGroupRelationBean) reportList.get(k);
            reportName += " " + (k + 1) + ". "
                    + ReportBean.getRecordbyPrimarykey(reportGroupRelationBean.getReportId()).getTitle() + "\n";
        }
        dataCell = new PdfPCell(new Phrase("\n" + reportName + "\n"));
        dataCell.setBackgroundColor(tableContentBackColor);
        dataCell.setBorderColor(tableBorderColor);

        frontPageTable.addCell(dataCell);

        dataCell = new PdfPCell(new Phrase(new Chunk("Device Names (IP Address)",
                FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(0, 0, 0)))));
        dataCell.setBackgroundColor(tableContentBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);

        DeviceBean deviceBean = null;
        String deviceNameWithIP = "";
        if (deviceIDs != null) {
            for (int i = 0; i < deviceIDs.length; i++) {
                deviceBean = DeviceBean.getRecordbyPrimarykey(deviceIDs[i]);
                if (deviceBean != null) {
                    deviceNameWithIP += " " + (i + 1) + ". " + deviceBean.getName() + " (" + deviceBean.getIp()
                            + ")\n";
                }
            }
        }
        dataCell = new PdfPCell(new Phrase("\n" + deviceNameWithIP + "\n"));
        dataCell.setBackgroundColor(tableContentBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);

        /*
         * Adding Table to PDF      
         */
        document.add(frontPageTable);

        /*
         * Adding Charts and Table to PDF 
         */
        for (int i = 0; i < reportList.size(); i++) {
            document.newPage();
            reportBean = ReportBean
                    .getRecordbyPrimarykey(((ReportGroupRelationBean) reportList.get(i)).getReportId());
            String query = null;
            if (request == null) {
                query = PrepareQuery.getQuery(reportBean, startDate, endDate, applianceID, null, null, "0",
                        limit, paramMap);
            } else {
                PrepareQuery prepareQuery = new PrepareQuery();
                query = prepareQuery.getQuery(reportBean, request);
            }
            CyberoamLogger.sysLog.debug("PDF:ReportID:" + reportBean.getReportId() + "Query->" + query);

            try {
                rsw = sqlReader.getInstanceResultSetWrapper(query);
            } catch (org.postgresql.util.PSQLException e) {
                if (query.indexOf("5min_ts_20") > -1) {
                    query = query.substring(0, query.indexOf("5min_ts_20")) + "4hr"
                            + query.substring(query.indexOf("5min_ts_20") + 16, query.length());
                    CyberoamLogger.appLog.debug("New query : " + query);
                    rsw = sqlReader.getInstanceResultSetWrapper(query);

                } else {
                    CyberoamLogger.appLog.error("Exeption in AjaxController.java " + e, e);
                }
            } catch (Exception e) {
                CyberoamLogger.appLog.error("Exeption in AjaxController.java " + e, e);
                rsw.close();
            }

            /*
             * PDF Rendering work starts here
             */

            for (int j = 0; j < (int) (rec_hieght / 16) + 1; j++) {
                document.add(new Paragraph("\n"));
            }
            // This fix is to resolve the problems associated with reports which don't have graphs.
            // If there is no graph associated with the report than no need to generate 
            //a chart for it.
            GraphBean graphBean = GraphBean.getRecordbyPrimarykey(reportBean.getReportId());
            //if(graphBean!=null)
            if (reportBean.getReportFormatId() != 2) {
                chart = Chart.getChart(reportBean.getReportId(), rsw, null);
                PdfTemplate pdfTemplate = contentByte.createTemplate(width, height);
                Graphics2D graphics2D = pdfTemplate.createGraphics(width, height);
                Rectangle2D rectangle = new Rectangle2D.Double(100, 85, 540, rec_hieght);
                chart.draw(graphics2D, rectangle);
                graphics2D.dispose();
                contentByte.addTemplate(pdfTemplate, 0, 0);
            } else {
                Paragraph p = new Paragraph(reportBean.getTitle() + "\n\n",
                        FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLD));
                p.setAlignment("center");
                document.add(p);
            }

            // Retrieving PdfPTable
            PdfPTable pdfTable = getPdfPTable(reportBean, rsw);
            rsw.close();

            /*
             * Adding Table to PDF
             */

            document.add(pdfTable);
        }
        CyberoamLogger.appLog.info("*************Finishing Chart****************");
    } catch (Exception e) {
        CyberoamLogger.sysLog.debug("Chart.writeChartToPDF.e" + e.getMessage(), e);
    } finally {
        sqlReader.close();
    }

    document.close();
}

From source file:org.cyberoam.iview.charts.Chart.java

License:Open Source License

/**
 * Function for getting report PdfPtable instance for given report and record set
 * @param report bean specifies the report for which table is generated 
 * @param rsw specifies Result set collection
 * @return instance of PdfPtable/*  www. jav  a 2s. com*/
 */
public static PdfPTable getPdfPTable(ReportBean reportBean, ResultSetWrapper rsw) {
    PdfPTable pdfTable = null;
    try {
        rsw.last();
        //int rowCount=rsw.getRow();
        ReportColumnBean[] reportColumns = (ReportColumnBean[]) ReportColumnBean
                .getReportColumnsByReportID(reportBean.getReportId()).toArray(new ReportColumnBean[0]);
        pdfTable = new PdfPTable(reportColumns.length);
        // Adding Column Name to PDF Table
        PdfPCell headCell;
        for (int count = 0; count < reportColumns.length; count++) {
            headCell = new PdfPCell(new Phrase(18, new Chunk(reportColumns[count].getColumnName(),
                    FontFactory.getFont(FontFactory.HELVETICA_BOLD, 16, Font.BOLD, Color.blue))));
            headCell.setBackgroundColor(new Color(238, 238, 238));
            pdfTable.addCell(headCell);
        }
        String data;
        int i = 0;
        rsw.beforeFirst();
        while (rsw.next()) {
            for (int j = 0; j < reportColumns.length; j++) {
                if (reportColumns[j].getColumnFormat() == TabularReportConstants.BYTE_FORMATTING) {
                    data = ByteInUnit.getBytesInUnit(rsw.getLong(reportColumns[j].getDbColumnName()));
                } else if (reportColumns[j].getColumnFormat() == TabularReportConstants.PERCENTAGE_FORMATTING) {
                    data = rsw.getString(reportColumns[j].getDbColumnName()) + " %";
                } else if (reportColumns[j].getColumnFormat() == TabularReportConstants.DECODE_FORMATTING) {
                    data = URLDecoder.decode(rsw.getString(reportColumns[j].getDbColumnName()));
                } else if (reportColumns[j].getColumnFormat() == TabularReportConstants.PROTOCOL_FORMATTING) {
                    int index = rsw.getString(reportColumns[j].getDbColumnName()).indexOf(':');
                    if (index != -1) {
                        data = ProtocolBean.getProtocolNameById(Integer.parseInt(
                                rsw.getString(reportColumns[j].getDbColumnName()).substring(0, index)));
                        data = data + rsw.getString(reportColumns[j].getDbColumnName()).substring(index,
                                rsw.getString(reportColumns[j].getDbColumnName()).length());
                    } else {
                        data = rsw.getString(reportColumns[j].getDbColumnName());
                    }
                } else if (reportColumns[j].getColumnFormat() == TabularReportConstants.SEVERITY_FORMATTING) {
                    data = TabularReportConstants
                            .getSeverity(rsw.getString(reportColumns[j].getDbColumnName()));
                } else if (reportColumns[j].getColumnFormat() == TabularReportConstants.ACTION_FORMATTING) {
                    data = TabularReportConstants.getAction(rsw.getString(reportColumns[j].getDbColumnName()));
                } else {
                    data = rsw.getString(reportColumns[j].getDbColumnName());
                }
                if (data == null || "".equalsIgnoreCase(data))
                    data = "N/A";
                pdfTable.addCell(data);
            }
            i++;
        }
    } catch (SQLException e) {
        CyberoamLogger.sysLog.debug("Chart.getPDFPTable.e" + e, e);
    }

    return pdfTable;
}

From source file:org.cyberoam.iview.charts.Chart.java

License:Open Source License

public static void generatePDFReport(OutputStream out, int reportID, String applianceID, String startDate,
        String endDate, String limit, int[] deviceIDs, HttpServletRequest request, int reportGroupID,
        LinkedHashMap paramMap) throws Exception {
    float width = 768;
    float height = 1024;
    float rec_hieght = 470;
    Rectangle pagesize = new Rectangle(768, 1024);
    Document document = new Document(pagesize, 30, 30, 30, 30);
    IndexManager indexManager = null;/*from  www .  j  a v  a 2s  . c o  m*/
    JFreeChart chart = null;
    SqlReader sqlReader = new SqlReader(false);
    CyberoamLogger.sysLog.debug("reportID:" + reportID);
    CyberoamLogger.sysLog.debug("applianceID:" + applianceID);
    CyberoamLogger.sysLog.debug("startDate:" + startDate);
    CyberoamLogger.sysLog.debug("endDate:" + endDate);
    CyberoamLogger.sysLog.debug("limit:" + limit);

    try {
        //PdfWriter writer = PdfWriter.getInstance(document, response!=null ? response.getOutputStream():new FileOutputStream(pdfFileName));         
        PdfWriter writer = PdfWriter.getInstance(document, out);
        writer.setPageEvent(new Chart());
        document.addAuthor("iView");
        document.addSubject("iView Report");
        document.open();
        PdfContentByte contentByte = writer.getDirectContent();
        //ReportGroupBean reportGroupBean=ReportGroupBean.getRecordbyPrimarykey(reportGroupID);

        //ArrayList reportList=reportGroupBean.getReportIdByReportGroupId(reportGroupID);          
        ReportBean reportBean;
        ResultSetWrapper rsw = null;

        String seperator = System.getProperty("file.separator");
        //         String path=System.getProperty("catalina.home") +seperator+"webapps" +seperator+"ROOT" + seperator + "images" + seperator; 
        String path = InitServlet.contextPath + seperator + "images" + seperator + "iViewPDF.jpg";
        /*          
         *   Loading Image to add into PDF 
         */

        Image iViewImage = Image.getInstance(path);
        iViewImage.scaleAbsolute(750, 900);
        //iViewImage.scaleAbsolute(600,820);
        iViewImage.setAbsolutePosition(10, 10);

        /*Image headerImage= Image.getInstance(path+ "iViewPDFHeader.jpg");
                
        PdfPTable headerTable = new PdfPTable(2);
        PdfPCell cell = new PdfPCell(headerImage);
        headerTable.addCell(cell);         
        HeaderFooter docHeader=null;         
        //document.setHeader(new HeaderFooter(new Phrase(new Chunk())), true);
        */
        document.add(iViewImage);

        document.add(new Paragraph("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"));

        /*
         *   Generating Table on the First Page of Report providing summary of Content 
         */
        PdfPTable frontPageTable = new PdfPTable(2);

        PdfPCell dataCell;
        String reportName = "";

        Color tableHeadBackColor = new Color(150, 174, 190);
        Color tableContentBackColor = new Color(229, 232, 237);
        Color tableBorderColor = new Color(229, 232, 237);

        dataCell = new PdfPCell(new Phrase(new Chunk("Report Profile",
                FontFactory.getFont(FontFactory.HELVETICA_BOLD, 16, Font.PLAIN, new Color(255, 255, 255)))));
        dataCell.setBackgroundColor(tableHeadBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);
        if (paramMap != null) {
            reportName = paramMap.get("title").toString();
            paramMap.remove("title");
        }
        if (request != null) {
            ReportGroupBean reportGroupBean = ReportGroupBean.getRecordbyPrimarykey(reportGroupID);
            reportName = getFormattedTitle(request, reportGroupBean, true);
        }
        dataCell = new PdfPCell();

        dataCell.addElement(new Phrase(new Chunk(reportName,
                FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(255, 255, 255)))));
        //dataCell.addElement(new Phrase(new Chunk(ReportBean.getRecordbyPrimarykey(reportID).getTitle(), FontFactory.getFont(FontFactory.HELVETICA_BOLD, 11, Font.PLAIN, new Color(10,10,10)))));
        if (request != null) {
            dataCell.addElement(new Phrase(new Chunk(reportName + " >> ", FontFactory
                    .getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(255, 255, 255)))));
            dataCell.addElement(
                    new Phrase(new Chunk(ReportBean.getRecordbyPrimarykey(reportID).getTitle(), FontFactory
                            .getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(255, 255, 255)))));
        }
        dataCell.setBackgroundColor(tableHeadBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);

        dataCell = new PdfPCell(new Phrase(new Chunk("Start Date",
                FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(0, 0, 0)))));
        dataCell.setBackgroundColor(tableContentBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);

        dataCell = new PdfPCell(new Phrase(startDate));
        dataCell.setBackgroundColor(tableContentBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);

        dataCell = new PdfPCell(new Phrase(new Chunk("End Date",
                FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(0, 0, 0)))));
        dataCell.setBackgroundColor(tableContentBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);

        dataCell = new PdfPCell(new Phrase(endDate));
        dataCell.setBackgroundColor(tableContentBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);

        dataCell = new PdfPCell(new Phrase(new Chunk("iView Server Time",
                FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(0, 0, 0)))));
        dataCell.setBackgroundColor(tableContentBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);

        java.util.Date currentDate = new java.util.Date();
        dataCell = new PdfPCell(new Phrase(currentDate.toString()));
        dataCell.setBackgroundColor(tableContentBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);

        dataCell = new PdfPCell(new Phrase(new Chunk("Device Names (IP Address)",
                FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(0, 0, 0)))));
        dataCell.setBackgroundColor(tableContentBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);

        DeviceBean deviceBean = null;
        String deviceNameWithIP = "";
        if (deviceIDs != null) {
            for (int i = 0; i < deviceIDs.length; i++) {
                deviceBean = DeviceBean.getRecordbyPrimarykey(deviceIDs[i]);
                if (deviceBean != null) {
                    deviceNameWithIP += " " + (i + 1) + ". " + deviceBean.getName() + " (" + deviceBean.getIp()
                            + ")\n";
                }
            }
        }
        dataCell = new PdfPCell(new Phrase("\n" + deviceNameWithIP + "\n"));
        dataCell.setBackgroundColor(tableContentBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);

        /*
         * Adding Table to PDF      
         */
        document.add(frontPageTable);

        /*
         * Adding Charts and Table to PDF 
         */
        document.newPage();
        reportBean = ReportBean.getRecordbyPrimarykey(reportID);
        String query = null;
        if (request == null) {
            query = PrepareQuery.getQuery(reportBean, startDate, endDate, applianceID, null, null, "0", limit,
                    paramMap);
        } else {
            PrepareQuery prepareQuery = new PrepareQuery();
            query = prepareQuery.getQuery(reportBean, request);
        }
        String searchQuery = "";
        if (request == null) {
            searchQuery = null;
        } else {
            searchQuery = request.getParameter("searchquery");
        }
        if (searchQuery != null && !"".equalsIgnoreCase(searchQuery)) {
            query = query.replaceFirst("where", "where " + searchQuery + " and");
        }
        CyberoamLogger.sysLog.debug("PDF:ReportID:" + reportBean.getReportId() + "Query->" + query);
        try {
            if (query.indexOf("select") == -1 && query.indexOf("SELECT") == -1) {
                indexManager = new IndexManager();
                rsw = indexManager.getSearch(query);
                //rsw=indexManager.getResutSetFromArrayList(searchRecord);
            } else {
                rsw = sqlReader.getInstanceResultSetWrapper(query);
            }
        } catch (org.postgresql.util.PSQLException e) {
            if (query.indexOf("5min_ts_20") > -1) {
                query = query.substring(0, query.indexOf("5min_ts_20")) + "4hr"
                        + query.substring(query.indexOf("5min_ts_20") + 16, query.length());
                CyberoamLogger.appLog.debug("New query : " + query);
                rsw = sqlReader.getInstanceResultSetWrapper(query);
            } else {
                CyberoamLogger.appLog.error("Exeption in AjaxController.java " + e, e);
            }
        } catch (Exception e) {
            CyberoamLogger.appLog.error("Exeption in AjaxController.java " + e, e);
            rsw.close();
        }
        /*
         * PDF Rendering work starts here
         */
        //if(Integer.parseInt(limit)<=10 && query.indexOf("where")>-1){
        if (reportBean.getReportFormatId() != 2) {
            chart = Chart.getChart(reportBean.getReportId(), rsw, null);
            PdfTemplate pdfTemplate = contentByte.createTemplate(width, height);
            Graphics2D graphics2D = pdfTemplate.createGraphics(width, height);
            Rectangle2D rectangle = new Rectangle2D.Double(100, 85, 540, rec_hieght);
            chart.draw(graphics2D, rectangle);
            graphics2D.dispose();
            contentByte.addTemplate(pdfTemplate, 0, 0);

            for (int j = 0; j < (int) (rec_hieght / 16) + 1; j++) {
                document.add(new Paragraph("\n"));
            }
        } else
            document.add(new Paragraph("\n"));

        // Retrieving PdfPTable
        PdfPTable pdfTable = getPdfPTable(reportBean, rsw);
        rsw.close();

        document.add(pdfTable);
        CyberoamLogger.appLog.info("*************Finishing PDF Work****************");
    } catch (Exception e) {

        CyberoamLogger.sysLog.debug("Chart.writeChartToPDF.e" + e.getMessage(), e);
    } finally {
        sqlReader.close();
    }
    document.close();
}

From source file:org.drools.verifier.doc.DroolsDocsComponentFactory.java

License:Apache License

public void onEndPage(PdfWriter writer, Document document) {

    try {//from ww  w .  j  av  a2s  . co m
        Image image = Image.getInstance(DroolsDocsBuilder.class.getResource("guvnor-webapp.png")); // TODO this image never existed
        image.setAlignment(Image.RIGHT);
        image.scaleAbsolute(100, 30);
        Rectangle page = document.getPageSize();
        PdfPTable head = new PdfPTable(2);

        PdfPCell cell1 = new PdfPCell(image);
        cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell1.setBorder(0);

        head.addCell(cell1);

        PdfPCell cell2 = new PdfPCell(new Phrase(currentDate, DroolsDocsComponentFactory.HEADER_FOOTER_TEXT));
        cell2.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell2.setBorder(0);

        head.addCell(cell2);

        head.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
        head.writeSelectedRows(0, -1, document.leftMargin(),
                page.getHeight() - document.topMargin() + head.getTotalHeight(), writer.getDirectContent());

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

From source file:org.egov.works.utils.AbstractPDFGenerator.java

License:Open Source License

protected void addRow(final PdfPTable table, final boolean needsBorder, final Paragraph... elements) {
    for (final Paragraph element : elements) {
        final PdfPCell cell = new PdfPCell(element);
        // cell.setHorizontalAlignment(element.getAlignment());
        cell.setVerticalAlignment(Element.ALIGN_TOP);
        if (!needsBorder)
            cell.setBorderWidth(0);//from  w ww  .  ja va2 s.c  o  m
        table.addCell(cell);
    }
}

From source file:org.egov.works.web.actions.contractorBill.ContractorBillPDFGenerator.java

License:Open Source License

protected void createHeaderRow(final PdfPTable contractorBillMainTable) {
    final PdfPTable contractorBillLeftHeader = createContractorBillHeader(
            pdfLabel.get("contractorbill.pdf.leftheader"), 0);
    contractorBillLeftHeader.getDefaultCell().setBorderWidth(0);
    final PdfPCell contractorBillLeftHeaderCell = new PdfPCell(contractorBillLeftHeader);
    contractorBillLeftHeaderCell.setBorderWidth(0);
    contractorBillLeftHeaderCell.setColspan(4);
    contractorBillMainTable.addCell(contractorBillLeftHeaderCell);
    final PdfPTable contractorBillMainHeader = createContractorBillHeader(
            pdfLabel.get("contractorbill.pdf.mainheader"), 1);
    contractorBillMainHeader.getDefaultCell().setBorderWidth(0);
    final PdfPCell contractorBillMainHeaderCell = new PdfPCell(contractorBillMainHeader);
    contractorBillMainHeaderCell.setBorderWidth(0);
    contractorBillMainHeaderCell.setColspan(3);
    contractorBillMainTable.addCell(contractorBillMainHeaderCell);
    final PdfPTable contractorBillRightHeader = createContractorBillHeader(
            pdfLabel.get("contractorbill.pdf.rightheader"), 2);
    contractorBillMainHeader.getDefaultCell().setBorderWidth(0);
    final PdfPCell contractorBillRightHeaderCell = new PdfPCell(contractorBillRightHeader);
    contractorBillRightHeaderCell.setBorderWidth(0);
    contractorBillRightHeaderCell.setColspan(4);
    contractorBillMainTable.addCell(contractorBillRightHeaderCell);
}

From source file:org.egov.works.web.actions.contractorBill.ContractorBillPDFGenerator.java

License:Open Source License

protected void createDeductionTypeLabel(final PdfPTable contractorBillMainTable) {
    contractorBillMainTable.getDefaultCell().setBorderWidth(1);
    final PdfPTable deductionTypeTable = createDeductionTypeLabelTable();
    deductionTypeTable.getDefaultCell().setBorderWidth(1);
    final PdfPCell deductionTypeCell = new PdfPCell(deductionTypeTable);
    deductionTypeCell.setColspan(11);//from w w w. j av a  2  s.c  o  m
    contractorBillMainTable.addCell(deductionTypeCell);
}