Example usage for com.itextpdf.text Paragraph setSpacingAfter

List of usage examples for com.itextpdf.text Paragraph setSpacingAfter

Introduction

In this page you can find the example usage for com.itextpdf.text Paragraph setSpacingAfter.

Prototype

public void setSpacingAfter(float spacing) 

Source Link

Usage

From source file:com.github.wolfposd.imsqti2pdf.PDFCreator.java

License:Open Source License

public void createPDF(String outputFile, ArrayList<Question> qlist, boolean showCorrectAnswer,
        PageCounter pagecounter, int maximumPageNumber, String inputFolder)
        throws DocumentException, IOException {
    _inputFolder = inputFolder;//  ww  w .  jav a  2  s . c o  m
    Document document = new Document(PageSize.A4, 50, 50, 70, 50);
    PdfWriter pdfwriter = PdfWriter.getInstance(document, new FileOutputStream(outputFile));

    pdfwriter.setBoxSize("art", new Rectangle(36, 54, 559, 788));

    pdfwriter.setPageEvent(new HeaderFooter(maximumPageNumber));

    if (pagecounter != null) {
        pdfwriter.setPageEvent(pagecounter);
    }

    document.open();

    Paragraph p = new Paragraph();
    // p.setSpacingBefore(SPACING);
    p.setSpacingAfter(SPACING);
    p.setIndentationLeft(INDENTATION);

    writeQuestions(p, document, showCorrectAnswer, qlist);

    document.close();

}

From source file:com.gp.cong.logisoft.lcl.report.LclAllBLPdfCreator.java

public PdfPTable bodySection() throws Exception {
    String exportRefRemarks = "";
    String routingInsRemarks = "";
    String InsStatement = "";
    StringBuilder pierValues = new StringBuilder();
    String[] remarkTypes = { REMARKS_TYPE_ROUTING_INSTRU, REMARKS_TYPE_EXPORT_REF };
    List remarks = new LclRemarksDAO().getRemarksByTypes(lclbl.getFileNumberId(), remarkTypes);
    for (Object row : remarks) {
        Object[] col = (Object[]) row;
        if (col[1].toString().equalsIgnoreCase("Export Reference")) {
            exportRefRemarks = col[0].toString();
        }//from  w ww.  ja  v a2 s .c  o  m
        if (col[1].toString().equalsIgnoreCase("Routing Instruction")) {
            routingInsRemarks = col[0].toString();
        }
    }
    String bill_type = lclbl.getBillingType();

    billingType = bill_type.equalsIgnoreCase("P") ? "** FREIGHT PREPAID **"
            : bill_type.equalsIgnoreCase("C") ? "** FREIGHT COLLECT **"
                    : bill_type.equalsIgnoreCase("B") && "Y".equalsIgnoreCase(printPpdBlBothKey)
                            ? "** FREIGHT PREPAID **"
                            : "** FREIGHT COLLECT **";
    billType = bill_type.equalsIgnoreCase("P") ? "PPD" : bill_type.equalsIgnoreCase("C") ? "COL" : "BOTH";
    LclSsDetail bookedOrPickedVoy = null;
    ExportVoyageSearchModel pickedDetails = new LclUnitSsDAO()
            .getPickedVoyageByVessel(lclBooking.getFileNumberId(), "E");
    if (pickedDetails != null && CommonUtils.isNotEmpty(pickedDetails.getUnitSsId())) {
        LclUnitSs lclUnitSs = new LclUnitSsDAO().findById(Long.parseLong(pickedDetails.getUnitSsId()));
        bookedOrPickedVoy = lclUnitSs.getLclSsHeader().getVesselSsDetail();
        unitNumber = lclUnitSs.getLclUnit().getUnitNo();
        voyageNumber = lclUnitSs.getLclSsHeader().getScheduleNo();
        sealOut = CommonUtils.isNotEmpty(lclUnitSs.getSUHeadingNote())
                ? lclUnitSs.getSUHeadingNote().toUpperCase()
                : "";
    } else {
        bookedOrPickedVoy = null != lclbl.getBookedSsHeaderId()
                ? lclbl.getBookedSsHeaderId().getVesselSsDetail()
                : null;
    }
    StringBuilder carrierName = new StringBuilder();
    if (bookedOrPickedVoy != null) {
        sailDate = DateUtils.formatStringDateToAppFormatMMM(bookedOrPickedVoy.getStd());
        sailDateFormat = DateUtils.formatDateToMMMMDDYYYY(bookedOrPickedVoy.getStd());
        ladenSailDateRemarks = "\nLaden On Board:" + sailDate;
        if (CommonFunctions.isNotNull(bookedOrPickedVoy.getSpReferenceName())) {
            carrierName.append(bookedOrPickedVoy.getSpReferenceName()).append("  ");
        }
        if (CommonUtils.isNotEmpty(bookedOrPickedVoy.getTransMode())) {
            carrierName.append(bookedOrPickedVoy.getTransMode()).append(". ");
        }
        if (CommonUtils.isNotEmpty(bookedOrPickedVoy.getSpReferenceNo())) {
            carrierName.append(bookedOrPickedVoy.getSpReferenceNo());
        }
        pierValues.append(bookedOrPickedVoy.getDeparture().getUnLocationName());
        if (null != bookedOrPickedVoy.getDeparture().getStateId()) {
            pierValues.append("/").append(bookedOrPickedVoy.getDeparture().getStateId().getCode());
        }
    }
    Paragraph p = null;
    table = new PdfPTable(2);
    table.setWidthPercentage(100f);
    table.setWidths(new float[] { 5.3f, 4.7f });
    PdfPCell bCell = null;

    bCell = new PdfPCell();
    bCell.setBorder(0);
    bCell.setPadding(0f);
    bCell.setBorderWidthBottom(0.06f);
    bCell.setBorderWidthTop(0.06f);
    bCell.setBorderWidthRight(0.06f);
    PdfPTable bTable = new PdfPTable(2);
    bTable.setWidths(new float[] { 5f, 4f });
    bTable.setWidthPercentage(100f);

    bTable.addCell(makeCellLeftTopNoBorderFont("SHIPPER/EXPORTER", -0.5f, 0.8f, blackBoldFont65));

    PdfPCell shCell = new PdfPCell();
    shCell.setBorder(0);
    shCell.setColspan(2);
    shCell.setPadding(0f);
    shCell.setPaddingLeft(4f);
    shCell.setBorderWidthBottom(0.06f);
    shCell.setFixedHeight(65f);
    String shipperDetails = lclUtils.getConcatenatedAccountDetails(lclbl.getShipContact());
    if (CommonUtils.isNotEmpty(shipperDetails)) {
        p = new Paragraph(11f, "" + shipperDetails.toUpperCase(), totalFontQuote);
        p.setAlignment(Element.ALIGN_LEFT);
        p.setSpacingAfter(15f);
    } else {
        p = new Paragraph(8f, "", totalFontQuote);
        shCell.setPadding(35f);
    }
    shCell.addElement(p);
    bTable.addCell(shCell);

    //consignee
    bTable.addCell(makeCellLeftTopNoBorderFont("CONSIGNEE", -0.5f, 0.8f, blackBoldFont65));
    //consignee Values
    PdfPCell cvCell = new PdfPCell();
    cvCell.setBorder(0);
    cvCell.setColspan(2);
    cvCell.setPadding(0f);
    cvCell.setPaddingLeft(4f);
    cvCell.setBorderWidthBottom(0.06f);
    cvCell.setFixedHeight(65f);
    String consDetails = lclUtils.getConcatenatedAccountDetails(lclbl.getConsContact());
    if (CommonUtils.isNotEmpty(consDetails)) {
        p = new Paragraph(11f, "" + consDetails.toUpperCase(), totalFontQuote);
        p.setSpacingAfter(15f);
        p.setAlignment(Element.ALIGN_LEFT);
    } else {
        p = new Paragraph(8f, "", totalFontQuote);
        cvCell.setPadding(30f);
    }
    cvCell.addElement(p);
    bTable.addCell(cvCell);

    //Notify
    bTable.addCell(makeCellLeftTopNoBorderFont("NOTIFY PARTY", -0.5f, 0.8f, blackBoldFont65));
    //consignee Values
    PdfPCell nvCell = new PdfPCell();
    nvCell.setBorder(0);
    nvCell.setColspan(2);
    nvCell.setPadding(0f);
    nvCell.setPaddingLeft(4f);
    nvCell.setBorderWidthBottom(0.06f);
    nvCell.setFixedHeight(70f);
    String notyDetails = lclUtils.getConcatenatedAccountDetails(lclbl.getNotyContact());
    if (CommonUtils.isNotEmpty(notyDetails)) {
        p = new Paragraph(11f, "" + notyDetails.toUpperCase(), totalFontQuote);
        p.setSpacingAfter(25f);
        p.setAlignment(Element.ALIGN_LEFT);
    } else {
        p = new Paragraph(8f, "", totalFontQuote);
        nvCell.setPadding(40f);
    }
    nvCell.addElement(p);
    bTable.addCell(nvCell);

    //place of receipt
    PdfPCell prCell = new PdfPCell();
    prCell.setBorder(0);
    prCell.setPaddingLeft(-0.9f);
    prCell.setPaddingTop(-0.2f);
    p = new Paragraph(7f, "PLACE OF RECEIPT", blackBoldFont65);
    p.setAlignment(Element.ALIGN_LEFT);
    prCell.addElement(p);
    bTable.addCell(prCell);
    /* Pier Logic */
    String pier = "N".equalsIgnoreCase(printPierPol)
            ? ("N".equalsIgnoreCase(printPierPol) && !"N".equalsIgnoreCase(hblPierOverRideKey))
                    ? hblPierOverRideKey
                    : pierValues.toString()
            : "";
    /* POL Logic */
    String pol = "";
    if ("Y".equalsIgnoreCase(printPierPol)) {
        if ("N".equalsIgnoreCase(hblPierOverRideKey)) {
            pol = pierValues.toString();
        } else {
            pol = hblPierOverRideKey;
        }
    } else {
        pol = !"N".equalsIgnoreCase(hblPolOverRideKey) ? hblPolOverRideKey : polValues;
    }
    Boolean checkBlInsurance = new LclBlAcDAO().checkBlInsurance(lclbl.getFileNumberId(),
            INSURANCE_CHARGE_CODE);
    if (checkBlInsurance && "Y".equalsIgnoreCase(printBlInsuranceKey)) {
        InsStatement = LoadLogisoftProperties.getProperty("InsuranceChargeComment");
    }
    PdfPCell pierCell = new PdfPCell();
    pierCell.setBorder(0);
    pierCell.setBorderWidthLeft(0.06f);
    pierCell.setPaddingTop(-0.2f);
    p = new Paragraph(7f, "PIER", blackBoldFont65);
    p.setAlignment(Element.ALIGN_LEFT);
    pierCell.addElement(p);
    bTable.addCell(pierCell);
    //place of receipt values
    PdfPCell prvCell = new PdfPCell();
    prvCell.setBorder(0);
    prvCell.setBorderWidthBottom(0.06f);
    if (lclBooking.getPooPickup()) {
        LclBookingPad lclBookingPad = lclBooking.getLclFileNumber().getLclBookingPadList().get(0);
        String pickUp_city = lclBookingPad.getPickUpCity().replaceAll("/", ",");
        pickUp_city = pickUp_city.substring(pickUp_city.indexOf("-") + 1, pickUp_city.length());
        p = new Paragraph(7f, "" + pickUp_city.toUpperCase(), totalFontQuote);
    } else {
        StringBuilder placeofReceipt = new StringBuilder();
        if (null != lclbl.getPortOfOrigin()) {
            placeofReceipt.append(lclbl.getPortOfOrigin().getUnLocationName());
            if (CommonFunctions.isNotNull(lclbl.getPortOfOrigin().getStateId())
                    && CommonFunctions.isNotNull(lclbl.getPortOfOrigin().getStateId().getCode())) {
                placeofReceipt.append(",").append(lclbl.getPortOfOrigin().getStateId().getCode());
            }
        }
        p = new Paragraph(7f, "" + placeofReceipt.toString().toUpperCase(), totalFontQuote);
    }
    p.setSpacingAfter(5f);
    p.setSpacingBefore(5f);
    p.setAlignment(Element.ALIGN_LEFT);
    prvCell.addElement(p);
    bTable.addCell(prvCell);
    //pier values

    PdfPCell piervCell = new PdfPCell();
    piervCell.setBorder(0);
    piervCell.setBorderWidthLeft(0.06f);
    piervCell.setBorderWidthBottom(0.06f);
    p = new Paragraph(7f, "" + pier, totalFontQuote);
    p.setSpacingAfter(5f);
    p.setSpacingBefore(5f);
    p.setAlignment(Element.ALIGN_LEFT);
    piervCell.addElement(p);
    bTable.addCell(piervCell);

    //exporting carrier
    PdfPCell ecCell = new PdfPCell();
    ecCell.setBorder(0);
    ecCell.setPaddingLeft(-0.5f);
    ecCell.setPaddingTop(-0.2f);
    p = new Paragraph(7f, "EXPORTING CARRIER (Vessel) (Flag)", blackBoldFont65);
    p.setAlignment(Element.ALIGN_LEFT);
    ecCell.addElement(p);
    bTable.addCell(ecCell);
    //portof loading
    PdfPCell portCell = new PdfPCell();
    portCell.setBorder(0);
    portCell.setPaddingTop(-0.2f);
    portCell.setBorderWidthLeft(0.06f);
    p = new Paragraph(7f, "PORT OF LOADING", blackBoldFont65);
    p.setAlignment(Element.ALIGN_LEFT);
    portCell.addElement(p);
    bTable.addCell(portCell);
    //exporting values
    PdfPCell exvCell = new PdfPCell();
    exvCell.setBorder(0);
    exvCell.setFixedHeight(15f);
    exvCell.setBorderWidthBottom(0.06f);
    p = new Paragraph(7f, "" + carrierName.toString().toUpperCase(), totalFontQuote);
    p.setSpacingAfter(5f);
    p.setSpacingBefore(5f);
    p.setAlignment(Element.ALIGN_LEFT);
    exvCell.addElement(p);
    bTable.addCell(exvCell);
    //port of loading values

    PdfPCell portvCell = new PdfPCell();
    portvCell.setBorder(0);
    portvCell.setBorderWidthLeft(0.06f);
    portvCell.setBorderWidthBottom(0.06f);
    p = new Paragraph(7f, "" + pol.toUpperCase(), totalFontQuote);
    p.setAlignment(Element.ALIGN_LEFT);
    portvCell.addElement(p);
    bTable.addCell(portvCell);
    //sea port of discharge
    PdfPCell seaCell = new PdfPCell();
    seaCell.setBorder(0);
    seaCell.setPaddingLeft(-0.5f);
    seaCell.setPaddingTop(-0.2f);
    p = new Paragraph(7f, "SEA PORT OF DISCHARGE", blackBoldFont65);
    p.setAlignment(Element.ALIGN_LEFT);
    seaCell.addElement(p);
    bTable.addCell(seaCell);
    //finalde
    PdfPCell finalCell = new PdfPCell();
    finalCell.setBorder(0);
    finalCell.setBorderWidthLeft(0.06f);
    finalCell.setPaddingTop(-0.2f);
    p = new Paragraph(7f, "FINAL DELIVERY TO", blackBoldFont65);
    p.setAlignment(Element.ALIGN_LEFT);
    finalCell.addElement(p);
    bTable.addCell(finalCell);
    //sea values
    PdfPCell seavCell = new PdfPCell();
    seavCell.setBorder(0);
    seavCell.setFixedHeight(25f);
    //   seavCell.setBorderWidthBottom(0.06f);
    p = new Paragraph(7f, "" + podValues.toUpperCase(), totalFontQuote);
    p.setAlignment(Element.ALIGN_LEFT);
    seavCell.addElement(p);
    bTable.addCell(seavCell);
    //fina deliver  values

    String finalDest = !fdOverride.equalsIgnoreCase("N") ? fdOverride
            : (agencyInfo != null && CommonUtils.isNotEmpty(agencyInfo[2])) ? agencyInfo[2]
                    : blUtils.getBLConcatenatedFinalDestination(lclbl);
    PdfPCell finalvCell = new PdfPCell();
    finalvCell.setBorder(0);
    finalvCell.setBorderWidthLeft(0.06f);
    p = new Paragraph(7f, !finalDest.equalsIgnoreCase(podValues) ? "" + finalDest.toUpperCase() : "",
            totalFontQuote);
    p.setAlignment(Element.ALIGN_LEFT);
    finalvCell.addElement(p);
    bTable.addCell(finalvCell);

    bCell.addElement(bTable);
    table.addCell(bCell);
    //2column

    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setPadding(0f);
    cell.setBorderWidthBottom(0.06f);
    cell.setBorderWidthTop(0.06f);
    PdfPTable pTable = new PdfPTable(2);
    pTable.setWidths(new float[] { 4f, 2f });
    pTable.setWidthPercentage(100f);
    PdfPCell nCell = null;

    nCell = new PdfPCell();
    nCell.setBorder(0);
    nCell.setPaddingTop(0.2f);
    p = new Paragraph(7f, "DOCUMENT NO", blackBoldFont65);
    p.setAlignment(Element.ALIGN_LEFT);
    nCell.addElement(p);
    pTable.addCell(nCell);

    nCell = new PdfPCell();
    nCell.setBorder(0);
    nCell.setPaddingTop(0.2f);
    p = new Paragraph(7f, "PAGE : " + ++page_count, blackBoldFont65);
    p.setAlignment(Element.ALIGN_RIGHT);
    nCell.addElement(p);
    pTable.addCell(nCell);

    String consolidateNumber = new LclConsolidateDAO()
            .getConsolidatesFileNumbers(lclbl.getLclFileNumber().getId().toString());
    consolidateNumber = null == consolidateNumber ? lclbl.getLclFileNumber().getFileNumber()
            : lclbl.getLclFileNumber().getFileNumber() + "," + consolidateNumber;

    PdfPCell dvCell = new PdfPCell();
    dvCell.setBorder(0);
    dvCell.setColspan(2);
    dvCell.setBorderWidthBottom(0.06f);
    dvCell.setPaddingLeft(8f);
    dvCell.setPaddingBottom(5f);
    dvCell.setPaddingTop(2f);
    p = new Paragraph(8f, "" + consolidateNumber.toUpperCase(), totalFontQuote);
    p.setAlignment(Element.ALIGN_LEFT);
    dvCell.addElement(p);
    pTable.addCell(dvCell);

    PdfPCell eCell = new PdfPCell();
    eCell.setBorder(0);
    eCell.setPaddingTop(0.2f);
    eCell.setColspan(2);
    p = new Paragraph(7f, "EXPORT REFERENCE", blackBoldFont65);
    p.setAlignment(Element.ALIGN_LEFT);
    eCell.addElement(p);
    pTable.addCell(eCell);

    PdfPCell evCell = new PdfPCell();
    evCell.setBorder(0);
    evCell.setColspan(2);
    evCell.setBorderWidthBottom(0.06f);
    evCell.setPaddingLeft(8f);
    evCell.setFixedHeight(35f);
    exportRefRemarks = exportRefRemarks
            + ("EXPORT".equalsIgnoreCase(ladenSailDateOptKey) ? ladenSailDateRemarks : "")
            + ("EXPORT".equalsIgnoreCase(printTermsTypeKey) ? termsType1 : "");
    if (exportRefRemarks != null && !exportRefRemarks.equals("")) {
        p = new Paragraph(10f, "" + exportRefRemarks, totalFontQuote);
        p.setAlignment(Element.ALIGN_LEFT);
    } else {
        p = new Paragraph(8f, "", contentBLNormalFont);
    }
    evCell.addElement(p);
    pTable.addCell(evCell);

    PdfPCell fCell = new PdfPCell();
    fCell.setBorder(0);
    fCell.setColspan(2);
    fCell.setPaddingTop(0.2f);
    p = new Paragraph(7f, "FORWARDING AGENT-REFERENCES", blackBoldFont65);
    p.setAlignment(Element.ALIGN_LEFT);
    fCell.addElement(p);
    pTable.addCell(fCell);
    //forwarding avlues
    PdfPCell fvCell = new PdfPCell();
    fvCell.setBorder(0);
    fvCell.setColspan(2);
    fvCell.setPaddingLeft(3f);
    fvCell.setPaddingTop(2f);
    fvCell.setBorderWidthBottom(0.06f);
    fvCell.setFixedHeight(65f);
    if (null != lclbl.getFwdAcct()
            && !lclbl.getFwdAcct().getAccountName().equalsIgnoreCase("NO FRT. FORWARDER ASSIGNED")) {
        boolean forwarderAcctFlag = new LCLBlDAO()
                .getFreightForwardAcctStatus(lclbl.getFwdAcct().getAccountno());
        String fwdDetails = lclUtils.getConcatenatedAccountDetails(lclbl.getFwdContact());
        if (CommonUtils.isNotEmpty(fwdDetails) && !forwarderAcctFlag) {
            p = new Paragraph(11f, "" + fwdDetails.toUpperCase(), totalFontQuote);
            p.setSpacingAfter(15f);
            p.setAlignment(Element.ALIGN_LEFT);
        } else {
            p = new Paragraph(8f, "", totalFontQuote);
            fvCell.setPadding(25f);
        }
        fvCell.addElement(p);
        pTable.addCell(fvCell);
    } else {
        p = new Paragraph(8f, "", totalFontQuote);
        fvCell.setBorderWidthBottom(0.06f);
        pTable.addCell(fvCell);
    }

    //pointoforigin
    PdfPCell pCell = new PdfPCell();
    pCell.setBorder(0);
    pCell.setColspan(2);
    pCell.setPaddingTop(0.2f);
    p = new Paragraph(7f, "POINT AND COUNTRY OF ORIGIN", blackBoldFont65);
    p.setAlignment(Element.ALIGN_LEFT);
    pCell.addElement(p);
    pTable.addCell(pCell);
    //point avlues
    PdfPCell pvCell = new PdfPCell();
    pvCell.setBorder(0);
    pvCell.setColspan(2);
    pvCell.setPaddingLeft(8f);
    pvCell.setPaddingBottom(5f);
    pvCell.setPaddingTop(2f);
    pvCell.setFixedHeight(20f);
    pvCell.setBorderWidthBottom(0.06f);
    if (lclbl.getPointOfOrigin() != null) {
        p = new Paragraph(9f, "" + lclbl.getPointOfOrigin(), totalFontQuote);
        pvCell.addElement(p);
    }
    p.setAlignment(Element.ALIGN_LEFT);
    pTable.addCell(pvCell);

    //domes
    PdfPCell doCell = new PdfPCell();
    doCell.setBorder(0);
    doCell.setColspan(2);
    doCell.setPaddingTop(0.2f);
    p = new Paragraph(7f, "DOMESTIC ROUTING/EXPORT INSTRUCTIONS", blackBoldFont65);
    p.setAlignment(Element.ALIGN_LEFT);
    doCell.addElement(p);
    pTable.addCell(doCell);
    //point avlues
    PdfPCell dovCell = new PdfPCell();
    dovCell.setBorder(0);
    dovCell.setColspan(2);
    dovCell.setPaddingLeft(8f);
    dovCell.setBorderWidthBottom(0.06f);
    dovCell.setFixedHeight(45f);
    routingInsRemarks = routingInsRemarks
            + ("ROUTING".equalsIgnoreCase(ladenSailDateOptKey) ? ladenSailDateRemarks : "")
            + ("ROUTING".equalsIgnoreCase(printTermsTypeKey) ? termsType1 : "");
    if (routingInsRemarks != null && !"".equalsIgnoreCase(routingInsRemarks)) {
        p = new Paragraph(10f, "" + routingInsRemarks, totalFontQuote);
        p.setSpacingAfter(10f);
        p.setAlignment(Element.ALIGN_LEFT);
    } else {
        p = new Paragraph(8f, "", contentBLNormalFont);
        dovCell.setPadding(15f);
    }
    dovCell.addElement(p);
    pTable.addCell(dovCell);

    //addito
    PdfPCell adCell = new PdfPCell();
    adCell.setBorder(0);
    adCell.setColspan(2);
    adCell.setPaddingTop(0.2f);
    p = new Paragraph(7f, "ADDITIONAL DOCUMENT NUMBERS", blackBoldFont65);
    p.setAlignment(Element.ALIGN_LEFT);
    adCell.addElement(p);
    pTable.addCell(adCell);
    //add values
    PdfPCell advCell = new PdfPCell();
    advCell.setBorder(0);
    advCell.setColspan(2);
    advCell.setPadding(10f);
    p = new Paragraph(7f, InsStatement, totalFontQuote);
    p.setAlignment(Element.ALIGN_LEFT);
    advCell.addElement(p);
    pTable.addCell(advCell);

    cell.addElement(pTable);
    table.addCell(cell);
    return table;
}

From source file:com.gp.cong.logisoft.lcl.report.LclAllBLPdfCreator.java

public PdfPTable commodityTab(LclBlPiece lclBlPiece) throws DocumentException, Exception {
    LclReportUtils reportUtils = new LclReportUtils();
    LclConsolidateDAO consolidateDAO = new LclConsolidateDAO();
    List<Long> conoslidatelist = consolidateDAO.getConsolidatesFiles(lclbl.getFileNumberId());
    conoslidatelist.add(lclbl.getFileNumberId());
    Lcl3pRefNoDAO _3pRefNoDAO = new Lcl3pRefNoDAO();
    StringBuilder inbondAppend = new StringBuilder();//Inbond
    inbondAppend.append(reportUtils.appendInbond(conoslidatelist, new LclInbondsDAO()));
    StringBuilder ncmAppend = new StringBuilder();//NCM
    ncmAppend.append(reportUtils.appendNcm(conoslidatelist, _3pRefNoDAO));
    StringBuilder hsAppend = new StringBuilder();//HS
    hsAppend.append(reportUtils.appendHsCode(conoslidatelist, new LclBookingHsCodeDAO()));
    StringBuilder aesAppend = new StringBuilder();//AES
    aesAppend.append(reportUtils.appendAes(conoslidatelist, _3pRefNoDAO));
    Paragraph p = null;
    table = new PdfPTable(5);
    table.setWidthPercentage(100f);/*  ww  w  . j  a  v a  2 s.com*/
    table.setWidths(new float[] { 2f, 0.75f, 4.74f, 1.047f, 1.047f });
    LclHazmatDAO hazmatDAO = new LclHazmatDAO();
    StringBuilder hazmatValues = new StringBuilder();
    if (commodity_count == 1) {
        hazmatValues.append(reportUtils.appendHazmatForFreightInvoice(conoslidatelist, hazmatDAO));//Hazmat List
    }
    cell = new PdfPCell();
    cell.setBorder(0);
    if (lclBlPiece.getMarkNoDesc() != null && !lclBlPiece.getMarkNoDesc().equals("")) {
        p = new Paragraph(7f, "" + lclBlPiece.getMarkNoDesc().toUpperCase(), totalFontQuote);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
    }
    if (CommonUtils.isNotEmpty(inbondAppend)) {
        p = new Paragraph(7f, "INBOND:" + inbondAppend.toString(), totalFontQuote);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
    }
    if ("N".equalsIgnoreCase(ncmKeyValue) && CommonUtils.isNotEmpty(ncmAppend)) {
        p = new Paragraph(7f, "" + ncmAppend.toString(), totalFontQuote);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
    }
    if ("N".equalsIgnoreCase(aesKeyValue) && CommonUtils.isNotEmpty(aesAppend)) {
        p = new Paragraph(7f, "" + aesAppend.toString(), totalFontQuote);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
    }
    if ("N".equalsIgnoreCase(hsKeyValue) && CommonUtils.isNotEmpty(hsAppend)) {
        p = new Paragraph(7f, "" + hsAppend.toString(), totalFontQuote);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
    }
    if ("MARKS".equalsIgnoreCase(printTermsTypeKey)) {
        p = new Paragraph(7f, "" + termsType1, totalFontQuote);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
    }
    table.addCell(cell);

    //no of pkgs
    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setBorderWidthLeft(0.6f);
    if (printdocumentName.equalsIgnoreCase("Bill Of Lading") && "Y".equalsIgnoreCase(miniKeyValue)) {
        List<LclBookingPiece> lclBookingPieceList = new LclBookingPieceDAO()
                .getConsolidatePieceCount(conoslidatelist);
        for (LclBookingPiece bkgPiece : lclBookingPieceList) {
            String packageDesc = null != bkgPiece.getActualPackageType()
                    ? bkgPiece.getActualPackageType().getAbbr01()
                    : bkgPiece.getPackageType().getAbbr01();
            Integer pieceCount = bkgPiece.getActualPieceCount() != null ? bkgPiece.getActualPieceCount()
                    : bkgPiece.getBookedPieceCount();
            p = new Paragraph(7f, "" + pieceCount + " " + packageDesc, totalFontQuote);
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
        }
    } else if (lclBlPiece != null && lclBlPiece.getActualPieceCount() != null
            && lclBlPiece.getPackageType().getAbbr01() != null) {
        p = new Paragraph(7f,
                "" + lclBlPiece.getActualPieceCount() + " " + lclBlPiece.getPackageType().getAbbr01(),
                totalFontQuote);
        p.setAlignment(Element.ALIGN_CENTER);
        // p.setSpacingAfter(spaceSize);
        cell.addElement(p);
    }
    table.addCell(cell);

    //desc
    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setBorderWidthLeft(0.6f);
    // print option "Y" Print Haz info first before Descriptions
    if (CommonUtils.isNotEmpty(hazmatValues) && "Y".equalsIgnoreCase(printHazBeforeKeyValue)) {
        String hazmat = hazmatValues.toString().replace("WEIGHT", "WT");
        p = new Paragraph(7f, "" + hazmat.toUpperCase(), totalFontQuote);
        p.setAlignment(Element.ALIGN_LEFT);
        p.setSpacingAfter(10f);
        cell.addElement(p);
    }
    String commodityDesc = null != lclBlPiece.getPieceDesc() ? lclBlPiece.getPieceDesc().toUpperCase() : "";
    p = new Paragraph(6.7f,
            "" + commodityDesc + ("BODYBL".equalsIgnoreCase(ladenSailDateOptKey) ? ladenSailDateRemarks : "")
                    + ("BODYBL".equalsIgnoreCase(printTermsTypeKey) ? termsType1 : ""),
            totalFontQuote);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);

    if (CommonUtils.isNotEmpty(hazmatValues) && "N".equalsIgnoreCase(printHazBeforeKeyValue)) {
        String hazmat = hazmatValues.toString().replace("WEIGHT", "WT");
        p = new Paragraph(7f, "" + hazmat.toUpperCase(), totalFontQuote);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
    }
    if ("Y".equalsIgnoreCase(ncmKeyValue) && CommonUtils.isNotEmpty(ncmAppend)) {
        p = new Paragraph(7f, "" + ncmAppend.toString(), totalFontQuote);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
    }
    if ("Y".equalsIgnoreCase(aesKeyValue) && CommonUtils.isNotEmpty(aesAppend)) {
        p = new Paragraph(7f, "" + aesAppend.toString(), totalFontQuote);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
    }
    if ("Y".equalsIgnoreCase(hsKeyValue) && CommonUtils.isNotEmpty(hsAppend)) {
        p = new Paragraph(7f, "" + hsAppend.toString(), totalFontQuote);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
    }
    table.addCell(cell);
    setCaribbenAndNonCaribben(lclBlPiece, impKeyValue, metKeyValue, "M".equalsIgnoreCase(engmet));
    if (commodity_count == lclBlPiecesList.size()) {
        table.setExtendLastRow(true);
    }
    return table;
}

From source file:com.gp.cong.logisoft.lcl.report.LclAllBLPdfCreator.java

public PdfPTable addingCommodityValues() throws DocumentException, ParseException, Exception {
    Font font6 = new Font(FontFamily.COURIER, 6f, Font.BOLD);
    Font blackContentNormalFont8 = FontFactory.getFont("Arial", 8f, Font.NORMAL);
    Paragraph p = null;

    table = new PdfPTable(5);
    table.setWidthPercentage(100f);// w ww  . ja  va 2 s .co m
    table.setWidths(new float[] { 2.74f, 1f, 6.33f, 1.40f, 1.40f });

    cell = new PdfPCell();
    cell.setBorder(0);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setBorderWidthLeft(0.6f);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setColspan(0);
    cell.setBorderWidthLeft(0.6f);
    p = new Paragraph(7f, " " + ipeHotCodeComments, blackContentNormalFont8);
    p.setAlignment(Element.ALIGN_LEFT);
    p.setSpacingAfter(2f);
    cell.addElement(p);
    p = new Paragraph(7f, "" + billingType, totalFontQuote);
    p.setAlignment(Element.ALIGN_CENTER);
    p.setSpacingAfter(2f);
    cell.addElement(p);

    if ("Y".equalsIgnoreCase(receiveKeyValue)) {
        p = new Paragraph(7f,
                "*** PLEASE NOTE THAT PAYMENT MUST BE RECEIVED PRIOR TO  ISSUING EXPRESS RELEASE / ORIGINAL HBL ***",
                blackContentNormalFont8);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
    }
    p = new Paragraph(7f,
            "I HEREBY DECLARE THAT THE ABOVE NAMED MATERIALS ARE PROPERLY CLASSIFIED," + "\n"
                    + "DESCRIBED,PACKAGED, MARKED, AND LABELED, AND ARE IN PROPER CONDITION FOR" + "\n"
                    + "TRANSPORTATION ACCORDING TO THE APPLICABLE REGULATIONS OF THE DEPARTMENT" + "\n"
                    + " OF TRANSPORTATION AND IMO.",
            font6);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setColspan(0);
    cell.setBorderWidthLeft(0.6f);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setBorderWidthLeft(0.6f);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setColspan(5);
    p = new Paragraph(7f,
            " Declared value per Package if value is More Than $500 Per Package USD___________________________",
            blackContentNormalFont8);
    p.setAlignment(Element.ALIGN_CENTER);
    p.setSpacingBefore(5f);
    cell.addElement(p);

    p = new Paragraph(7f,
            "These Commodities, Technology Or Software Were Exported From the United States in Accordance with the Export "
                    + "Administration Regulations.",
            blackContentNormalFont8);
    p.setSpacingBefore(5f);
    p.setAlignment(Element.ALIGN_CENTER);
    cell.addElement(p);

    p = new Paragraph(7f, "Diversion Contrary To U.S. Law Prohibited.", blackContentNormalFont8);
    p.setSpacingBefore(3f);
    p.setAlignment(Element.ALIGN_CENTER);
    cell.addElement(p);
    table.addCell(cell);
    return table;
}

From source file:com.gp.cong.logisoft.lcl.report.LclAllBLPdfCreator.java

public PdfPTable appendDescComments() throws Exception {
    PdfPTable descTable = new PdfPTable(5);
    descTable.setWidthPercentage(100f);//from   www.jav a 2s.  c  om
    descTable.setWidths(new float[] { 0.1f, 0.5f, 4f, 0.5f, 0.01f });
    PdfPCell descCell = null;
    Paragraph p = null;
    descCell = new PdfPCell();
    descCell.setBorder(0);
    descCell.setColspan(5);
    String comments = LoadLogisoftProperties.getProperty(ruleName.equalsIgnoreCase("ECU") ? "ECU.tariffterms"
            : this.ruleName.equalsIgnoreCase("OTI") ? "OTI.tariffterms" : "Econo.tariffterms");
    p = new Paragraph(8f, comments + "" + "" + "\n"
            + "IN WITNESS WHERE OF THE CARRIER BY ITS AGENT HAS SIGNED................. 3(THREE) BILLS OF LADING, ALL OF THE SAME TENOR AND DATE, "
            + "ONE OF WHICH BEING ACCOMPLISHED, THE OTHERS TO STAND VOID.\nPLEASE SEE OUR WEBSITE FOR TERMS AND CONDITIONS.",
            contentNormalFont);
    p.setSpacingAfter(10f);
    p.setAlignment(Element.ALIGN_LEFT);
    descCell.addElement(p);
    descCell.setFixedHeight(100f);
    descTable.addCell(descCell);

    descCell = new PdfPCell();
    descCell.setBorder(0);
    descTable.addCell(descCell);

    descCell = new PdfPCell();
    descCell.setColspan(5);
    descCell.setFixedHeight(10f);
    descCell.setBorder(0);
    descTable.addCell(descCell);

    descCell = new PdfPCell();
    descCell.setBorder(0);
    descCell.setColspan(2);
    descTable.addCell(descCell);

    descCell = new PdfPCell();
    descCell.setBorder(0);
    descCell.setBorderWidthBottom(0.06f);
    String carrierName = LoadLogisoftProperties.getProperty(ruleName.equalsIgnoreCase("ECU") ? "ECU.carrier"
            : ruleName.equalsIgnoreCase("OTI") ? "OTI.carrier" : "Econo.carrier");
    p = new Paragraph(12f, "BY " + carrierName.toUpperCase(), fontCompNormalSub);
    p.setAlignment(Element.ALIGN_LEFT);
    descCell.addElement(p);
    descTable.addCell(descCell);

    descCell = new PdfPCell();
    descCell.setBorder(0);
    descCell.setColspan(2);
    descTable.addCell(descCell);

    descCell = new PdfPCell();
    descCell.setFixedHeight(15f);
    descCell.setColspan(2);
    descCell.setBorder(0);
    descTable.addCell(descCell);

    descCell = new PdfPCell();
    descCell.setBorder(0);
    descCell.setBorderWidthBottom(0.06f);
    p = new Paragraph(7f, "", blackBoldFontSize8);
    p.setAlignment(Element.ALIGN_LEFT);
    descCell.addElement(p);
    descTable.addCell(descCell);

    descCell = new PdfPCell();
    descCell.setBorder(0);
    descCell.setColspan(2);
    descTable.addCell(descCell);

    descCell = new PdfPCell();
    descCell.setBorder(0);
    descCell.setColspan(2);
    descCell.setFixedHeight(15f);
    descTable.addCell(descCell);

    descCell = new PdfPCell();
    descCell.setBorder(0);
    descCell.setBorderWidthBottom(0.06f);
    p = new Paragraph(12f, "" + polValues.toUpperCase(), fontCompNormalSub);
    p.setAlignment(Element.ALIGN_CENTER);
    descCell.addElement(p);
    descTable.addCell(descCell);

    descCell = new PdfPCell();
    descCell.setBorder(0);
    descCell.setColspan(2);
    descTable.addCell(descCell);

    descCell = new PdfPCell();
    descCell.setBorder(0);
    descCell.setColspan(2);
    descTable.addCell(descCell);

    descCell = new PdfPCell();
    descCell.setBorder(0);
    if ("N".equalsIgnoreCase(portKey)) {
        p = new Paragraph(7f, "PORT", fontCompNormalSub);
    } else {
        p = new Paragraph(7f, "PORT" + " " + portKeyValue, fontCompNormalSub);
    }
    p.setAlignment(Element.ALIGN_CENTER);
    descCell.addElement(p);
    descTable.addCell(descCell);

    descCell = new PdfPCell();
    descCell.setBorder(0);
    descCell.setColspan(2);
    descTable.addCell(descCell);
    return descTable;
}

From source file:com.ideationdesignservices.txtbook.pdf.TxtBookPdf.java

public float addConversationPart(ColumnText ct, int column, String dateString, String senderString,
        String contentString, Bitmap contentBitmap, Boolean isVideo, Boolean isMe)
        throws DocumentException, MalformedURLException, IOException {
    float messageWidth = 196.0f;
    Chunk dateChunk = new Chunk(new StringBuilder(String.valueOf(dateString))
            .append(MinimalPrettyPrinter.DEFAULT_ROOT_VALUE_SEPARATOR).toString(), this.sansFont6Gray);
    float dateWidth = dateChunk.getWidthPoint();
    Paragraph contentParagraph = new Paragraph();
    if (contentString.length() > 0) {
        Element contentChunk = new Chunk(contentString, this.sansFont9);
        messageWidth = contentChunk.getWidthPoint();
        contentParagraph.add(contentChunk);
    }/*from w  w w .j  a v  a  2s.c  om*/
    if (messageWidth < dateWidth) {
        messageWidth = dateWidth;
    }
    if (messageWidth > MAX_COLUMN_CONTENT_WIDTH) {
        messageWidth = MAX_COLUMN_CONTENT_WIDTH;
        dateWidth += 7.0f;
    }
    Paragraph dateParagraph = new Paragraph(dateChunk);
    if (isMe.booleanValue()) {
        dateParagraph.setAlignment(0);
        dateParagraph
                .setIndentationLeft((((BUBBLE_L_WIDTH + messageWidth) + BUBBLE_R_WIDTH) + 7.0f) - dateWidth);
    } else {
        dateParagraph.setAlignment(2);
        dateParagraph
                .setIndentationRight((((BUBBLE_L_WIDTH + messageWidth) + BUBBLE_R_WIDTH) + 7.0f) - dateWidth);
    }
    ct.addElement(dateParagraph);
    contentParagraph.setExtraParagraphSpace(10.0f);
    if (contentString.length() > 0) {
        contentParagraph.setAlignment(0);
        if (isMe.booleanValue()) {
            contentParagraph.setIndentationLeft(8.6f);
            contentParagraph.setIndentationRight(BUBBLE_TEXT_INDENT_ALTERNATE);
        } else {
            contentParagraph.setIndentationRight(8.6f);
            float indentLeft = COLUMN_WIDTH - (BUBBLE_L_WIDTH + messageWidth);
            if (messageWidth == MAX_COLUMN_CONTENT_WIDTH) {
                indentLeft += BUBBLE_TEXT_INDENT_ALTERNATE;
            }
            contentParagraph.setIndentationLeft(indentLeft);
        }
        ct.addElement(contentParagraph);
    } else if (contentBitmap != null) {
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        if (isVideo.booleanValue()) {
            contentBitmap.compress(CompressFormat.PNG, 50, stream);
        } else {
            contentBitmap.compress(CompressFormat.JPEG, 50, stream);
        }
        Image contentImage = Image.getInstance(stream.toByteArray());
        contentImage.scaleToFit(198.0f, 198.0f);
        if (isVideo.booleanValue()) {
            contentImage.setCompressionLevel(this.settings.compressionLevel);
        }
        contentImage.setSpacingBefore(10.0f);
        contentImage.setSpacingAfter(10.0f);
        if (isMe.booleanValue()) {
            contentImage.setAlignment(1);
        } else {
            contentImage.setAlignment(1);
        }
        ct.addElement(contentImage);
    }
    Paragraph senderParagraph = new Paragraph(new Chunk(senderString, this.sansFont9Gray));
    if (!isMe.booleanValue()) {
        senderParagraph.setAlignment(2);
    }
    senderParagraph.setSpacingAfter(BUBBLE_TEXT_INDENT_ALTERNATE);
    ct.addElement(senderParagraph);
    return messageWidth;
}

From source file:com.kohmiho.mpsr.export.PDFGenerator.java

/**
 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
 *      response)/*  w w w .ja va 2  s. c om*/
 */
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    String mpsrID = request.getParameter("MPSR_ID");
    if (null == mpsrID)
        return;

    MPSRProjectInfo basicInfo = MPSRProjectInfo.getInstance(mpsrID);
    MPSRExecutiveSummary exeSummary = MPSRExecutiveSummary.getInstance(mpsrID);
    MPSRStatusSummary statusSummary = MPSRStatusSummary.getInstance(mpsrID);
    MPSRFunctionPerformance funcPerform = MPSRFunctionPerformance.getInstance(mpsrID);
    MPSRCostPerformance costPerform = MPSRCostPerformance.getInstance(mpsrID);
    MPSRSchedulePerformance[] schedulePerform = MPSRSchedulePerformance.getInstance(mpsrID);
    MPSRSafety safety = MPSRSafety.getInstance(mpsrID);
    MPSRAuthorization auth = MPSRAuthorization.getInstance(mpsrID);
    MPSRBudget budget = MPSRBudget.getInstance(mpsrID);
    MPSRCostReport[] costRpt = MPSRCostReport.getInstance(mpsrID);
    MPSRSchedule schedule = MPSRSchedule.getInstance(mpsrID);
    MPSRMilestone[] milestones = MPSRMilestone.getInstance(mpsrID);
    MPSRLPE lpe = MPSRLPE.getInstance(mpsrID);
    MPSRInsidePlantDesign[] ipds = MPSRInsidePlantDesign.getInstance(mpsrID);
    MPSROutsidePlantDesign[] opds = MPSROutsidePlantDesign.getInstance(mpsrID);
    MPSRProcure procure = MPSRProcure.getInstance(mpsrID);
    MPSRApprovedChanges[] approvedChanges = MPSRApprovedChanges.getInstance(mpsrID);
    MPSRPendingChanges[] pendingChanges = MPSRPendingChanges.getInstance(mpsrID);
    MPSRInsidePlantConstruction[] ipcs = MPSRInsidePlantConstruction.getInstance(mpsrID);
    MPSROutsidePlantConstruction[] opcs = MPSROutsidePlantConstruction.getInstance(mpsrID);
    MPSRAppendix[] appendixs = MPSRAppendix.getInstance(mpsrID);
    MPSRAttachment[] attachments = MPSRAttachment.getInstance(mpsrID);

    // response.setContentType("application/pdf");
    // response.setHeader("Content-Disposition",
    // "attachment; filename=\"test.pdf\"");

    Font fontNormal = null;
    Font fontCoverTitle = new Font(FontFamily.HELVETICA, 20, Font.BOLD);
    Font fontCoverTableHeader = new Font(FontFamily.HELVETICA, 16, Font.BOLD);
    Font fontCoverTableContent = new Font(FontFamily.HELVETICA, 16);
    Font fontChapterHeader = new Font(FontFamily.HELVETICA, 18, Font.BOLD);
    Font fontSection1Header = new Font(FontFamily.HELVETICA, 16, Font.BOLD);
    Font fontSection2Header = new Font(FontFamily.HELVETICA, 14, Font.BOLD);
    Font fontWork = new Font(FontFamily.HELVETICA, 12, Font.UNDERLINE);

    Font fontTableCaption = new Font(FontFamily.TIMES_ROMAN, 12, Font.BOLD);
    Font fontTableColumnHeader = new Font(FontFamily.HELVETICA, 12, Font.BOLD);
    Font fontTableColumnHeaderYellow = new Font(FontFamily.HELVETICA, 12, Font.BOLD);
    fontTableColumnHeaderYellow.setColor(BaseColor.YELLOW);
    Font fontTableRowTitle = new Font(FontFamily.HELVETICA, 12, Font.ITALIC);
    Font fontTableCellBold = new Font(FontFamily.HELVETICA, 12, Font.BOLD);
    Font fontTableNote = new Font(FontFamily.HELVETICA, 10, Font.ITALIC);
    Font fontImageCaption = new Font(FontFamily.TIMES_ROMAN, 9, Font.BOLD);

    Font fontPOTableHeader = new Font(FontFamily.HELVETICA, 10, Font.BOLD);
    fontPOTableHeader.setColor(BaseColor.YELLOW);
    Font fontPOTable = new Font(FontFamily.HELVETICA, 9);
    Font fontPOTableSummary = new Font(FontFamily.HELVETICA, 9, Font.BOLD);

    Font fontPageHeader = new Font(FontFamily.HELVETICA, 8);
    Font fontPageFooter = new Font(FontFamily.HELVETICA, 10);

    Phrase[] headerTexts = new Phrase[] { new Phrase("ELECTRIC DELIVERY", fontPageHeader),
            new Phrase("DELIVERY PROJECTS & CONSTRUCTION (DP&C)", fontPageHeader),
            new Phrase("PROJECT MONTHLY REPORT", fontPageHeader) };

    Paragraph paragraph = null;
    PdfPTable table = null;
    PdfPCell cell = null;

    Document document = new Document(DEFAULT_PAGE_SIZE, 36, 36, 9 * 10, 36);
    ByteArrayOutputStream baosOrig = new ByteArrayOutputStream();
    XMLWorkerHelper xmlWorker = XMLWorkerHelper.getInstance();

    try {
        PdfWriter writer = PdfWriter.getInstance(document, baosOrig);
        writer.setStrictImageSequence(true);
        writer.setLinearPageMode();
        writer.setViewerPreferences(PdfWriter.PageModeUseOutlines | PdfWriter.FitWindow);

        Image icon = getEmbeddedImage(getServletContext(), "/resource/image/company_logo.png");

        document.open();

        PdfOutline root = writer.getRootOutline();

        // *******************************************************************************************//

        // addOutline(root, writer, MPSRUI.TREE_0);

        for (int i = 0; i < 2; i++) {
            document.add(new Paragraph(" "));
        }

        String[] titles = { " DELIVERY PROJECTS & CONSTRUCTION", "MONTHLY REPORT",
                basicInfo.getReportMonthYear(), basicInfo.getProjectTitle(),
                "PROJECT No. " + basicInfo.getProjectDefinition() };
        int[] spaceingAfters = { 48, 48, 48, 24, 48 };
        for (int i = 0; i < titles.length; i++) {
            paragraph = new Paragraph();
            paragraph.setSpacingAfter(spaceingAfters[i]);
            paragraph.setFont(fontCoverTitle);
            paragraph.setAlignment(Element.ALIGN_CENTER);
            paragraph.add(new Chunk(titles[i]));
            document.add(paragraph);
        }

        addCoverImage(document, MPSRUI.getFilePath(mpsrID, basicInfo.getFileName()));

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

        table = new PdfPTable(2);
        table.addCell(new Phrase("Client", fontCoverTableHeader));
        table.addCell(new Phrase(basicInfo.getProjectManager(), fontCoverTableContent));
        table.addCell(new Phrase("Location", fontCoverTableHeader));
        table.addCell(new Phrase(basicInfo.getProjectDirector(), fontCoverTableContent));
        document.add(table);

        // *******************************************************************************************//

        document.resetPageCount();
        document.add(Chunk.NEXTPAGE);
        writer.setPageEvent(new MPSRPageEventHelper(icon, headerTexts, fontPageFooter));

        // *******************************************************************************************//

        PdfOutline outline1 = addOutline(root, writer, MPSRUI.TREE_1);
        addSectionTitle(document, MPSRUI.TREE_1, fontChapterHeader, 0, 0, 12);

        PdfOutline outline2 = addOutline(outline1, writer, "1.1");

        addOutline(outline2, writer, MPSRUI.TREE_1_1_1);
        addSectionTitle(document, MPSRUI.TREE_1_1_1, fontSection2Header, 12, 12, 0);
        addParagraph(document, writer, xmlWorker, exeSummary.getDesc_1_1_1(), fontNormal, 12, 0, 12);

        addOutline(outline2, writer, MPSRUI.TREE_1_1_2);
        addSectionTitle(document, MPSRUI.TREE_1_1_2, fontSection2Header, 12, 12, 0);
        addParagraph(document, writer, xmlWorker, exeSummary.getDesc_1_1_2(), fontNormal, 12, 0, 12);

        addOutline(outline2, writer, MPSRUI.TREE_1_1_3);
        addSectionTitle(document, MPSRUI.TREE_1_1_3, fontSection2Header, 12, 12, 0);
        addParagraph(document, writer, xmlWorker, exeSummary.getDesc_1_1_3(), fontNormal, 12, 0, 12);

        addOutline(outline2, writer, MPSRUI.TREE_1_1_4);
        addSectionTitle(document, MPSRUI.TREE_1_1_4, fontSection2Header, 12, 12, 0);
        addParagraph(document, writer, xmlWorker, exeSummary.getDesc_1_1_4(), fontNormal, 12, 0, 12);

        // *******************************************************************************************//
        // 1.2 Status Summary
        // *******************************************************************************************//

        outline2 = addOutline(outline1, writer, MPSRUI.TREE_1_2);
        addSectionTitle(document, MPSRUI.TREE_1_2, fontSection1Header, 6, 12, 12);

        paragraph = new Paragraph();
        paragraph.add(basicInfo.getProjectTitle());
        paragraph.setSpacingAfter(4);
        document.add(paragraph);

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

        cell = new PdfPCell(
                new Phrase("Project #: " + basicInfo.getProjectDefinition(), fontTableColumnHeader));
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table.addCell(cell);
        String[] headers = { "Status", "Approved (Include RnC)", "To Date", "At Completion" };
        for (String header : headers) {
            cell = new PdfPCell(new Phrase(header, fontTableColumnHeader));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);
        }

        String[][] cellValues = {
                { "Budget ($M)", statusSummary.getBudgetStatus(),
                        !"".equals(statusSummary.getBudgetApproved()) ? CURRENCY_FORMATTER
                                .format(Double.parseDouble(statusSummary.getBudgetApproved())) : "",
                        !"".equals(statusSummary.getBudgetToDate())
                                ? CURRENCY_FORMATTER.format(Double.parseDouble(statusSummary.getBudgetToDate()))
                                : "",
                        !"".equals(statusSummary.getBudgetAtCompletion()) ? CURRENCY_FORMATTER
                                .format(Double.parseDouble(statusSummary.getBudgetAtCompletion())) : "" },
                { "Schedule - Duration (months)", statusSummary.getScheduleStatus(),
                        statusSummary.getScheduleApproved(), statusSummary.getScheduleToDate(),
                        statusSummary.getScheduleAtCompletion() },
                { "In-Service Date", statusSummary.getInServiceDateStatus(),
                        statusSummary.getInServiceDateApproved(), statusSummary.getInServiceDateToDate(),
                        statusSummary.getInServiceDateAtCompletion() } };
        for (int i = 0; i < cellValues.length; i++) {
            table.addCell(new Phrase(cellValues[i][0]));
            cell = new PdfPCell(new Phrase(cellValues[i][1]));
            cell.setBackgroundColor(getBackgroundColor(cellValues[i][1]));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);
            for (int j = 2; j < 5; j++) {
                cell = new PdfPCell(new Phrase(cellValues[i][j]));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(cell);
            }
        }

        document.add(table);

        // -------------------------------------------------------------------//

        paragraph = new Paragraph("Legend:");
        paragraph.setSpacingAfter(4);
        paragraph.setIndentationLeft(25);
        document.add(paragraph);

        table = new PdfPTable(3);
        table.setTotalWidth(240);
        table.setLockedWidth(true);
        table.setHorizontalAlignment(Element.ALIGN_LEFT);
        String[] legends = { "On Target", "At Risk", "Off Target" };
        for (String legend : legends) {
            cell = new PdfPCell(new Phrase(legend));
            cell.setBackgroundColor(getBackgroundColor(legend));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setMinimumHeight(18);
            cell.setPadding(0);
            table.addCell(cell);
        }

        paragraph = new Paragraph();
        paragraph.add(table);
        paragraph.setIndentationLeft(25);
        document.add(paragraph);

        // *******************************************************************************************//
        // 1.2.1 Functional Area Performance Indicators
        // *******************************************************************************************//

        addOutline(outline2, writer, MPSRUI.TREE_1_2_1);
        addSectionTitle(document, MPSRUI.TREE_1_2_1, fontSection2Header, 12, 12, 12);

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

        headers = new String[] { "Activities", "Current Status", "Trend",
                "Comments (main performance drives)" };
        for (String header : headers) {
            cell = new PdfPCell(new Phrase(header, fontTableColumnHeader));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);
        }

        Image imgArrowUp = getEmbeddedImage(getServletContext(), "/VAADIN/themes/MPSR/img/Arrow_Up.png");
        Image imgArrowDown = getEmbeddedImage(getServletContext(), "/VAADIN/themes/MPSR/img/Arrow_Down.png");
        Image imgArrowEven = getEmbeddedImage(getServletContext(), "/VAADIN/themes/MPSR/img/Arrow_Even.png");
        Image[] images = { imgArrowUp, imgArrowDown, imgArrowEven };
        for (Image image : images) {
            image.scaleToFit(12, 12);
        }

        cellValues = new String[][] {
                { "Project - " + basicInfo.getProjectTitle(), funcPerform.getProjectStatus(),
                        funcPerform.getProjectTrend(), funcPerform.getProjectComment() },
                { "  Target Budget", funcPerform.getTargetBudgetStatus(), funcPerform.getTargetBudgetTrend(),
                        funcPerform.getTargetBudgetComment() },
                { "  Safety", funcPerform.getSafetyStatus(), funcPerform.getSafetyTrend(),
                        funcPerform.getSafetyComment() },
                { "  Licensing & Permitting", funcPerform.getLicensingStatus(), funcPerform.getLicensingTrend(),
                        funcPerform.getLicensingComment() },
                { "  Corporate Properties", funcPerform.getCorporateStatus(), funcPerform.getCorporateTrend(),
                        funcPerform.getCorporateComment() },
                { "  Inside Plant Design & Engineering", funcPerform.getIPDEStatus(),
                        funcPerform.getIPDETrend(), funcPerform.getIPDEComment() },
                { "  Public Outreach", funcPerform.getOutreachStatus(), funcPerform.getOutreachTrend(),
                        funcPerform.getOutreachComment() },
                { "  Procurement", funcPerform.getProcureStatus(), funcPerform.getProcureTrend(),
                        funcPerform.getProcureComment() },
                { "  Construction", funcPerform.getConstructionStatus(), funcPerform.getConstructionTrend(),
                        funcPerform.getConstructionComment() },
                { "  Environmental - Resource Recovery", funcPerform.getEnviromentStatus(),
                        funcPerform.getEnviromentTrend(), funcPerform.getEnviromentComment() },
                { "  Salvage", funcPerform.getSalvageStatus(), funcPerform.getSalvageTrend(),
                        funcPerform.getSalvageComment() },
                { "  Withdrawal", funcPerform.getWithdrawalStatus(), funcPerform.getWithdrawalTrend(),
                        funcPerform.getWithdrawalComment() } };
        for (int i = 0; i < cellValues.length; i++) {
            cell = new PdfPCell(new Phrase(cellValues[i][0]));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(cellValues[i][1]));
            cell.setBackgroundColor(getBackgroundColor(cellValues[i][1]));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);

            if ("Up".equals(cellValues[i][2])) {
                cell = new PdfPCell(imgArrowUp);
            } else if ("Down".equals(cellValues[i][2])) {
                cell = new PdfPCell(imgArrowDown);
            } else if ("Even".equals(cellValues[i][2])) {
                cell = new PdfPCell(imgArrowEven);
            } else {
                cell = new PdfPCell();
            }

            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(cellValues[i][3]));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            table.addCell(cell);
        }

        document.add(table);

        // *******************************************************************************************//

        document.setPageSize(DEFAULT_PAGE_SIZE.rotate());
        document.add(Chunk.NEXTPAGE);

        addOutline(outline2, writer, MPSRUI.TREE_1_2_2);
        addSectionTitle(document, MPSRUI.TREE_1_2_2, fontSection2Header, 12, 12, 12);
        addImage(document, MPSRUI.getFilePath(mpsrID, costPerform.getFileName()));

        // *******************************************************************************************//
        // 1.2.3 Schedule Performance
        // *******************************************************************************************//

        document.add(Chunk.NEXTPAGE);

        addOutline(outline2, writer, MPSRUI.TREE_1_2_3);
        addSectionTitle(document, MPSRUI.TREE_1_2_3, fontSection2Header, 12, 12, 12);

        table = new PdfPTable(9);
        table.setTotalWidth(750);
        table.setLockedWidth(true);
        table.setWidths(new int[] { 3, 1, 1, 1, 1, 1, 1, 1, 1 });
        table.setHorizontalAlignment(Element.ALIGN_CENTER);

        headers = new String[] { "WBS", "Original Duration", "Remaining Duration", "Baseline Start Date",
                "Baseline Finish Date", "Start Date", "Finish Date", "Total Float", "Status" };
        for (String header : headers) {
            cell = new PdfPCell(new Phrase(header, fontTableColumnHeaderYellow));
            cell.setBackgroundColor(BaseColor.BLUE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);
        }

        for (int i = 0; i < schedulePerform.length; i++) {
            cell = new PdfPCell(new Phrase(schedulePerform[i].getWBS()));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(Double.toString(schedulePerform[i].getOriginalDuration())));
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(Double.toString(schedulePerform[i].getRemainingDuration())));
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(schedulePerform[i].getPlannedStartDate()));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(schedulePerform[i].getPlannedFinishDate()));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(schedulePerform[i].getStartDate()));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(schedulePerform[i].getFinishDate()));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(schedulePerform[i].getTotalFloat()));
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(schedulePerform[i].getStatus()));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);
        }

        table.setHeaderRows(1);

        document.add(table);

        // *******************************************************************************************//
        // 1.3 Project Change Control
        // *******************************************************************************************//

        document.setPageSize(DEFAULT_PAGE_SIZE);
        document.add(Chunk.NEXTPAGE);

        outline2 = addOutline(outline1, writer, MPSRUI.TREE_1_3);
        addSectionTitle(document, MPSRUI.TREE_1_3, fontSection1Header, 6, 12, 12);

        addOutline(outline2, writer, MPSRUI.TREE_1_3_1);
        addSectionTitle(document, MPSRUI.TREE_1_3_1, fontSection2Header, 12, 12, 0);
        addParagraph(document, writer, xmlWorker, exeSummary.getDesc_1_3_1(), fontNormal, 12, 0, 12);

        addOutline(outline2, writer, MPSRUI.TREE_1_3_2);
        addSectionTitle(document, MPSRUI.TREE_1_3_2, fontSection2Header, 12, 12, 0);
        addParagraph(document, writer, xmlWorker, exeSummary.getDesc_1_3_2(), fontNormal, 12, 0, 12);

        // *******************************************************************************************//
        // 2 Safety
        // *******************************************************************************************//

        addOutline(root, writer, MPSRUI.TREE_2);
        addSectionTitle(document, MPSRUI.TREE_2, fontChapterHeader, 0, 24, 12);
        addParagraph(document, writer, xmlWorker, safety.getDesc1(), fontNormal, 12, 0, 12);

        paragraph = new Paragraph("Table 2.1 Project Safety Summary", fontTableCaption);
        paragraph.setAlignment(Element.ALIGN_CENTER);
        paragraph.setSpacingAfter(6);
        document.add(paragraph);

        table = new PdfPTable(3);
        table.setTotalWidth(300);
        table.setLockedWidth(true);
        table.setWidths(new int[] { 1, 1, 1 });
        table.setHorizontalAlignment(Element.ALIGN_RIGHT);

        cell = new PdfPCell(new Phrase("Total Work Hours", fontTableColumnHeaderYellow));
        cell.setColspan(3);
        cell.setBackgroundColor(BaseColor.BLUE);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table.addCell(cell);

        headers = new String[] { "Current Period", "Calendar YTD", "Project To Date" };
        for (String header : headers) {
            cell = new PdfPCell(new Phrase(header, fontTableColumnHeader));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);
        }

        cellValues = new String[][] { { INTEGER_FORMATTER.format(safety.getTotalWorkHoursCurrent()),
                INTEGER_FORMATTER.format(safety.getTotalWorkHoursYTD()),
                INTEGER_FORMATTER.format(safety.getTotalWorkHoursPTD()) } };
        for (int i = 0; i < cellValues.length; i++) {
            cell = new PdfPCell(new Phrase(cellValues[i][0]));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(cellValues[i][1]));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(cellValues[i][2], fontTableCellBold));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);
        }

        document.add(table);

        // -----------------------------------

        table = new PdfPTable(4);
        table.setTotalWidth(500);
        table.setLockedWidth(true);
        table.setWidths(new int[] { 2, 1, 1, 1 });
        table.setHorizontalAlignment(Element.ALIGN_RIGHT);

        cell = new PdfPCell(new Phrase("Incidents", fontTableColumnHeaderYellow));
        cell.setColspan(4);
        cell.setBackgroundColor(BaseColor.BLUE);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table.addCell(cell);

        cellValues = new String[][] {
                { "OSHA Recordable", INTEGER_FORMATTER.format(safety.getOshaRecordableCurrent()),
                        INTEGER_FORMATTER.format(safety.getOshaRecordableYTD()),
                        INTEGER_FORMATTER.format(safety.getOshaRecordablePTD()) },
                { "First Aid", INTEGER_FORMATTER.format(safety.getFirstAid1Current()),
                        INTEGER_FORMATTER.format(safety.getFirstAid1YTD()),
                        INTEGER_FORMATTER.format(safety.getFirstAid1PTD()) },
                { "Near Miss", INTEGER_FORMATTER.format(safety.getNearMissCurrent()),
                        INTEGER_FORMATTER.format(safety.getNearMissYTD()),
                        INTEGER_FORMATTER.format(safety.getNearMissPTD()) },
                { "First Aid", INTEGER_FORMATTER.format(safety.getFirstAid2Current()),
                        INTEGER_FORMATTER.format(safety.getFirstAid2YTD()),
                        INTEGER_FORMATTER.format(safety.getFirstAid2PTD()) } };
        for (int i = 0; i < cellValues.length; i++) {
            cell = new PdfPCell(new Phrase(cellValues[i][0], fontTableRowTitle));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(cellValues[i][1]));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(cellValues[i][2]));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(cellValues[i][3], fontTableCellBold));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);
        }

        cell = new PdfPCell(new Phrase("*Note - " + safety.getNote(), fontTableNote));
        cell.setColspan(4);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setVerticalAlignment(Element.ALIGN_TOP);
        table.addCell(cell);

        document.add(table);

        // *******************************************************************************************//
        // 3 Project Authorization
        // *******************************************************************************************//

        addOutline(root, writer, MPSRUI.TREE_3);
        addSectionTitle(document, MPSRUI.TREE_3, fontChapterHeader, 0, 24, 12);
        addParagraph(document, writer, xmlWorker, auth.getDesc1(), fontNormal, 12, 0, 12);

        table = new PdfPTable(10);
        table.setSpacingBefore(6);
        table.setTotalWidth(550);
        table.setLockedWidth(true);
        table.setWidths(new int[] { 3, 1, 1, 1, 1, 1, 1, 2, 1, 1 });
        table.setHorizontalAlignment(Element.ALIGN_CENTER);

        headers = new String[] { "$ Millions", "Prior", auth.getHeaderYear0(), auth.getHeaderYear1(),
                auth.getHeaderYear2(), auth.getHeaderYear3(), auth.getHeaderYear4(), auth.getHeaderPostYear(),
                "Total", "Auth" };
        for (String header : headers) {
            cell = new PdfPCell(new Phrase(header, fontTableColumnHeader));
            cell.setBackgroundColor(BaseColor.YELLOW);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);
        }

        cellValues = new String[][] { { "Base", NUMBER_FORMATTER.format(auth.getBasePriorYear()),
                NUMBER_FORMATTER.format(auth.getBaseYear0()), NUMBER_FORMATTER.format(auth.getBaseYear1()),
                NUMBER_FORMATTER.format(auth.getBaseYear2()), NUMBER_FORMATTER.format(auth.getBaseYear3()),
                NUMBER_FORMATTER.format(auth.getBaseYear4()), NUMBER_FORMATTER.format(auth.getBasePostYear()),
                NUMBER_FORMATTER.format(auth.getBaseTotal()), "" },
                { "Risk & Contingency", NUMBER_FORMATTER.format(auth.getRnCPriorYear()),
                        NUMBER_FORMATTER.format(auth.getRnCYear0()),
                        NUMBER_FORMATTER.format(auth.getRnCYear1()),
                        NUMBER_FORMATTER.format(auth.getRnCYear2()),
                        NUMBER_FORMATTER.format(auth.getRnCYear3()),
                        NUMBER_FORMATTER.format(auth.getRnCYear4()),
                        NUMBER_FORMATTER.format(auth.getRnCPostYear()),
                        NUMBER_FORMATTER.format(auth.getRnCTotal()), "" },
                { "Total Project " + auth.getTotalProjectDate(), NUMBER_FORMATTER.format(auth.getPriorTotal()),
                        NUMBER_FORMATTER.format(auth.getYear0Total()),
                        NUMBER_FORMATTER.format(auth.getYear1Total()),
                        NUMBER_FORMATTER.format(auth.getYear2Total()),
                        NUMBER_FORMATTER.format(auth.getYear3Total()),
                        NUMBER_FORMATTER.format(auth.getYear4Total()),
                        NUMBER_FORMATTER.format(auth.getPostTotal()),
                        NUMBER_FORMATTER.format(auth.getTotalTotal()), "" },
                { "Current Request " + auth.getReq0RequestDate(),
                        NUMBER_FORMATTER.format(auth.getReq0PriorYear()),
                        NUMBER_FORMATTER.format(auth.getReq0Year0()),
                        NUMBER_FORMATTER.format(auth.getReq0Year1()),
                        NUMBER_FORMATTER.format(auth.getReq0Year2()),
                        NUMBER_FORMATTER.format(auth.getReq0Year3()),
                        NUMBER_FORMATTER.format(auth.getReq0Year4()),
                        NUMBER_FORMATTER.format(auth.getReq0PostYear()),
                        NUMBER_FORMATTER.format(auth.getReq0Total()),
                        NUMBER_FORMATTER.format(auth.getReq0Authorization()) },
                { "Request Date " + auth.getReq1RequestDate(), NUMBER_FORMATTER.format(auth.getReq1PriorYear()),
                        NUMBER_FORMATTER.format(auth.getReq1Year0()),
                        NUMBER_FORMATTER.format(auth.getReq1Year1()),
                        NUMBER_FORMATTER.format(auth.getReq1Year2()),
                        NUMBER_FORMATTER.format(auth.getReq1Year3()),
                        NUMBER_FORMATTER.format(auth.getReq1Year4()),
                        NUMBER_FORMATTER.format(auth.getReq1PostYear()),
                        NUMBER_FORMATTER.format(auth.getReq1Total()),
                        NUMBER_FORMATTER.format(auth.getReq1Authorization()) },
                { "Request Date " + auth.getReq2RequestDate(), NUMBER_FORMATTER.format(auth.getReq2PriorYear()),
                        NUMBER_FORMATTER.format(auth.getReq2Year0()),
                        NUMBER_FORMATTER.format(auth.getReq2Year1()),
                        NUMBER_FORMATTER.format(auth.getReq2Year2()),
                        NUMBER_FORMATTER.format(auth.getReq2Year3()),
                        NUMBER_FORMATTER.format(auth.getReq2Year4()),
                        NUMBER_FORMATTER.format(auth.getReq2PostYear()),
                        NUMBER_FORMATTER.format(auth.getReq2Total()),
                        NUMBER_FORMATTER.format(auth.getReq2Authorization()) },
                { "Target Budget", "", "", "", "", "", "", "", auth.getTargetBudget(), "" } };
        for (int i = 0; i < cellValues.length; i++) {

            cell = new PdfPCell(new Phrase(cellValues[i][0]));
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);

            for (int j = 1; j < cellValues[i].length; j++) {
                cell = new PdfPCell(new Phrase(cellValues[i][j]));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                table.addCell(cell);
            }
        }

        document.add(table);

        // *******************************************************************************************//
        // 4 Project Budget
        // *******************************************************************************************//

        addOutline(root, writer, MPSRUI.TREE_4);
        addSectionTitle(document, MPSRUI.TREE_4, fontChapterHeader, 0, 24, 12);
        addParagraph(document, writer, xmlWorker, budget.getDesc1(), fontNormal, 12, 0, 12);

        table = new PdfPTable(2);
        table.setSpacingBefore(6);
        table.setTotalWidth(350);
        table.setLockedWidth(true);
        table.setWidths(new int[] { 5, 2 });
        table.setHorizontalAlignment(Element.ALIGN_CENTER);

        cellValues = new String[][] {
                { "Current Approved Budget (Base + RnC)",
                        CURRENCY_FORMATTER.format(budget.getPMBudget()) + "M" },
                { "Approved Phase Funding", CURRENCY_FORMATTER.format(budget.getPMActual()) + "M" },
                { "Expended To Date", CURRENCY_FORMATTER.format(budget.getPMCommitment()) + "M" },
                { "At Completion", CURRENCY_FORMATTER.format(budget.getPMAdditionalCost()) + "M" } };
        for (int i = 0; i < cellValues.length; i++) {
            cell = new PdfPCell(new Phrase(cellValues[i][0]));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(cellValues[i][1]));
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);
        }

        document.add(table);

        // ----------------------------------------------------
        // table 4.1
        // ----------------------------------------------------

        paragraph = new Paragraph("Table 4.1 Cost Report Summary", fontTableCaption);
        paragraph.setAlignment(Element.ALIGN_CENTER);
        paragraph.setSpacingAfter(6);
        document.add(paragraph);

        table = new PdfPTable(5);
        table.setTotalWidth(500);
        table.setLockedWidth(true);
        table.setWidths(new int[] { 1, 1, 1, 1, 1 });
        table.setHorizontalAlignment(Element.ALIGN_CENTER);

        headers = new String[] { "Work Element", "Description", "Estimate", "Actual", "EAC" };
        for (String header : headers) {
            cell = new PdfPCell(new Phrase(header, fontTableColumnHeaderYellow));
            cell.setBackgroundColor(BaseColor.BLUE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);
        }

        for (int i = 0; i < costRpt.length; i++) {
            cell = new PdfPCell(new Phrase(costRpt[i].getWbs()));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(costRpt[i].getWbsDesc()));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(formatNumberString(costRpt[i].getEstimate())));
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(formatNumberString(costRpt[i].getActual())));
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(formatNumberString(costRpt[i].getEAC())));
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);
        }

        document.add(table);

        // *******************************************************************************************//
        // 5 Project Schedule
        // *******************************************************************************************//

        outline1 = addOutline(root, writer, MPSRUI.TREE_5);
        addSectionTitle(document, MPSRUI.TREE_5, fontChapterHeader, 0, 24, 12);

        addOutline(outline1, writer, MPSRUI.TREE_5_1);
        addSectionTitle(document, MPSRUI.TREE_5_1, fontSection1Header, 6, 12, 12);
        addParagraph(document, writer, xmlWorker, schedule.getDesc_5_1(), fontNormal, 12, 0, 12);

        addOutline(outline1, writer, MPSRUI.TREE_5_2);
        addSectionTitle(document, MPSRUI.TREE_5_2, fontSection1Header, 6, 12, 12);
        addParagraph(document, writer, xmlWorker, schedule.getDesc_5_2(), fontNormal, 12, 0, 12);

        addOutline(outline1, writer, MPSRUI.TREE_5_3);
        addSectionTitle(document, MPSRUI.TREE_5_3, fontSection1Header, 6, 12, 12);
        addParagraph(document, writer, xmlWorker, schedule.getDesc_5_3(), fontNormal, 12, 0, 12);

        addOutline(outline1, writer, MPSRUI.TREE_5_4);
        addSectionTitle(document, MPSRUI.TREE_5_4, fontSection1Header, 6, 12, 12);
        addParagraph(document, writer, xmlWorker, schedule.getDesc_5_4(), fontNormal, 12, 0, 12);

        // ----------------------------------------------------
        // table 5.1
        // ----------------------------------------------------

        paragraph = new Paragraph("Table 5.1 Planned Scorecard Milestones", fontTableCaption);
        paragraph.setAlignment(Element.ALIGN_CENTER);
        paragraph.setSpacingAfter(6);
        document.add(paragraph);

        table = new PdfPTable(3);
        table.setTotalWidth(500);
        table.setLockedWidth(true);
        table.setWidths(new int[] { 3, 1, 1 });
        table.setHorizontalAlignment(Element.ALIGN_CENTER);

        headers = new String[] { "Milestone", "Planned Date", "Finish Date" };
        for (String header : headers) {
            cell = new PdfPCell(new Phrase(header, fontTableColumnHeaderYellow));
            cell.setBackgroundColor(BaseColor.BLUE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);
        }

        for (int i = 0; i < milestones.length; i++) {
            cell = new PdfPCell(new Phrase(milestones[i].getMilestone()));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(milestones[i].getPlannedDate()));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(milestones[i].getFinishDate()));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);
        }

        document.add(table);

        // *******************************************************************************************//
        // 6 License & Permitting, and Environmental Status
        // *******************************************************************************************//

        outline1 = addOutline(root, writer, MPSRUI.TREE_6);
        addSectionTitle(document, MPSRUI.TREE_6, fontChapterHeader, 0, 24, 12);

        addOutline(outline1, writer, MPSRUI.TREE_6_1);
        addSectionTitle(document, MPSRUI.TREE_6_1, fontSection1Header, 6, 12, 12);
        addParagraph(document, writer, xmlWorker, lpe.getDesc_6_1(), fontNormal, 12, 0, 12);

        outline2 = addOutline(outline1, writer, MPSRUI.TREE_6_2);
        addSectionTitle(document, MPSRUI.TREE_6_2, fontSection1Header, 6, 12, 12);

        addOutline(outline2, writer, MPSRUI.TREE_6_2_1);
        addSectionTitle(document, MPSRUI.TREE_6_2_1, fontSection2Header, 12, 12, 12);
        addParagraph(document, writer, xmlWorker, lpe.getDesc_6_2_1(), fontNormal, 12, 0, 12);

        addOutline(outline2, writer, MPSRUI.TREE_6_2_2);
        addSectionTitle(document, MPSRUI.TREE_6_2_2, fontSection2Header, 12, 12, 12);
        addParagraph(document, writer, xmlWorker, lpe.getDesc_6_2_2(), fontNormal, 12, 0, 12);

        // *******************************************************************************************//
        // 7 Engineering Status
        // *******************************************************************************************//

        outline1 = addOutline(root, writer, MPSRUI.TREE_7);
        addSectionTitle(document, MPSRUI.TREE_7, fontChapterHeader, 0, 24, 12);

        addOutline(outline1, writer, MPSRUI.TREE_7_1);
        addSectionTitle(document, MPSRUI.TREE_7_1, fontSection1Header, 6, 12, 12);

        table = new PdfPTable(5);
        table.setTotalWidth(500);
        table.setLockedWidth(true);
        table.setWidths(new int[] { 2, 1, 1, 1, 3 });
        table.setHorizontalAlignment(Element.ALIGN_CENTER);

        headers = new String[] { "Package", "IFR", "IFC", "Indicator", "Note" };
        for (String header : headers) {
            cell = new PdfPCell(new Phrase(header, fontTableColumnHeaderYellow));
            cell.setBackgroundColor(BaseColor.BLUE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);
        }

        for (int i = 0; i < ipds.length; i++) {
            cell = new PdfPCell(new Phrase(ipds[i].getPackage()));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setVerticalAlignment(Element.ALIGN_TOP);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(ipds[i].getIFR()));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setVerticalAlignment(Element.ALIGN_TOP);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(ipds[i].getIFC()));
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cell.setVerticalAlignment(Element.ALIGN_TOP);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(ipds[i].getIndicator()));
            cell.setBackgroundColor(getBackgroundColor(ipds[i].getIndicator()));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_TOP);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(ipds[i].getNote()));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setVerticalAlignment(Element.ALIGN_TOP);
            table.addCell(cell);
        }

        document.add(table);

        // -----------------------------------------------------------------------------------//

        addOutline(outline1, writer, MPSRUI.TREE_7_2);
        addSectionTitle(document, MPSRUI.TREE_7_2, fontSection1Header, 6, 12, 12);

        table = new PdfPTable(5);
        table.setTotalWidth(500);
        table.setLockedWidth(true);
        table.setWidths(new int[] { 2, 1, 1, 1, 3 });
        table.setHorizontalAlignment(Element.ALIGN_CENTER);

        headers = new String[] { "Package", "IFR", "IFC", "Indicator", "Note" };
        for (String header : headers) {
            cell = new PdfPCell(new Phrase(header, fontTableColumnHeaderYellow));
            cell.setBackgroundColor(BaseColor.BLUE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);
        }

        for (int i = 0; i < opds.length; i++) {
            cell = new PdfPCell(new Phrase(opds[i].getPackage()));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setVerticalAlignment(Element.ALIGN_TOP);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(opds[i].getIFR()));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setVerticalAlignment(Element.ALIGN_TOP);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(opds[i].getIFC()));
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cell.setVerticalAlignment(Element.ALIGN_TOP);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(opds[i].getIndicator()));
            cell.setBackgroundColor(getBackgroundColor(opds[i].getIndicator()));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_TOP);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(opds[i].getNote()));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setVerticalAlignment(Element.ALIGN_TOP);
            table.addCell(cell);
        }

        document.add(table);

        // *******************************************************************************************//
        // 8 Procurement Status
        // *******************************************************************************************//

        outline1 = addOutline(root, writer, MPSRUI.TREE_8);
        addSectionTitle(document, MPSRUI.TREE_8, fontChapterHeader, 0, 24, 12);

        outline2 = addOutline(outline1, writer, MPSRUI.TREE_8_1);
        addSectionTitle(document, MPSRUI.TREE_8_1, fontSection1Header, 6, 12, 12);

        table = new PdfPTable(2);
        table.setTotalWidth(300);
        table.setLockedWidth(true);
        table.setWidths(new int[] { 1, 1 });
        table.setHorizontalAlignment(Element.ALIGN_CENTER);

        cellValues = new String[][] {
                { "Receipted to Date", CURRENCY_FORMATTER.format(procure.getReceiptedToDate()) },
                { "Open Commitments", CURRENCY_FORMATTER.format(procure.getOpenCommitment()) },
                { "Total", CURRENCY_FORMATTER.format(procure.getTotalPurchaseOrder()) } };
        for (int i = 0; i < cellValues.length; i++) {
            cell = new PdfPCell(new Phrase(cellValues[i][0]));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(cellValues[i][1]));
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);
        }

        document.add(table);

        addParagraph(document, writer, xmlWorker, procure.getDesc_8_1_B(), fontNormal, 12, 12, 12);

        outline2 = addOutline(outline1, writer, MPSRUI.TREE_8_2);
        addSectionTitle(document, MPSRUI.TREE_8_2, fontSection1Header, 6, 12, 12);

        // ----------------------------------------------------
        // section 8.2.1
        // ----------------------------------------------------

        addOutline(outline2, writer, MPSRUI.TREE_8_2_1);
        addSectionTitle(document, MPSRUI.TREE_8_2_1, fontSection2Header, 12, 12, 12);
        addParagraph(document, writer, xmlWorker, procure.getDesc_8_2_1(), fontNormal, 12, 0, 12);

        table = new PdfPTable(6);
        table.setTotalWidth(550);
        table.setLockedWidth(true);
        table.setWidths(new int[] { 1, 2, 1, 1, 2, 1 });
        table.setHorizontalAlignment(Element.ALIGN_CENTER);

        headers = new String[] { "Purchase Order", "Vendor", "Previous Amount", "This Month Amount",
                "This Month Description", "Total Amount" };
        for (String header : headers) {
            cell = new PdfPCell(new Phrase(header, fontPOTableHeader));
            cell.setBackgroundColor(BaseColor.BLUE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);
        }

        double totalToDate = 0;

        for (int i = 0; i < approvedChanges.length; i++) {
            cell = new PdfPCell(new Phrase(approvedChanges[i].getPurchaseOrder(), fontPOTable));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setVerticalAlignment(Element.ALIGN_TOP);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(approvedChanges[i].getVendor(), fontPOTable));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setVerticalAlignment(Element.ALIGN_TOP);
            table.addCell(cell);

            cell = new PdfPCell(
                    new Phrase(CURRENCY_FORMATTER.format(approvedChanges[i].getPreviousAmount()), fontPOTable));
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cell.setVerticalAlignment(Element.ALIGN_TOP);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(CURRENCY_FORMATTER.format(approvedChanges[i].getThisMonthAmount()),
                    fontPOTable));
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cell.setVerticalAlignment(Element.ALIGN_TOP);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(approvedChanges[i].getThisMonthDescription(), fontPOTable));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setVerticalAlignment(Element.ALIGN_TOP);
            table.addCell(cell);

            cell = new PdfPCell(
                    new Phrase(CURRENCY_FORMATTER.format(approvedChanges[i].getTotalAmount()), fontPOTable));
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cell.setVerticalAlignment(Element.ALIGN_TOP);
            table.addCell(cell);

            totalToDate += approvedChanges[i].getTotalAmount();
        }

        document.add(table);

        table = new PdfPTable(2);
        table.setTotalWidth(550);
        table.setLockedWidth(true);
        table.setWidths(new int[] { 7, 1 });
        table.setHorizontalAlignment(Element.ALIGN_CENTER);

        cell = new PdfPCell(new Phrase("Total To Date", fontPOTableSummary));
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setVerticalAlignment(Element.ALIGN_TOP);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(CURRENCY_FORMATTER.format(totalToDate), fontPOTableSummary));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setVerticalAlignment(Element.ALIGN_TOP);
        table.addCell(cell);

        document.add(table);

        // ----------------------------------------------------
        // section 8.2.2
        // ----------------------------------------------------

        addOutline(outline2, writer, MPSRUI.TREE_8_2_2);
        addSectionTitle(document, MPSRUI.TREE_8_2_2, fontSection2Header, 12, 12, 12);
        addParagraph(document, writer, xmlWorker, procure.getDesc_8_2_2(), fontNormal, 12, 0, 12);

        table = new PdfPTable(6);
        table.setTotalWidth(550);
        table.setLockedWidth(true);
        table.setWidths(new int[] { 1, 2, 1, 1, 2, 1 });
        table.setHorizontalAlignment(Element.ALIGN_CENTER);

        headers = new String[] { "Purchase Order", "Vendor", "Previous Amount", "This Month Amount",
                "This Month Description", "Total Amount" };
        for (String header : headers) {
            cell = new PdfPCell(new Phrase(header, fontPOTableHeader));
            cell.setBackgroundColor(BaseColor.BLUE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);
        }

        totalToDate = 0;

        for (int i = 0; i < pendingChanges.length; i++) {
            cell = new PdfPCell(new Phrase(pendingChanges[i].getPurchaseOrder(), fontPOTable));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setVerticalAlignment(Element.ALIGN_TOP);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(pendingChanges[i].getVendor(), fontPOTable));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setVerticalAlignment(Element.ALIGN_TOP);
            table.addCell(cell);

            cell = new PdfPCell(
                    new Phrase(CURRENCY_FORMATTER.format(pendingChanges[i].getPreviousAmount()), fontPOTable));
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cell.setVerticalAlignment(Element.ALIGN_TOP);
            table.addCell(cell);

            cell = new PdfPCell(
                    new Phrase(CURRENCY_FORMATTER.format(pendingChanges[i].getThisMonthAmount()), fontPOTable));
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cell.setVerticalAlignment(Element.ALIGN_TOP);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(pendingChanges[i].getThisMonthDescription(), fontPOTable));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setVerticalAlignment(Element.ALIGN_TOP);
            table.addCell(cell);

            cell = new PdfPCell(
                    new Phrase(CURRENCY_FORMATTER.format(pendingChanges[i].getTotalAmount()), fontPOTable));
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cell.setVerticalAlignment(Element.ALIGN_TOP);
            table.addCell(cell);

            totalToDate += pendingChanges[i].getTotalAmount();
        }

        document.add(table);

        table = new PdfPTable(2);
        table.setTotalWidth(550);
        table.setLockedWidth(true);
        table.setWidths(new int[] { 7, 1 });
        table.setHorizontalAlignment(Element.ALIGN_CENTER);

        cell = new PdfPCell(new Phrase("Total To Date", fontPOTableSummary));
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setVerticalAlignment(Element.ALIGN_TOP);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(CURRENCY_FORMATTER.format(totalToDate), fontPOTableSummary));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setVerticalAlignment(Element.ALIGN_TOP);
        table.addCell(cell);

        document.add(table);

        // *******************************************************************************************//
        // 9 Construction Status
        // *******************************************************************************************//

        outline1 = addOutline(root, writer, MPSRUI.TREE_9);
        addSectionTitle(document, MPSRUI.TREE_9, fontChapterHeader, 0, 24, 12);

        addOutline(outline1, writer, MPSRUI.TREE_9_1);
        addSectionTitle(document, MPSRUI.TREE_9_1, fontSection1Header, 6, 12, 12);

        for (int i = 0; i < ipcs.length; i++) {
            addParagraph(document, writer, xmlWorker, ipcs[i].getWork(), fontWork, 12, 12, 0);
            addParagraph(document, writer, xmlWorker, ipcs[i].getDescription(), fontNormal, 12, 0, 0);
            addImage(document, MPSRUI.getFilePath(mpsrID, ipcs[i].getFileName()),
                    "Figure " + ipcs[i].getFigure() + " " + ipcs[i].getTitle(), fontImageCaption, 12, 3, 12);
        }

        // -----------------------------------------------------------------------------------------//

        addOutline(outline1, writer, MPSRUI.TREE_9_2);
        addSectionTitle(document, MPSRUI.TREE_9_2, fontSection1Header, 6, 12, 12);

        for (int i = 0; i < opcs.length; i++) {
            addParagraph(document, writer, xmlWorker, opcs[i].getWork(), fontWork, 12, 12, 0);
            addParagraph(document, writer, xmlWorker, opcs[i].getDescription(), fontNormal, 12, 0, 0);
            addImage(document, MPSRUI.getFilePath(mpsrID, opcs[i].getFileName()),
                    "Figure " + opcs[i].getFigure() + " " + opcs[i].getTitle(), fontImageCaption, 12, 3, 12);
        }

        // *******************************************************************************************//
        // Appendix
        // *******************************************************************************************//

        if (appendixs.length > 0) {

            document.add(Chunk.NEXTPAGE);
            outline1 = addOutline(root, writer, MPSRUI.TREE_APPENDIX);

            for (int i = 0; i < appendixs.length; i++) {
                addOutline(outline1, writer,
                        "Appendix " + appendixs[i].getNumber() + "  " + appendixs[i].getTitle());
                addSectionTitle(document,
                        "Appendix " + appendixs[i].getNumber() + "  " + appendixs[i].getTitle(),
                        fontChapterHeader, 0, 12, 12);
                addParagraph(document, writer, xmlWorker, appendixs[i].getDescription(), fontNormal, 12, 0, 0);

                importPages(document, writer, mpsrID, appendixs[i].getFileName());
            }
        }

        // *******************************************************************************************//
        // Attachment
        // *******************************************************************************************//

        if (attachments.length > 0) {

            document.setPageSize(DEFAULT_PAGE_SIZE);
            document.add(Chunk.NEXTPAGE);
            outline1 = addOutline(root, writer, MPSRUI.TREE_ATTACHMENT);

            for (int i = 0; i < attachments.length; i++) {
                addOutline(outline1, writer,
                        "Attachment " + attachments[i].getNumber() + "  " + attachments[i].getTitle());
                addSectionTitle(document,
                        "Attachment " + attachments[i].getNumber() + "  " + attachments[i].getTitle(),
                        fontChapterHeader, 0, 12, 12);
                addParagraph(document, writer, xmlWorker, attachments[i].getDescription(), fontNormal, 12, 0,
                        0);

                importPages(document, writer, mpsrID, attachments[i].getFileName());
            }
        }

        document.close();

        // *******************************************************************************************//

        // retrieve outline
        PdfReader readerOrig = new PdfReader(baosOrig.toByteArray());
        // int origNumberOfPages = readerOrig.getNumberOfPages();
        ColumnText ct = new ColumnText(null);
        ct.addElement(new Paragraph("Table of Contents", fontCoverTitle));
        List<HashMap<String, Object>> bookmarkList = SimpleBookmark.getBookmark(readerOrig);
        fillColumnText(bookmarkList, ct, 18, 0, fontSection2Header);

        // generate TOC after cover page
        ByteArrayOutputStream baosTOC = new ByteArrayOutputStream();
        PdfStamper stamperTOC = new PdfStamper(readerOrig, baosTOC);
        int tocPageEnd = 1;
        while (true) {
            stamperTOC.insertPage(++tocPageEnd, readerOrig.getPageSize(1));

            PdfContentByte underContent = stamperTOC.getUnderContent(tocPageEnd);

            generatePageHeader(document, underContent, icon, headerTexts);

            ct.setCanvas(stamperTOC.getOverContent(tocPageEnd));
            ct.setSimpleColumn(36, 36, 558, 693);
            if (!ColumnText.hasMoreText(ct.go()))
                break;
        }
        stamperTOC.close();

        // change page labels
        PdfPageLabels labels = new PdfPageLabels();
        labels.addPageLabel(1, PdfPageLabels.LOWERCASE_ROMAN_NUMERALS);
        labels.addPageLabel(tocPageEnd + 1, PdfPageLabels.DECIMAL_ARABIC_NUMERALS);

        // add labels
        ByteArrayOutputStream baosFinal = new ByteArrayOutputStream();
        PdfReader readerTOC = new PdfReader(baosTOC.toByteArray());
        // String selectPages = String.format("1-%s,%s-%s", tocPageEnd,
        // tocPageEnd + 1, origNumberOfPages + (tocPageEnd - 1));
        // readerTOC.selectPages(selectPages);
        PdfStamper stamperFinal = new PdfStamper(readerTOC, baosFinal);
        stamperFinal.getWriter().setPageLabels(labels);
        stamperFinal.close();

        // *******************************************************************************************//

        // send final PDF to browser
        response.setHeader("Expires", "0");
        response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
        response.setHeader("Pragma", "public");
        response.setContentType("application/pdf");
        response.setContentLength(baosFinal.size());

        OutputStream os = response.getOutputStream();
        os.write(baosFinal.toByteArray());
        os.flush();
        os.close();

    } catch (DocumentException e) {
        e.printStackTrace();
    }

}

From source file:com.kohmiho.mpsr.export.PDFGenerator.java

private void addSectionTitle(Document document, String sectionTitle, Font fontChapterHeader, int indentation,
        int spacingBefore, int spacingAfter) throws DocumentException {
    Paragraph paragraph = new Paragraph();
    paragraph.setSpacingBefore(spacingBefore);
    paragraph.setSpacingAfter(spacingAfter);
    paragraph.setIndentationLeft(indentation);
    paragraph.setFont(fontChapterHeader);
    paragraph.add(new Phrase(sectionTitle));
    document.add(paragraph);//from ww w  .  j a va  2s. c  o m
}

From source file:com.kohmiho.mpsr.export.PDFGenerator.java

private void addParagraph(Document document, PdfWriter writer, XMLWorkerHelper xmlWorker, String data,
        Font font, int indentationLeft, int spacingBefore, int spacingAfter)
        throws DocumentException, IOException {

    if (!data.startsWith("<")) {
        Paragraph paragraph = new Paragraph();
        paragraph.setIndentationLeft(indentationLeft);
        paragraph.setSpacingBefore(spacingBefore);
        paragraph.setSpacingAfter(spacingAfter);
        if (null != font)
            paragraph.setFont(font);//ww  w .j av  a  2  s. com

        paragraph.add(data);
        document.add(paragraph);
    } else {
        xmlWorker.parseXHtml(writer, document, new StringReader(data));
    }
}

From source file:com.kohmiho.mpsr.export.PDFGenerator.java

private void addImage(Document document, String filename, String caption, Font font, int indentationLeft,
        int spacingBefore, int spacingAfter)
        throws BadElementException, MalformedURLException, IOException, DocumentException {

    if (null == filename) {
        addParagraph(document, null, null, String.format("[*** No Picture for %s ***]", caption), font,
                indentationLeft, 0, 0);//w  w  w .  j a v  a 2s. c  o  m
        return;
    }

    try {
        Paragraph paragraph = new Paragraph();
        paragraph.setIndentationLeft(indentationLeft);
        paragraph.setSpacingBefore(spacingBefore);
        paragraph.setSpacingAfter(spacingAfter);
        if (null != font)
            paragraph.setFont(font);
        paragraph.setKeepTogether(true);
        paragraph.setAlignment(Element.ALIGN_CENTER);

        Image image = Image.getInstance(filename);
        image.scaleToFit(400, 400);

        paragraph.add(new Chunk(image, 0, 0, true));
        paragraph.add(new Chunk("\n"));
        paragraph.add(caption);
        document.add(paragraph);
    } catch (Exception e) {
        addParagraph(document, null, null, String.format("[*** Unable to render picture for %s ***]", caption),
                font, indentationLeft, 0, 0);
    }
}