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

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

Introduction

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

Prototype

public void setNoWrap(boolean noWrap) 

Source Link

Document

Setter for property noWrap.

Usage

From source file:jdbreport.model.io.pdf.itext2.PdfWriter.java

License:Apache License

private PdfPCell writeCell(ReportModel model, jdbreport.model.Cell srcCell, int row, int col)
        throws BadElementException, IOException, SaveReportException {

    CellStyle style = model.getStyles(srcCell.getStyleId());

    java.awt.Rectangle rect = model.getCellRect(row, col, true, true);

    float h = Math.round((float) Units.PT.setYPixels((int) rect.getHeight()));
    float w = Math.round((float) Units.PT.setXPixels((int) rect.getWidth()));

    PdfPCell pdfCell = null;

    if (srcCell.getPicture() != null) {
        java.awt.Image awtImage = srcCell.getPicture().getImage();
        com.lowagie.text.Image image = awtImageToImage(awtImage, srcCell, w, h);
        pdfCell = new PdfPCell(image);
    } else {/*from  w  ww .j av a  2 s.c  om*/

        String text = null;

        if (srcCell.getValue() instanceof CellValue<?>) {

            StringWriter strWriter = new StringWriter();
            PrintWriter printWriter = new PrintWriter(strWriter);

            if (!((CellValue<?>) srcCell.getValue()).write(printWriter, model, row, col, this,
                    ReportBook.PDF)) {
                java.awt.Image awtImage = ((CellValue<?>) srcCell.getValue()).getAsImage(model, row, col);
                if (awtImage != null) {
                    com.lowagie.text.Image image = awtImageToImage(awtImage, srcCell, w, h);
                    pdfCell = new PdfPCell(image);
                }
            } else {
                text = strWriter.getBuffer().toString();
            }

        } else {
            if (jdbreport.model.Cell.TEXT_HTML.equals(srcCell.getContentType())) {
                pdfCell = new PdfPCell();
                writeHTMLText(model.getStyles(srcCell.getStyleId()), srcCell, pdfCell);
            } else {
                text = model.getCellText(srcCell);
            }
        }

        if (pdfCell == null) {
            pdfCell = new PdfPCell();
        }

        if (text != null && text.length() > 0) {
            com.lowagie.text.Font font;
            if (fonts.containsKey(style.getId())) {
                font = fonts.get(style.getId());
            } else {
                font = getFontMapper().styleToPdf(style);
                fonts.put(style.getId(), font);
            }
            Paragraph p;
            if (font != null) {
                p = new Paragraph(text, font);
            } else {
                p = new Paragraph(text);
            }
            pdfCell.setPhrase(p);
            pdfCell.setPadding(1);
            pdfCell.setLeading(0f, 1.1f);
        } else {
            pdfCell.setPadding(0);
        }
    }

    pdfCell.setFixedHeight(h);
    pdfCell.setBackgroundColor(style.getBackground());
    pdfCell.setHorizontalAlignment(toPdfHAlignment(style.getHorizontalAlignment()));
    pdfCell.setVerticalAlignment(toPdfVAlignment(style.getVerticalAlignment()));

    if (style.getAngle() != 0) {
        pdfCell.setRotation(roundAngle(style.getAngle()));
    }

    assignBorders(style, pdfCell);
    pdfCell.setNoWrap(!style.isWrapLine());
    if (srcCell.getColSpan() > 0) {
        pdfCell.setColspan(srcCell.getColSpan() + 1);
    }
    if (srcCell.getRowSpan() > 0) {
        pdfCell.setRowspan(srcCell.getRowSpan() + 1);
    }

    return pdfCell;
}

From source file:open.dolphin.hiro.PrescriptionPDFMaker.java

private List<PdfPTable> createPrescriptionTbl2() {
    ClaimItem[] items;//from   w ww  .jav  a 2 s. c  o  m
    PdfPCell pcell, blank, numCell, amountCell;
    int num, cnt;
    double sum; // @009 ?????(?*)
    List<PdfPTable> preTblList = null;
    String admin, number; // @009
    String classCode, amount, medicine; // @009

    try {
        StringBuilder sb = new StringBuilder();
        sb.append(
                "???????(??)??????????????\n");
        sb.append(
                "?????????????????????????");
        PdfPTable ptbl = new PdfPTable(9); // @009
        ptbl.setWidthPercentage(100f);
        // @009 ???, ?, ??, ?, ??, , "(", , ")"
        float[] widthsP = { 14, 7, 52, 8, 15, 32, 2, 5, 9 };
        ptbl.setWidths(widthsP);
        ptbl.getDefaultCell().setPadding(0f);
        preTblList = new ArrayList<PdfPTable>();

        num = 1;
        //admin = "";  // @009 
        //number = ""; // @009 
        //amount = ""; // @009 ?
        numCell = new PdfPCell(new Paragraph("", min_8)); // @009
        numCell.setBorderWidth(LINE_WIDTH_0); // @009

        PdfPCell notes = new PdfPCell(new Paragraph("??", min_8));
        notes.setBorderWidth(LINE_WIDTH_1);
        notes.setBorderWidthBottom(LINE_WIDTH_0);
        PdfPCell bracket = new PdfPCell(new Paragraph("", min_15));
        bracket.setBorderWidth(LINE_WIDTH_0);
        bracket.setHorizontalAlignment(Element.ALIGN_RIGHT);
        bracket.setPadding(0f);
        PdfPCell notesDetail = new PdfPCell(new Paragraph(sb.toString(), min_6));
        notesDetail.setBorderWidth(LINE_WIDTH_0);
        notesDetail.setColspan(5);
        PdfPCell bracketC = new PdfPCell(new Paragraph("", min_15));
        bracketC.setBorderWidth(LINE_WIDTH_0);
        bracketC.setHorizontalAlignment(Element.ALIGN_LEFT);
        bracketC.setPadding(0f);
        bracketC.setColspan(2);

        for (Iterator<BundleMed> ite = pkg.getPriscriptionList().iterator(); ite.hasNext();) {
            BundleMed prescription = ite.next();
            admin = prescription.getAdmin(); // @009  
            number = prescription.getBundleNumber(); // @009  ????=1 bundeNumber
            classCode = prescription.getClassCode(); // @009   221 etc 

            items = prescription.getClaimItem();
            //minagawa^                
            boolean genericIsOk = true;

            if (items != null) {
                for (ClaimItem i : items) {
                    if (i.getCode().equals("099209903")) {
                        genericIsOk = false;
                        break;
                    }
                }
            }
            genericIsOk = true;
            //minagawa4                

            if (ptbl.getRows().isEmpty()) {
                ptbl.addCell(notes);
                ptbl.addCell(bracket);
                ptbl.addCell(notesDetail);
                ptbl.addCell(bracketC);
            }

            // @001 2009/11/17 ?
            // items?null???????????????
            // ???????????items ? null ??????
            // if???????????(??????????)
            if (items != null) {
                boolean clearFlg = true; // @004 2010/02/26  ?
                // ********** @009  **********
                //sum = 0; // ?????
                Font adminF = min_8; // 
                boolean wrap = true;
                if (admin != null) {
                    if (admin.length() > 17) {
                        // ??17???4??
                        adminF = min_4;
                        wrap = false;
                    } else if (admin.length() > 11) {
                        // ??11???6??
                        adminF = min_6;
                    }
                }
                Font medicineF; // ??
                // ********** @009  **********

                // ??? ClaimItem iterate
                for (cnt = 0; cnt < items.length; cnt++) {
                    //System.out.println("row size:" + ptbl.getRows().size());

                    // ??
                    if (!genericIsOk) {
                        blank = new PdfPCell(new Paragraph("", min_8));
                        blank.setBorderWidth(LINE_WIDTH_0);
                        blank.setBorderWidthRight(LINE_WIDTH_1);
                        ptbl.addCell(blank);
                        genericIsOk = true;

                    } else {
                        blank = new PdfPCell();
                        blank.setBorderWidth(LINE_WIDTH_0);
                        blank.setBorderWidthRight(LINE_WIDTH_1);
                        ptbl.addCell(blank);
                    }

                    if (ptbl.getRows().size() > 13) {
                        // ?13???????????
                        blank = new PdfPCell();
                        blank.setBorderWidth(LINE_WIDTH_0);
                        blank.setColspan(4);
                        ptbl.addCell(blank);
                        pcell = new PdfPCell(new Paragraph("???", min_8));
                        pcell.setBorderWidth(LINE_WIDTH_0);
                        pcell.setColspan(5);
                        ptbl.addCell(pcell);
                        preTblList.add(ptbl);
                        ptbl = new PdfPTable(9);
                        ptbl.setWidthPercentage(100f);
                        ptbl.setWidths(widthsP);
                        ptbl.getDefaultCell().setPadding(0f);
                        // ??
                        ptbl.addCell(notes);
                        ptbl.addCell(bracket);
                        ptbl.addCell(notesDetail);
                        ptbl.addCell(bracketC);
                        blank = new PdfPCell();
                        blank.setBorderWidth(LINE_WIDTH_0);
                        blank.setBorderWidthRight(LINE_WIDTH_1);
                        ptbl.addCell(blank);
                    }

                    if (cnt > 0) {
                        // ?1?????????
                        blank = new PdfPCell();
                        blank.setBorderWidth(LINE_WIDTH_0);
                        ptbl.addCell(blank);
                    } else {
                        // ?1??????
                        numCell = new PdfPCell(new Paragraph(num++ + ")", min_8));
                        numCell.setBorderWidth(LINE_WIDTH_0);
                        setAlignRight(numCell);
                        ptbl.addCell(numCell);
                        // @004 2010/02/26  
                        // ?1?????? false ??
                        if (!ClaimConst.COMMENT_CODE_0.equals(items[cnt].getCode())) {
                            clearFlg = false;
                        }
                        // @004 2010/02/26  
                    }

                    // ********** @009  **********
                    amount = items[cnt].getNumber();
                    //                        System.out.println("??" + items[cnt].getName());
                    //                        System.out.println("?" + amount);
                    //medicine = "";
                    medicine = items[cnt].getName();
                    //                        System.out.println("????" + medicine.length());
                    if (medicine.length() > 19) {
                        // ????19???7??
                        medicineF = min_7;
                    } else {
                        // ????19???8???
                        medicineF = min_8;
                    }
                    // ********** @009  **********

                    if ((ClaimConst.SUBCLASS_CODE_ID.equals(items[cnt].getClassCodeSystem()))
                            && ((String.valueOf(ClaimConst.YAKUZAI).equals(items[cnt].getClassCode()))
                                    || (String.valueOf(ClaimConst.ZAIRYO).equals(items[cnt].getClassCode())))) {

                        pcell = new PdfPCell(new Paragraph(convertNVL(items[cnt].getName()), medicineF)); // ?? ??? ????
                        pcell.setBorderWidth(LINE_WIDTH_0);
                        ptbl.addCell(pcell);
                        amountCell = new PdfPCell(new Paragraph(convertNVL(amount), min_8)); // ?
                        setAlignRight(amountCell);
                        amountCell.setBorderWidth(LINE_WIDTH_0);
                        ptbl.addCell(amountCell);

                        if (!(String.valueOf(ClaimConst.ZAIRYO).equals(items[cnt].getClassCode()))) {
                            // ?????
                            pcell = new PdfPCell(new Paragraph(convertNVL(items[cnt].getUnit()), min_8)); // ??
                            pcell.setBorderWidth(LINE_WIDTH_0);
                            ptbl.addCell(pcell);
                            // ********** @009  **********
                            pcell = new PdfPCell(new Paragraph(admin, adminF)); // 
                            pcell.setBorderWidth(LINE_WIDTH_0);
                            pcell.setNoWrap(wrap);
                            ptbl.addCell(pcell);
                        } else {
                            blank = new PdfPCell();
                            blank.setColspan(2);
                            blank.setBorderWidth(LINE_WIDTH_0);
                            ptbl.addCell(blank);
                        }

                        if (ClaimConst.RECEIPT_CODE_GAIYO.equals(classCode)) {
                            pcell = new PdfPCell(new Paragraph("", min_8));
                            pcell.setBorderWidth(LINE_WIDTH_0);
                            pcell.setColspan(3);
                            ptbl.addCell(pcell);
                            sum = Double.parseDouble(amount) * Double.parseDouble(number);
                            DecimalFormat f = new DecimalFormat("####0.###");
                            //                                System.out.println("??" + sum);
                            amountCell.getPhrase().clear();
                            amountCell.getPhrase().add(new Paragraph(String.valueOf(f.format(sum)), min_8)); // ?
                        } else {
                            // 
                            if ((number != null) && !("".equals(number))) {
                                pcell = new PdfPCell(new Paragraph("(", min_8));
                                pcell.setBorderWidth(LINE_WIDTH_0);
                                ptbl.addCell(pcell);
                                pcell = new PdfPCell(new Paragraph(number, min_8));
                                pcell.setBorderWidth(LINE_WIDTH_0);
                                setAlignRight(pcell);
                                ptbl.addCell(pcell);

                                //minagawa^          
                                if (classCode.startsWith("22")) {
                                    // 
                                    pcell = new PdfPCell(new Paragraph(")", min_8));
                                } else if (classCode.startsWith("21")) {
                                    // 
                                    pcell = new PdfPCell(new Paragraph(")", min_8));
                                    // 
                                } else if (classCode.startsWith("23")) {
                                    pcell = new PdfPCell(new Paragraph("", min_8));
                                }
                                //minagawa$     
                                pcell.setBorderWidth(LINE_WIDTH_0);
                                setAlignRight(pcell);
                                ptbl.addCell(pcell);
                            } else {
                                blank = new PdfPCell();
                                blank.setBorderWidth(LINE_WIDTH_0);
                                blank.setColspan(3);
                                ptbl.addCell(blank);
                            }
                        }
                        // ********** @009  **********
                    } else {
                        pcell = new PdfPCell(new Paragraph(convertNVL(items[cnt].getName()), min_8));
                        pcell.setBorderWidth(LINE_WIDTH_0);
                        pcell.setColspan(7);
                        ptbl.addCell(pcell);
                    }
                }
                // @004 2010/02/26  
                // ?? true ????
                if (clearFlg && (admin == null)) {
                    numCell.getPhrase().clear();
                    num--;
                }
                // @004 2010/02/26  

            } else {
                String stampName = prescription.getOrderName();
                System.err.println("??" + stampName
                        + "????????????");
                StringBuilder b = new StringBuilder();
                b.append("??").append(stampName)
                        .append("?????????").append(System.getProperty(STR_LF));
                System.err.println(b.toString());
            }

            if (!ite.hasNext()) {
                blank = new PdfPCell();
                blank.setBorderWidth(LINE_WIDTH_0);
                ptbl.addCell(blank);
                pcell = new PdfPCell(new Paragraph("", min_8));
                pcell.setBorderWidth(LINE_WIDTH_0);
                pcell.setBorderWidthLeft(LINE_WIDTH_1);
                pcell.setPaddingLeft(30f);
                pcell.setColspan(8);
                ptbl.addCell(pcell);
                preTblList.add(ptbl);
            }
        }
    } catch (Exception e) {
        e.printStackTrace(System.err);
    }
    return preTblList;
}

From source file:org.areasy.common.doclet.document.tags.TagTD.java

License:Open Source License

private PdfPCell createCell(Element[] content) {
    int defaultAlign = (getType() == TAG_TH) ? Element.ALIGN_CENTER : Element.ALIGN_LEFT;

    String align = getInheritedAttribute("align", false);
    String valign = getInheritedAttribute("valign", false);
    String bgcolor = getInheritedAttribute("bgcolor", true);
    int alignment = HtmlTagUtility.getAlignment(align, defaultAlign);

    PdfPCell cell = PDFUtility.createElementCell(2, alignment, content);

    cell.setHorizontalAlignment(HtmlTagUtility.getAlignment(align, defaultAlign));
    cell.setVerticalAlignment(HtmlTagUtility.getVerticalAlignment(valign, Element.ALIGN_MIDDLE));
    cell.setBackgroundColor(HtmlTagUtility.getColor(bgcolor));
    cell.setColspan(parseSpan(getAttribute("colspan")));

    cell.setUseAscender(true); // needs newer iText
    cell.setUseDescender(true); // needs newer iText
    cell.setUseBorderPadding(true); // needs newer iText

    if (getAttribute("nowrap") != null)
        cell.setNoWrap(true);
    if (getType() == TAG_TH)
        cell.setMarkupAttribute(HEADER_INDICATOR_ATTR, "true");

    return cell;/* ww  w .  j a  v  a  2  s . c o m*/
}

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//from   w ww.j a  va  2 s. c om
 * @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.ole.module.purap.pdf.PurchaseOrderPdf.java

License:Educational Community License

/**
 * Create a PDF using the given input parameters.
 *
 * @param po                            The PurchaseOrderDocument to be used to create the pdf.
 * @param 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//www .  j a v a  2  s .  co  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.isInfoEnabled()) {
        LOG.info("Inside createPdf statement" + "PO:" + po + "Document:" + document + "PdfWriter:" + writer
                + "StatusInquiryUrl:" + statusInquiryUrl + "Campus Name:" + campusName + "Contract Language"
                + contractLanguage + "Logo Image:" + logoImage + "Director Signature Image:"
                + directorSignatureImage + "Director Name" + directorName + "Director Title:" + directorTitle
                + "Contract Manager Signature Image :" + contractManagerSignatureImage + "isRetransmit"
                + isRetransmit + "Environment" + environment + "retransmitItems" + retransmitItems);
    }
    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;
    // Code has been changed to get the locale dynamically
    NumberFormat numberFormat = NumberFormat.getCurrencyInstance();
    Collection errors = new ArrayList();

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

    // 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 (!OLEConstants.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())
                && !OLEConstants.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())
                && !OLEConstants.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.25f, 0.25f, 0.10f, 0.10f };

    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("Special Instructions", 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)) {
            boolean noteFlag = true;
            String description = (poi.getItemCatalogNumber() != null)
                    ? poi.getItemCatalogNumber().trim() + " - "
                    : "";
            String vendorNotes = "";
            if (poi.getNotes().size() > 0) {
                for (OleNotes oleNotes : poi.getNotes()) {
                    String note = getNoteType(oleNotes.getNoteTypeId());
                    if ((note != null && note.equals(OLEConstants.VENDOR_TYPE)) && noteFlag) {
                        vendorNotes = oleNotes.getNote();
                        noteFlag = false;
                    }
                }
            }

            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);
            tableCell = new PdfPCell(new Paragraph(" " + vendorNotes, cour_7_normal));
            tableCell.setHorizontalAlignment(Element.ALIGN_LEFT);
            itemsTable.addCell(tableCell);
            String unitPrice = poi.getItemUnitPrice().setScale(2, 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 5 cols empty
    itemsTable.addCell(" ");
    itemsTable.addCell(" ");
    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 (FileNotFoundException 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.tellervo.desktop.util.labels.PDFLabelMaker.java

License:Open Source License

public void addCell(PdfPCell cell) {

    cell.setBorder(borderwidth);//  www .  ja  v  a  2s .com

    cell.setNoWrap(false);
    cell.setFixedHeight(margins.getLabelHeight());

    //cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    //cell.setVerticalAlignment(Element.ALIGN_TOP);

    if (curX != 0) {
        PdfPCell gapcell = new PdfPCell();
        gapcell.setBorder(borderwidth);
        table.addCell(gapcell);
    }

    curX++;
    table.addCell(cell);

    if (curX == nAcross)
        //table.completeRow();
        curX = 0;
}

From source file:org.unitime.timetable.webutil.PdfWebTable.java

License:Open Source License

private float addText(PdfPCell cell, String text, boolean bold) {
    if (text == null)
        return addText(cell, "", bold, false, false, Color.BLACK, null);
    if (text.indexOf("@@") < 0)
        return addText(cell, text, bold, false, false, Color.BLACK, null);

    Color color = Color.BLACK;
    Color bcolor = Color.BLACK;
    Color bgColor = null;//from  w ww .j  a va 2  s .c  o m
    boolean bd = bold, it = false, un = false;
    boolean ba = false, bt = false, bb = false, bl = false, br = false;
    float maxWidth = 0;
    boolean first = true;

    for (StringTokenizer s = new StringTokenizer(text, "\n"); s.hasMoreTokens();) {
        String line = s.nextToken();
        float width = 0;
        int pos = 0;
        while (true) {
            int idx = line.indexOf("@@", pos);
            if (idx < 0) {
                if (ba) {
                    width += addText(cell, (!first && pos == 0 ? "\n" : "") + line.substring(pos), bd, it, un,
                            color, true, bcolor, bgColor);
                } else {
                    if (bt || bb || bl || br) {
                        width += addText(cell, (!first && pos == 0 ? "\n" : "") + line.substring(pos), bd, it,
                                un, color, bt, bb, bl, br, bcolor, bgColor);
                    } else
                        width += addText(cell, (!first && pos == 0 ? "\n" : "") + line.substring(pos), bd, it,
                                un, color, bgColor);
                }
                break;
            } else {
                if (ba) {
                    width += addText(cell, (!first && pos == 0 ? "\n" : "") + line.substring(pos, idx), bd, it,
                            un, color, true, bcolor, bgColor);
                } else {
                    if (bt || bb || bl || br) {
                        width += addText(cell, (!first && pos == 0 ? "\n" : "") + line.substring(pos, idx), bd,
                                it, un, color, bt, bb, bl, br, bcolor, bgColor);
                    } else
                        width += addText(cell, (!first && pos == 0 ? "\n" : "") + line.substring(pos, idx), bd,
                                it, un, color, bgColor);
                }
                pos = idx;
            }
            pos += 2; //for @@
            String cmd = line.substring(pos, line.indexOf(' ', pos));
            pos += cmd.length() + 1;
            if ("BOLD".equals(cmd))
                bd = true;
            if ("END_BOLD".equals(cmd))
                bd = false;
            if ("ITALIC".equals(cmd))
                it = true;
            if ("END_ITALIC".equals(cmd))
                it = false;
            if ("UNDERLINE".equals(cmd))
                un = true;
            if ("END_UNDERLINE".equals(cmd))
                un = false;
            if ("COLOR".equals(cmd)) {
                String hex = line.substring(pos, line.indexOf(' ', pos));
                pos += hex.length() + 1;
                if (hex.startsWith("#"))
                    hex = hex.substring(1);
                color = new Color(Integer.parseInt(hex, 16));
            }
            if ("END_COLOR".equals(cmd)) {
                color = Color.BLACK;
            }
            if ("BGCOLOR".equals(cmd)) {
                String hex = line.substring(pos, line.indexOf(' ', pos));
                pos += hex.length() + 1;
                bgColor = new Color(Integer.parseInt(hex, 16));
            }
            if ("END_BGCOLOR".equals(cmd)) {
                bgColor = null;
            }
            if ("IMAGE".equals(cmd)) {
                String name = line.substring(pos, line.indexOf(' ', pos));
                pos += name.length() + 1;
                width += addImage(cell, name);
            }
            if ("BORDER_ALL".equals(cmd) || "BORDER_TOP".equals(cmd) || "BORDER_BOTTOM".equals(cmd)
                    || "BORDER_LEFT".equals(cmd) || "BORDER_RIGHT".equals(cmd)) {

                String hex = line.substring(pos, line.indexOf(' ', pos));
                pos += hex.length() + 1;
                bcolor = new Color(Integer.parseInt(hex, 16));

                if ("BORDER_ALL".equals(cmd)) {
                    ba = true;
                } else {
                    if ("BORDER_TOP".equals(cmd)) {
                        bt = true;
                    }
                    if ("BORDER_BOTTOM".equals(cmd)) {
                        bb = true;
                    }
                    if ("BORDER_LEFT".equals(cmd)) {
                        bl = true;
                    }
                    if ("BORDER_RIGHT".equals(cmd)) {
                        br = true;
                    }
                }
            }
            if ("NO_WRAP".equals(cmd)) {
                cell.setNoWrap(true);
            }
        }
        maxWidth = Math.max(maxWidth, width);
        first = false;
    }
    return maxWidth;
}

From source file:recite18th.controller.Controller.java

License:Open Source License

public void print(String action) {
    /** thanks to http://www.java2s.com/Code/Java/PDF-RTF/DemonstratesthecreatingPDFinportraitlandscape.htm
     * QUICK FIX : do landscape//  w w  w .  j a va  2s  .c  om
     */
    response.setContentType("application/pdf"); // Code 1
    if (action.equals("download")) {
        response.setHeader("Content-Transfer-Encoding", "binary");
        response.setHeader("Content-Disposition",
                "attachment; filename=\"" + "Report " + controllerName + ".pdf\"");
    }
    Document document = new Document(PageSize.A1.rotate());
    try {
        PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); // Code 2
        document.open();

        // various fonts
        BaseFont bf_helv = BaseFont.createFont(BaseFont.HELVETICA, "Cp1252", false);
        BaseFont bf_times = BaseFont.createFont(BaseFont.TIMES_ROMAN, "Cp1252", false);
        BaseFont bf_courier = BaseFont.createFont(BaseFont.COURIER, "Cp1252", false);
        BaseFont bf_symbol = BaseFont.createFont(BaseFont.SYMBOL, "Cp1252", false);

        String headerImage = Config.base_path + "images/report-logo.gif";

        Image imghead = Image.getInstance(headerImage);
        imghead.setAbsolutePosition(0, 0);
        PdfContentByte cbhead = writer.getDirectContent();
        PdfTemplate tpLogo = cbhead.createTemplate(600, 300);
        tpLogo.addImage(imghead);

        PdfTemplate tpTitle = cbhead.createTemplate(1100, 300);
        String txtHeader = "BADAN KEPEGAWAIAN DAERAH PEMERINTAH DAERAH";//Config.application_title;
        tpTitle.beginText();
        tpTitle.setFontAndSize(bf_times, 36);
        tpTitle.showText(txtHeader);
        tpTitle.endText();

        PdfTemplate tpTitle2 = cbhead.createTemplate(900, 300);
        String txtHeader2 = "         KABUPATEN BANTUL YOGYAKARTA";
        tpTitle2.beginText();
        tpTitle2.setFontAndSize(bf_times, 36);
        tpTitle2.showText(txtHeader2);
        tpTitle2.endText();

        PdfTemplate tpAlamat = cbhead.createTemplate(1000, 400);
        tpAlamat.beginText();
        tpAlamat.setFontAndSize(bf_times, 24);
        tpAlamat.showText(
                "Alamat : Jln. R. W. Monginsidi No. 01 Kompleks Parasamya Bantul, Telp. (0274) 367509");
        tpAlamat.endText();

        DateFormat df = new SimpleDateFormat("dd MMM yyyy");
        java.util.Date dt = new java.util.Date();
        PdfTemplate tp3 = cbhead.createTemplate(600, 300);
        tp3.beginText();
        tp3.setFontAndSize(bf_times, 16);

        tp3.showText("Tanggal : " + df.format(dt));
        tp3.endText();

        cbhead.addTemplate(tpLogo, 800, 1500);//logo
        cbhead.addTemplate(tpTitle, 1000, 1580);
        cbhead.addTemplate(tpTitle2, 1000, 1540);
        cbhead.addTemplate(tpAlamat, 1000, 1500);//alamat
        cbhead.addTemplate(tp3, 270, 1500);//tanggal

        HeaderFooter header = new HeaderFooter(new Phrase(cbhead + "", new Font(bf_helv)), false);
        header.setAlignment(Element.ALIGN_CENTER);

        document.setHeader(header);

        //PdfContentByte cb = writer.getDirectContent();
        Paragraph par = new Paragraph(
                "\n\n\n\n\n\n\nLAPORAN DATA SELURUH " + controllerName.toUpperCase() + "\n");
        par.getFont().setStyle(Font.BOLD);
        par.getFont().setSize(18);
        par.setAlignment("center");
        document.add(par);
        document.add(new Paragraph("\n\n"));

        // get data
        initSqlViewDataPerPage();
        if (sqlViewDataPerPageForReport == null) {
            sqlViewDataPerPageForReport = sqlViewDataPerPage;
        }
        PreparedStatement pstmt = Db.getCon().prepareStatement(sqlViewDataPerPageForReport,
                ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
        ResultSet resultSet = pstmt.executeQuery();
        ResultSetMetaData metaColumn = resultSet.getMetaData();
        int nColoumn = metaColumn.getColumnCount();
        // thanks to set cell width http://www.jexp.ru/index.php/Java/PDF_RTF/Table_Cell_Size#Setting_Cell_Widths
        if (nColoumn > 0) {
            Model model = initModel();
            String tableName = model.getTableName();
            // create table header
            //     float[] widths = {1, 4};
            PdfPTable table;// = new PdfPTable(nColoumn);
            PdfPCell cell = new PdfPCell(new Paragraph("Daftar " + controllerName));

            Hashtable hashModel = TableCustomization.getTable(model.getTableName());

            int ncolumnHeader = nColoumn + 1; // +1 because of row. number
            if (hashModel != null) {
                ncolumnHeader = Integer.parseInt("" + hashModel.get("columnCount")) + 1;
            }
            table = new PdfPTable(ncolumnHeader);
            cell.setColspan(ncolumnHeader);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);

            Paragraph p2 = new Paragraph("No.");
            p2.getFont().setSize(20);
            PdfPCell cellColNo = new PdfPCell(p2);
            cellColNo.setNoWrap(true);
            cellColNo.setMinimumHeight(50);
            cellColNo.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellColNo);

            if (hashModel != null) {
                Enumeration k = hashModel.keys();
                while (k.hasMoreElements()) {
                    String key = (String) k.nextElement();
                    if (key.equals("columnCount")) {
                        continue;
                    }
                    PdfPCell cellCol = new PdfPCell(new Paragraph(hashModel.get(key) + ""));
                    cellCol.setNoWrap(true);
                    cellCol.setMinimumHeight(50);
                    cellCol.setHorizontalAlignment(Element.ALIGN_CENTER);

                    table.addCell(cellCol);
                }
            } else {
                for (int i = 1; i < ncolumnHeader; i++) {
                    System.out.println("DATA = " + metaColumn.getColumnName(i));
                    Paragraph p1 = new Paragraph(metaColumn.getColumnName(i) + "");
                    p1.getFont().setSize(20);
                    PdfPCell cellCol = new PdfPCell(p1);
                    cellCol.setHorizontalAlignment(Element.ALIGN_CENTER);
                    table.addCell(cellCol);
                }
            }

            //iterate all columns : table data
            resultSet.beforeFirst();
            int row = 1;
            while (resultSet.next()) {
                System.out.println(row);
                Paragraph p3 = new Paragraph(row + "");
                p3.getFont().setSize(20);
                cell = new PdfPCell(p3);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(cell);
                if (hashModel != null) {//skip dulu u/ kasus ga pny class kustomasi table
                    Enumeration k = hashModel.keys();
                    while (k.hasMoreElements()) {
                        String key = (String) k.nextElement();
                        if (key.equals("columnCount")) {
                            continue;
                        }
                        table.addCell(resultSet.getObject(key) + "");
                    }
                } else {
                    for (int i = 1; i < ncolumnHeader; i++) {
                        System.out.println("DATA = " + metaColumn.getColumnName(i));
                        Paragraph p1 = new Paragraph(resultSet.getObject(metaColumn.getColumnName(i)) + "");
                        p1.getFont().setSize(18);
                        PdfPCell cellCol = new PdfPCell(p1);
                        cellCol.setHorizontalAlignment(Element.ALIGN_CENTER);
                        table.addCell(cellCol);
                    }
                }

                row++;
            }

            document.add(table);
            document.add(new Paragraph("\n\n"));
            par = new Paragraph("Mengetahui");
            par.setAlignment("center");
            document.add(par);
            par = new Paragraph("Kepada Badan Kepegawaian");
            par.setAlignment("center");
            document.add(par);
            par = new Paragraph("\n\n\n");

            document.add(par);
            par = new Paragraph("Drs. Maman Permana");
            par.setAlignment("center");
            document.add(par);
            par = new Paragraph("Nip: 197802042006041013");
            par.setAlignment("center");

            document.add(par);

        }
        document.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:webBoltOns.server.reportWriter.JRivetWriter.java

License:Open Source License

/**
 * <h2><code>buildDetilLine</code></h2>
 * /*w  w  w. j  a v  a2 s  . c om*/
 * <p>
 *  create and print a detail line on the report    
 * </p>
 * 
 * 
 * @param   String [] record - report record to print
 * 
 */
private void buildDetilLine(String[] record) throws DocumentException {
    newpage = isNewPage(++rowCount);
    PdfPCell cell;

    if (record != null) {
        for (int c = 0; c < reportColumns.length; c++) {
            ReportColumn column = (ReportColumn) reportColumns[c];
            String value = " ";

            if (record != null) {
                if (column.getLevelBreak() > 0)
                    value = column.getAccumulator().getPrintValue(newpage);
                else
                    value = record[c];
            }

            cell = new PdfPCell(
                    new Paragraph(value, FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL)));

            cell.setBorder(0);
            cell.setNoWrap(true);

            cell.setBackgroundColor(detailColor);

            if (column.getAlignment().equals(ReportColumn.LEFT))
                cell.setHorizontalAlignment(Cell.ALIGN_LEFT);
            else if (column.getAlignment().equals(ReportColumn.RIGHT))
                cell.setHorizontalAlignment(Cell.ALIGN_RIGHT);
            else
                cell.setHorizontalAlignment(Cell.ALIGN_CENTER);

            reportBody.addCell(cell);

        }
    }
}

From source file:webBoltOns.server.reportWriter.JRivetWriter.java

License:Open Source License

/**
 * <h2><code>buildTotalLine</code></h2>
 * /*from  w  ww  . ja v a2 s.c o m*/
 * <p>
 *  Create printed total lines        
 * </p>
 * 
 * @param   String[] record - A report total line
 * 
 */
private void buildTotalLine(String[] record) throws DocumentException {
    ++rowCount;
    PdfPCell cell;

    if (record != null) {
        for (int c = 0; c < reportColumns.length; c++) {
            ReportColumn column = (ReportColumn) reportColumns[c];
            String value = record[c];

            cell = new PdfPCell(
                    new Paragraph(value, FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL)));

            cell.setBorder(0);
            cell.setNoWrap(true);

            cell.setBackgroundColor(totalColor);

            if (column.getAlignment().equals(ReportColumn.LEFT))
                cell.setHorizontalAlignment(Cell.ALIGN_LEFT);
            else if (column.getAlignment().equals(ReportColumn.RIGHT))
                cell.setHorizontalAlignment(Cell.ALIGN_RIGHT);
            else
                cell.setHorizontalAlignment(Cell.ALIGN_CENTER);

            reportBody.addCell(cell);

        }
    }
}