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

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

Introduction

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

Prototype

public PdfPCell getDefaultCell() 

Source Link

Document

Gets the default PdfPCell that will be used as reference for all the addCell methods except addCell(PdfPCell).

Usage

From source file:org.kuali.ole.module.purap.pdf.PurchaseOrderQuotePdf.java

License:Educational Community License

/**
 * Create a PDF using the given input parameters.
 *
 * @param po                        The PurchaseOrderDocument to be used to create the pdf.
 * @param poqv                      The PurchaseOrderVendorQuote to be used to generate the pdf.
 * @param campusName                The campus name to be used to generate the pdf.
 * @param contractManagerCampusCode The contract manager campus code to be used to generate the pdf.
 * @param logoImage                 The logo image file name to be used to generate the pdf.
 * @param document                  The pdf document whose margins have already been set.
 * @param writer                    The PdfWriter to write the pdf document into.
 * @param environment               The current environment used (e.g. DEV if it is a development environment).
 * @throws DocumentException//ww w. ja va2 s. c o m
 */
private void createPOQuotePdf(PurchaseOrderDocument po, PurchaseOrderVendorQuote poqv, String campusName,
        String contractManagerCampusCode, String logoImage, Document document, PdfWriter writer,
        String environment) throws DocumentException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("createQuotePdf() started for po number " + po.getPurapDocumentIdentifier());
    }

    // These have to be set because they are used by the onOpenDocument() and onStartPage() methods.
    this.campusName = campusName;
    this.po = po;
    this.logoImage = logoImage;
    this.environment = environment;

    NumberFormat numberFormat = NumberFormat.getCurrencyInstance(Locale.US);
    // Date format pattern: MM-dd-yyyy
    SimpleDateFormat sdf = new SimpleDateFormat(RiceConstants.SIMPLE_DATE_FORMAT_FOR_DATE, Locale.getDefault());

    CampusParameter campusParameter = getCampusParameter(contractManagerCampusCode);
    String purchasingAddressFull = getPurchasingAddressFull(campusParameter);

    // Turn on the page events that handle the header and page numbers.
    PurchaseOrderQuotePdf events = new PurchaseOrderQuotePdf().getPageEvents();
    writer.setPageEvent(this); // Passing in "this" lets it know about the po, campusName, etc.

    document.open();

    PdfPCell cell;
    Paragraph p = new Paragraph();

    // ***** Info table (address, vendor, other info) *****
    LOG.debug("createQuotePdf() info table started.");
    float[] infoWidths = { 0.45f, 0.55f };
    PdfPTable infoTable = new PdfPTable(infoWidths);
    infoTable.setWidthPercentage(100);
    infoTable.setHorizontalAlignment(Element.ALIGN_CENTER);
    infoTable.setSplitLate(false);

    p = new Paragraph();
    ContractManager contractManager = po.getContractManager();
    p.add(new Chunk("\n Return this form to:\n", ver_8_bold));
    p.add(new Chunk(purchasingAddressFull + "\n", cour_10_normal));
    p.add(new Chunk("\n", cour_10_normal));
    p.add(new Chunk(" Fax #: ", ver_6_normal));
    p.add(new Chunk(contractManager.getContractManagerFaxNumber() + "\n", cour_10_normal));
    p.add(new Chunk(" Contract Manager: ", ver_6_normal));
    p.add(new Chunk(contractManager.getContractManagerName() + " "
            + contractManager.getContractManagerPhoneNumber() + "\n", cour_10_normal));
    p.add(new Chunk("\n", cour_10_normal));
    p.add(new Chunk(" To:\n", ver_6_normal));
    StringBuffer vendorInfo = new StringBuffer();
    if (StringUtils.isNotBlank(poqv.getVendorAttentionName())) {
        vendorInfo.append("     ATTN: " + poqv.getVendorAttentionName().trim() + "\n");
    }
    vendorInfo.append("     " + poqv.getVendorName() + "\n");
    if (StringUtils.isNotBlank(poqv.getVendorLine1Address())) {
        vendorInfo.append("     " + poqv.getVendorLine1Address() + "\n");
    }
    if (StringUtils.isNotBlank(poqv.getVendorLine2Address())) {
        vendorInfo.append("     " + poqv.getVendorLine2Address() + "\n");
    }
    if (StringUtils.isNotBlank(poqv.getVendorCityName())) {
        vendorInfo.append("     " + poqv.getVendorCityName());
    }
    if ((StringUtils.isNotBlank(poqv.getVendorStateCode())) && (!poqv.getVendorStateCode().equals("--"))) {
        vendorInfo.append(", " + poqv.getVendorStateCode());
    }
    if (StringUtils.isNotBlank(poqv.getVendorAddressInternationalProvinceName())) {
        vendorInfo.append(", " + poqv.getVendorAddressInternationalProvinceName());
    }
    if (StringUtils.isNotBlank(poqv.getVendorPostalCode())) {
        vendorInfo.append(" " + poqv.getVendorPostalCode() + "\n");
    } else {
        vendorInfo.append("\n");
    }

    if (!OLEConstants.COUNTRY_CODE_UNITED_STATES.equalsIgnoreCase(poqv.getVendorCountryCode())
            && poqv.getVendorCountryCode() != null) {
        vendorInfo.append("     " + poqv.getVendorCountry().getName() + "\n\n");
    } else {
        vendorInfo.append("     \n\n");
    }

    p.add(new Chunk(vendorInfo.toString(), cour_10_normal));
    cell = new PdfPCell(p);
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    infoTable.addCell(cell);

    p = new Paragraph();
    p.add(new Chunk("\n     R.Q. Number: ", ver_8_bold));
    p.add(new Chunk(po.getPurapDocumentIdentifier() + "\n", cour_10_normal));
    java.sql.Date requestDate = getDateTimeService().getCurrentSqlDate();
    if (poqv.getPurchaseOrderQuoteTransmitTimestamp() != null) {
        try {
            requestDate = getDateTimeService().convertToSqlDate(poqv.getPurchaseOrderQuoteTransmitTimestamp());
        } catch (ParseException e) {
            throw new RuntimeException(
                    "ParseException thrown when trying to convert from Timestamp to SqlDate.", e);
        }
    }
    p.add(new Chunk("     R.Q. Date: ", ver_8_bold));
    p.add(new Chunk(sdf.format(requestDate) + "\n", cour_10_normal));
    p.add(new Chunk("     RESPONSE MUST BE RECEIVED BY: ", ver_8_bold));
    if (po.getPurchaseOrderQuoteDueDate() != null) {
        p.add(new Chunk(sdf.format(po.getPurchaseOrderQuoteDueDate()) + "\n\n", cour_10_normal));
    } else {
        p.add(new Chunk("N/A\n\n", cour_10_normal));
    }

    // retrieve the quote stipulations
    StringBuffer quoteStipulations = getPoQuoteLanguage();

    p.add(new Chunk(quoteStipulations.toString(), ver_6_normal));
    p.add(new Chunk("\n ALL QUOTES MUST BE TOTALED", ver_12_normal));
    cell = new PdfPCell(p);
    infoTable.addCell(cell);

    document.add(infoTable);

    // ***** Notes and Stipulations table *****
    // The notes and stipulations table is type Table instead of PdfPTable
    // because Table has the method setCellsFitPage and I can't find an equivalent
    // in PdfPTable. Long notes or stipulations would break to the next page, leaving
    // a large white space on the previous page.
    PdfPTable notesStipulationsTable = new PdfPTable(1);
    notesStipulationsTable.setWidthPercentage(100);
    notesStipulationsTable.setSplitLate(false);

    p = new Paragraph();
    p.add(new Chunk("  Vendor Stipulations and Information\n\n", ver_6_normal));
    if ((po.getPurchaseOrderBeginDate() != null) && (po.getPurchaseOrderEndDate() != null)) {
        p.add(new Chunk("     Order in effect from " + sdf.format(po.getPurchaseOrderBeginDate()) + " to "
                + sdf.format(po.getPurchaseOrderEndDate()) + ".\n", cour_10_normal));
    }
    Collection<PurchaseOrderVendorStipulation> vendorStipulationsList = po.getPurchaseOrderVendorStipulations();
    if (vendorStipulationsList.size() > 0) {
        StringBuffer vendorStipulations = new StringBuffer();
        for (PurchaseOrderVendorStipulation povs : vendorStipulationsList) {
            vendorStipulations.append("     " + povs.getVendorStipulationDescription() + "\n");
        }
        p.add(new Chunk("     " + vendorStipulations.toString(), cour_10_normal));
    }

    PdfPCell tableCell = new PdfPCell(p);
    tableCell.setHorizontalAlignment(Element.ALIGN_LEFT);
    tableCell.setVerticalAlignment(Element.ALIGN_TOP);
    notesStipulationsTable.addCell(tableCell);
    document.add(notesStipulationsTable);

    // ***** Items table *****
    LOG.debug("createQuotePdf() items table started.");
    float[] itemsWidths = { 0.07f, 0.1f, 0.07f, 0.50f, 0.13f, 0.13f };
    PdfPTable itemsTable = new PdfPTable(6);
    // itemsTable.setCellsFitPage(false); With this set to true a large cell will
    // skip to the next page. The default Table behaviour seems to be what we want:
    // start the large cell on the same page and continue it to the next.
    itemsTable.setWidthPercentage(100);
    itemsTable.setWidths(itemsWidths);
    itemsTable.setSplitLate(false);

    tableCell = createCell("Item\nNo.", false, false, false, false, Element.ALIGN_CENTER, ver_6_normal);
    itemsTable.addCell(tableCell);
    tableCell = createCell("Quantity", false, false, false, false, Element.ALIGN_CENTER, ver_6_normal);
    itemsTable.addCell(tableCell);
    tableCell = createCell("UOM", false, false, false, false, Element.ALIGN_CENTER, ver_6_normal);
    itemsTable.addCell(tableCell);
    tableCell = createCell("Description", false, false, false, false, Element.ALIGN_CENTER, ver_6_normal);
    itemsTable.addCell(tableCell);
    tableCell = createCell("Unit Cost\n(Required)", false, false, false, false, Element.ALIGN_CENTER,
            ver_6_normal);
    itemsTable.addCell(tableCell);
    tableCell = createCell("Extended Cost\n(Required)", false, false, false, false, Element.ALIGN_CENTER,
            ver_6_normal);
    itemsTable.addCell(tableCell);

    if (StringUtils.isNotBlank(po.getPurchaseOrderQuoteVendorNoteText())) {
        // Vendor notes line.
        itemsTable.addCell(" ");
        itemsTable.addCell(" ");
        itemsTable.addCell(" ");
        tableCell = createCell(po.getPurchaseOrderQuoteVendorNoteText(), false, false, false, false,
                Element.ALIGN_LEFT, cour_10_normal);
        itemsTable.addCell(tableCell);
        itemsTable.addCell(" ");
        itemsTable.addCell(" ");
    }

    for (PurchaseOrderItem poi : (List<PurchaseOrderItem>) po.getItems()) {
        if ((poi.getItemType() != null) && (StringUtils.isNotBlank(poi.getItemDescription())) && (poi
                .getItemType().isLineItemIndicator()
                || poi.getItemTypeCode().equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_SHIP_AND_HAND_CODE)
                || poi.getItemTypeCode().equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_FREIGHT_CODE)
                || poi.getItemTypeCode().equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_ORDER_DISCOUNT_CODE)
                || poi.getItemTypeCode().equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_TRADE_IN_CODE))) {
            // "ITEM"s display the line number; other types don't.
            String description = "";
            description = (StringUtils.isNotBlank(poi.getItemCatalogNumber()))
                    ? poi.getItemCatalogNumber().trim() + " - "
                    : "";
            description = description
                    + ((StringUtils.isNotBlank(poi.getItemDescription())) ? poi.getItemDescription().trim()
                            : "");

            // If this is a full order discount item or trade in item, we add the
            // itemType description and a dash to the purchase order item description.
            if (StringUtils.isNotBlank(poi.getItemDescription())) {
                if (poi.getItemTypeCode().equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_ORDER_DISCOUNT_CODE)
                        || poi.getItemTypeCode().equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_TRADE_IN_CODE)) {
                    description = poi.getItemType().getItemTypeDescription() + " - " + description;
                }
            }

            // We can do the normal table now because description is not too long.
            String itemLineNumber = new String();
            if (poi.getItemType().isLineItemIndicator()) {
                itemLineNumber = poi.getItemLineNumber().toString();
            } else {
                itemLineNumber = "";
            }
            tableCell = createCell(itemLineNumber, false, false, false, false, Element.ALIGN_CENTER,
                    cour_10_normal);
            itemsTable.addCell(tableCell);
            String quantity = (poi.getItemQuantity() != null) ? poi.getItemQuantity().toString() : " ";
            tableCell = createCell(quantity, false, false, false, false, Element.ALIGN_CENTER, cour_10_normal);
            itemsTable.addCell(tableCell);
            tableCell = createCell(poi.getItemUnitOfMeasureCode(), false, false, false, false,
                    Element.ALIGN_CENTER, cour_10_normal);
            itemsTable.addCell(tableCell);

            tableCell = createCell(description, false, false, false, false, Element.ALIGN_LEFT, cour_10_normal);
            itemsTable.addCell(tableCell);
            itemsTable.addCell(" ");
            itemsTable.addCell(" ");

        }
    }

    // Blank line before totals
    createBlankRowInItemsTable(itemsTable);

    // Totals line.
    itemsTable.addCell(" ");
    itemsTable.addCell(" ");
    itemsTable.addCell(" ");
    tableCell = createCell("Total: ", false, false, false, false, Element.ALIGN_RIGHT, ver_10_normal);
    itemsTable.addCell(tableCell);
    itemsTable.addCell(" ");
    itemsTable.addCell(" ");
    // Blank line after totals
    createBlankRowInItemsTable(itemsTable);

    document.add(itemsTable);

    LOG.debug("createQuotePdf() vendorFillsIn table started.");
    float[] vendorFillsInWidths = { 0.50f, 0.50f };
    PdfPTable vendorFillsInTable = new PdfPTable(vendorFillsInWidths);
    vendorFillsInTable.setWidthPercentage(100);
    vendorFillsInTable.setHorizontalAlignment(Element.ALIGN_CENTER);
    vendorFillsInTable.setSplitLate(false);
    vendorFillsInTable.getDefaultCell().setBorderWidth(0);
    vendorFillsInTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    vendorFillsInTable.getDefaultCell().setVerticalAlignment(Element.ALIGN_CENTER);

    // New row
    String important = new String(
            "\nIMPORTANT: The information and signature below MUST BE COMPLETED or your offer may be rejected.\n");
    cell = createCell(important, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal);
    cell.setColspan(2);
    vendorFillsInTable.addCell(cell);
    // New row
    String cashDiscount = new String(
            "Terms of Payment:  Cash discount_________%_________Days-Net________Days\n");
    cell = createCell(cashDiscount, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal);
    cell.setColspan(2);
    vendorFillsInTable.addCell(cell);
    // New row
    String fob = new String(" FOB: __ Destination (Title)\n");
    cell = createCell(fob, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal);
    vendorFillsInTable.addCell(cell);
    String freightVendor = new String(" __ Freight Vendor Paid (Allowed)\n");
    cell = createCell(freightVendor, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal);
    vendorFillsInTable.addCell(cell);
    // New row
    String shipping = new String("          __ Shipping Point (Title)\n");
    cell = createCell(shipping, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal);
    vendorFillsInTable.addCell(cell);
    String freightPrepaid = new String(" __ Freight Prepaid & Added Amount $_________\n");
    cell = createCell(freightPrepaid, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal);
    vendorFillsInTable.addCell(cell);
    // New row
    String commonCarrier = new String(
            "      If material will ship common carrier, please provide the following:\n");
    cell = createCell(commonCarrier, true, false, false, false, Element.ALIGN_LEFT, ver_8_bold);
    cell.setColspan(2);
    vendorFillsInTable.addCell(cell);
    // New row
    String origin = new String(
            "      Point of origin and zip code: ______________________ Weight: _________ Class: _________\n");
    cell = createCell(origin, true, false, false, false, Element.ALIGN_LEFT, ver_8_bold);
    cell.setColspan(2);
    vendorFillsInTable.addCell(cell);
    // New row
    p = new Paragraph();
    p.add(new Chunk(" Unless otherwise stated, all material to be shipped to ", ver_8_normal));
    String purchasingAddressPartial;
    if (po.getAddressToVendorIndicator()) // use receiving address
        purchasingAddressPartial = po.getReceivingCityName() + ", " + po.getReceivingStateCode() + " "
                + po.getReceivingPostalCode();
    else // use final delivery address
        purchasingAddressPartial = po.getDeliveryCityName() + ", " + po.getDeliveryStateCode() + " "
                + po.getDeliveryPostalCode();
    p.add(new Chunk(purchasingAddressPartial + "\n", cour_10_normal));
    cell = new PdfPCell(p);
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell.setBorderWidth(0);
    vendorFillsInTable.addCell(cell);
    // New row
    String offerEffective = new String(" Offer effective until (Date):_____________\n");
    cell = createCell(offerEffective, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal);
    vendorFillsInTable.addCell(cell);
    String deliverBy = new String(" Delivery can be made by (Date):_____________\n");
    cell = createCell(deliverBy, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal);
    vendorFillsInTable.addCell(cell);
    // New row
    String sign = new String(" SIGN HERE:____________________________\n");
    cell = createCell(sign, true, false, false, false, Element.ALIGN_RIGHT, ver_10_bold);
    vendorFillsInTable.addCell(cell);
    String date = new String(" DATE:____________________________\n");
    cell = createCell(date, true, false, false, false, Element.ALIGN_RIGHT, ver_10_bold);
    vendorFillsInTable.addCell(cell);
    // New row
    String name = new String(" PRINT NAME:____________________________\n");
    cell = createCell(name, true, false, false, false, Element.ALIGN_RIGHT, ver_10_bold);
    vendorFillsInTable.addCell(cell);
    String phone = new String(" PHONE:____________________________\n");
    cell = createCell(phone, true, false, false, false, Element.ALIGN_RIGHT, ver_10_bold);
    vendorFillsInTable.addCell(cell);
    // New row
    String company = new String(" COMPANY:____________________________\n");
    cell = createCell(company, true, false, false, false, Element.ALIGN_RIGHT, ver_10_bold);
    vendorFillsInTable.addCell(cell);
    String fax = new String(" FAX:____________________________\n");
    cell = createCell(fax, true, false, false, false, Element.ALIGN_RIGHT, ver_10_bold);
    vendorFillsInTable.addCell(cell);

    document.add(vendorFillsInTable);
    document.close();
    LOG.debug("createQuotePdf()pdf document closed.");
}

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;//  ww  w  . j a v a  2  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.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;/* w  w w.j av a2s  .  c o m*/
    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.ExportToPDF14.java

License:Open Source License

/**
 * Append current row to result./*from ww  w. j  av  a  2 s.c om*/
 * @return current row to append
 */
private void appendRow(Document document, ExportOptions exportOptions, PdfPTable table, Object vo,
        GridExportOptions opt, Hashtable gettersMethods, SimpleDateFormat sdf, SimpleDateFormat sdatf,
        SimpleDateFormat stf, int row, int tableType // 0 = header, 1 = body, 2 = footer
) throws Throwable {
    int type;
    String aName = null;
    Method getter = null;
    Class clazz = null;
    Object obj = null;

    for (int i = 0; i < opt.getExportColumns().size(); i++) {
        //      value = ((Method)gettersMethods.get(opt.getExportAttrColumns().get(i))).invoke(vo,new Object[0]);

        clazz = vo.getClass();
        obj = vo;
        aName = opt.getExportAttrColumns().get(i).toString();

        // check if the specified attribute is a composed attribute and there exist inner v.o. to instantiate...
        while (aName.indexOf(".") != -1) {
            try {
                getter = clazz.getMethod(
                        "get" + aName.substring(0, 1).toUpperCase() + aName.substring(1, aName.indexOf(".")),
                        new Class[0]);
            } catch (NoSuchMethodException ex2) {
                getter = clazz.getMethod(
                        "is" + aName.substring(0, 1).toUpperCase() + aName.substring(1, aName.indexOf(".")),
                        new Class[0]);
            }
            aName = aName.substring(aName.indexOf(".") + 1);
            clazz = getter.getReturnType();
            obj = getter.invoke(obj, new Object[0]);
            if (obj == null)
                break;
        }

        try {
            getter = clazz.getMethod("get" + aName.substring(0, 1).toUpperCase() + aName.substring(1),
                    new Class[0]);
        } catch (NoSuchMethodException ex2) {
            getter = clazz.getMethod("is" + aName.substring(0, 1).toUpperCase() + aName.substring(1),
                    new Class[0]);
        }

        if (obj != null)
            obj = getter.invoke(obj, new Object[0]);

        if (obj != null) {
            if (obj instanceof Date || obj instanceof java.util.Date || obj instanceof java.sql.Timestamp) {
                type = ((Integer) opt.getColumnsType().get(opt.getExportAttrColumns().get(i))).intValue();
                if (type == opt.TYPE_DATE) {
                    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
                    table.addCell(new Phrase(sdf.format((java.util.Date) obj),
                            (Font) exportOptions.getExportToPDFAdapter().getRowFont(aName)));
                } else if (type == opt.TYPE_DATE_TIME) {
                    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
                    table.addCell(new Phrase(sdatf.format((java.util.Date) obj),
                            (Font) exportOptions.getExportToPDFAdapter().getRowFont(aName)));
                } else if (type == opt.TYPE_TIME) {
                    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
                    table.addCell(new Phrase(stf.format((java.util.Date) obj),
                            (Font) exportOptions.getExportToPDFAdapter().getRowFont(aName)));
                }
            } else {
                table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
                table.addCell(new Phrase(obj.toString(),
                        (Font) exportOptions.getExportToPDFAdapter().getRowFont(aName)));
            }
        } else {
            table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
            table.addCell(new Phrase("", (Font) exportOptions.getExportToPDFAdapter().getRowFont(aName)));
        }

    }

    if (opt.getCallbacks() != null) {
        if (tableType == 0)
            processComponent(table, opt.getExportColumns().size(), document, exportOptions,
                    opt.getCallbacks().getComponentPerRowInHeader((ValueObject) vo, row));
        else if (tableType == 1)
            processComponent(table, opt.getExportColumns().size(), document, exportOptions,
                    opt.getCallbacks().getComponentPerRow((ValueObject) vo, row));
        else if (tableType == 2)
            processComponent(table, opt.getExportColumns().size(), document, exportOptions,
                    opt.getCallbacks().getComponentPerRowInFooter((ValueObject) vo, row));
    }

}

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  www .  j  a va 2  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.oscarehr.casemgmt.print.OscarChartPrinter.java

License:Open Source License

public void printDocHeaderFooter() throws DocumentException {
    String headerTitle = demographic.getFormattedName() + " " + demographic.getAge() + " "
            + demographic.getSex() + " DOB:" + demographic.getFormattedDob();

    //set up document title and header
    ResourceBundle propResource = ResourceBundle.getBundle("oscarResources");
    String title = propResource.getString("oscarEncounter.pdfPrint.title") + " "
            + (String) request.getAttribute("demoName") + "\n";
    String gender = propResource.getString("oscarEncounter.pdfPrint.gender") + " "
            + (String) request.getAttribute("demoSex") + "\n";
    String dob = propResource.getString("oscarEncounter.pdfPrint.dob") + " "
            + (String) request.getAttribute("demoDOB") + "\n";
    String age = propResource.getString("oscarEncounter.pdfPrint.age") + " "
            + (String) request.getAttribute("demoAge") + "\n";
    String mrp = propResource.getString("oscarEncounter.pdfPrint.mrp") + " "
            + (String) request.getAttribute("mrp") + "\n";
    String[] info = new String[] { title, gender, dob, age, mrp };

    ClinicData clinicData = new ClinicData();
    clinicData.refreshClinicData();//from   w  ww  .jav  a  2  s  .  c om
    String[] clinic = new String[] { clinicData.getClinicName(), clinicData.getClinicAddress(),
            clinicData.getClinicCity() + ", " + clinicData.getClinicProvince(), clinicData.getClinicPostal(),
            clinicData.getClinicPhone() };

    if (newPage) {
        document.newPage();
        newPage = false;
    }

    //Header will be printed at top of every page beginning with p2
    Phrase headerPhrase = new Phrase(LEADING, headerTitle, boldFont);
    HeaderFooter header = new HeaderFooter(headerPhrase, false);
    header.setAlignment(HeaderFooter.ALIGN_CENTER);
    document.setHeader(header);

    getDocument().add(headerPhrase);
    getDocument().add(new Phrase("\n"));

    Paragraph p = new Paragraph("Tel:" + demographic.getPhone(), getFont());
    p.setAlignment(Paragraph.ALIGN_LEFT);
    // getDocument().add(p);

    Paragraph p2 = new Paragraph("Date of Visit: ", getFont());
    p2.setAlignment(Paragraph.ALIGN_RIGHT);
    // getDocument().add(p);

    PdfPTable table = new PdfPTable(2);
    table.setWidthPercentage(100f);
    table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
    PdfPCell cell1 = new PdfPCell(p);
    cell1.setBorder(PdfPCell.NO_BORDER);
    cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
    PdfPCell cell2 = new PdfPCell(p2);
    cell2.setHorizontalAlignment(Element.ALIGN_RIGHT);
    cell2.setBorder(PdfPCell.NO_BORDER);
    table.addCell(cell1);
    table.addCell(cell2);

    getDocument().add(table);

    table = new PdfPTable(3);
    table.setWidthPercentage(100f);
    table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
    cell1 = new PdfPCell(getParagraph("Signed Provider:" + ((signingProvider != null) ? signingProvider : "")));
    cell1.setBorder(PdfPCell.NO_BORDER);
    cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell2 = new PdfPCell(getParagraph("RFR:"));
    cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell2.setBorder(PdfPCell.NO_BORDER);
    PdfPCell cell3 = new PdfPCell(getParagraph("Ref:"));
    cell3.setHorizontalAlignment(Element.ALIGN_RIGHT);
    cell3.setBorder(PdfPCell.NO_BORDER);
    table.addCell(cell1);
    table.addCell(cell2);
    table.addCell(cell3);

    getDocument().add(table);

    //Write title with top and bottom borders on p1
    cb = writer.getDirectContent();
    cb.setColorStroke(new Color(0, 0, 0));
    cb.setLineWidth(0.5f);

    cb.moveTo(document.left(), document.top() - (font.getCalculatedLeading(LINESPACING) * 5f));
    cb.lineTo(document.right(), document.top() - (font.getCalculatedLeading(LINESPACING) * 5f));
    cb.stroke();
}

From source file:org.oscarehr.casemgmt.print.OscarChartPrinter.java

License:Open Source License

public void printAppointmentHistory() throws DocumentException {
    if (newPage) {
        document.newPage();//  w  w w. ja va 2  s . co m
        newPage = false;
    }

    List<Appointment> appts = appointmentDao.getAppointmentHistory(demographic.getDemographicNo());

    PdfPTable table = new PdfPTable(6);
    table.setWidthPercentage(100f);
    table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
    table.addCell("Date");
    table.addCell("From");
    table.addCell("To");
    table.addCell("Reason");
    table.addCell("Provider");
    table.addCell("Notes");

    for (Appointment appt : appts) {
        table.addCell(generalCellForApptHistory(formatter.format(appt.getAppointmentDate())));
        table.addCell(generalCellForApptHistory(timeFormatter.format(appt.getStartTime())));
        table.addCell(generalCellForApptHistory(timeFormatter.format(appt.getEndTime())));
        table.addCell(generalCellForApptHistory(appt.getReason()));
        table.addCell(
                generalCellForApptHistory(providerDao.getProvider(appt.getProviderNo()).getFormattedName()));
        table.addCell(generalCellForApptHistory(appt.getNotes()));
    }

    getDocument().add(table);
}

From source file:org.oscarehr.common.service.PdfRecordPrinter.java

License:Open Source License

public void printDocHeaderFooter() throws DocumentException {
    document.resetHeader();/*from ww  w. j  av a 2s  . com*/
    document.resetFooter();
    //document.resetPageCount();
    String headerTitle = demographic.getFormattedName() + " " + demographic.getAge() + " "
            + demographic.getSex() + " DOB:" + demographic.getFormattedDob();

    //set up document title and header
    ResourceBundle propResource = ResourceBundle.getBundle("oscarResources");
    String title = propResource.getString("oscarEncounter.pdfPrint.title") + " "
            + (String) request.getAttribute("demoName") + "\n";
    String gender = propResource.getString("oscarEncounter.pdfPrint.gender") + " "
            + (String) request.getAttribute("demoSex") + "\n";
    String dob = propResource.getString("oscarEncounter.pdfPrint.dob") + " "
            + (String) request.getAttribute("demoDOB") + "\n";
    String age = propResource.getString("oscarEncounter.pdfPrint.age") + " "
            + (String) request.getAttribute("demoAge") + "\n";
    String mrp = propResource.getString("oscarEncounter.pdfPrint.mrp") + " "
            + (String) request.getAttribute("mrp") + "\n";
    String[] info = new String[] { title, gender, dob, age, mrp };

    ClinicData clinicData = new ClinicData();
    clinicData.refreshClinicData();
    String[] clinic = new String[] { clinicData.getClinicName(), clinicData.getClinicAddress(),
            clinicData.getClinicCity() + ", " + clinicData.getClinicProvince(), clinicData.getClinicPostal(),
            clinicData.getClinicPhone() };

    if (newPage) {
        document.newPage();
        newPage = false;
    }

    //Header will be printed at top of every page beginning with p2

    Phrase headerPhrase = new Phrase(LEADING, headerTitle, boldFont);
    /*
            HeaderFooter header = new HeaderFooter(headerPhrase,false);
            header.setAlignment(HeaderFooter.ALIGN_CENTER);
            document.setHeader(header);
    */
    getDocument().add(headerPhrase);
    getDocument().add(new Phrase("\n"));

    Paragraph p = new Paragraph("Tel:" + demographic.getPhone(), getFont());
    p.setAlignment(Paragraph.ALIGN_LEFT);
    // getDocument().add(p);

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Paragraph p2 = new Paragraph("Date of Visit: " + sdf.format(appointment.getAppointmentDate()), getFont());
    p2.setAlignment(Paragraph.ALIGN_RIGHT);
    // getDocument().add(p);

    PdfPTable table = new PdfPTable(2);
    table.setWidthPercentage(100f);
    table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
    PdfPCell cell1 = new PdfPCell(p);
    cell1.setBorder(PdfPCell.NO_BORDER);
    cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
    PdfPCell cell2 = new PdfPCell(p2);
    cell2.setHorizontalAlignment(Element.ALIGN_RIGHT);
    cell2.setBorder(PdfPCell.NO_BORDER);
    table.addCell(cell1);
    table.addCell(cell2);

    getDocument().add(table);

    table = new PdfPTable(3);
    table.setWidthPercentage(100f);
    table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
    cell1 = new PdfPCell(getParagraph("Signed Provider:" + ((signingProvider != null) ? signingProvider : "")));
    cell1.setBorder(PdfPCell.BOTTOM);
    cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell2 = new PdfPCell(getParagraph("RFR:" + this.appointment.getReason()));
    cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell2.setBorder(PdfPCell.BOTTOM);
    PdfPCell cell3 = new PdfPCell(getParagraph("Ref:" + this.getRefName(this.demographic)));
    cell3.setHorizontalAlignment(Element.ALIGN_RIGHT);
    cell3.setBorder(PdfPCell.BOTTOM);
    table.addCell(cell1);
    table.addCell(cell2);
    table.addCell(cell3);
    getDocument().add(table);

    /*
    HeaderFooter footer = new HeaderFooter(new Phrase("-",font),new Phrase("-",font));
    footer.setAlignment(HeaderFooter.ALIGN_CENTER);
    footer.setBorder(0);
            
    document.setFooter(footer);
    */

    //Write title with top and bottom borders on p1

    // cb = writer.getDirectContent();
    /*
    cb.setColorStroke(new Color(0,0,0));
    cb.setLineWidth(0.5f);
    * 
    cb.moveTo(document.left(), document.top() - (font.getCalculatedLeading(LINESPACING)*5f));
    cb.lineTo(document.right(), document.top() - (font.getCalculatedLeading(LINESPACING)*5f));
    cb.stroke();     
    */
}

From source file:org.oscarehr.common.service.PdfRecordPrinter.java

License:Open Source License

public void printSpecsHistory(List<EyeformSpecsHistory> specsHistory) throws DocumentException {
    ProviderDao providerDao = (ProviderDao) SpringUtils.getBean("providerDao");

    /*/*from w w  w .  java2s.co m*/
         if( getNewPage() )
    getDocument().newPage();
           else
    setNewPage(true);
    */

    Font obsfont = new Font(getBaseFont(), FONTSIZE, Font.UNDERLINE);

    Paragraph p = new Paragraph();
    p.setAlignment(Paragraph.ALIGN_LEFT);
    Phrase phrase = new Phrase(LEADING, "\n", getFont());
    p.add(phrase);
    phrase = new Phrase(LEADING, "Specs History", obsfont);
    p.add(phrase);
    getDocument().add(p);

    PdfPTable table = new PdfPTable(2);
    table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
    table.setSpacingBefore(10f);
    table.setSpacingAfter(10f);
    table.setTotalWidth(new float[] { 10f, 60f });
    table.setTotalWidth(5f);
    table.setHorizontalAlignment(PdfPTable.ALIGN_LEFT);

    for (EyeformSpecsHistory specs : specsHistory) {
        PdfPCell cell1 = new PdfPCell(new Phrase(getFormatter().format(specs.getDate()), getFont()));
        cell1.setBorder(PdfPCell.NO_BORDER);
        cell1.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        table.addCell(cell1);

        PdfPCell cell2 = new PdfPCell(new Phrase(specs.toString2(), getFont()));
        cell2.setBorder(PdfPCell.NO_BORDER);
        cell2.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        table.addCell(cell2);
    }

    getDocument().add(table);
}

From source file:org.oscarehr.web.reports.ocan.IndividualNeedRatingOverTimeReportGenerator.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);//w w w. j a v a 2s . com
    PdfWriter writer = PdfWriter.getInstance(d, os);
    writer.setStrictImageSequence(true);
    d.open();

    //header
    Paragraph p = new Paragraph("Individual Need Rating Over Time", 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:", reportBean.getConsumerName()),
            Element.ALIGN_LEFT));
    table.addCell(makeCell(
            createFieldNameAndValuePhrase("Report Date:", dateFormatter.format(reportBean.getReportDate())),
            Element.ALIGN_RIGHT));
    table.addCell(makeCell(createFieldNameAndValuePhrase("Staff Name:", reportBean.getStaffName()),
            Element.ALIGN_LEFT));
    table.addCell("");
    d.add(table);
    d.add(Chunk.NEWLINE);

    int height = 260;

    if (reportBean.isShowUnmetNeeds()) {
        d.add(Image.getInstance(reportBean.getUnmetNeedsChart()
                .createBufferedImage((int) PageSize.A4.rotate().getWidth() - 40, height), null));
    }

    if (reportBean.isShowMetNeeds()) {
        d.add(Image.getInstance(reportBean.getMetNeedsChart()
                .createBufferedImage((int) PageSize.A4.rotate().getWidth() - 40, height), null));
    }

    if (reportBean.isShowNoNeeds()) {
        d.add(Image.getInstance(reportBean.getNoNeedsChart()
                .createBufferedImage((int) PageSize.A4.rotate().getWidth() - 40, height), null));
    }
    if (reportBean.isShowUnknownNeeds()) {
        d.add(Image.getInstance(reportBean.getUnknownNeedsChart()
                .createBufferedImage((int) PageSize.A4.rotate().getWidth() - 40, height), null));
    }

    d.close();
}