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

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

Introduction

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

Prototype

public void setWidths(int relativeWidths[]) throws DocumentException 

Source Link

Document

Sets the relative widths of the table.

Usage

From source file:org.jsondoc.springmvc.pdf.PdfExportView.java

License:Open Source License

public File getPdfFile(String filename) {
    try {//www .j  ava 2  s .c o  m
        File file = new File(filename + "-v" + jsonDoc.getVersion() + FILE_EXTENSION);
        FileOutputStream fileout = new FileOutputStream(file);
        Document document = new Document();
        PdfWriter.getInstance(document, fileout);

        // Header
        HeaderFooter header = new HeaderFooter(new Phrase("Copyright "
                + Calendar.getInstance().get(Calendar.YEAR) + " Paybay Networks - All rights reserved"), false);
        header.setBorder(Rectangle.NO_BORDER);
        header.setAlignment(Element.ALIGN_LEFT);
        document.setHeader(header);

        // Footer
        HeaderFooter footer = new HeaderFooter(new Phrase("Page "), true);
        footer.setBorder(Rectangle.NO_BORDER);
        footer.setAlignment(Element.ALIGN_CENTER);
        document.setFooter(footer);

        document.open();

        //init documentation
        apiDocs = buildApiDocList();
        apiMethodDocs = buildApiMethodDocList(apiDocs);

        Phrase baseUrl = new Phrase("Base url: " + jsonDoc.getBasePath());
        document.add(baseUrl);
        document.add(Chunk.NEWLINE);
        document.add(Chunk.NEWLINE);

        int pos = 1;
        for (ApiMethodDoc apiMethodDoc : apiMethodDocs) {
            Phrase phrase = new Phrase(/*"Description: " + */apiMethodDoc.getDescription());
            document.add(phrase);
            document.add(Chunk.NEWLINE);

            PdfPTable table = new PdfPTable(2);
            table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
            table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
            table.setWidthPercentage(100);

            table.setWidths(new int[] { 50, 200 });

            // HEADER CELL START TABLE
            table.addCell(ITextUtils.getHeaderCell("URL"));
            table.addCell(ITextUtils.getHeaderCell("<baseUrl> " + apiMethodDoc.getPath()));
            table.completeRow();

            // FIRST CELL
            table.addCell(ITextUtils.getCell("Http Method", 0));
            table.addCell(ITextUtils.getCell(apiMethodDoc.getVerb().name(), pos));
            pos++;
            table.completeRow();

            // PRODUCES
            if (!apiMethodDoc.getProduces().isEmpty()) {
                table.addCell(ITextUtils.getCell("Produces", 0));
                table.addCell(ITextUtils.getCell(buildApiMethodProduces(apiMethodDoc), pos));
                pos++;
                table.completeRow();
            }

            // CONSUMES
            if (!apiMethodDoc.getConsumes().isEmpty()) {
                table.addCell(ITextUtils.getCell("Consumes", 0));
                table.addCell(ITextUtils.getCell(buildApiMethodConsumes(apiMethodDoc), pos));
                pos++;
                table.completeRow();
            }

            // HEADERS
            if (!apiMethodDoc.getHeaders().isEmpty()) {
                table.addCell(ITextUtils.getCell("Request headers", 0));

                PdfPTable pathParamsTable = new PdfPTable(3);
                pathParamsTable.setWidths(new int[] { 30, 20, 40 });

                pathParamsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
                pathParamsTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);

                for (ApiHeaderDoc apiHeaderDoc : apiMethodDoc.getHeaders()) {
                    PdfPCell boldCell = new PdfPCell();
                    Font fontbold = FontFactory.getFont("Times-Roman", 12, Font.BOLD);
                    boldCell.setPhrase(new Phrase(apiHeaderDoc.getName(), fontbold));
                    boldCell.getPhrase().setFont(new Font(Font.BOLD));
                    boldCell.setBorder(Rectangle.NO_BORDER);
                    pathParamsTable.addCell(boldCell);

                    PdfPCell paramCell = new PdfPCell();

                    StringBuilder builder = new StringBuilder();

                    for (String value : apiHeaderDoc.getAllowedvalues())
                        builder.append(value).append(", ");

                    paramCell.setPhrase(new Phrase("Allowed values: " + builder.toString()));
                    paramCell.setBorder(Rectangle.NO_BORDER);

                    pathParamsTable.addCell(paramCell);

                    paramCell.setPhrase(new Phrase(apiHeaderDoc.getDescription()));

                    pathParamsTable.addCell(paramCell);
                    pathParamsTable.completeRow();
                }

                PdfPCell bluBorderCell = new PdfPCell(pathParamsTable);
                bluBorderCell.setBorder(Rectangle.NO_BORDER);
                bluBorderCell.setBorderWidthRight(1f);
                bluBorderCell.setBorderColorRight(Colors.CELL_BORDER_COLOR);

                table.addCell(ITextUtils.setOddEvenStyle(bluBorderCell, pos));
                pos++;
                table.completeRow();
            }

            // PATH PARAMS
            if (!apiMethodDoc.getPathparameters().isEmpty()) {
                table.addCell(ITextUtils.getCell("Path params", 0));

                PdfPTable pathParamsTable = new PdfPTable(3);
                pathParamsTable.setWidths(new int[] { 30, 15, 40 });

                pathParamsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
                pathParamsTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);

                for (ApiParamDoc apiParamDoc : apiMethodDoc.getPathparameters()) {
                    PdfPCell boldCell = new PdfPCell();
                    Font fontbold = FontFactory.getFont("Times-Roman", 12, Font.BOLD);
                    boldCell.setPhrase(new Phrase(apiParamDoc.getName(), fontbold));
                    boldCell.getPhrase().setFont(new Font(Font.BOLD));
                    boldCell.setBorder(Rectangle.NO_BORDER);
                    pathParamsTable.addCell(boldCell);

                    PdfPCell paramCell = new PdfPCell();
                    paramCell.setPhrase(new Phrase(apiParamDoc.getJsondocType().getOneLineText()));
                    paramCell.setBorder(Rectangle.NO_BORDER);

                    pathParamsTable.addCell(paramCell);

                    paramCell.setPhrase(new Phrase(apiParamDoc.getDescription()));

                    pathParamsTable.addCell(paramCell);
                    pathParamsTable.completeRow();
                }

                PdfPCell bluBorderCell = new PdfPCell(pathParamsTable);
                bluBorderCell.setBorder(Rectangle.NO_BORDER);
                bluBorderCell.setBorderWidthRight(1f);
                bluBorderCell.setBorderColorRight(Colors.CELL_BORDER_COLOR);

                table.addCell(ITextUtils.setOddEvenStyle(bluBorderCell, pos));
                pos++;
                table.completeRow();
            }

            // QUERY PARAMS
            if (!apiMethodDoc.getQueryparameters().isEmpty()) {
                table.addCell(ITextUtils.getCell("Query params", 0));

                PdfPTable queryParamsTable = new PdfPTable(3);
                queryParamsTable.setWidths(new int[] { 30, 15, 40 });

                queryParamsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
                queryParamsTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);

                for (ApiParamDoc apiParamDoc : apiMethodDoc.getQueryparameters()) {
                    PdfPCell boldCell = new PdfPCell();
                    Font fontbold = FontFactory.getFont("Times-Roman", 12, Font.BOLD);
                    boldCell.setPhrase(new Phrase(apiParamDoc.getName(), fontbold));
                    boldCell.getPhrase().setFont(new Font(Font.BOLD));
                    boldCell.setBorder(Rectangle.NO_BORDER);
                    queryParamsTable.addCell(boldCell);

                    PdfPCell paramCell = new PdfPCell();
                    paramCell.setPhrase(new Phrase(apiParamDoc.getJsondocType().getOneLineText()));
                    paramCell.setBorder(Rectangle.NO_BORDER);

                    queryParamsTable.addCell(paramCell);

                    paramCell.setPhrase(new Phrase(
                            apiParamDoc.getDescription() + ", mandatory: " + apiParamDoc.getRequired()));

                    queryParamsTable.addCell(paramCell);
                    queryParamsTable.completeRow();
                }

                PdfPCell bluBorderCell = new PdfPCell(queryParamsTable);
                bluBorderCell.setBorder(Rectangle.NO_BORDER);
                bluBorderCell.setBorderWidthRight(1f);
                bluBorderCell.setBorderColorRight(Colors.CELL_BORDER_COLOR);

                table.addCell(ITextUtils.setOddEvenStyle(bluBorderCell, pos));
                pos++;
                table.completeRow();
            }

            // BODY OBJECT
            if (null != apiMethodDoc.getBodyobject()) {
                table.addCell(ITextUtils.getCell("Body object:", 0));
                String jsonObject = buildJsonFromTemplate(apiMethodDoc.getBodyobject().getJsondocTemplate());
                table.addCell(ITextUtils.getCell(jsonObject, pos));
                pos++;
                table.completeRow();
            }

            // RESPONSE OBJECT
            table.addCell(ITextUtils.getCell("Json response:", 0));
            table.addCell(
                    ITextUtils.getCell(apiMethodDoc.getResponse().getJsondocType().getOneLineText(), pos));
            pos++;
            table.completeRow();

            // RESPONSE STATUS CODE
            table.addCell(ITextUtils.getCell("Status code:", 0));
            table.addCell(ITextUtils.getCell(apiMethodDoc.getResponsestatuscode(), pos));
            pos++;
            table.completeRow();

            table.setSpacingAfter(10f);
            table.setSpacingBefore(5f);
            document.add(table);
        }

        document.close();
        return file;
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (DocumentException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:org.kuali.kfs.module.ar.report.service.impl.ContractsGrantsInvoiceReportServiceImpl.java

License:Open Source License

/**
 * this method generated the actual pdf for the Contracts & Grants LOC Review Document.
 *
 * @param os//from ww w .  ja  va2s .c o m
 * @param LOCDocument
 */
protected void generateLOCReviewInPdf(OutputStream os,
        ContractsGrantsLetterOfCreditReviewDocument locDocument) {
    try {
        Document document = new Document(
                new Rectangle(ArConstants.LOCReviewPdf.LENGTH, ArConstants.LOCReviewPdf.WIDTH));
        PdfWriter.getInstance(document, os);
        document.open();

        Paragraph header = new Paragraph();
        Paragraph text = new Paragraph();
        Paragraph title = new Paragraph();

        // Lets write the header
        header.add(new Paragraph(configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_TITLE),
                ArConstants.PdfReportFonts.LOC_REVIEW_TITLE_FONT));
        if (StringUtils.isNotEmpty(locDocument.getLetterOfCreditFundGroupCode())) {
            header.add(new Paragraph(
                    configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_HEADER_FUND_GROUP_CODE)
                            + locDocument.getLetterOfCreditFundGroupCode(),
                    ArConstants.PdfReportFonts.LOC_REVIEW_TITLE_FONT));
        }
        if (StringUtils.isNotEmpty(locDocument.getLetterOfCreditFundCode())) {
            header.add(new Paragraph(
                    configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_HEADER_FUND_CODE)
                            + locDocument.getLetterOfCreditFundCode(),
                    ArConstants.PdfReportFonts.LOC_REVIEW_TITLE_FONT));
        }
        header.add(new Paragraph(KFSConstants.BLANK_SPACE));
        header.setAlignment(Element.ALIGN_CENTER);
        title.add(new Paragraph(
                configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_HEADER_DOCUMENT_NUMBER)
                        + locDocument.getDocumentNumber(),
                ArConstants.PdfReportFonts.LOC_REVIEW_HEADER_FONT));
        Person person = getPersonService()
                .getPerson(locDocument.getFinancialSystemDocumentHeader().getInitiatorPrincipalId());
        // writing the Document details
        title.add(new Paragraph(
                configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_HEADER_APP_DOC_STATUS)
                        + locDocument.getFinancialSystemDocumentHeader().getApplicationDocumentStatus(),
                ArConstants.PdfReportFonts.LOC_REVIEW_HEADER_FONT));
        title.add(
                new Paragraph(
                        configService.getPropertyValueAsString(
                                ArKeyConstants.LOC_REVIEW_PDF_HEADER_DOCUMENT_INITIATOR) + person.getName(),
                        ArConstants.PdfReportFonts.LOC_REVIEW_HEADER_FONT));
        title.add(new Paragraph(
                configService
                        .getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_HEADER_DOCUMENT_CREATE_DATE)
                        + getDateTimeService().toDateString(
                                locDocument.getFinancialSystemDocumentHeader().getWorkflowCreateDate()),
                ArConstants.PdfReportFonts.LOC_REVIEW_HEADER_FONT));

        title.add(new Paragraph(KFSConstants.BLANK_SPACE));
        title.setAlignment(Element.ALIGN_RIGHT);

        text.add(new Paragraph(
                configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_SUBHEADER_AWARDS),
                ArConstants.PdfReportFonts.LOC_REVIEW_SMALL_BOLD));
        text.add(new Paragraph(KFSConstants.BLANK_SPACE));

        document.add(header);
        document.add(title);
        document.add(text);
        PdfPTable table = new PdfPTable(11);
        table.setTotalWidth(ArConstants.LOCReviewPdf.RESULTS_TABLE_WIDTH);
        // fix the absolute width of the table
        table.setLockedWidth(true);

        // relative col widths in proportions - 1/11
        float[] widths = new float[] { 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f };
        table.setWidths(widths);
        table.setHorizontalAlignment(0);
        addAwardHeaders(table);
        if (CollectionUtils.isNotEmpty(locDocument.getHeaderReviewDetails())
                && CollectionUtils.isNotEmpty(locDocument.getAccountReviewDetails())) {
            for (ContractsGrantsLetterOfCreditReviewDetail item : locDocument.getHeaderReviewDetails()) {
                table.addCell(Long.toString(item.getProposalNumber()));
                table.addCell(item.getAwardDocumentNumber());
                table.addCell(item.getAgencyNumber());
                table.addCell(item.getCustomerNumber());
                table.addCell(getDateTimeService().toDateString(item.getAwardBeginningDate()));
                table.addCell(getDateTimeService().toDateString(item.getAwardEndingDate()));
                table.addCell(
                        contractsGrantsBillingUtilityService.formatForCurrency(item.getAwardBudgetAmount()));
                table.addCell(
                        contractsGrantsBillingUtilityService.formatForCurrency(item.getLetterOfCreditAmount()));
                table.addCell(
                        contractsGrantsBillingUtilityService.formatForCurrency(item.getClaimOnCashBalance()));
                table.addCell(contractsGrantsBillingUtilityService.formatForCurrency(item.getAmountToDraw()));
                table.addCell(contractsGrantsBillingUtilityService
                        .formatForCurrency(item.getAmountAvailableToDraw()));

                PdfPCell cell = new PdfPCell();
                cell.setPadding(ArConstants.LOCReviewPdf.RESULTS_TABLE_CELL_PADDING);
                cell.setColspan(ArConstants.LOCReviewPdf.RESULTS_TABLE_COLSPAN);
                PdfPTable newTable = new PdfPTable(ArConstants.LOCReviewPdf.INNER_TABLE_COLUMNS);
                newTable.setTotalWidth(ArConstants.LOCReviewPdf.INNER_TABLE_WIDTH);
                // fix the absolute width of the newTable
                newTable.setLockedWidth(true);

                // relative col widths in proportions - 1/8
                float[] newWidths = new float[] { 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f };
                newTable.setWidths(newWidths);
                newTable.setHorizontalAlignment(0);
                addAccountsHeaders(newTable);
                for (ContractsGrantsLetterOfCreditReviewDetail newItem : locDocument
                        .getAccountReviewDetails()) {
                    if (item.getProposalNumber().equals(newItem.getProposalNumber())) {
                        newTable.addCell(newItem.getAccountDescription());
                        newTable.addCell(newItem.getChartOfAccountsCode());
                        newTable.addCell(newItem.getAccountNumber());
                        String accountExpirationDate = KFSConstants.EMPTY_STRING;
                        if (!ObjectUtils.isNull(newItem.getAccountExpirationDate())) {
                            accountExpirationDate = getDateTimeService()
                                    .toDateString(newItem.getAccountExpirationDate());
                        }
                        newTable.addCell(accountExpirationDate);
                        newTable.addCell(contractsGrantsBillingUtilityService
                                .formatForCurrency(newItem.getAwardBudgetAmount()));
                        newTable.addCell(contractsGrantsBillingUtilityService
                                .formatForCurrency(newItem.getClaimOnCashBalance()));
                        newTable.addCell(contractsGrantsBillingUtilityService
                                .formatForCurrency(newItem.getAmountToDraw()));
                        newTable.addCell(contractsGrantsBillingUtilityService
                                .formatForCurrency(newItem.getFundsNotDrawn()));
                    }
                }
                cell.addElement(newTable);
                table.addCell(cell);

            }
            document.add(table);
        }
        document.close();
    } catch (DocumentException e) {
        LOG.error("problem during ContractsGrantsInvoiceReportServiceImpl.generateInvoiceInPdf()", e);
    }
}

From source file:org.kuali.kfs.module.endow.report.util.EndowmentReportPrintBase.java

License:Educational Community License

/** 
 * Generates the report header sheet/*from   ww w  .  j av  a  2  s .c om*/
 * 
 * @param reportRequestHeaderDataHolder
 * @param document
 * @return
 */
public boolean printReportHeaderPage(EndowmentReportHeaderDataHolder reportRequestHeaderDataHolder,
        Document document, String listKemidsInHeader) {

    try {
        // report header
        Phrase header = new Paragraph(new Date().toString());
        Paragraph title = new Paragraph(reportRequestHeaderDataHolder.getInstitutionName());
        title.setAlignment(Element.ALIGN_CENTER);
        title.add("\nReport Request Header Sheet\n\n");
        document.add(title);

        PdfPTable requestTable = new PdfPTable(2);
        requestTable.setWidthPercentage(REQUEST_INFO_TABLE_WIDTH);
        int[] requestWidths = { 20, 80 };
        requestTable.setWidths(requestWidths);
        requestTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);

        Paragraph reportRequested = new Paragraph(reportRequestHeaderDataHolder.getReportRequested(),
                headerSheetRegularFont);
        Paragraph dateRequested = new Paragraph(new Date().toString(), headerSheetRegularFont);
        Paragraph requestedBy = new Paragraph(reportRequestHeaderDataHolder.getRequestedBy(),
                headerSheetRegularFont);
        Paragraph endowmentOption = new Paragraph(reportRequestHeaderDataHolder.getEndowmentOption(),
                headerSheetRegularFont);
        Paragraph reportOption = new Paragraph(reportRequestHeaderDataHolder.getReportOption(),
                headerSheetRegularFont);

        requestTable.addCell(
                createCellWithDefaultFontAndWithoutBorderLine("Report Requested:", Element.ALIGN_RIGHT));
        requestTable.addCell(reportRequested);
        requestTable
                .addCell(createCellWithDefaultFontAndWithoutBorderLine("Date Requested:", Element.ALIGN_RIGHT));
        requestTable.addCell(dateRequested);
        requestTable
                .addCell(createCellWithDefaultFontAndWithoutBorderLine("Reqeusted by:", Element.ALIGN_RIGHT));
        requestTable.addCell(requestedBy);
        requestTable.addCell("");
        requestTable.addCell("");
        requestTable.addCell(
                createCellWithDefaultFontAndWithoutBorderLine("Endowment Option:", Element.ALIGN_RIGHT));
        requestTable.addCell(endowmentOption);
        requestTable
                .addCell(createCellWithDefaultFontAndWithoutBorderLine("Report Option:", Element.ALIGN_RIGHT));
        requestTable.addCell(reportOption);
        document.add(requestTable);

        // Criteria
        Paragraph criteria = new Paragraph("\nCriteria:\n\n");
        document.add(criteria);

        PdfPTable criteriaTable = new PdfPTable(2);
        criteriaTable.setWidthPercentage(CRITERIA_TABLE_WIDTH);
        int[] criteriaWidths = { 30, 50 };
        criteriaTable.setWidths(criteriaWidths);
        criteriaTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);

        Paragraph benefittingCampus = new Paragraph(reportRequestHeaderDataHolder.getBenefittingCampus(),
                headerSheetRegularFont);
        Paragraph benefittingChart = new Paragraph(reportRequestHeaderDataHolder.getBenefittingChart(),
                headerSheetRegularFont);
        Paragraph benefittingOrganization = new Paragraph(
                reportRequestHeaderDataHolder.getBenefittingOrganization(), headerSheetRegularFont);
        Paragraph kemidTypeCode = new Paragraph(reportRequestHeaderDataHolder.getKemidTypeCode(),
                headerSheetRegularFont);
        Paragraph kemidPurposeCode = new Paragraph(reportRequestHeaderDataHolder.getKemidPurposeCode(),
                headerSheetRegularFont);
        Paragraph combinationGroupCode = new Paragraph(reportRequestHeaderDataHolder.getCombineGroupCode(),
                headerSheetRegularFont);

        criteriaTable.addCell(
                createCellWithDefaultFontAndWithoutBorderLine("Benefitting Campus:", Element.ALIGN_RIGHT));
        criteriaTable.addCell(benefittingCampus);
        criteriaTable.addCell(
                createCellWithDefaultFontAndWithoutBorderLine("Benefitting Chart:", Element.ALIGN_RIGHT));
        criteriaTable.addCell(benefittingChart);
        criteriaTable.addCell(createCellWithDefaultFontAndWithoutBorderLine("Benefitting Organization:",
                Element.ALIGN_RIGHT));
        criteriaTable.addCell(benefittingOrganization);
        criteriaTable.addCell(
                createCellWithDefaultFontAndWithoutBorderLine("KEMID Type Code:", Element.ALIGN_RIGHT));
        criteriaTable.addCell(kemidTypeCode);
        criteriaTable.addCell(
                createCellWithDefaultFontAndWithoutBorderLine("KEMID Purpose Code:", Element.ALIGN_RIGHT));
        criteriaTable.addCell(kemidPurposeCode);
        criteriaTable.addCell(
                createCellWithDefaultFontAndWithoutBorderLine("Combine Group Code:", Element.ALIGN_RIGHT));
        criteriaTable.addCell(combinationGroupCode);
        document.add(criteriaTable);

        // kemids with multiple benefitting organization
        Paragraph kemidWithMultipleBenefittingOrganization = new Paragraph(
                "\nKEMIDs with Multiple Benefitting Organizations:\n\n");
        document.add(kemidWithMultipleBenefittingOrganization);

        List<KemidsWithMultipleBenefittingOrganizationsDataHolder> kemidsWithMultipleBenefittingOrganizationsDataHolder = reportRequestHeaderDataHolder
                .getKemidsWithMultipleBenefittingOrganizationsDataHolders();
        if (kemidsWithMultipleBenefittingOrganizationsDataHolder != null
                && !kemidsWithMultipleBenefittingOrganizationsDataHolder.isEmpty()) {
            PdfPTable kemidWithMultipleBenefittingOrganizationTable = new PdfPTable(5);
            kemidWithMultipleBenefittingOrganizationTable.setWidthPercentage(MULTIPLE_KEMID_TABLE_WIDTH);
            kemidWithMultipleBenefittingOrganizationTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);

            Paragraph kemid = new Paragraph("KEMID", titleFont);
            Paragraph campus = new Paragraph("Campus", titleFont);
            Paragraph chart = new Paragraph("Chart", titleFont);
            Paragraph organization = new Paragraph("Organziation", titleFont);
            Paragraph percent = new Paragraph("Percent", titleFont);
            kemidWithMultipleBenefittingOrganizationTable.addCell(kemid);
            kemidWithMultipleBenefittingOrganizationTable.addCell(campus);
            kemidWithMultipleBenefittingOrganizationTable.addCell(chart);
            kemidWithMultipleBenefittingOrganizationTable.addCell(organization);
            kemidWithMultipleBenefittingOrganizationTable.addCell(percent);

            for (KemidsWithMultipleBenefittingOrganizationsDataHolder kmbo : kemidsWithMultipleBenefittingOrganizationsDataHolder) {
                kemidWithMultipleBenefittingOrganizationTable
                        .addCell(new Paragraph(kmbo.getKemid(), headerSheetRegularFont));
                kemidWithMultipleBenefittingOrganizationTable
                        .addCell(new Paragraph(kmbo.getCampus(), headerSheetRegularFont));
                kemidWithMultipleBenefittingOrganizationTable
                        .addCell(new Paragraph(kmbo.getChart(), headerSheetRegularFont));
                kemidWithMultipleBenefittingOrganizationTable
                        .addCell(new Paragraph(kmbo.getOrganization(), headerSheetRegularFont));
                kemidWithMultipleBenefittingOrganizationTable
                        .addCell(new Paragraph(kmbo.getPercent().toString(), headerSheetRegularFont));
            }
            document.add(kemidWithMultipleBenefittingOrganizationTable);
        } else {
            Paragraph noneExistMessage = new Paragraph("NONE EXIST\n\n", headerSheetRegularFont);
            document.add(noneExistMessage);
        }

        // kemids selected
        if ("Y".equalsIgnoreCase(listKemidsInHeader)) {
            List<String> kemidsSelected = reportRequestHeaderDataHolder.getKemidsSelected();
            int totalKemidsSelected = reportRequestHeaderDataHolder.getKemidsSelected().size();
            Paragraph kemidsSelectedTitle = new Paragraph("\nKEMIDs Selected: " + totalKemidsSelected + "\n\n");
            document.add(kemidsSelectedTitle);

            PdfPTable kemidsTable = new PdfPTable(KEMIDS_SELECTED_COLUMN_NUM);
            kemidsTable.setWidthPercentage(KEMID_SELECTED_TABLE_WIDTH);
            kemidsTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);

            for (int i = 0; i < totalKemidsSelected; i++) {
                kemidsTable.addCell(new Paragraph(kemidsSelected.get(i), headerSheetRegularFont));
            }
            // to fill out the rest of the empty cells. Otherwise, the row won't be displayed
            if (totalKemidsSelected % KEMIDS_SELECTED_COLUMN_NUM != 0) {
                for (int i = 0; i < (KEMIDS_SELECTED_COLUMN_NUM
                        - totalKemidsSelected % KEMIDS_SELECTED_COLUMN_NUM); i++) {
                    kemidsTable.addCell("");
                }
            }
            document.add(kemidsTable);
        }

    } catch (Exception e) {
        return false;
    }

    return true;
}

From source file:org.kuali.kfs.module.endow.report.util.EndowmentReportPrintBase.java

License:Educational Community License

/**
 * Generates the footer/*w  w w  .  j  a  v a2s  .  co  m*/
 * 
 * @param footerData
 * @param document
 */
public boolean printFooter(EndowmentReportFooterDataHolder footerData, Document document) {

    if (footerData == null) {
        return false;
    }

    try {
        document.add(new Phrase("\n"));

        PdfPTable table = new PdfPTable(2);
        table.setWidthPercentage(FULL_TABLE_WIDTH);
        int[] colWidths = { 40, 60 };
        table.setWidths(colWidths);
        table.getDefaultCell().setPadding(2);

        // left column
        PdfPTable leftTable = new PdfPTable(2);
        leftTable.setWidths(colWidths);
        leftTable.setWidthPercentage(40);

        leftTable.addCell(createCell("Reference: ", footerTitleFont, Element.ALIGN_LEFT, false));
        leftTable.addCell(createCell(footerData.getReference(), footerRegularFont, Element.ALIGN_LEFT, false));
        leftTable.addCell(createCell("Date Established: ", footerTitleFont, Element.ALIGN_LEFT, false));
        leftTable.addCell(
                createCell(footerData.getEstablishedDate(), footerRegularFont, Element.ALIGN_LEFT, false));
        leftTable.addCell(createCell("KEMID Type: ", footerTitleFont, Element.ALIGN_LEFT, false));
        leftTable.addCell(createCell(footerData.getKemidType(), footerRegularFont, Element.ALIGN_LEFT, false));
        leftTable.addCell(createCell("KEMID Purpose: ", footerTitleFont, Element.ALIGN_LEFT, false));
        leftTable.addCell(
                createCell(footerData.getKemidPurpose(), footerRegularFont, Element.ALIGN_LEFT, false));
        leftTable.addCell(createCell("Report Run Date: ", footerTitleFont, Element.ALIGN_LEFT, false));
        leftTable.addCell(
                createCell(footerData.getReportRunDate(), footerRegularFont, Element.ALIGN_LEFT, false));
        table.addCell(leftTable);

        // right column
        PdfPTable rightTable = new PdfPTable(4);
        rightTable.setWidthPercentage(60);

        PdfPCell cellBenefitting = new PdfPCell(new Paragraph("BENEFITTING\n", titleFont));
        cellBenefitting.setColspan(4);
        cellBenefitting.setBorderWidth(0);
        rightTable.addCell(cellBenefitting);

        rightTable.addCell(createCell("Campus", footerTitleFont, Element.ALIGN_LEFT, false));
        rightTable.addCell(createCell("Chart", footerTitleFont, Element.ALIGN_LEFT, false));
        rightTable.addCell(createCell("Organizaztion", footerTitleFont, Element.ALIGN_LEFT, false));
        rightTable.addCell(createCell("Percent", footerTitleFont, Element.ALIGN_LEFT, false));

        List<BenefittingForFooter> benefittingList = footerData.getBenefittingList();
        if (benefittingList != null) {
            for (BenefittingForFooter benefitting : benefittingList) {
                rightTable.addCell(createCell(benefitting.getCampusName(), footerRegularFont,
                        Element.ALIGN_LEFT, Element.ALIGN_TOP, false));
                rightTable.addCell(createCell(benefitting.getChartName(), footerRegularFont, Element.ALIGN_LEFT,
                        Element.ALIGN_TOP, false));
                rightTable.addCell(createCell(benefitting.getOrganizationName(), footerRegularFont,
                        Element.ALIGN_LEFT, Element.ALIGN_TOP, false));
                rightTable.addCell(createCell(benefitting.getBenefittingPercent(), footerRegularFont,
                        Element.ALIGN_LEFT, Element.ALIGN_TOP, false));
            }
        }

        table.addCell(rightTable);

        document.add(table);

    } catch (Exception e) {
        return false;
    }

    return true;
}

From source file:org.kuali.kfs.module.endow.report.util.TransactionStatementReportPrint.java

License:Educational Community License

/**
 * Generates the Transaction Statement report    
 * //from  w ww  .j a  va2  s .c  om
 * @param transactionStatementReports
 * @param document
 * @return
 */
public boolean printTransactionStatementReportBody(
        List<TransactionStatementReportDataHolder> transactionStatementReportDataHolders, Document document) {

    // for each kemid
    try {
        Font cellFont = regularFont;
        for (TransactionStatementReportDataHolder transactionStatementReport : transactionStatementReportDataHolders) {

            // new page
            document.newPage();

            // header
            StringBuffer title = new StringBuffer();
            title.append(transactionStatementReport.getInstitution()).append("\n");
            title.append("STATEMENT OF TRANSACTIONS FROM").append("\n");
            title.append(transactionStatementReport.getBeginningDate()).append(" to ")
                    .append(transactionStatementReport.getEndingDate()).append("\n");
            title.append(transactionStatementReport.getKemid()).append("     ")
                    .append(transactionStatementReport.getKemidLongTitle()).append("\n\n");
            Paragraph header = new Paragraph(title.toString());
            header.setAlignment(Element.ALIGN_CENTER);
            document.add(header);

            // report table
            PdfPTable table = new PdfPTable(4);
            table.setWidthPercentage(FULL_TABLE_WIDTH);
            int[] relativeWidths = { 10, 40, 25, 25 };
            table.setWidths(relativeWidths);
            table.getDefaultCell().setPadding(5);

            // table titles
            table.addCell(new Phrase("DATE", titleFont));
            table.addCell(new Phrase("DESCRIPTION", titleFont));
            table.addCell(
                    createCell("INCOME AMOUNT", titleFont, Element.ALIGN_RIGHT, Element.ALIGN_MIDDLE, true));
            table.addCell(
                    createCell("PRINCIPAL AMOUNT", titleFont, Element.ALIGN_RIGHT, Element.ALIGN_MIDDLE, true));

            // beginning cash balance
            table.addCell(new Phrase(transactionStatementReport.getBeginningDate(), cellFont));
            table.addCell(new Phrase("Beginning Cash Balance", cellFont));
            String amount = "";
            amount = formatAmount(transactionStatementReport.getBeginningIncomeCash());
            table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
            amount = formatAmount(transactionStatementReport.getBeginningPrincipalCash());
            table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));

            // transactions
            List<TransactionArchiveInfo> TransactionArchiveInfoList = transactionStatementReport
                    .getTransactionArchiveInfoList();
            for (TransactionArchiveInfo transactionArchiveInfo : TransactionArchiveInfoList) {
                table.addCell(new Phrase(transactionArchiveInfo.getPostedDate(), cellFont));
                table.addCell(new Phrase(getDescription(transactionArchiveInfo), cellFont));
                amount = formatAmount(transactionArchiveInfo.getTransactionIncomeCash());
                table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
                amount = formatAmount(transactionArchiveInfo.getTransactionPrincipalCash());
                table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
            }

            // ending cash balance
            table.addCell(new Phrase(transactionStatementReport.getEndingDate(), cellFont));
            table.addCell(new Phrase("Ending Cash Balance", cellFont));
            amount = formatAmount(transactionStatementReport.getEndingIncomeCash());
            table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
            amount = formatAmount(transactionStatementReport.getEndingPrincipalCash());
            table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));

            document.add(table);

            // footer
            printFooter(transactionStatementReport.getFooter(), document);
        }

    } catch (Exception e) {
        return false;
    }

    return true;
}

From source file:org.kuali.kfs.module.endow.report.util.TransactionSummaryReportPrint.java

License:Educational Community License

/**
 * Helper method to write a line containing the column headings for the report
 * /* w w w.j av  a 2  s.c  om*/
 * @return table
 */
protected PdfPTable writeDocumentTitleHeadings(String reportOption) {
    // report table
    int pdfPTableColumns;
    int[] relativeWidthsForDetails = { 140, 25, 25, 25 };
    int[] relativeWidthsForSummary = { 140, 25 };

    if (EndowConstants.EndowmentReport.DETAIL.equalsIgnoreCase(reportOption)) {
        pdfPTableColumns = 4;
    } else {
        pdfPTableColumns = 2;
    }

    try {
        PdfPTable table = new PdfPTable(pdfPTableColumns);
        table.setWidthPercentage(FULL_TABLE_WIDTH);
        table.setWidths((EndowConstants.EndowmentReport.DETAIL.equalsIgnoreCase(reportOption))
                ? relativeWidthsForDetails
                : relativeWidthsForSummary);
        table.getDefaultCell().setPadding(5);

        // table titles
        table.addCell(new Phrase("", titleFont));

        if (EndowConstants.EndowmentReport.DETAIL.equalsIgnoreCase(reportOption)) {
            table.addCell(createCell("INCOME", titleFont, Element.ALIGN_CENTER, true));
            table.addCell(createCell("PRINCIPAL", titleFont, Element.ALIGN_CENTER, true));
        }

        table.addCell(createCell("TOTAL", titleFont, Element.ALIGN_CENTER, true));
        return table;
    } catch (DocumentException ex) {
        LOG.info("Unable to write column headers.");
        return null;
    }
}

From source file:org.kuali.kfs.module.endow.report.util.TrialBalanceReportPrint.java

License:Educational Community License

/**
 * Generates the Trial Balance report/*w  ww  . ja v  a 2s .  com*/
 * 
 * @param trialBalanceReports
 * @param document
 * @return
 */
public boolean printTrialBalanceReportBody(List<TrialBalanceReportDataHolder> trialBalanceReports,
        Document document) {

    try {
        // title
        Paragraph title = new Paragraph("KEMID Trial Balance");
        title.setAlignment(Element.ALIGN_CENTER);
        Date currentDate = SpringContext.getBean(KEMService.class).getCurrentDate();
        DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
        String asOfDate = dateTimeService.toDateString(currentDate);
        title.add("\nAs of " + asOfDate + "\n\n");
        document.add(title);

        // report table
        PdfPTable table = new PdfPTable(7);
        table.setWidthPercentage(FULL_TABLE_WIDTH);
        int[] relativeWidths = { 10, 15, 15, 15, 15, 15, 15 };
        table.setWidths(relativeWidths);
        table.getDefaultCell().setPadding(2);

        // table titles
        table.addCell(new Phrase("KEMID", titleFont));
        table.addCell(new Phrase("KEMID Name", titleFont));
        table.addCell(new Phrase("Income Cash Balance", titleFont));
        table.addCell(new Phrase("Principal Cash Balance", titleFont));
        table.addCell(new Phrase("KEMID Total Market Value", titleFont));
        table.addCell(new Phrase("Available Expendable Funds", titleFont));
        table.addCell(new Phrase("FY Remainder Estimated Income", titleFont));

        // table body
        Font cellFont = regularFont;
        BigDecimal totalIncomeCashBalance = BigDecimal.ZERO;
        BigDecimal totalPrincipalCashBalance = BigDecimal.ZERO;
        BigDecimal totalMarketValueBalance = BigDecimal.ZERO;
        BigDecimal totalAvailableExpendableFundsBalance = BigDecimal.ZERO;
        BigDecimal totalFyRemainderEstimatedIncome = BigDecimal.ZERO;

        for (TrialBalanceReportDataHolder trialBalanceReport : trialBalanceReports) {

            // totals, which is the last row
            if (trialBalanceReport.getKemid().equalsIgnoreCase("TOTALS")) {
                cellFont = titleFont;
            }

            table.addCell(new Phrase(trialBalanceReport.getKemid(), cellFont));
            table.addCell(new Phrase(trialBalanceReport.getKemidName(), cellFont));
            if (trialBalanceReport.getInocmeCashBalance() != null) {
                String amount = formatAmount(trialBalanceReport.getInocmeCashBalance().bigDecimalValue());
                table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
                totalIncomeCashBalance = totalIncomeCashBalance
                        .add(trialBalanceReport.getInocmeCashBalance().bigDecimalValue());
            } else {
                table.addCell(createCell(ZERO_FOR_REPORT, cellFont, Element.ALIGN_RIGHT, true));
            }
            if (trialBalanceReport.getPrincipalcashBalance() != null) {
                String amount = formatAmount(trialBalanceReport.getPrincipalcashBalance().bigDecimalValue());
                totalPrincipalCashBalance = totalPrincipalCashBalance
                        .add(trialBalanceReport.getPrincipalcashBalance().bigDecimalValue());
                table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
            } else {
                table.addCell(createCell(ZERO_FOR_REPORT, cellFont, Element.ALIGN_RIGHT, true));
            }
            if (trialBalanceReport.getKemidTotalMarketValue() != null) {
                String amount = formatAmount(trialBalanceReport.getKemidTotalMarketValue());
                totalMarketValueBalance = totalMarketValueBalance
                        .add(trialBalanceReport.getKemidTotalMarketValue());
                table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
            } else {
                table.addCell(createCell(ZERO_FOR_REPORT, cellFont, Element.ALIGN_RIGHT, true));
            }
            if (trialBalanceReport.getAvailableExpendableFunds() != null) {
                String amount = formatAmount(trialBalanceReport.getAvailableExpendableFunds());
                totalAvailableExpendableFundsBalance = totalAvailableExpendableFundsBalance
                        .add(trialBalanceReport.getAvailableExpendableFunds());
                table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
            } else {
                table.addCell(createCell(ZERO_FOR_REPORT, cellFont, Element.ALIGN_RIGHT, true));
            }
            if (trialBalanceReport.getFyRemainderEstimatedIncome() != null) {
                String amount = formatAmount(trialBalanceReport.getFyRemainderEstimatedIncome());
                totalFyRemainderEstimatedIncome = totalFyRemainderEstimatedIncome
                        .add(trialBalanceReport.getFyRemainderEstimatedIncome());
                table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
            } else {
                table.addCell(createCell(ZERO_FOR_REPORT, cellFont, Element.ALIGN_RIGHT, true));
            }
        }

        // totals
        PdfPCell blank = new PdfPCell(new Paragraph("", cellFont));
        blank.setColspan(7);
        blank.setBackgroundColor(Color.LIGHT_GRAY);
        table.addCell(blank);

        table.addCell(createCell("TOTALS", titleFont, Element.ALIGN_LEFT, true));
        table.addCell(createCell("", cellFont, Element.ALIGN_RIGHT, true));
        table.addCell(createCell(formatAmount(totalIncomeCashBalance), cellFont, Element.ALIGN_RIGHT, true));
        table.addCell(createCell(formatAmount(totalPrincipalCashBalance), cellFont, Element.ALIGN_RIGHT, true));
        table.addCell(createCell(formatAmount(totalMarketValueBalance), cellFont, Element.ALIGN_RIGHT, true));
        table.addCell(createCell(formatAmount(totalAvailableExpendableFundsBalance), cellFont,
                Element.ALIGN_RIGHT, true));
        table.addCell(
                createCell(formatAmount(totalFyRemainderEstimatedIncome), cellFont, Element.ALIGN_RIGHT, true));

        document.add(table);

    } catch (Exception e) {
        return false;
    }

    return true;
}

From source file:org.kuali.kfs.module.purap.pdf.PurchaseOrderPdf.java

License:Open Source License

/**
 * Create a PDF using the given input parameters.
 *
 * @param po                             The PurchaseOrderDocument to be used to create the pdf.
 * @param document                       The pdf document whose margins have already been set.
 * @param writer                         The PdfWriter to write the pdf document into.
 * @param statusInquiryUrl               The status inquiry url to be displayed on the pdf document.
 * @param campusName                     The campus name to be displayed on the pdf document.
 * @param contractLanguage               The contract language to be displayed on the pdf document.
 * @param logoImage                      The logo image file name to be displayed on the pdf document.
 * @param directorSignatureImage         The director signature image to be displayed on the pdf document.
 * @param directorName                   The director name to be displayed on the pdf document.
 * @param directorTitle                  The director title to be displayed on the pdf document.
 * @param contractManagerSignatureImage  The contract manager signature image to be displayed on the pdf document.
 * @param isRetransmit                   The boolean to indicate whether this is for a retransmit purchase order document.
 * @param environment                    The current environment used (e.g. DEV if it is a development environment).
 * @param retransmitItems                The items selected by the user to be retransmitted.
 * @throws DocumentException/*  w w  w .j  a v a 2 s.c o  m*/
 * @throws IOException
 */
private void createPdf(PurchaseOrderDocument po, Document document, PdfWriter writer, String statusInquiryUrl,
        String campusName, String contractLanguage, String logoImage, String directorSignatureImage,
        String directorName, String directorTitle, String contractManagerSignatureImage, boolean isRetransmit,
        String environment, List<PurchaseOrderItem> retransmitItems) throws DocumentException, IOException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("createPdf() started for po number " + po.getPurapDocumentIdentifier().toString());
    }

    // 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);
    Collection errors = new ArrayList();

    // Date format pattern: MM-dd-yyyy
    SimpleDateFormat sdf = PurApDateFormatUtils
            .getSimpleDateFormat(PurapConstants.NamedDateFormats.KUALI_SIMPLE_DATE_FORMAT_2);

    // This turns on the page events that handle the header and page numbers.
    PurchaseOrderPdf events = new PurchaseOrderPdf().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 (vendor, address info) *****
    LOG.debug("createPdf() info table started.");
    float[] infoWidths = { 0.50f, 0.50f };
    PdfPTable infoTable = new PdfPTable(infoWidths);

    infoTable.setWidthPercentage(100);
    infoTable.setHorizontalAlignment(Element.ALIGN_CENTER);
    infoTable.setSplitLate(false);

    StringBuffer vendorInfo = new StringBuffer();
    vendorInfo.append("\n");
    if (StringUtils.isNotBlank(po.getVendorName())) {
        vendorInfo.append("     " + po.getVendorName() + "\n");
    }

    vendorInfo.append("     ATTN: " + po.getVendorAttentionName() + "\n");

    if (StringUtils.isNotBlank(po.getVendorLine1Address())) {
        vendorInfo.append("     " + po.getVendorLine1Address() + "\n");
    }
    if (StringUtils.isNotBlank(po.getVendorLine2Address())) {
        vendorInfo.append("     " + po.getVendorLine2Address() + "\n");
    }
    if (StringUtils.isNotBlank(po.getVendorCityName())) {
        vendorInfo.append("     " + po.getVendorCityName());
    }
    if (StringUtils.isNotBlank(po.getVendorStateCode())) {
        vendorInfo.append(", " + po.getVendorStateCode());
    }
    if (StringUtils.isNotBlank(po.getVendorAddressInternationalProvinceName())) {
        vendorInfo.append(", " + po.getVendorAddressInternationalProvinceName());
    }
    if (StringUtils.isNotBlank(po.getVendorPostalCode())) {
        vendorInfo.append(" " + po.getVendorPostalCode() + "\n");
    } else {
        vendorInfo.append("\n");
    }
    if (!KFSConstants.COUNTRY_CODE_UNITED_STATES.equalsIgnoreCase(po.getVendorCountryCode())
            && po.getVendorCountry() != null) {
        vendorInfo.append("     " + po.getVendorCountry().getName() + "\n\n");
    } else {
        vendorInfo.append("\n\n");
    }
    p = new Paragraph();
    p.add(new Chunk(" Vendor", ver_5_normal));
    p.add(new Chunk(vendorInfo.toString(), cour_7_normal));
    cell = new PdfPCell(p);
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    infoTable.addCell(cell);

    StringBuffer shipToInfo = new StringBuffer();
    shipToInfo.append("\n");

    if (po.getAddressToVendorIndicator()) { // use receiving address
        shipToInfo.append("     " + po.getReceivingName() + "\n");
        shipToInfo.append("     " + po.getReceivingLine1Address() + "\n");
        if (StringUtils.isNotBlank(po.getReceivingLine2Address())) {
            shipToInfo.append("     " + po.getReceivingLine2Address() + "\n");
        }
        shipToInfo.append("     " + po.getReceivingCityName() + ", " + po.getReceivingStateCode() + " "
                + po.getReceivingPostalCode() + "\n");
        if (StringUtils.isNotBlank(po.getReceivingCountryCode())
                && !KFSConstants.COUNTRY_CODE_UNITED_STATES.equalsIgnoreCase(po.getReceivingCountryCode())) {
            shipToInfo.append("     " + po.getReceivingCountryName() + "\n");
        }
    } else { // use delivery address
        shipToInfo.append("     " + po.getDeliveryToName() + "\n");
        // extra space needed below to separate other text going on same PDF line
        String deliveryBuildingName = po.getDeliveryBuildingName() + " ";
        if (po.isDeliveryBuildingOtherIndicator()) {
            deliveryBuildingName = "";
        }
        shipToInfo
                .append("     " + deliveryBuildingName + "Room #" + po.getDeliveryBuildingRoomNumber() + "\n");
        shipToInfo.append("     " + po.getDeliveryBuildingLine1Address() + "\n");
        if (StringUtils.isNotBlank(po.getDeliveryBuildingLine2Address())) {
            shipToInfo.append("     " + po.getDeliveryBuildingLine2Address() + "\n");
        }
        shipToInfo.append("     " + po.getDeliveryCityName() + ", " + po.getDeliveryStateCode() + " "
                + po.getDeliveryPostalCode() + "\n");
        if (StringUtils.isNotBlank(po.getDeliveryCountryCode())
                && !KFSConstants.COUNTRY_CODE_UNITED_STATES.equalsIgnoreCase(po.getDeliveryCountryCode())) {
            shipToInfo.append("     " + po.getDeliveryCountryName() + "\n");
        }
    }
    // display deliveryToPhoneNumber disregard of whether receiving or delivery address is used
    shipToInfo.append("     " + po.getDeliveryToPhoneNumber());
    /*
    // display deliveryToPhoneNumber based on the parameter indicator, disregard of whether receiving or delivery address is used
    boolean displayDeliveryPhoneNumber = SpringContext.getBean(ParameterService.class).getIndicatorParameter(PurchaseOrderDocument.class, PurapParameterConstants.DISPLAY_DELIVERY_PHONE_NUMBER_ON_PDF_IND);
    if (displayDeliveryPhoneNumber && StringUtils.isNotBlank(po.getDeliveryToPhoneNumber())) {
    shipToInfo.append("     " + po.getDeliveryToPhoneNumber());
    }
    */

    p = new Paragraph();
    p.add(new Chunk("  Shipping Address", ver_5_normal));
    p.add(new Chunk(shipToInfo.toString(), cour_7_normal));
    cell = new PdfPCell(p);
    infoTable.addCell(cell);

    p = new Paragraph();
    p.add(new Chunk("  Shipping Terms\n", ver_5_normal));
    if (po.getVendorShippingPaymentTerms() != null && po.getVendorShippingTitle() != null) {
        p.add(new Chunk("     " + po.getVendorShippingPaymentTerms().getVendorShippingPaymentTermsDescription(),
                cour_7_normal));
        p.add(new Chunk(" - " + po.getVendorShippingTitle().getVendorShippingTitleDescription(),
                cour_7_normal));
    } else if (po.getVendorShippingPaymentTerms() != null && po.getVendorShippingTitle() == null) {
        p.add(new Chunk("     " + po.getVendorShippingPaymentTerms().getVendorShippingPaymentTermsDescription(),
                cour_7_normal));
    } else if (po.getVendorShippingTitle() != null && po.getVendorShippingPaymentTerms() == null) {
        p.add(new Chunk("     " + po.getVendorShippingTitle().getVendorShippingTitleDescription(),
                cour_7_normal));
    }
    cell = new PdfPCell(p);
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    infoTable.addCell(cell);

    p = new Paragraph();
    p.add(new Chunk("  Payment Terms\n", ver_5_normal));
    if (po.getVendorPaymentTerms() != null) {
        p.add(new Chunk("     " + po.getVendorPaymentTerms().getVendorPaymentTermsDescription(),
                cour_7_normal));
    }
    cell = new PdfPCell(p);
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    infoTable.addCell(cell);

    p = new Paragraph();
    p.add(new Chunk("  Delivery Required By\n", ver_5_normal));

    if (po.getDeliveryRequiredDate() != null && po.getDeliveryRequiredDateReason() != null) {
        p.add(new Chunk("     " + sdf.format(po.getDeliveryRequiredDate()), cour_7_normal));
        p.add(new Chunk(" - " + po.getDeliveryRequiredDateReason().getDeliveryRequiredDateReasonDescription(),
                cour_7_normal));
    } else if (po.getDeliveryRequiredDate() != null && po.getDeliveryRequiredDateReason() == null) {
        p.add(new Chunk("     " + sdf.format(po.getDeliveryRequiredDate()), cour_7_normal));
    } else if (po.getDeliveryRequiredDate() == null && po.getDeliveryRequiredDateReason() != null) {
        p.add(new Chunk("     " + po.getDeliveryRequiredDateReason().getDeliveryRequiredDateReasonDescription(),
                cour_7_normal));
    }
    cell = new PdfPCell(p);
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    infoTable.addCell(cell);

    p = new Paragraph();
    p.add(new Chunk("  ", ver_5_normal));
    cell = new PdfPCell(p);
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    infoTable.addCell(cell);

    // Nested table for Order Date, etc.
    float[] nestedInfoWidths = { 0.50f, 0.50f };
    PdfPTable nestedInfoTable = new PdfPTable(nestedInfoWidths);
    nestedInfoTable.setSplitLate(false);

    p = new Paragraph();
    p.add(new Chunk("  Order Date\n", ver_5_normal));

    String orderDate = "";
    if (po.getPurchaseOrderInitialOpenTimestamp() != null) {
        orderDate = sdf.format(po.getPurchaseOrderInitialOpenTimestamp());
    } else {
        // This date isn't set until the first time this document is printed, so will be null the first time; use today's date.
        orderDate = sdf.format(getDateTimeService().getCurrentSqlDate());
    }

    p.add(new Chunk("     " + orderDate, cour_7_normal));
    cell = new PdfPCell(p);
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    nestedInfoTable.addCell(cell);

    p = new Paragraph();
    p.add(new Chunk("  Customer #\n", ver_5_normal));
    if (po.getVendorCustomerNumber() != null) {
        p.add(new Chunk("     " + po.getVendorCustomerNumber(), cour_7_normal));
    }
    cell = new PdfPCell(p);
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    nestedInfoTable.addCell(cell);

    p = new Paragraph();
    p.add(new Chunk("  Delivery Instructions\n", ver_5_normal));
    if (StringUtils.isNotBlank(po.getDeliveryInstructionText())) {
        p.add(new Chunk("     " + po.getDeliveryInstructionText(), cour_7_normal));
    }
    cell = new PdfPCell(p);
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    nestedInfoTable.addCell(cell);

    p = new Paragraph();
    p.add(new Chunk("  Contract ID\n", ver_5_normal));
    if (po.getVendorContract() != null) {
        p.add(new Chunk(po.getVendorContract().getVendorContractName(), cour_7_normal));
    }
    cell = new PdfPCell(p);
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    nestedInfoTable.addCell(cell);

    // Add the nestedInfoTable to the infoTable
    cell = new PdfPCell(nestedInfoTable);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    infoTable.addCell(cell);

    StringBuffer billToInfo = new StringBuffer();
    billToInfo.append("\n");
    billToInfo.append("     " + po.getBillingName() + "\n");
    billToInfo.append("     " + po.getBillingLine1Address() + "\n");
    if (po.getBillingLine2Address() != null) {
        billToInfo.append("     " + po.getBillingLine2Address() + "\n");
    }
    billToInfo.append("     " + po.getBillingCityName() + ", " + po.getBillingStateCode() + " "
            + po.getBillingPostalCode() + "\n");
    if (po.getBillingPhoneNumber() != null) {
        billToInfo.append("     " + po.getBillingPhoneNumber());
    }
    if (po.getBillingEmailAddress() != null) {
        billToInfo.append("\n     " + po.getBillingEmailAddress());
    }
    p = new Paragraph();
    p.add(new Chunk("  Billing Address", ver_5_normal));
    p.add(new Chunk("     " + billToInfo.toString(), cour_7_normal));
    p.add(new Chunk("\n Invoice status inquiry: " + statusInquiryUrl, ver_6_normal));
    cell = new PdfPCell(p);
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    infoTable.addCell(cell);

    document.add(infoTable);

    PdfPTable notesStipulationsTable = new PdfPTable(1);
    notesStipulationsTable.setWidthPercentage(100);
    notesStipulationsTable.setSplitLate(false);

    p = new Paragraph();
    p.add(new Chunk("  Vendor Note(s)\n", ver_5_normal));
    if (po.getVendorNoteText() != null) {
        p.add(new Chunk("     " + po.getVendorNoteText() + "\n", cour_7_normal));
    }

    PdfPCell tableCell = new PdfPCell(p);
    tableCell.setHorizontalAlignment(Element.ALIGN_LEFT);
    tableCell.setVerticalAlignment(Element.ALIGN_TOP);

    notesStipulationsTable.addCell(tableCell);

    p = new Paragraph();
    p.add(new Chunk("  Vendor Stipulations and Information\n", ver_5_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_7_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_7_normal));
    }

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

    document.add(notesStipulationsTable);

    // ***** Items table *****
    LOG.debug("createPdf() items table started.");

    float[] itemsWidths = { 0.07f, 0.1f, 0.07f, 0.45f, 0.15f, 0.15f };

    if (!po.isUseTaxIndicator()) {
        itemsWidths = ArrayUtils.add(itemsWidths, 0.14f);
        itemsWidths = ArrayUtils.add(itemsWidths, 0.15f);
    }

    PdfPTable itemsTable = new PdfPTable(itemsWidths.length);

    // 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 = new PdfPCell(new Paragraph("Item\nNo.", ver_5_normal));
    tableCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    itemsTable.addCell(tableCell);
    tableCell = new PdfPCell(new Paragraph("Quantity", ver_5_normal));
    tableCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    itemsTable.addCell(tableCell);
    tableCell = new PdfPCell(new Paragraph("UOM", ver_5_normal));
    tableCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    itemsTable.addCell(tableCell);
    tableCell = new PdfPCell(new Paragraph("Description", ver_5_normal));
    tableCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    itemsTable.addCell(tableCell);
    tableCell = new PdfPCell(new Paragraph("Unit Cost", ver_5_normal));
    tableCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    itemsTable.addCell(tableCell);
    tableCell = new PdfPCell(new Paragraph("Extended Cost", ver_5_normal));
    tableCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    itemsTable.addCell(tableCell);

    if (!po.isUseTaxIndicator()) {
        tableCell = new PdfPCell(new Paragraph("Tax Amount", ver_5_normal));
        tableCell.setHorizontalAlignment(Element.ALIGN_CENTER);
        itemsTable.addCell(tableCell);

        tableCell = new PdfPCell(new Paragraph("Total Amount", ver_5_normal));
        tableCell.setHorizontalAlignment(Element.ALIGN_CENTER);
        itemsTable.addCell(tableCell);
    }

    Collection<PurchaseOrderItem> itemsList = new ArrayList();
    if (isRetransmit) {
        itemsList = retransmitItems;
    } else {
        itemsList = po.getItems();
    }
    for (PurchaseOrderItem poi : itemsList) {
        if ((poi.getItemType() != null)
                && (poi.getItemType().isLineItemIndicator()
                        || poi.getItemType().getItemTypeCode()
                                .equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_SHIP_AND_HAND_CODE)
                        || poi.getItemType().getItemTypeCode()
                                .equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_FREIGHT_CODE)
                        || poi.getItemType().getItemTypeCode()
                                .equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_ORDER_DISCOUNT_CODE)
                        || poi.getItemType().getItemTypeCode()
                                .equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_TRADE_IN_CODE))
                && lineItemDisplaysOnPdf(poi)) {

            String description = (poi.getItemCatalogNumber() != null)
                    ? poi.getItemCatalogNumber().trim() + " - "
                    : "";
            description = description
                    + ((poi.getItemDescription() != null) ? poi.getItemDescription().trim() : "");
            if (StringUtils.isNotBlank(description)) {
                if (poi.getItemType().getItemTypeCode()
                        .equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_ORDER_DISCOUNT_CODE)
                        || poi.getItemType().getItemTypeCode()
                                .equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_TRADE_IN_CODE)
                        || poi.getItemType().getItemTypeCode()
                                .equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_FREIGHT_CODE)
                        || poi.getItemType().getItemTypeCode()
                                .equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_SHIP_AND_HAND_CODE)) {
                    // If this is a full order discount or trade-in item, we add the item type description to the description.
                    description = poi.getItemType().getItemTypeDescription() + " - " + description;
                }
            }

            // Above the line item types items display the line number; other types don't.
            if (poi.getItemType().isLineItemIndicator()) {
                tableCell = new PdfPCell(new Paragraph(poi.getItemLineNumber().toString(), cour_7_normal));
            } else {
                tableCell = new PdfPCell(new Paragraph(" ", cour_7_normal));
            }
            tableCell.setHorizontalAlignment(Element.ALIGN_CENTER);
            itemsTable.addCell(tableCell);
            String quantity = (poi.getItemQuantity() != null) ? poi.getItemQuantity().toString() : " ";
            tableCell = new PdfPCell(new Paragraph(quantity, cour_7_normal));
            tableCell.setHorizontalAlignment(Element.ALIGN_CENTER);
            tableCell.setNoWrap(true);
            itemsTable.addCell(tableCell);
            tableCell = new PdfPCell(new Paragraph(poi.getItemUnitOfMeasureCode(), cour_7_normal));
            tableCell.setHorizontalAlignment(Element.ALIGN_CENTER);
            itemsTable.addCell(tableCell);

            tableCell = new PdfPCell(new Paragraph(" " + description, cour_7_normal));
            tableCell.setHorizontalAlignment(Element.ALIGN_LEFT);
            itemsTable.addCell(tableCell);
            String unitPrice = poi.getItemUnitPrice().setScale(4, BigDecimal.ROUND_HALF_UP).toString();
            tableCell = new PdfPCell(new Paragraph(unitPrice + " ", cour_7_normal));
            tableCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            tableCell.setNoWrap(true);
            itemsTable.addCell(tableCell);
            tableCell = new PdfPCell(
                    new Paragraph(numberFormat.format(poi.getExtendedPrice()) + " ", cour_7_normal));
            tableCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            tableCell.setNoWrap(true);
            itemsTable.addCell(tableCell);

            if (!po.isUseTaxIndicator()) {
                KualiDecimal taxAmount = poi.getItemTaxAmount();
                taxAmount = taxAmount == null ? KualiDecimal.ZERO : taxAmount;
                tableCell = new PdfPCell(new Paragraph(numberFormat.format(taxAmount) + " ", cour_7_normal));
                tableCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
                tableCell.setNoWrap(true);
                itemsTable.addCell(tableCell);

                tableCell = new PdfPCell(
                        new Paragraph(numberFormat.format(poi.getTotalAmount()) + " ", cour_7_normal));
                tableCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
                tableCell.setNoWrap(true);
                itemsTable.addCell(tableCell);
            }

        }
    }
    // Blank line before totals
    itemsTable.addCell(" ");
    itemsTable.addCell(" ");
    itemsTable.addCell(" ");
    itemsTable.addCell(" ");
    itemsTable.addCell(" ");
    itemsTable.addCell(" ");

    if (!po.isUseTaxIndicator()) {
        itemsTable.addCell(" ");
        itemsTable.addCell(" ");
    }

    //Next Line
    if (!po.isUseTaxIndicator()) {

        //Print Total Prior to Tax
        itemsTable.addCell(" ");
        itemsTable.addCell(" ");
        itemsTable.addCell(" ");
        itemsTable.addCell(" ");
        itemsTable.addCell(" ");

        tableCell = new PdfPCell(new Paragraph("Total Prior to Tax: ", ver_10_normal));
        tableCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        itemsTable.addCell(tableCell);
        itemsTable.addCell(" ");
        KualiDecimal totalDollarAmount = new KualiDecimal(BigDecimal.ZERO);
        if (po instanceof PurchaseOrderRetransmitDocument) {
            totalDollarAmount = ((PurchaseOrderRetransmitDocument) po)
                    .getTotalPreTaxDollarAmountForRetransmit();
        } else {
            totalDollarAmount = po.getTotalPreTaxDollarAmount();
        }
        tableCell = new PdfPCell(new Paragraph(numberFormat.format(totalDollarAmount) + " ", cour_7_normal));
        tableCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        tableCell.setNoWrap(true);
        itemsTable.addCell(tableCell);

        //Print Total Tax
        itemsTable.addCell(" ");
        itemsTable.addCell(" ");
        itemsTable.addCell(" ");
        itemsTable.addCell(" ");
        itemsTable.addCell(" ");

        tableCell = new PdfPCell(new Paragraph("Total Tax: ", ver_10_normal));
        tableCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        itemsTable.addCell(tableCell);
        itemsTable.addCell(" ");
        totalDollarAmount = new KualiDecimal(BigDecimal.ZERO);
        if (po instanceof PurchaseOrderRetransmitDocument) {
            totalDollarAmount = ((PurchaseOrderRetransmitDocument) po).getTotalTaxDollarAmountForRetransmit();
        } else {
            totalDollarAmount = po.getTotalTaxAmount();
        }
        tableCell = new PdfPCell(new Paragraph(numberFormat.format(totalDollarAmount) + " ", cour_7_normal));
        tableCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        tableCell.setNoWrap(true);
        itemsTable.addCell(tableCell);

    }

    // Totals line; first 3 cols empty
    itemsTable.addCell(" ");
    itemsTable.addCell(" ");
    itemsTable.addCell(" ");

    if (!po.isUseTaxIndicator()) {
        itemsTable.addCell(" ");
        itemsTable.addCell(" ");
    }

    tableCell = new PdfPCell(new Paragraph("Total order amount: ", ver_10_normal));
    tableCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    itemsTable.addCell(tableCell);
    itemsTable.addCell(" ");
    KualiDecimal totalDollarAmount = new KualiDecimal(BigDecimal.ZERO);
    if (po instanceof PurchaseOrderRetransmitDocument) {
        totalDollarAmount = ((PurchaseOrderRetransmitDocument) po).getTotalDollarAmountForRetransmit();
    } else {
        totalDollarAmount = po.getTotalDollarAmount();
    }
    tableCell = new PdfPCell(new Paragraph(numberFormat.format(totalDollarAmount) + " ", cour_7_normal));
    tableCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tableCell.setNoWrap(true);
    itemsTable.addCell(tableCell);
    // Blank line after totals
    itemsTable.addCell(" ");
    itemsTable.addCell(" ");
    itemsTable.addCell(" ");
    itemsTable.addCell(" ");
    itemsTable.addCell(" ");
    itemsTable.addCell(" ");

    if (!po.isUseTaxIndicator()) {
        itemsTable.addCell(" ");
        itemsTable.addCell(" ");
    }

    document.add(itemsTable);

    // Contract language.
    LOG.debug("createPdf() contract language started.");
    document.add(new Paragraph(contractLanguage, ver_6_normal));
    document.add(new Paragraph("\n", ver_6_normal));

    // ***** Signatures table *****
    LOG.debug("createPdf() signatures table started.");
    float[] signaturesWidths = { 0.30f, 0.70f };
    PdfPTable signaturesTable = new PdfPTable(signaturesWidths);
    signaturesTable.setWidthPercentage(100);
    signaturesTable.setHorizontalAlignment(Element.ALIGN_CENTER);
    signaturesTable.setSplitLate(false);

    // Director signature and "for more info" line; only on APOs
    if (po.getPurchaseOrderAutomaticIndicator()) {
        // Empty cell.
        cell = new PdfPCell(new Paragraph(" ", cour_7_normal));
        cell.setBorderWidth(0);
        signaturesTable.addCell(cell);

        //boolean displayRequestorEmail = true; //SpringContext.getBean(ParameterService.class).getIndicatorParameter(PurchaseOrderDocument.class, PurapParameterConstants.DISPLAY_REQUESTOR_EMAIL_ADDRESS_ON_PDF_IND);
        if (StringUtils.isBlank(po.getInstitutionContactName())
                || StringUtils.isBlank(po.getInstitutionContactPhoneNumber())
                || StringUtils.isBlank(po.getInstitutionContactEmailAddress())) {
            //String emailAddress = displayRequestorEmail ? "  " + po.getRequestorPersonEmailAddress() : "";
            //p = new Paragraph("For more information contact: " + po.getRequestorPersonName() + "  " + po.getRequestorPersonPhoneNumber() + emailAddress, cour_7_normal);
            p = new Paragraph(
                    "For more information contact: " + po.getRequestorPersonName() + "  "
                            + po.getRequestorPersonPhoneNumber() + "  " + po.getRequestorPersonEmailAddress(),
                    cour_7_normal);
        } else {
            //String emailAddress = displayRequestorEmail ? "  " + po.getInstitutionContactEmailAddress() : "";
            //p = new Paragraph("For more information contact: " + po.getInstitutionContactName() + "  " + po.getInstitutionContactPhoneNumber() + emailAddress, cour_7_normal);
            p = new Paragraph("For more information contact: " + po.getInstitutionContactName() + "  "
                    + po.getInstitutionContactPhoneNumber() + "  " + po.getInstitutionContactEmailAddress(),
                    cour_7_normal);
        }
        cell = new PdfPCell(p);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setVerticalAlignment(Element.ALIGN_CENTER);
        cell.setBorderWidth(0);
        signaturesTable.addCell(cell);

        Image directorSignature = null;
        if (StringUtils.isNotBlank(directorSignatureImage)) {
            try {
                directorSignature = Image.getInstance(directorSignatureImage);
            } catch (FileNotFoundException e) {
                LOG.info("The director signature image [" + directorSignatureImage
                        + "] is not available.  Defaulting to the default image.");
            }
        }

        if (directorSignature == null) {
            // an empty cell if the contract manager signature image is not available.
            cell = new PdfPCell();
        } else {
            directorSignature.scalePercent(30, 30);
            cell = new PdfPCell(directorSignature, false);
        }

        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
        cell.setBorderWidth(0);
        signaturesTable.addCell(cell);

        // Empty cell.
        cell = new PdfPCell(new Paragraph(" ", cour_7_normal));
        cell.setBorderWidth(0);
        signaturesTable.addCell(cell);
    }

    // Director name and title; on every pdf.
    p = new Paragraph();
    if (LOG.isDebugEnabled()) {
        LOG.debug("createPdf() directorName parameter: " + directorName);
    }
    if (po.getPurchaseOrderAutomaticIndicator()) { // The signature is on the pdf; use small font.
        p.add(new Chunk(directorName, ver_6_normal));
    } else { // The signature isn't on the pdf; use larger font.
        p.add(new Chunk(directorName, ver_10_normal));
    }
    p.add(new Chunk("\n" + directorTitle, ver_4_normal));
    cell = new PdfPCell(p);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_TOP);
    cell.setBorderWidth(0);
    signaturesTable.addCell(cell);

    // Contract manager signature, name and phone; only on non-APOs
    if (!po.getPurchaseOrderAutomaticIndicator()) {

        Image contractManagerSignature = null;
        if (StringUtils.isNotBlank(contractManagerSignatureImage)) {
            try {
                contractManagerSignature = Image.getInstance(contractManagerSignatureImage);
            } catch (IOException e) {
                LOG.info("The contract manager image [" + contractManagerSignatureImage
                        + "] is not available.  Defaulting to the default image.");
            }
        }

        if (contractManagerSignature == null) {
            // an empty cell if the contract manager signature image is not available.
            cell = new PdfPCell();
        } else {
            contractManagerSignature.scalePercent(15, 15);
            cell = new PdfPCell(contractManagerSignature, false);
        }
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
        cell.setBorderWidth(0);
        signaturesTable.addCell(cell);

        // Empty cell.
        cell = new PdfPCell(new Paragraph(" ", ver_10_normal));
        cell.setBorderWidth(0);
        signaturesTable.addCell(cell);

        cell = new PdfPCell(new Paragraph(po.getContractManager().getContractManagerName() + "  "
                + po.getContractManager().getContractManagerPhoneNumber(), cour_7_normal));
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setVerticalAlignment(Element.ALIGN_TOP);
        cell.setBorderWidth(0);
        signaturesTable.addCell(cell);
    } else { // Empty cell.
        cell = new PdfPCell(new Paragraph(" ", ver_10_normal));
        cell.setBorderWidth(0);
        signaturesTable.addCell(cell);
    }
    document.add(signaturesTable);

    document.close();
    LOG.debug("createPdf()pdf document closed.");
}

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

License:Open Source 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/*from   w w w . java2 s .c om*/
 */
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 = PurApDateFormatUtils
            .getSimpleDateFormat(PurapConstants.NamedDateFormats.KUALI_SIMPLE_DATE_FORMAT_2);

    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 (!KFSConstants.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()) {
        purchasingAddressPartial = po.getReceivingCityName() + ", " + po.getReceivingStateCode() + " "
                + po.getReceivingPostalCode();
    } else {
        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.kuali.ole.describe.controller.EditorController.java

License:Open Source License

private void generateCallSlip(EditorForm editorForm, HttpServletResponse response) {
    LOG.debug("Creating pdf");
    String title = "", author = "", callNumber = "", location = "", copyNumber = "", enumeration = "",
            chronology = "", barcode = "";
    SearchResponse searchResponse = null;
    SearchParams searchParams = new SearchParams();
    SearchField searchField1 = searchParams.buildSearchField("item", "ItemIdentifier_search",
            editorForm.getDocId());//w  w  w.  ja  v  a 2s.c  om
    searchParams.getSearchConditions().add(searchParams.buildSearchCondition("OR", searchField1, "AND"));
    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("bibliographic", "Title"));
    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("bibliographic", "Author"));
    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("item", "CallNumber"));
    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("item", "LocationName"));
    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("item", "CopyNumber"));
    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("item", "enumeration"));
    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("item", "chronology"));
    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("item", "ItemBarcode"));
    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("holdings", "CallNumber"));
    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("holdings", "LocationName"));
    try {
        searchResponse = getDocstoreClientLocator().getDocstoreClient().search(searchParams);
    } catch (Exception e) {
        LOG.error(e, e);
    }
    if (CollectionUtils.isNotEmpty(searchResponse.getSearchResults())) {
        for (SearchResultField searchResultField : searchResponse.getSearchResults().get(0)
                .getSearchResultFields()) {
            if (searchResultField.getDocType().equalsIgnoreCase(DocType.BIB.getCode())
                    && searchResultField.getFieldName().equalsIgnoreCase("Title")) {
                if (StringUtils.isBlank(title)) {
                    title = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
                }
            } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.BIB.getCode())
                    && searchResultField.getFieldName().equalsIgnoreCase("Author")) {
                if (StringUtils.isBlank(author)) {
                    author = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
                }
            } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.ITEM.getCode())
                    && searchResultField.getFieldName().equalsIgnoreCase("CallNumber")) {
                callNumber = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
            } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.ITEM.getCode())
                    && searchResultField.getFieldName().equalsIgnoreCase("LocationName")) {
                location = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
            } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.ITEM.getCode())
                    && searchResultField.getFieldName().equalsIgnoreCase("CopyNumber")) {
                copyNumber = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
            } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.ITEM.getCode())
                    && searchResultField.getFieldName().equalsIgnoreCase("enumeration")) {
                enumeration = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue()
                        : "";
            } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.ITEM.getCode())
                    && searchResultField.getFieldName().equalsIgnoreCase("chronology")) {
                chronology = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
            } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.ITEM.getCode())
                    && searchResultField.getFieldName().equalsIgnoreCase("ItemBarcode")) {
                barcode = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
            } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.HOLDINGS.getCode())
                    && searchResultField.getFieldName().equalsIgnoreCase("CallNumber")) {
                if (StringUtils.isBlank(callNumber)) {
                    callNumber = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue()
                            : "";
                }
            } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.HOLDINGS.getCode())
                    && searchResultField.getFieldName().equalsIgnoreCase("LocationName")) {
                if (StringUtils.isBlank(location)) {
                    location = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue()
                            : "";
                }
            }
        }
    }
    String fileName = "Call/Paging Slip" + "_" + (editorForm.getTitle() != null ? editorForm.getTitle() : "")
            + "_" + new Date(System.currentTimeMillis()) + ".pdf";
    if (LOG.isInfoEnabled()) {
        LOG.info("File Created :" + title + "file name ::" + fileName + "::");
    }
    try {
        Document document = this.getDocument(0, 0, 5, 5);
        OutputStream outputStream = null;
        response.setContentType("application/pdf");
        //response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
        outputStream = response.getOutputStream();
        PdfWriter.getInstance(document, outputStream);
        Font boldFont = new Font(Font.TIMES_ROMAN, 15, Font.BOLD);
        document.open();
        document.newPage();
        PdfPTable pdfTable = new PdfPTable(3);
        pdfTable.setWidths(new int[] { 20, 2, 30 });
        Paragraph paraGraph = new Paragraph();
        paraGraph.setAlignment(Element.ALIGN_CENTER);
        paraGraph.add(new Chunk("Call/Paging Slip", boldFont));
        paraGraph.add(Chunk.NEWLINE);
        paraGraph.add(Chunk.NEWLINE);
        paraGraph.add(Chunk.NEWLINE);
        document.add(paraGraph);

        pdfTable.addCell(getPdfPCellInJustified("Title"));
        pdfTable.addCell(getPdfPCellInLeft(":"));
        pdfTable.addCell(getPdfPCellInJustified(title));

        pdfTable.addCell(getPdfPCellInJustified("Author"));
        pdfTable.addCell(getPdfPCellInLeft(":"));
        pdfTable.addCell(getPdfPCellInJustified(author));

        pdfTable.addCell(getPdfPCellInJustified("Call Number"));
        pdfTable.addCell(getPdfPCellInLeft(":"));
        pdfTable.addCell(getPdfPCellInJustified(callNumber));

        pdfTable.addCell(getPdfPCellInJustified("Location"));
        pdfTable.addCell(getPdfPCellInLeft(":"));
        pdfTable.addCell(getPdfPCellInJustified(location));

        pdfTable.addCell(getPdfPCellInJustified("Copy Number"));
        pdfTable.addCell(getPdfPCellInLeft(":"));
        pdfTable.addCell(getPdfPCellInJustified(copyNumber));

        pdfTable.addCell(getPdfPCellInJustified("Enumeration"));
        pdfTable.addCell(getPdfPCellInLeft(":"));
        pdfTable.addCell(getPdfPCellInJustified(enumeration));

        pdfTable.addCell(getPdfPCellInJustified("Chronology"));
        pdfTable.addCell(getPdfPCellInLeft(":"));
        pdfTable.addCell(getPdfPCellInJustified(chronology));

        pdfTable.addCell(getPdfPCellInJustified("Barcode"));
        pdfTable.addCell(getPdfPCellInLeft(":"));
        pdfTable.addCell(getPdfPCellInJustified(barcode));

        document.add(pdfTable);
        document.close();
        outputStream.flush();
        outputStream.close();
    } catch (Exception e) {
        LOG.error(e, e);
    }
}