Example usage for com.lowagie.text.pdf PdfPTable setHeaderRows

List of usage examples for com.lowagie.text.pdf PdfPTable setHeaderRows

Introduction

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

Prototype

public void setHeaderRows(int headerRows) 

Source Link

Document

Sets the number of the top rows that constitute the header.

Usage

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

License:Open Source License

private void addProjectLocations() {
    Paragraph title = new Paragraph("3. " + this.getText("summaries.projectLocation.title"), HEADING3_FONT);
    Paragraph cell;// w w  w.  j  a  v  a2s.c om
    StringBuffer projectLocations = new StringBuffer();
    List<Location> locationList = (project.getLocations());
    PdfPTable table;
    try {
        document.newPage();
        document.add(title);

        if (project.isGlobal()) {
            Image global = Image.getInstance(config.getBaseUrl() + "/images/summaries/global-map.png");
            global.scalePercent(60f);
            global.setAlignment(Element.ALIGN_CENTER);
            document.add(global);
        } else if (locationList.isEmpty()) {
            cell = new Paragraph();
            cell.setFont(BODY_TEXT_FONT);
            cell.add(this.getText("summaries.project.empty"));
            document.add(cell);
        } else {
            table = new PdfPTable(4);

            // Set table widths
            table.setLockedWidth(true);
            table.setTotalWidth(480);
            table.setWidths(new int[] { 4, 4, 4, 5 });
            table.setHeaderRows(1);

            // Headers
            cell = new Paragraph(this.getText("summaries.projectLocation.table.level"), TABLE_HEADER_FONT);
            this.addTableHeaderCell(table, cell);

            cell = new Paragraph(this.getText("summaries.projectLocation.table.latitude"), TABLE_HEADER_FONT);
            this.addTableHeaderCell(table, cell);

            cell = new Paragraph(this.getText("summaries.projectLocation.table.longitude"), TABLE_HEADER_FONT);
            this.addTableHeaderCell(table, cell);

            cell = new Paragraph(this.getText("summaries.projectLocation.table.name"), TABLE_HEADER_FONT);
            this.addTableHeaderCell(table, cell);
            double answer = 0;
            OtherLocation otherLocation;

            for (Location location : locationList) {
                answer = 0;
                projectLocations = new StringBuffer();
                // Level
                if (location.isCountry()) {
                    projectLocations.append("Country");
                } else if (location.isRegion()) {
                    projectLocations.append("Region");
                } else if (location.isClimateSmartVillage()) {
                    projectLocations.append("CSV");
                } else if (location.isOtherLocation()) {
                    otherLocation = (OtherLocation) location;
                    projectLocations.append(otherLocation.getType().getName());
                }

                cell = new Paragraph();
                cell.setFont(TABLE_BODY_FONT);
                cell.add(projectLocations.toString());
                this.addTableBodyCell(table, cell, Element.ALIGN_CENTER, 1);

                // Latitude
                projectLocations = new StringBuffer();
                if (location.isOtherLocation()) {
                    otherLocation = (OtherLocation) location;

                    answer = otherLocation.getGeoPosition().getLatitude();

                    cell = new Paragraph();
                    cell.setFont(TABLE_BODY_FONT);
                    if (answer != 0) {
                        cell.add(String.valueOf(answer));
                    } else {
                        cell.add("Not applicable");
                    }
                    this.addTableBodyCell(table, cell, Element.ALIGN_CENTER, 1);

                    // Longitude
                    answer = otherLocation.getGeoPosition().getLatitude();
                    cell = new Paragraph();
                    cell.setFont(TABLE_BODY_FONT);
                    if (answer != 0) {
                        cell.add(String.valueOf(answer));
                    } else {
                        cell.add("Not applicable");
                    }
                    this.addTableBodyCell(table, cell, Element.ALIGN_CENTER, 1);

                } else {

                    // Latitude
                    cell = new Paragraph();
                    cell.setFont(TABLE_BODY_FONT);
                    cell.add("Not applicable");
                    this.addTableBodyCell(table, cell, Element.ALIGN_CENTER, 1);

                    cell = new Paragraph();
                    cell.setFont(TABLE_BODY_FONT);
                    // Longitude
                    cell.add("Not applicable");
                    this.addTableBodyCell(table, cell, Element.ALIGN_CENTER, 1);
                }

                // Name
                cell = new Paragraph();
                cell.setFont(TABLE_BODY_FONT);
                projectLocations = new StringBuffer();
                projectLocations.append(location.getName());
                cell.add(projectLocations.toString());
                this.addTableBodyCell(table, cell, Element.ALIGN_CENTER, 1);
            }
            title = new Paragraph();

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

            if (!project.isReporting()) {
                // Lesson regarding locations
                Paragraph locationsBlock = new Paragraph();
                locationsBlock.setAlignment(Element.ALIGN_JUSTIFIED);
                locationsBlock.add(Chunk.NEWLINE);
                locationsBlock.add(Chunk.NEWLINE);
                locationsBlock.setFont(BODY_TEXT_BOLD_FONT);
                locationsBlock.add(this.getText("summaries.project.location.lessonRegarding"));
                locationsBlock.setFont(BODY_TEXT_FONT);
                if (project.getComponentLesson("locations") != null) {
                    locationsBlock
                            .add(this.messageReturn(project.getComponentLesson("locations").getLessons()));
                } else {
                    locationsBlock.add(this.messageReturn(null));
                }
                document.add(locationsBlock);
            }
        }

    } catch (DocumentException e) {
        LOG.error("There was an error trying to add the project locations to the project summary pdf", e);
    } catch (MalformedURLException e) {
        LOG.error("There was an error trying to add the project focuses to the project summary pdf", e);
        e.printStackTrace();
    } catch (IOException e) {
        LOG.error("There was an error trying to add the project focuses to the project summary pdf", e);
        e.printStackTrace();
    }

}

From source file:org.gtdfree.addons.PDFExportAddOn.java

License:Open Source License

@Override
public void export(GTDModel model, ActionsCollection collection, OutputStream out,
        ExportAddOn.ExportOrder order, FileFilter ff, boolean compact) throws Exception {

    fontSelector = new FontSelector();
    fontSelectorB = new FontSelector();
    fontSelectorB2 = new FontSelector();
    fontSelectorB4 = new FontSelector();

    baseFont = fontModel.getBaseFont();//from   ww w  . java  2  s .  c  om

    for (BaseFont bf : fontModel.getFonts()) {
        fontSelector.addFont(new Font(bf, baseFontSize));
        fontSelectorB.addFont(new Font(bf, baseFontSize, Font.BOLD));
        fontSelectorB2.addFont(new Font(bf, baseFontSize + 2, Font.BOLD));
        fontSelectorB4.addFont(new Font(bf, baseFontSize + 4, Font.BOLD));
    }

    boolean emptyH2 = false;
    boolean emptyH3 = false;

    PdfPTable actionTable = null;

    Document doc = new Document();

    if (sizeSet) {
        doc.setPageSize(pageSize);
    }
    if (marginSet) {
        doc.setMargins(marginLeft, marginRight, marginTop, marginBottom);
    }

    //System.out.println("PDF size "+doc.getPageSize().toString());
    //System.out.println("PDF m "+marginLeft+" "+marginRight+" "+marginTop+" "+marginBottom);

    @SuppressWarnings("unused")
    PdfWriter pw = PdfWriter.getInstance(doc, out);

    doc.addCreationDate();
    doc.addTitle("GTD-Free PDF");
    doc.addSubject("GTD-Free data exported as PDF");

    HeaderFooter footer = new HeaderFooter(newParagraph(), true);
    footer.setAlignment(HeaderFooter.ALIGN_CENTER);
    footer.setBorder(HeaderFooter.TOP);
    doc.setFooter(footer);

    doc.open();

    Phrase ch = newTitle("GTD-Free Data");
    Paragraph p = new Paragraph(ch);
    p.setAlignment(Paragraph.ALIGN_CENTER);

    PdfPTable t = new PdfPTable(1);
    t.setWidthPercentage(100f);
    PdfPCell c = newCell(p);
    c.setBorder(Table.BOTTOM);
    c.setBorderWidth(2.5f);
    c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    c.setPadding(5f);
    t.addCell(c);
    doc.add(t);

    Iterator<Object> it = collection.iterator(order);

    while (it.hasNext()) {
        Object o = it.next();

        if (o == ActionsCollection.ACTIONS_WITHOUT_PROJECT) {

            if (order == ExportAddOn.ExportOrder.FoldersProjectsActions) {

                doc.add(newSubSection(ActionsCollection.ACTIONS_WITHOUT_PROJECT));

                emptyH2 = false;
                emptyH3 = true;
            } else {

                doc.add(newSection(ActionsCollection.ACTIONS_WITHOUT_PROJECT));

                emptyH2 = true;
                emptyH3 = false;
            }

            continue;
        }

        if (o instanceof Folder) {

            Folder f = (Folder) o;

            if (actionTable != null) {
                doc.add(actionTable);
                actionTable = null;
            }

            if (f.isProject()) {

                if (order == ExportAddOn.ExportOrder.ProjectsActions
                        || order == ExportAddOn.ExportOrder.ProjectsFoldersActions) {

                    if (emptyH2 || emptyH3) {
                        p = newParagraph(NONE_DOT);
                        doc.add(p);
                    }

                    doc.add(newSection(f.getName()));

                    if (compact) {
                        if (f.getDescription() != null && f.getDescription().length() > 0) {
                            p = newParagraph(f.getDescription());
                            p.setIndentationLeft(10f);
                            p.setIndentationRight(10f);
                            doc.add(p);
                        }
                    } else {
                        t = new PdfPTable(2);
                        t.setKeepTogether(true);
                        t.setSpacingBefore(5f);
                        t.setWidthPercentage(66f);
                        t.setWidths(new float[] { 0.33f, 0.66f });

                        c = newCell("ID");
                        t.addCell(c);
                        c = newCell(newStrongParagraph(String.valueOf(f.getId())));
                        t.addCell(c);
                        c = newCell("Type");
                        t.addCell(c);
                        c = newCell(newStrongParagraph("Project"));
                        t.addCell(c);
                        c = newCell("Open");
                        t.addCell(c);
                        c = newCell(newStrongParagraph(String.valueOf(f.getOpenCount())));
                        t.addCell(c);
                        c = newCell("All");
                        t.addCell(c);
                        c = newCell(newStrongParagraph(String.valueOf(f.size())));
                        t.addCell(c);
                        c = newCell("Description");
                        t.addCell(c);
                        c = newDescriptionCell(f.getDescription());
                        t.addCell(c);

                        doc.add(t);
                    }

                    emptyH2 = true;
                    emptyH3 = false;

                } else {

                    if (emptyH3) {
                        p = newParagraph(NONE_DOT);
                        doc.add(p);
                    }

                    doc.add(newSubSection("Project:" + " " + f.getName()));

                    emptyH2 = false;
                    emptyH3 = true;
                }

                continue;

            }
            if (order == ExportAddOn.ExportOrder.FoldersActions
                    || order == ExportAddOn.ExportOrder.FoldersProjectsActions) {

                if (emptyH2 || emptyH3) {
                    p = newParagraph(NONE_DOT);
                    doc.add(p);
                }

                doc.add(newSection(f.getName()));

                if (compact) {
                    if (f.getDescription() != null && f.getDescription().length() > 0) {
                        p = newParagraph(f.getDescription());
                        p.setIndentationLeft(10f);
                        p.setIndentationRight(10f);
                        doc.add(p);
                    }
                } else {

                    t = new PdfPTable(2);
                    t.setKeepTogether(true);
                    t.setSpacingBefore(5f);
                    t.setWidthPercentage(66f);
                    t.setWidths(new float[] { 0.33f, 0.66f });

                    c = newCell("ID");
                    t.addCell(c);
                    c = newCell(newStrongParagraph(String.valueOf(f.getId())));
                    t.addCell(c);

                    String type = "";
                    if (f.isAction()) {
                        type = "Action list";
                    } else if (f.isInBucket()) {
                        type = "In-Bucket";
                    } else if (f.isQueue()) {
                        type = "Next action queue";
                    } else if (f.isReference()) {
                        type = "Reference list";
                    } else if (f.isSomeday()) {
                        type = "Someday/Maybe list";
                    } else if (f.isBuildIn()) {
                        type = "Default list";
                    }

                    c = newCell("Type");
                    t.addCell(c);
                    c = newCell(newStrongParagraph(type));
                    t.addCell(c);
                    c = newCell("Open");
                    t.addCell(c);
                    c = newCell(newStrongParagraph(String.valueOf(f.getOpenCount())));
                    t.addCell(c);
                    c = newCell("All");
                    t.addCell(c);
                    c = newCell(newStrongParagraph(String.valueOf(f.size())));
                    t.addCell(c);
                    c = newCell("Description");
                    t.addCell(c);
                    c = newDescriptionCell(f.getDescription());
                    t.addCell(c);

                    doc.add(t);
                }

                emptyH2 = true;
                emptyH3 = false;

            } else {

                if (emptyH3) {
                    p = newParagraph(NONE_DOT);
                    doc.add(p);
                }

                doc.add(newSubSection("List:" + " " + f.getName()));

                emptyH2 = false;
                emptyH3 = true;

            }

            continue;

        }

        if (o instanceof Action) {
            emptyH2 = false;
            emptyH3 = false;

            Action a = (Action) o;

            if (compact) {

                if (actionTable == null) {
                    actionTable = new PdfPTable(5);
                    actionTable.setWidthPercentage(100f);
                    actionTable.setHeaderRows(1);
                    actionTable.setSpacingBefore(5f);
                    c = newHeaderCell("ID");
                    actionTable.addCell(c);
                    c = newHeaderCell("Pri.");
                    actionTable.addCell(c);
                    c = newHeaderCell("Description");
                    actionTable.addCell(c);
                    c = newHeaderCell("Reminder");
                    actionTable.addCell(c);
                    c = newHeaderCell(CHECK_RESOLVED);
                    actionTable.addCell(c);

                    float width = doc.getPageSize().getWidth() - doc.getPageSize().getBorderWidthLeft()
                            - doc.getPageSize().getBorderWidthRight();
                    int i = model.getLastActionID();
                    float step = baseFontSize - 1;
                    int steps = (int) Math.floor(Math.log10(i)) + 1;
                    // ID column
                    float col1 = 8 + steps * step;
                    // Priority column
                    float col2 = 4 + 3 * (baseFontSize + 4);
                    // Reminder column
                    float col4 = 10 + step * 11;
                    // Resolved column
                    float col5 = 8 + baseFontSize;
                    // Description column
                    float col3 = width - col1 - col2 - col4 - col5;
                    actionTable.setWidths(new float[] { col1, col2, col3, col4, col5 });

                }

                addSingleActionRow(a, actionTable);

            } else {
                addSingleActionTable(model, doc, a);
            }
        }

    }

    if (actionTable != null) {
        doc.add(actionTable);
        actionTable = null;
    }
    if (emptyH2 || emptyH3) {

        p = newParagraph(NONE_DOT);
        doc.add(p);
    }

    //w.writeCharacters("Exported: "+ApplicationHelper.toISODateTimeString(new Date()));

    doc.close();
}

From source file:org.kuali.kfs.gl.report.TransactionReport.java

License:Open Source License

/**
 * Appends the scrubber totals/statistics and error report to the given (iText) document object.
 * /* w  ww . j a v  a  2s  .c  o m*/
 * @param document the PDF document
 * @param headerFont font for header
 * @param textFont font for report text
 * @param errorSortedList list of error'd transactions
 * @param reportErrors map containing transactions and the errors associated with each transaction
 * @param reportSummary list of summary objects
 * @param runDate date report was run
 * @throws DocumentException
 */
public void appendReport(Document document, Font headerFont, Font textFont, List<Transaction> errorSortedList,
        Map<Transaction, List<Message>> reportErrors, List<Summary> reportSummary, Date runDate)
        throws DocumentException {
    // Sort what we get
    Collections.sort(reportSummary);

    float[] summaryWidths = { 80, 20 };
    PdfPTable summary = new PdfPTable(summaryWidths);
    summary.setWidthPercentage(40);
    PdfPCell cell = new PdfPCell(new Phrase("S T A T I S T I C S", headerFont));
    cell.setColspan(2);
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    summary.addCell(cell);

    for (Iterator iter = reportSummary.iterator(); iter.hasNext();) {
        Summary s = (Summary) iter.next();

        cell = new PdfPCell(new Phrase(s.getDescription(), textFont));
        cell.setBorder(Rectangle.NO_BORDER);
        summary.addCell(cell);

        if ("".equals(s.getDescription())) {
            cell = new PdfPCell(new Phrase("", textFont));
            cell.setBorder(Rectangle.NO_BORDER);
            summary.addCell(cell);
        } else {
            DecimalFormat nf = new DecimalFormat("###,###,###,##0");
            cell = new PdfPCell(new Phrase(nf.format(s.getCount()), textFont));
            cell.setBorder(Rectangle.NO_BORDER);
            cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            summary.addCell(cell);
        }
    }
    cell = new PdfPCell(new Phrase(""));
    cell.setColspan(2);
    cell.setBorder(Rectangle.NO_BORDER);
    summary.addCell(cell);

    document.add(summary);

    if (reportErrors != null && reportErrors.size() > 0) {
        float[] warningWidths = { 4, 3, 6, 5, 5, 4, 5, 5, 4, 5, 5, 9, 4, 36 };
        PdfPTable warnings = new PdfPTable(warningWidths);
        warnings.setHeaderRows(2);
        warnings.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("W A R N I N G S", headerFont));
        cell.setColspan(14);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        warnings.addCell(cell);

        // Add headers
        cell = new PdfPCell(new Phrase("Year", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("COA", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("Account", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("Sacct", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("Obj", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("SObj", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("BalTyp", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("ObjTyp", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("Prd", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("DocType", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("Origin", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("DocNbr", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("Seq", headerFont));
        warnings.addCell(cell);
        cell = new PdfPCell(new Phrase("Warning", headerFont));
        warnings.addCell(cell);

        for (Iterator errorIter = errorSortedList.iterator(); errorIter.hasNext();) {
            Transaction tran = (Transaction) errorIter.next();
            boolean first = true;

            List errors = (List) reportErrors.get(tran);
            for (Iterator listIter = errors.iterator(); listIter.hasNext();) {
                String msg = null;
                Object m = listIter.next();
                if (m instanceof Message) {
                    Message mm = (Message) m;
                    msg = mm.getMessage();
                } else {
                    if (m == null) {
                        msg = "";
                    } else {
                        msg = m.toString();
                    }
                }

                if (first) {
                    first = false;

                    if (tran.getUniversityFiscalYear() == null) {
                        cell = new PdfPCell(new Phrase("NULL", textFont));
                    } else {
                        cell = new PdfPCell(new Phrase(tran.getUniversityFiscalYear().toString(), textFont));
                    }
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getChartOfAccountsCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getAccountNumber(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getSubAccountNumber(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getFinancialObjectCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getFinancialSubObjectCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getFinancialBalanceTypeCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getFinancialObjectTypeCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getUniversityFiscalPeriodCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getFinancialDocumentTypeCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getFinancialSystemOriginationCode(), textFont));
                    warnings.addCell(cell);
                    cell = new PdfPCell(new Phrase(tran.getDocumentNumber(), textFont));
                    warnings.addCell(cell);
                    if (tran.getTransactionLedgerEntrySequenceNumber() == null) {
                        cell = new PdfPCell(new Phrase("NULL", textFont));
                    } else {
                        cell = new PdfPCell(new Phrase(
                                tran.getTransactionLedgerEntrySequenceNumber().toString(), textFont));
                    }
                    warnings.addCell(cell);
                } else {
                    cell = new PdfPCell(new Phrase("", textFont));
                    cell.setColspan(13);
                    warnings.addCell(cell);
                }
                cell = new PdfPCell(new Phrase(msg, textFont));
                warnings.addCell(cell);
            }
        }
        document.add(warnings);
    }
}

From source file:org.kuali.kfs.pdp.batch.service.impl.DailyReportServiceImpl.java

License:Educational Community License

public void runReport() {
    LOG.debug("runReport() started");

    Collection<DailyReport> data = getData();
    Date today = dateTimeService.getCurrentDate();
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");

    String reportFilePrefix = this.kualiConfigurationService
            .getPropertyValueAsString(PdpKeyConstants.DAILY_REPORT_SERVICE_FILE_PREFIX);
    reportFilePrefix = MessageFormat.format(reportFilePrefix, new Object[] { null });

    String reportTitle = this.kualiConfigurationService
            .getPropertyValueAsString(PdpKeyConstants.DAILY_REPORT_SERVICE_REPORT_TITLE);
    reportTitle = MessageFormat.format(reportTitle, new Object[] { sdf.format(today) });

    Document document = openPdfWriter(directoryName, reportFilePrefix, dateTimeService.getCurrentDate(),
            reportTitle);//  www . j  a v  a2  s  .  com

    try {
        float[] summaryWidths = { 20, 20, 20, 20, 20 };
        PdfPTable dataTable = new PdfPTable(summaryWidths);
        dataTable.setWidthPercentage(100);
        dataTable.setHeaderRows(1);
        addHeader(dataTable);

        boolean rows = false;
        DailyReport sortTotal = new DailyReport();
        DailyReport total = new DailyReport();
        DailyReport dr = new DailyReport();

        String totalForSubtitle = this.kualiConfigurationService
                .getPropertyValueAsString(PdpKeyConstants.DAILY_REPORT_SERVICE_TOTAL_FOR_SUBTITLE);

        String totalSubtitle = this.kualiConfigurationService
                .getPropertyValueAsString(PdpKeyConstants.DAILY_REPORT_SERVICE_TOTAL_SUBTITLE);
        totalSubtitle = MessageFormat.format(totalSubtitle, new Object[] { null });

        for (Iterator iter = data.iterator(); iter.hasNext();) {
            dr = (DailyReport) iter.next();

            if (!rows) {
                rows = true;
                sortTotal = new DailyReport(dr);
                sortTotal.addRow(dr);
                addRow(dataTable, dr, false, this.paymentGroupService
                        .getSortGroupName(this.paymentGroupService.getSortGroupId(dr.getPaymentGroup())));
            } else if (this.paymentGroupService.getSortGroupId(sortTotal
                    .getPaymentGroup()) != (this.paymentGroupService.getSortGroupId(dr.getPaymentGroup()))) {
                String newTotalForSubtitle = MessageFormat.format(totalForSubtitle,
                        new Object[] { this.paymentGroupService.getSortGroupName(
                                this.paymentGroupService.getSortGroupId(sortTotal.getPaymentGroup())) });

                addRow(dataTable, sortTotal, true, newTotalForSubtitle);
                sortTotal = new DailyReport(dr);
                sortTotal.addRow(dr);
                addRow(dataTable, dr, false, this.paymentGroupService
                        .getSortGroupName(this.paymentGroupService.getSortGroupId(dr.getPaymentGroup())));
            } else {
                sortTotal.addRow(dr);
                addRow(dataTable, dr, false, "");
            }

            total.addRow(dr);
        }

        if (rows) {
            String newTotalForSubtitle = MessageFormat.format(totalForSubtitle,
                    new Object[] { this.paymentGroupService.getSortGroupName(
                            this.paymentGroupService.getSortGroupId(sortTotal.getPaymentGroup())) });

            addRow(dataTable, sortTotal, true, newTotalForSubtitle);
        }
        addRow(dataTable, total, true, totalSubtitle);

        document.add(dataTable);
    } catch (DocumentException d) {
        throw new RuntimeException(d);
    }
    document.close();
}

From source file:org.mapfish.print.config.layout.AttributesBlock.java

License:Open Source License

public void render(PJsonObject params, PdfElement target, RenderingContext context) throws DocumentException {
    PJsonObject sourceJson = params.optJSONObject(source);
    if (sourceJson == null) {
        sourceJson = context.getGlobalParams().optJSONObject(source);
    }/*ww w  . ja va  2 s  .  co m*/
    if (sourceJson == null || sourceJson.size() == 0) {
        return;
    }
    PJsonArray data = sourceJson.optJSONArray("data");
    PJsonArray firstLine = sourceJson.getJSONArray("columns");

    final List<Integer> columnWidths;
    if (columnDefs.values().iterator().next().getColumnWeight() > 0) {
        columnWidths = new ArrayList<Integer>();
    } else {
        columnWidths = null;
    }

    //Compute the actual number of columns
    int nbCols = 0;
    for (int colNum = 0; colNum < firstLine.size(); ++colNum) {
        String name = firstLine.getString(colNum);
        ColumnDef colDef = columnDefs.get(name);
        if (colDef != null && colDef.isVisible(context, params)) {
            nbCols++;
            if (columnWidths != null) {
                columnWidths.add(colDef.getColumnWeight());
            }
        } else {
            //noinspection ThrowableInstanceNeverThrown
            context.addError(new InvalidJsonValueException(firstLine, name, "Unknown column"));
        }
    }

    final PdfPTable table = new PdfPTable(nbCols);
    table.setWidthPercentage(100f);

    //deal with the weigths for the column widths, if specified 
    if (columnWidths != null) {
        int[] array = new int[columnWidths.size()];
        for (int i = 0; i < columnWidths.size(); i++) {
            array[i] = columnWidths.get(i);
        }
        table.setWidths(array);
    }

    //add the header
    int nbRows = data.size() + 1;
    for (int colNum = 0; colNum < firstLine.size(); ++colNum) {
        String name = firstLine.getString(colNum);
        ColumnDef colDef = columnDefs.get(name);
        if (colDef != null && colDef.isVisible(context, params)) {
            table.addCell(colDef.createHeaderPdfCell(params, context, colNum, nbRows, nbCols, tableConfig));
        }
    }
    table.setHeaderRows(1);

    //add the content
    for (int rowNum = 0; rowNum < data.size(); ++rowNum) {
        PJsonObject row = data.getJSONObject(rowNum);
        int realColNum = 0;
        for (int colNum = 0; colNum < firstLine.size(); ++colNum) {
            String name = firstLine.getString(colNum);
            ColumnDef colDef = columnDefs.get(name);
            if (colDef != null && colDef.isVisible(context, params)) {
                table.addCell(colDef.createContentPdfCell(row, context, rowNum + 1, realColNum, nbRows, nbCols,
                        tableConfig));
                realColNum++;
            }
        }
    }
    table.setSpacingAfter((float) spacingAfter);

    target.add(table);
}

From source file:org.openswing.swing.export.java.ExportToPDF14.java

License:Open Source License

private void prepareGenericComponent(PdfPTable parentTable, int parentTableCols, Document document,
        ExportOptions exportOptions, ComponentExportOptions opt) throws Throwable {
    if (opt.getCellsContent() == null || opt.getCellsContent().length == 0)
        return;/*from   www  . j a  v  a2s.  co  m*/

    int cols = opt.getCellsContent()[0].length;
    Object[] row = null;
    Object obj = null;
    SimpleDateFormat sdatf = new SimpleDateFormat(exportOptions.getDateTimeFormat());
    int[] headerwidths = new int[cols];
    for (int i = 0; i < headerwidths.length; i++)
        headerwidths[i] = (int) PageSize.A4.width() / cols;

    PdfPTable table = new PdfPTable(cols);
    table.setWidths(headerwidths);
    table.setWidthPercentage(90);
    table.getDefaultCell().setBorderWidth(2);
    table.getDefaultCell().setBorderColor(Color.black);
    table.getDefaultCell().setGrayFill(exportOptions.getExportToPDFAdapter().getHeaderGrayFill());
    table.getDefaultCell().setPadding(3);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.setHeaderRows(0);
    table.getDefaultCell().setBorderWidth(0);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    table.getDefaultCell().setVerticalAlignment(Element.ALIGN_TOP);

    for (int i = 0; i < opt.getCellsContent().length; i++) {
        row = opt.getCellsContent()[i];
        for (int j = 0; j < row.length; j++) {
            obj = row[j];

            if (obj != null) {
                if (obj instanceof Date || obj instanceof java.util.Date || obj instanceof java.sql.Timestamp) {
                    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
                    table.addCell(new Phrase(sdatf.format((java.util.Date) obj),
                            (Font) exportOptions.getExportToPDFAdapter().getGenericComponentFont(i, j, obj)));
                } else {
                    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
                    table.addCell(new Phrase(obj.toString(),
                            (Font) exportOptions.getExportToPDFAdapter().getGenericComponentFont(i, j, obj)));
                }
            } else {
                table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
                table.addCell(new Phrase("",
                        (Font) exportOptions.getExportToPDFAdapter().getGenericComponentFont(i, j, null)));
            }

        }
    }

    if (parentTable != null) {
        PdfPCell cell = new PdfPCell(table);
        cell.setColspan(parentTableCols);
        parentTable.addCell(cell);
    } else
        document.add(table);
}

From source file:org.openswing.swing.export.java.ExportToPDF14.java

License:Open Source License

private void prepareGrid(PdfPTable parentTable, int parentTableCols, Document document,
        ExportOptions exportOptions, GridExportOptions opt) throws Throwable {
    // prepare vo getters methods...
    String methodName = null;//from ww w  .  j av  a 2s .  c om
    String attributeName = null;
    Hashtable gettersMethods = new Hashtable();
    Method[] voMethods = opt.getValueObjectType().getMethods();
    for (int i = 0; i < voMethods.length; i++) {
        methodName = voMethods[i].getName();
        if (methodName.startsWith("get")) {
            attributeName = methodName.substring(3, 4).toLowerCase() + methodName.substring(4);
            if (opt.getExportAttrColumns().contains(attributeName))
                gettersMethods.put(attributeName, voMethods[i]);
        }
    }

    Response response = null;
    int start = 0;
    int rownum = 0;
    Object value = null;
    Object vo = null;
    int type;

    SimpleDateFormat sdf = new SimpleDateFormat(exportOptions.getDateFormat());
    SimpleDateFormat sdatf = new SimpleDateFormat(exportOptions.getDateTimeFormat());
    SimpleDateFormat stf = new SimpleDateFormat(exportOptions.getTimeFormat());

    int headerwidths[] = new int[opt.getExportColumns().size()];
    int total = 0;
    for (int i = 0; i < opt.getExportColumns().size(); i++) {
        headerwidths[i] = Math.max(opt.getExportColumns().get(i).toString().length() * 10,
                ((Integer) opt.getColumnsWidth().get(opt.getExportAttrColumns().get(i))).intValue());
        total += headerwidths[i];
    }

    Paragraph line = null;
    if (opt.getTitle() != null && !opt.getTitle().equals("")) {
        line = new Paragraph(opt.getTitle(), (Font) exportOptions.getExportToPDFAdapter().getFontTitle());
        line.setAlignment(Element.ALIGN_CENTER);
        document.add(line);
        document.add(new Paragraph("\n"));
    }
    String[] filters = opt.getFilteringConditions();
    if (filters != null) {
        for (int i = 0; i < filters.length; i++) {
            line = new Paragraph(filters[i]);
            document.add(line);
        }
        document.add(new Paragraph("\n"));
    }

    PdfPTable table = new PdfPTable(opt.getExportColumns().size());
    table.setWidths(headerwidths);
    table.setWidthPercentage(90);
    table.getDefaultCell().setBorderWidth(2);
    table.getDefaultCell().setBorderColor(Color.black);
    table.getDefaultCell().setGrayFill(exportOptions.getExportToPDFAdapter().getHeaderGrayFill());
    table.getDefaultCell().setPadding(3);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);

    for (int i = 0; i < opt.getExportColumns().size(); i++)
        table.addCell(new Phrase(opt.getExportColumns().get(i).toString(), (Font) exportOptions
                .getExportToPDFAdapter().getHeaderFont(opt.getExportAttrColumns().get(i).toString())));

    table.setHeaderRows(1);
    table.getDefaultCell().setBorderWidth(1);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    table.getDefaultCell().setVerticalAlignment(Element.ALIGN_TOP);

    for (int j = 0; j < opt.getTopRows().size(); j++) {
        // create a row for each top rows...
        table.getDefaultCell().setGrayFill(exportOptions.getExportToPDFAdapter().getTopRowsGrayFill(j));
        vo = opt.getTopRows().get(j);
        appendRow(document, exportOptions, table, vo, opt, gettersMethods, sdf, sdatf, stf, j, 0);
    }

    do {
        response = opt.getGridDataLocator().loadData(GridParams.NEXT_BLOCK_ACTION, start,
                opt.getFilteredColumns(), opt.getCurrentSortedColumns(), opt.getCurrentSortedVersusColumns(),
                opt.getValueObjectType(), opt.getOtherGridParams());
        if (response.isError())
            throw new Exception(response.getErrorMessage());

        boolean even = false;

        for (int j = 0; j < ((VOListResponse) response).getRows().size(); j++) {
            if (even) {
                table.getDefaultCell().setGrayFill(exportOptions.getExportToPDFAdapter().getEvenRowsGrayFill());
                even = false;
            } else {
                table.getDefaultCell().setGrayFill(exportOptions.getExportToPDFAdapter().getOddRowsGrayFill());
                even = true;
            }

            vo = ((VOListResponse) response).getRows().get(j);

            appendRow(document, exportOptions, table, vo, opt, gettersMethods, sdf, sdatf, stf, rownum, 1);

            rownum++;
        }

        start = start + ((VOListResponse) response).getRows().size();

        if (!((VOListResponse) response).isMoreRows())
            break;
    } while (rownum < opt.getMaxRows());

    for (int j = 0; j < opt.getBottomRows().size(); j++) {
        // create a row for each bottom rows...
        table.getDefaultCell().setGrayFill(exportOptions.getExportToPDFAdapter().getBottomRowsGrayFill(j));
        vo = opt.getBottomRows().get(j);
        appendRow(document, exportOptions, table, vo, opt, gettersMethods, sdf, sdatf, stf, j, 2);
    }

    if (parentTable != null) {
        PdfPCell cell = new PdfPCell(table);
        cell.setColspan(parentTableCols);
        parentTable.addCell(cell);
    } else
        document.add(table);

}

From source file:org.openswing.swing.export.java.ExportToPDF15.java

License:Open Source License

private void prepareGenericComponent(PdfPTable parentTable, int parentTableCols, Document document,
        ExportOptions exportOptions, ComponentExportOptions opt) throws Throwable {
    if (opt.getCellsContent() == null || opt.getCellsContent().length == 0)
        return;/*from ww w .jav a2  s  . c o m*/

    int cols = opt.getCellsContent()[0].length;
    Object[] row = null;
    Object obj = null;
    SimpleDateFormat sdatf = new SimpleDateFormat(exportOptions.getDateTimeFormat());
    int[] headerwidths = new int[cols];
    for (int i = 0; i < headerwidths.length; i++)
        headerwidths[i] = (int) PageSize.A4.getWidth() / cols;

    PdfPTable table = new PdfPTable(cols);
    table.setWidths(headerwidths);
    table.setWidthPercentage(90);
    table.getDefaultCell().setBorderWidth(2);
    table.getDefaultCell().setBorderColor(Color.black);
    table.getDefaultCell().setGrayFill(exportOptions.getExportToPDFAdapter().getHeaderGrayFill());
    table.getDefaultCell().setPadding(3);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.setHeaderRows(0);
    table.getDefaultCell().setBorderWidth(0);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    table.getDefaultCell().setVerticalAlignment(Element.ALIGN_TOP);

    for (int i = 0; i < opt.getCellsContent().length; i++) {
        row = opt.getCellsContent()[i];
        for (int j = 0; j < row.length; j++) {
            obj = row[j];

            if (obj != null) {
                if (obj instanceof Date || obj instanceof java.util.Date || obj instanceof java.sql.Timestamp) {
                    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
                    table.addCell(new Phrase(sdatf.format((java.util.Date) obj),
                            (Font) exportOptions.getExportToPDFAdapter().getGenericComponentFont(i, j, obj)));
                } else {
                    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
                    table.addCell(new Phrase(obj.toString(),
                            (Font) exportOptions.getExportToPDFAdapter().getGenericComponentFont(i, j, obj)));
                }
            } else {
                table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
                table.addCell(new Phrase("",
                        (Font) exportOptions.getExportToPDFAdapter().getGenericComponentFont(i, j, null)));
            }

        }
    }

    if (parentTable != null) {
        PdfPCell cell = new PdfPCell(table);
        cell.setColspan(parentTableCols);
        parentTable.addCell(cell);
    } else
        document.add(table);
}

From source file:org.opentestsystem.delivery.testreg.rest.view.PDFReportView.java

License:Open Source License

@Override
@SuppressWarnings("unchecked")
protected void buildPdfDocument(final Map<String, Object> model, final Document document,
        final PdfWriter writer, final HttpServletRequest request, final HttpServletResponse response)
        throws Exception {
    document.setMarginMirroringTopBottom(true);
    final List<TestAdminReport> dataList = (List<TestAdminReport>) model.get(DATA_LIST);
    final String reportType = ((String) model.get(REPORT_TYPE)).toUpperCase();
    final String levelOfReport = (String) model.get(LEVEL_OF_REPORT);
    final String headerMessage = (String) model.get(HEADER_MESSAGE);
    writer.setPageEvent(new PdfReportPageEventHelper(writer));
    HierarchyLevel level = null;//w  ww .j av  a2s.  c  o m
    if (levelOfReport != null) {
        level = HierarchyLevel.valueOf(levelOfReport);
    }
    final String headerColumns[] = this.reportHeaders.get(reportType);
    if (headerColumns != null) {
        PdfPTable table = createMessageHeaders(headerColumns, level, headerMessage);
        table.setSpacingAfter(10f);
        if (reportType.equals("PARTICIPATION_DETAIL_REPORT") || reportType.equals("PROCTOR_SCHEDULE_REPORT")
                || reportType.equals("STUDENT_SCHEDULE_REPORT")) {
            table = createHeaders(headerColumns, table);
        } else {
            table = createSummaryHeaders(headerColumns, level, table);
        }
        table.setHeaderRows(2);
        if (dataList.size() == 0) {
            addEmptyCell(table);
        } else {
            addData(table, dataList, level);
        }
        document.add(table);
    }
}

From source file:org.oscarehr.web.reports.ocan.NeedRatingOverTimeReportGenerator.java

License:Open Source License

public void generateReport(OutputStream os) throws Exception {
    Document d = new Document(PageSize.A4.rotate());
    d.setMargins(20, 20, 20, 20);/*ww w  .  j  a v a 2 s . c o  m*/
    PdfWriter writer = PdfWriter.getInstance(d, os);
    writer.setStrictImageSequence(true);
    d.open();

    //header
    Paragraph p = new Paragraph("Needs Over Time (Consumer and Staff)", titleFont);
    p.setAlignment(Element.ALIGN_CENTER);
    d.add(p);
    d.add(Chunk.NEWLINE);

    //purpose
    Paragraph purpose = new Paragraph();
    purpose.add(new Chunk("Purpose of Report:", boldText));
    purpose.add(new Phrase(
            "The purpose of this report is to show change over time in a specific Need Rating for an individual Consumer. It adds up the number of needs across all Domains grouped by Need Rating (e.g. Unmet Needs, Met Needs, No Needs, Unknown) for all selected OCANs that were conducted with the Consumer and displays the results in an individual need rating line graph. Each line graph that is displayed compares the Consumer and the Staff's perspective. The staff may share this report with their Consumer as well.",
            normalText));
    d.add(purpose);
    d.add(Chunk.NEWLINE);

    //report parameters
    PdfPTable table = new PdfPTable(2);
    table.setWidthPercentage(100);
    table.getDefaultCell().setBorder(0);
    table.addCell(
            makeCell(createFieldNameAndValuePhrase("Consumer Name:", getConsumerName()), Element.ALIGN_LEFT));
    table.addCell(makeCell(createFieldNameAndValuePhrase("Report Date:", dateFormatter.format(getReportDate())),
            Element.ALIGN_RIGHT));
    table.addCell(makeCell(createFieldNameAndValuePhrase("Staff Name:", getStaffName()), Element.ALIGN_LEFT));
    table.addCell("");
    d.add(table);
    d.add(Chunk.NEWLINE);

    //loop here...groups of 3
    int loopNo = 1;
    List<OcanNeedRatingOverTimeSummaryOfNeedsBean> summaryBeanList = new ArrayList<OcanNeedRatingOverTimeSummaryOfNeedsBean>();
    summaryBeanList.addAll(this.summaryOfNeedsBeanList);

    while (true) {
        if (summaryBeanList.size() == 0) {
            break;
        }
        List<OcanNeedRatingOverTimeSummaryOfNeedsBean> currentBeanList = new ArrayList<OcanNeedRatingOverTimeSummaryOfNeedsBean>();
        for (int x = 0; x < 3; x++) {
            if (summaryBeanList.size() == 0) {
                break;
            }
            currentBeanList.add(summaryBeanList.remove(0));
        }

        //summary of needs
        PdfPTable summaryOfNeedsTable = null;
        if (currentBeanList.size() == 1) {
            summaryOfNeedsTable = new PdfPTable(3);
            summaryOfNeedsTable.setWidthPercentage(100f - 52.8f);
            summaryOfNeedsTable.setWidths(new float[] { 0.26f, 0.12f, 0.12f });
        }
        if (currentBeanList.size() == 2) {
            summaryOfNeedsTable = new PdfPTable(6);
            summaryOfNeedsTable.setWidthPercentage(100f - 26.4f);
            summaryOfNeedsTable.setWidths(new float[] { 0.26f, 0.12f, 0.12f, 0.024f, 0.12f, 0.12f });
        }
        if (currentBeanList.size() == 3) {
            summaryOfNeedsTable = new PdfPTable(9);
            summaryOfNeedsTable.setWidthPercentage(100f);
            summaryOfNeedsTable
                    .setWidths(new float[] { 0.26f, 0.12f, 0.12f, 0.024f, 0.12f, 0.12f, 0.024f, 0.12f, 0.12f });
        }
        summaryOfNeedsTable.setHorizontalAlignment(Element.ALIGN_LEFT);
        summaryOfNeedsTable.setHeaderRows(3);

        addSummaryOfNeedsHeader(summaryOfNeedsTable, currentBeanList, loopNo);
        addSummaryOfNeedsRow(summaryOfNeedsTable, "Unmet Needs", "unmet", currentBeanList);
        addSummaryOfNeedsRow(summaryOfNeedsTable, "Met Needs", "met", currentBeanList);
        addSummaryOfNeedsRow(summaryOfNeedsTable, "No Needs", "no", currentBeanList);
        addSummaryOfNeedsRow(summaryOfNeedsTable, "Unknown Needs", "unknown", currentBeanList);

        d.add(summaryOfNeedsTable);
        d.add(Chunk.NEWLINE);

        if (summaryBeanList.size() == 0) {
            break;
        }
        loopNo++;
    }

    //BREAKDOWN OF SUMMARY OF NEEDS

    //loop here...groups of 3
    loopNo = 1;
    List<OcanNeedRatingOverTimeNeedBreakdownBean> breakdownBeanList = new ArrayList<OcanNeedRatingOverTimeNeedBreakdownBean>();
    breakdownBeanList.addAll(this.needBreakdownListByOCAN);
    OcanNeedRatingOverTimeNeedBreakdownBean lastBreakDownBean = null;
    while (true) {
        if (breakdownBeanList.size() == 0) {
            break;
        }
        List<OcanNeedRatingOverTimeNeedBreakdownBean> currentBeanList = new ArrayList<OcanNeedRatingOverTimeNeedBreakdownBean>();
        for (int x = 0; x < 3; x++) {
            if (breakdownBeanList.size() == 0) {
                break;
            }
            currentBeanList.add(breakdownBeanList.remove(0));
        }

        //summary of needs
        PdfPTable summaryOfNeedsTable = null;
        if (currentBeanList.size() == 1) {
            if (lastBreakDownBean == null) {
                summaryOfNeedsTable = new PdfPTable(3);
                summaryOfNeedsTable.setWidthPercentage(100f - 52.8f);
                summaryOfNeedsTable.setWidths(new float[] { 0.26f, 0.12f, 0.12f });
            } else {
                summaryOfNeedsTable = new PdfPTable(4);
                summaryOfNeedsTable.setWidthPercentage(100f - 52.8f);
                summaryOfNeedsTable.setWidths(new float[] { 0.26f - 0.024f, 0.024f, 0.12f, 0.12f });
            }
        }
        if (currentBeanList.size() == 2) {
            if (lastBreakDownBean == null) {
                summaryOfNeedsTable = new PdfPTable(6);
                summaryOfNeedsTable.setWidthPercentage(100f - 26.4f);
                summaryOfNeedsTable.setWidths(new float[] { 0.26f, 0.12f, 0.12f, 0.024f, 0.12f, 0.12f });
            } else {
                summaryOfNeedsTable = new PdfPTable(7);
                summaryOfNeedsTable.setWidthPercentage(100f - 26.4f);
                summaryOfNeedsTable
                        .setWidths(new float[] { 0.26f - 0.024f, 0.024f, 0.12f, 0.12f, 0.024f, 0.12f, 0.12f });
            }
        }
        if (currentBeanList.size() == 3) {
            if (lastBreakDownBean == null) {
                summaryOfNeedsTable = new PdfPTable(9);
                summaryOfNeedsTable.setWidthPercentage(100f);
                summaryOfNeedsTable.setWidths(
                        new float[] { 0.26f, 0.12f, 0.12f, 0.024f, 0.12f, 0.12f, 0.024f, 0.12f, 0.12f });
            } else {
                summaryOfNeedsTable = new PdfPTable(10);
                summaryOfNeedsTable.setWidthPercentage(100f);
                summaryOfNeedsTable.setWidths(new float[] { 0.26f - 0.024f, 0.024f, 0.12f, 0.12f, 0.024f, 0.12f,
                        0.12f, 0.024f, 0.12f, 0.12f });
            }
        }
        summaryOfNeedsTable.setHorizontalAlignment(Element.ALIGN_LEFT);

        addSummaryOfNeedsDomainHeader(summaryOfNeedsTable, currentBeanList, loopNo);
        for (int x = 0; x < domains.size(); x++) {
            addSummaryOfNeedsDomainRow(summaryOfNeedsTable, x, getDomains(), currentBeanList,
                    lastBreakDownBean);
        }

        d.add(summaryOfNeedsTable);
        d.add(Chunk.NEWLINE);

        if (breakdownBeanList.size() == 0) {
            break;
        }
        if (currentBeanList.size() == 3) {
            lastBreakDownBean = currentBeanList.get(2);
        }
        loopNo++;
    }

    JFreeChart chart = generateNeedsOverTimeChart();
    BufferedImage image = chart.createBufferedImage((int) PageSize.A4.rotate().getWidth() - 40, 350);
    Image image2 = Image.getInstance(image, null);
    d.add(image2);

    d.close();
}