Example usage for com.lowagie.text Cell setColspan

List of usage examples for com.lowagie.text Cell setColspan

Introduction

In this page you can find the example usage for com.lowagie.text Cell setColspan.

Prototype

public void setColspan(int value) 

Source Link

Document

Sets the colspan.

Usage

From source file:QMSMultiQuoteController.java

License:Open Source License

private void doPdfAbbrivations(String fileName, MultiQuoteFinalDOB finalDOB, HttpServletRequest request,
        HttpServletResponse response, ArrayList Sd, ArrayList Cd, ArrayList Cdn, boolean frequencyFlag,
        boolean carrierFlag, boolean serviceFlag, Map<String, String> surChargesMap) {
    ArrayList filesList = new ArrayList();
    File file = null;//w  w w  .  j a  v a  2 s. c o m
    byte[] buffer = null;
    ArrayList bufferList = new ArrayList();
    ArrayList pdfFilesList = new ArrayList();
    HttpSession session = request.getSession();
    HashSet PortAbbSet = null;
    PdfWriter writer = null;
    QMSMultiQuoteSessionHome home = null;
    QMSMultiQuoteSession remote = null;
    int incoSize = 0;
    PdfPTable pTable;
    PdfPCell pCell;
    ESupplyDateUtility eSupplyDateUtility = new ESupplyDateUtility();
    MultiQuoteHeader headerDOB = null;
    MultiQuoteMasterDOB masterDOB = null;
    int LegSize = 0;
    MultiQuoteChargeInfo multiQuoteChargeInfo = null;

    try {

        String carrierChecked = request.getParameter("selectCarrier");
        String serviceLevelChecked = request.getParameter("selectService");
        String frequencyChecked = request.getParameter("selectFrequecy");
        String operation = request.getParameter("Operation");
        DecimalFormat df = new DecimalFormat("###,###,###,##0.00");
        ESupplyGlobalParameters loginbean = (ESupplyGlobalParameters) request.getSession()
                .getAttribute("loginbean");
        eSupplyDateUtility.setPatternWithTime("DD-MONTH-YYYY");

        Document document = new Document(PageSize.A4, 54f, 54f, 68.4f, 68.4f);//@@ 36 points represent 0.5 inch
        document.setPageSize(PageSize.A4.rotate());
        String PDF_FILE_NAME = "Approved.pdf";
        document.addTitle("Approved Report");
        document.addSubject("Report PDF");
        document.addKeywords("Test, Key Words");
        document.addAuthor("QuoteShop");
        document.addCreator("QuoteShop");
        document.addCreationDate();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ByteArrayOutputStream baosFile = new ByteArrayOutputStream();
        writer = PdfWriter.getInstance(document, baos);
        document.open();
        PdfContentByte cb = writer.getDirectContent();
        cb.rectangle(document.left(), document.bottom(), document.right() - document.left(),
                document.top() - document.bottom());

        cb.stroke();

        int[] widths = { 12, 12, 12, 12, 12, 12, 28 };

        int[] width = { 4, 1 };
        Table mainT = new Table(2, 2);
        mainT.setWidth(100);
        mainT.setWidths(width);
        mainT.setBorderColor(Color.white);
        mainT.setPadding(3);
        mainT.setSpacing(0);

        Phrase headingPhrase = new Phrase("", FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.BLACK));
        Cell cellHeading = new Cell(headingPhrase);
        cellHeading.setBorderColor(new Color(255, 255, 255));
        cellHeading.setHorizontalAlignment(cellHeading.ALIGN_CENTER);
        cellHeading.setBorderWidth(0);
        mainT.addCell(cellHeading);

        Cell imageCell = new Cell();
        java.net.URL url = getServletConfig().getServletContext().getResource("/images/DHLlogo.gif");
        Image img0 = Image.getInstance(url);
        img0.setAlignment(Image.ALIGN_RIGHT);
        imageCell.setHorizontalAlignment(imageCell.ALIGN_LEFT);
        imageCell.add(img0);
        imageCell.setBorderWidth(0);
        imageCell.setNoWrap(true);
        System.out.println(imageCell.cellWidth());
        mainT.addCell(imageCell);
        mainT.setAlignment(mainT.ALIGN_CENTER);

        document.add(mainT);

        pTable = new PdfPTable(1);
        pTable.setSpacingAfter(10f);
        pCell = new PdfPCell(new Phrase(new Chunk("")));
        pCell.setBorder(0);
        pTable.addCell(pCell);

        document.add(pTable);
        String orgDesc = "";
        String destDesc = "";
        pTable = new PdfPTable(1);
        pTable.setSpacingAfter(10f);
        pCell = new PdfPCell(new Phrase(new Chunk("")));
        pCell.setBorder(0);
        pTable.addCell(pCell);

        document.add(pTable);
        Table surChargesTable = new Table(2);
        surChargesTable.setOffset(5);
        surChargesTable.setWidth(100);
        surChargesTable.setPadding(1);
        surChargesTable.setSpacing(0);

        surChargesTable.setBackgroundColor(Color.WHITE);
        surChargesTable.setBorderColor(Color.black);
        surChargesTable.setBorderWidth(1f);
        Cell cellContent = new Cell(
                new Chunk("Abbreviation", FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.BLACK)));
        cellContent.setColspan(2);
        cellContent.setBackgroundColor(Color.ORANGE);
        cellContent.setBorder(1);
        surChargesTable.addCell(cellContent);
        home = (QMSMultiQuoteSessionHome) LookUpBean.getEJBHome("QMSMultiQuoteSessionBean");
        remote = home.create();

        if (surChargesMap != null) {

            cellContent = new Cell(
                    new Chunk("Surcharge ID", FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.BLACK)));
            cellContent.setBorder(1);
            surChargesTable.addCell(cellContent);

            cellContent = new Cell(new Chunk("Surcharge Description",
                    FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.BLACK)));
            cellContent.setBorder(1);
            surChargesTable.addCell(cellContent);

            Iterator<Entry<String, String>> it = surChargesMap.entrySet().iterator();

            while (it.hasNext()) {
                Map.Entry<String, String> pairs = it.next();
                cellContent = new Cell(
                        new Chunk(pairs.getKey(), FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK)));
                cellContent.setBorder(1);
                surChargesTable.addCell(cellContent);

                cellContent = new Cell(
                        new Chunk(pairs.getValue(), FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK)));
                cellContent.setBorder(1);
                surChargesTable.addCell(cellContent);
            }
        }
        // Cell cellContentForBasis = new Cell( new Chunk("",FontFactory.getFont("ARIAL", 9, Font.BOLD,Color.BLACK)));
        cellContent = new Cell(new Chunk("", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK)));
        cellContent.setColspan(2);
        cellContent.setBorder(1);
        surChargesTable.addCell(cellContent);

        cellContent = new Cell(
                new Chunk("Charge Basis ID", FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.BLACK)));
        cellContent.setBorder(1);
        surChargesTable.addCell(cellContent);

        cellContent = new Cell(new Chunk("Charge Basis Description",
                FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.BLACK)));
        cellContent.setBorder(1);
        surChargesTable.addCell(cellContent);
        cellContent = new Cell(new Chunk("Per KG", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK)));
        cellContent.setBorder(1);
        surChargesTable.addCell(cellContent);

        cellContent = new Cell(
                new Chunk("Per Kilogram", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK)));//Modified by silpa.p on 2-06-11
        cellContent.setBorder(1);
        surChargesTable.addCell(cellContent);

        cellContent = new Cell(
                new Chunk("Per Shpt", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK)));//Modified by silpa.p on 2-06-11
        cellContent.setBorder(1);
        surChargesTable.addCell(cellContent);
        cellContent = new Cell(
                new Chunk("Per Shipment", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK)));//Modified by silpa.p on 2-06-11
        cellContent.setBorder(1);
        surChargesTable.addCell(cellContent);
        cellContent = new Cell(new Chunk("Per W/M", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK)));//Modified by silpa.p on 2-06-11
        cellContent.setBorder(1);
        surChargesTable.addCell(cellContent);
        cellContent = new Cell(
                new Chunk("Per Weight Measurement", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK)));//Modified by silpa.p on 2-06-11
        cellContent.setBorder(1);
        surChargesTable.addCell(cellContent);
        cellContent = new Cell(
                new Chunk("% of freight rates", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK)));//Modified by silpa.p on 2-06-11
        cellContent.setBorder(1);
        surChargesTable.addCell(cellContent);
        cellContent = new Cell(new Chunk("Percent Of Freight Rates",
                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK)));//Modified by silpa.p on 2-06-11
        cellContent.setBorder(1);
        surChargesTable.addCell(cellContent);

        cellContent = new Cell(new Chunk("Per Ctr", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK)));//added by silpa.p on 5-07-11
        cellContent.setBorder(1);
        surChargesTable.addCell(cellContent);
        cellContent = new Cell(
                new Chunk("Per Container", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK)));//added by silpa.p on 5-07-11
        cellContent.setBorder(1);
        surChargesTable.addCell(cellContent);
        LegSize = finalDOB.getLegDetails().size();
        //LegSize=(Integer)session.getAttribute("legSize");
        if (LegSize > 0) {
            PortAbbSet = new HashSet();
            cellContent = new Cell(
                    new Chunk("Port ID", FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.BLACK)));//Modified by silpa.p on 2-06-11
            cellContent.setBorder(1);
            surChargesTable.addCell(cellContent);

            cellContent = new Cell(
                    new Chunk("Port Name", FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.BLACK)));//Modified by silpa.p on 2-06-11
            cellContent.setBorder(1);
            surChargesTable.addCell(cellContent);

            for (int ln = 0; ln < LegSize; ln++) {
                //orgDesc =multiQuoteChargeInfo.getOrginLoc();
                orgDesc = ((MultiQuoteFreightLegSellRates) finalDOB.getLegDetails().get(ln)).getOrigin();
                orgDesc = orgDesc.length() > 3 ? orgDesc.substring(2) : orgDesc;
                if (!PortAbbSet.contains(orgDesc)) {
                    cellContent = new Cell(new Chunk(orgDesc != null ? orgDesc : "",
                            FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK)));//added by silpa.p on 5-07-11
                    cellContent.setBorder(1);

                    surChargesTable.addCell(cellContent);
                    PortAbbSet.add(orgDesc);
                }

                //    orgDesc = remote.getLocationName(multiQuoteChargeInfo.getOrginLoc());
                orgDesc = ((MultiQuoteFreightLegSellRates) finalDOB.getLegDetails().get(ln)).getOrgFullName();
                if (!PortAbbSet.contains(orgDesc)) {
                    cellContent = new Cell(new Chunk(orgDesc != null ? orgDesc : "",
                            FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK)));//added by silpa.p on 5-07-11
                    cellContent.setBorder(1);
                    surChargesTable.addCell(cellContent);
                    PortAbbSet.add(orgDesc);
                }
                //destDesc =multiQuoteChargeInfo.getDestLoc();
                destDesc = ((MultiQuoteFreightLegSellRates) finalDOB.getLegDetails().get(ln)).getDestination();
                destDesc = destDesc.length() > 3 ? destDesc.substring(2) : destDesc;
                if (!PortAbbSet.contains(destDesc)) {
                    cellContent = new Cell(new Chunk(destDesc != null ? destDesc : "",
                            FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK)));//added by silpa.p on 5-07-11
                    cellContent.setBorder(1);
                    surChargesTable.addCell(cellContent);
                    PortAbbSet.add(destDesc);
                }

                //    destDesc = remote.getLocationName(multiQuoteChargeInfo.getDestLoc());
                destDesc = ((MultiQuoteFreightLegSellRates) finalDOB.getLegDetails().get(ln)).getDestFullName();
                if (!PortAbbSet.contains(destDesc)) {
                    cellContent = new Cell(new Chunk(destDesc != null ? destDesc : "",
                            FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK)));//added by silpa.p on 5-07-11
                    cellContent.setBorder(1);
                    surChargesTable.addCell(cellContent);
                    PortAbbSet.add(destDesc);
                }
            }

        }
        //@@Modified by kiran on 10/08/2011 for WPBN Issue-258778
        // 09/11/2011
        if ("add".equalsIgnoreCase(operation) || "modify".equalsIgnoreCase(operation)
                || "Copy".equalsIgnoreCase(operation)) {
            if (("checked".equalsIgnoreCase(carrierChecked))) {
                String Carrier = "";
                String CarrierName = "";
                System.out.println("Cd.size()" + Cd.size());
                if (Cd.size() > 0) {
                    PortAbbSet = new HashSet();
                    cellContent = new Cell(
                            new Chunk("Carrier ID", FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.BLACK)));
                    cellContent.setBorder(1);
                    surChargesTable.addCell(cellContent);

                    cellContent = new Cell(new Chunk("Carrier Name",
                            FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.BLACK)));
                    cellContent.setBorder(1);
                    surChargesTable.addCell(cellContent);

                    for (int ln = 0; ln < Cd.size(); ln++) {
                        //orgDesc =multiQuoteChargeInfo.getOrginLoc();
                        //orgDesc =((MultiQuoteFreightLegSellRates)finalDOB.getLegDetails().get(ln)).getServiceLevel();  
                        Carrier = (String) Cd.get(ln);

                        // orgDesc = orgDesc;
                        if (!PortAbbSet.contains(Carrier)) {
                            System.out.println("Carrier==" + Carrier);
                            cellContent = new Cell(new Chunk(Carrier != null ? Carrier : "",
                                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK)));
                            cellContent.setBorder(1);
                            surChargesTable.addCell(cellContent);
                            PortAbbSet.add(Carrier);

                            //    orgDesc = remote.getLocationName(multiQuoteChargeInfo.getOrginLoc());
                            CarrierName = (String) Cdn.get(ln);
                            // orgDesc =((MultiQuoteFreightLegSellRates)finalDOB.getLegDetails().get(ln)).getServiceLevel();   
                            //if(!PortAbbSet.contains(Carrier))
                            // {
                            cellContent = new Cell(new Chunk(CarrierName != null ? CarrierName : "",
                                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK)));
                            cellContent.setBorder(1);
                            surChargesTable.addCell(cellContent);
                            //   PortAbbSet.add(orgDesc);
                            // }
                        }

                    }

                }
            }
            if (("checked".equalsIgnoreCase(serviceLevelChecked))) {
                String serviceId = "";
                if (Sd.size() > 0) {
                    PortAbbSet = new HashSet();
                    cellContent = new Cell(
                            new Chunk("Service ID", FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.BLACK)));
                    cellContent.setBorder(1);
                    surChargesTable.addCell(cellContent);

                    cellContent = new Cell(new Chunk("Service  Name",
                            FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.BLACK)));
                    cellContent.setBorder(1);
                    surChargesTable.addCell(cellContent);

                    for (int ln = 0; ln < Sd.size(); ln++) {
                        //orgDesc =multiQuoteChargeInfo.getOrginLoc();
                        //orgDesc =((MultiQuoteFreightLegSellRates)finalDOB.getLegDetails().get(ln)).getServiceLevel();  
                        serviceId = (String) Sd.get(ln);

                        // orgDesc = orgDesc;
                        if (!PortAbbSet.contains(serviceId)) {
                            cellContent = new Cell(new Chunk(serviceId != null ? serviceId : "",
                                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK)));
                            cellContent.setBorder(1);
                            surChargesTable.addCell(cellContent);
                            PortAbbSet.add(serviceId);

                            //    orgDesc = remote.getLocationName(multiQuoteChargeInfo.getOrginLoc());
                            serviceId = remote.getServiceLevelName(serviceId);
                            // orgDesc =((MultiQuoteFreightLegSellRates)finalDOB.getLegDetails().get(ln)).getServiceLevel();   

                            cellContent = new Cell(new Chunk(serviceId != null ? serviceId : "",
                                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK)));
                            cellContent.setBorder(1);
                            surChargesTable.addCell(cellContent);
                            //   PortAbbSet.add(orgDesc);
                        }

                    }

                }
            }
        } else {
            if (("checked".equalsIgnoreCase(carrierChecked)) || carrierFlag) {
                String Carrier = "";
                String CarrierName = "";
                System.out.println("Cd.size()" + Cd.size());
                if (Cd.size() > 0) {
                    PortAbbSet = new HashSet();
                    cellContent = new Cell(
                            new Chunk("Carrier ID", FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.BLACK)));
                    cellContent.setBorder(1);
                    surChargesTable.addCell(cellContent);

                    cellContent = new Cell(new Chunk("Carrier Name",
                            FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.BLACK)));
                    cellContent.setBorder(1);
                    surChargesTable.addCell(cellContent);

                    for (int ln = 0; ln < Cd.size(); ln++) {
                        //orgDesc =multiQuoteChargeInfo.getOrginLoc();
                        //orgDesc =((MultiQuoteFreightLegSellRates)finalDOB.getLegDetails().get(ln)).getServiceLevel();  
                        Carrier = (String) Cd.get(ln);

                        // orgDesc = orgDesc;
                        if (!PortAbbSet.contains(Carrier)) {
                            System.out.println("Carrier==" + Carrier);
                            cellContent = new Cell(new Chunk(Carrier != null ? Carrier : "",
                                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK)));
                            cellContent.setBorder(1);
                            surChargesTable.addCell(cellContent);
                            PortAbbSet.add(Carrier);

                            //    orgDesc = remote.getLocationName(multiQuoteChargeInfo.getOrginLoc());
                            CarrierName = (String) Cdn.get(ln);
                            // orgDesc =((MultiQuoteFreightLegSellRates)finalDOB.getLegDetails().get(ln)).getServiceLevel();   
                            //if(!PortAbbSet.contains(Carrier))
                            // {
                            cellContent = new Cell(new Chunk(CarrierName != null ? CarrierName : "",
                                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK)));
                            cellContent.setBorder(1);
                            surChargesTable.addCell(cellContent);
                            //   PortAbbSet.add(orgDesc);
                            // }
                        }

                    }

                }
            }
            if (("checked".equalsIgnoreCase(serviceLevelChecked)) || serviceFlag) {
                String serviceId = "";
                if (Sd.size() > 0) {
                    PortAbbSet = new HashSet();
                    cellContent = new Cell(
                            new Chunk("Service ID", FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.BLACK)));
                    cellContent.setBorder(1);
                    surChargesTable.addCell(cellContent);

                    cellContent = new Cell(new Chunk("Service  Name",
                            FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.BLACK)));
                    cellContent.setBorder(1);
                    surChargesTable.addCell(cellContent);

                    for (int ln = 0; ln < Sd.size(); ln++) {
                        //orgDesc =multiQuoteChargeInfo.getOrginLoc();
                        //orgDesc =((MultiQuoteFreightLegSellRates)finalDOB.getLegDetails().get(ln)).getServiceLevel();  
                        serviceId = (String) Sd.get(ln);

                        // orgDesc = orgDesc;
                        if (!PortAbbSet.contains(serviceId)) {
                            cellContent = new Cell(new Chunk(serviceId != null ? serviceId : "",
                                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK)));
                            cellContent.setBorder(1);
                            surChargesTable.addCell(cellContent);
                            PortAbbSet.add(serviceId);

                            //    orgDesc = remote.getLocationName(multiQuoteChargeInfo.getOrginLoc());
                            serviceId = remote.getServiceLevelName(serviceId);
                            // orgDesc =((MultiQuoteFreightLegSellRates)finalDOB.getLegDetails().get(ln)).getServiceLevel();   

                            cellContent = new Cell(new Chunk(serviceId != null ? serviceId : "",
                                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK)));
                            cellContent.setBorder(1);
                            surChargesTable.addCell(cellContent);
                            //   PortAbbSet.add(orgDesc);
                        }

                    }

                }
            }
        }

        //@@Ended by kiran.v
        document.add(surChargesTable);
        PdfContentByte cb1 = writer.getDirectContent();
        cb1.rectangle(document.left(), document.bottom(), document.right() - document.left(),
                document.top() - document.bottom());
        cb1.stroke();
        if (document != null) {
            document.close();
            File f = new File("Cartage.pdf");
            FileOutputStream fileOutputStream = new FileOutputStream(f);
            baos.writeTo(fileOutputStream);
            fileOutputStream.close();
            PdfReader reader = new PdfReader("Cartage.pdf");
            int n = reader.getNumberOfPages();
            File fs = new File(fileName);
            String space = " ";
            PdfStamper stamp = new PdfStamper(reader, new FileOutputStream(fs));
            int k = 0;
            PdfContentByte under;
            PdfContentByte over = null;
            BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED);
            while (k < n) {
                k++;
                over = stamp.getOverContent(k);
                over.rectangle(document.left(), document.bottom(), document.right() - document.left(),
                        document.top() - document.bottom());
                over.stroke();
                over.beginText();
                over.setFontAndSize(bf, 8);
                over.setTextMatrix(15, 15);
                over.showText("page " + k + " of " + n);

                if (k > 1) {
                    over.setFontAndSize(bf, 7);
                    if (masterDOB != null)
                        over.showText("QUOTE REFERENCE:" + masterDOB.getQuoteId());
                    over.endText();
                    over.beginText();
                    if (headerDOB != null)
                        over.showText("CUSTOMER NAME: " + headerDOB.getCustomerName());
                }
                over.endText();
            }
            stamp.close();
            request.getSession().setAttribute("AbbrivationOuptutStream", fs);

            baos.close();
        }

    } catch (Exception exception) {
        exception.printStackTrace();
    }

}

From source file:QMSMultiQuoteController.java

License:Open Source License

private int doGenerateCartagePDF(String fileName, MultiQuoteFinalDOB finalDOB, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    try { //System.out.println("Starting zone PDF Generation------------------------------>");
        DecimalFormat df = new DecimalFormat("###,###,###,##0.00");
        // Added By Kishore Podili For Multi Zone Codes
        MultiQuoteCartageRates pickQuoteCartageRates = null;
        MultiQuoteCartageRates deliQuoteCartageRates = null;
        ArrayList pickUpQuoteCartageRates = null;
        ArrayList deliveryQuoteCartageRates = null;
        Set pickBreaks = null;/*from  ww  w.  j  a v a2s .c  o  m*/
        Set deliBreaks = null;
        Set pickUpZoneCodeSet = null;
        Set deliveryZoneCodeSet = null;
        HashMap pickUpZoneCodeMap = null;
        HashMap deliveryZoneCodeMap = null;
        HashMap pickUpZoneZipMap = null;
        HashMap deliveryZoneZipMap = null;
        ArrayList zipList = null;
        ArrayList pickupWeightBreaks = null;
        ArrayList delWeightBreaks = null;
        Iterator zones = null;
        Iterator breaksSet = null;
        int pickupWeightBreaksSize = 0;
        int delWeightBreaksSize = 0;
        HttpSession session = null;
        MultiQuoteFreightLegSellRates legDestCharges = null;
        ArrayList destLaneCharges = finalDOB.getLegDetails();
        int noOfLanes = destLaneCharges.size();
        MultiQuoteMasterDOB masterDOB = finalDOB.getMasterDOB();

        //Added by Kishore For Multiple Zip and Zone Codes

        Document document = null;
        ByteArrayOutputStream baos = null;
        PdfWriter writer = null;

        MultiQuoteHeader headerDOB = finalDOB.getHeaderDOB();

        ArrayList pickupChargeBasisList = null;
        ArrayList delChargeBasisList = null;
        int pickupChargeBasisSize = 0;
        int delChargeBasisSize = 0;

        for (int dc = 0; dc < noOfLanes; dc++) {
            legDestCharges = (MultiQuoteFreightLegSellRates) destLaneCharges.get(dc);
            //Added by Anil.k kishore for Quote Charges
            //if(!"Charges".equalsIgnoreCase(masterDOB.getQuoteWith())){//END
            //Added By Kishore Podili For CartagePDF Quote Add
            //if((masterDOB.getShipperZipCode()!=null && (masterDOB.getShipperZipCode()[dc]==null || "".equals(masterDOB.getShipperZipCode()[dc])))||( masterDOB.getConsigneeZipCode()!=null && (masterDOB.getConsigneeZipCode()[dc]==null || "".equals(masterDOB.getConsigneeZipCode()[dc]))))
            //{
            //Commented By Kishore Podili
            if ((legDestCharges.getPickZoneZipMap() != null && legDestCharges.getPickZoneZipMap().size() > 0)
                    || (legDestCharges.getDeliveryZoneZipMap() != null
                            && legDestCharges.getDeliveryZoneZipMap().size() > 0)) {

                pickUpQuoteCartageRates = legDestCharges.getPickUpCartageRatesList();

                deliveryQuoteCartageRates = legDestCharges.getDeliveryCartageRatesList();
                //Modified By Kishore For MultiZoneCodes
                pickupWeightBreaks = legDestCharges.getPickupWeightBreaks(); //finalDOB.getPickupWeightBreaks();
                delWeightBreaks = legDestCharges.getDeliveryWeightBreaks(); //finalDOB.getDeliveryWeightBreaks();

                if (pickupWeightBreaks != null)
                    pickupWeightBreaksSize = pickupWeightBreaks.size();
                if (delWeightBreaks != null)
                    delWeightBreaksSize = delWeightBreaks.size();

                pickupChargeBasisList = legDestCharges.getPickupChargeBasisList(); //finalDOB.getPickupWeightBreaks();
                delChargeBasisList = legDestCharges.getDelChargeBasisList(); //finalDOB.getDeliveryWeightBreaks();

                if (pickupChargeBasisList != null)
                    pickupChargeBasisSize = pickupChargeBasisList.size();
                if (delChargeBasisList != null)
                    delChargeBasisSize = delChargeBasisList.size();

                //Commented By Kishroe Podili

                //MultiQuoteHeader    headerDOB   =    finalDOB.getHeaderDOB();

                //MultiQuoteMasterDOB masterDOB  =   finalDOB.getMasterDOB();
                ESupplyDateUtility eSupplyDateUtility = new ESupplyDateUtility();
                ESupplyGlobalParameters loginbean = (ESupplyGlobalParameters) request.getSession()
                        .getAttribute("loginbean");
                eSupplyDateUtility.setPatternWithTime("DD-MONTH-YYYY");
                //eSupplyDateUtility.setPatternWithTime(loginbean.getUserPreferences().getDateFormat());
                //@@ Commented and added by subrahmanyam for the pbn issue 212006 on #26-jul-10
                /*          String[] strDate  = eSupplyDateUtility.getDisplayStringArray(headerDOB.getDateOfQuotation());
                String[] effDate  = eSupplyDateUtility.getDisplayStringArray(headerDOB.getEffDate());
                */
                String[] strDate = null;
                String[] effDate = null;
                if ("View".equalsIgnoreCase(request.getParameter("Operation"))) {
                    if ("PDF".equalsIgnoreCase(request.getParameter("PDF"))) {
                        strDate = eSupplyDateUtility.getDisplayStringArray(masterDOB.getModifiedDate());
                        effDate = eSupplyDateUtility.getDisplayStringArray(masterDOB.getEffDate());
                    } else {
                        strDate = eSupplyDateUtility.getDisplayStringArray(masterDOB.getModifiedDate());
                        effDate = eSupplyDateUtility.getDisplayStringArray(masterDOB.getCreatedDate());
                    }

                } else {
                    strDate = eSupplyDateUtility.getDisplayStringArray(headerDOB.getDateOfQuotation());
                    effDate = eSupplyDateUtility.getDisplayStringArray(headerDOB.getEffDate());

                }

                String[] validDate;
                String validUptoStr = "";
                if (headerDOB.getValidUpto() != null) {
                    validDate = eSupplyDateUtility.getDisplayStringArray(headerDOB.getValidUpto());
                    validUptoStr = validDate[0];
                }

                StringBuffer attentionTo = new StringBuffer("");
                if (masterDOB.getCustContactNames() != null) {
                    for (int i = 0; i < masterDOB.getCustContactNames().length; i++) {
                        //Logger.info(FILE_NAME,"masterDOB.getCustContactNames()[i]::"+masterDOB.getCustomerContacts()[i]);
                        attentionTo.append(
                                masterDOB.getCustContactNames()[i] != null ? masterDOB.getCustContactNames()[i]
                                        : "");
                        if (i != (masterDOB.getCustContactNames().length - 1))
                            attentionTo.append(",");
                    }
                }

                String chargeRate = null;

                //System.out.println("After getting data------------------------------>"+pickUpQuoteCartageRates.size());

                //Added By Kishore For MultiZone Codes
                Cell cellCountry;
                Chunk chk;
                if (dc == 0) {

                    //document = new Document(PageSize.A4,54f,54f,68.4f,68.4f);//@@ 36 points represent 0.5 inch  
                    document = new Document(PageSize.A4, 10f, 10f, 20f, 20f); //added by silpa on 27-06-11
                    document.addTitle("Approved Report");
                    document.addSubject("Report PDF");
                    document.addKeywords("Test, Key Words");
                    document.addAuthor("DHL");
                    document.addCreator("Auto Generated through 4S DHL");
                    document.addCreationDate();

                    baos = new ByteArrayOutputStream();
                    writer = PdfWriter.getInstance(document, baos);
                    //added by silpa on 27-06-11
                    document.open();
                    PdfContentByte cb = writer.getDirectContent();
                    cb.rectangle(document.left(), document.bottom(), document.right() - document.left(),
                            document.top() - document.bottom());
                    cb.stroke();//ended

                    int[] widths = { 10, 10, 10, 10, 10, 10, 12, 28 };

                    Table mainT = new Table(8);
                    mainT.setWidth(100);
                    mainT.setWidths(widths);
                    mainT.setBorderColor(Color.white);
                    mainT.setPadding(1);
                    mainT.setSpacing(0);

                    Phrase headingPhrase = new Phrase("",
                            FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.BLACK));
                    Cell cellHeading = new Cell(headingPhrase);
                    cellHeading.setBorderColor(new Color(255, 255, 255));
                    cellHeading.setHorizontalAlignment(cellHeading.ALIGN_CENTER);
                    cellHeading.setColspan(7);
                    mainT.addCell(cellHeading);

                    Cell imageCell = new Cell();
                    java.net.URL url = getServletConfig().getServletContext()
                            .getResource("/images/DHLlogo.gif");
                    Image img0 = Image.getInstance(url);
                    //img0.scalePercent(75);
                    imageCell.add(img0);
                    imageCell.setHorizontalAlignment(imageCell.ALIGN_RIGHT);
                    imageCell.setBorderWidth(0);
                    imageCell.setNoWrap(true);
                    imageCell.setColspan(1);
                    mainT.addCell(imageCell);
                    mainT.setAlignment(mainT.ALIGN_CENTER);
                    document.add(mainT);

                    //pickBreaks = pickQuoteCartageRates.getRates().keySet();
                    //System.out.println("After Heading ----------------pickBreaks----------->");            
                    Table partCountry = new Table(1, 4);
                    partCountry.setBorderWidth(0);
                    partCountry.setWidth(100);
                    partCountry.setBorderColor(Color.black);
                    //partCountry.setBackgroundColor(Color.ORANGE);
                    partCountry.setPadding(1);
                    partCountry.setSpacing(1);
                    partCountry.setAutoFillEmptyCells(true);
                    //partCountry.setTableFitsPage(true);
                    partCountry.setAlignment(partCountry.ALIGN_CENTER);
                    // partCountry.setWidth(100.0f);
                    /*Cell cellCountry;
                    Chunk chk;*/

                    chk = new Chunk("ANNEXURE", FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.BLACK));
                    cellCountry = new Cell(chk);
                    cellCountry.setWidth("100");
                    cellCountry.setBorderWidth(0);
                    cellCountry.setNoWrap(true);
                    cellCountry.setLeading(10.0f);
                    cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
                    partCountry.addCell(cellCountry);

                    if ("MY".equalsIgnoreCase(masterDOB.getCountryId())) {
                        chk = new Chunk((headerDOB.getOriginCountry() != null
                                ? headerDOB.getOriginCountry()[dc].toUpperCase()
                                : "")
                                + " TO "
                                + (headerDOB.getDestinationCountry() != null
                                        ? headerDOB.getDestinationCountry()[dc].toUpperCase()
                                        : ""),
                                FontFactory.getFont("ARIAL", 16, Font.BOLD, Color.BLUE));
                        cellCountry = new Cell(chk);
                        cellCountry.setWidth("100");
                        cellCountry.setBorderWidth(0);
                        cellCountry.setNoWrap(true);
                        cellCountry.setLeading(10.0f);
                        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
                        partCountry.addCell(cellCountry);

                        cellCountry = new Cell("");
                        cellCountry.setBorderWidth(0);
                        cellCountry.setLeading(5.0f);
                        partCountry.addCell(cellCountry);

                        chk = new Chunk(headerDOB.getCustomerName(),
                                FontFactory.getFont("ARIAL", 14, Font.BOLD, Color.BLUE));
                        cellCountry = new Cell(chk);
                        cellCountry.setHeader(true);
                        cellCountry.setWidth("100");
                        cellCountry.setBorderWidth(0);
                        cellCountry.setNoWrap(true);
                        cellCountry.setLeading(10.0f);
                        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
                        partCountry.addCell(cellCountry);
                        //Logger.info(FILE_NAME,"attentionTo.toString():"+attentionTo.toString());

                        chk = new Chunk("ATTENTION TO: " + toTitleCase(attentionTo.toString()),
                                FontFactory.getFont("ARIAL", 14, Font.BOLD, Color.BLUE));
                        cellCountry = new Cell(chk);
                        cellCountry.setWidth("100");
                        cellCountry.setBorderWidth(0);
                        cellCountry.setNoWrap(true);
                        cellCountry.setLeading(10.0f);
                        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
                        partCountry.addCell(cellCountry);

                        cellCountry = new Cell("");
                        cellCountry.setBorderWidth(0);
                        cellCountry.setLeading(5.0f);
                        partCountry.addCell(cellCountry);
                    } else {
                        chk = new Chunk((headerDOB.getOriginCountry() != null
                                ? headerDOB.getOriginCountry()[dc].toUpperCase()
                                : "")
                                + " TO "
                                + (headerDOB.getDestinationCountry() != null
                                        ? headerDOB.getDestinationCountry()[dc].toUpperCase()
                                        : ""),
                                FontFactory.getFont("ARIAL", 16, Font.BOLD, Color.RED));
                        cellCountry = new Cell(chk);
                        cellCountry.setWidth("100");
                        cellCountry.setBorderWidth(0);
                        cellCountry.setNoWrap(true);
                        cellCountry.setLeading(10.0f);
                        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
                        partCountry.addCell(cellCountry);

                        cellCountry = new Cell("");
                        cellCountry.setBorderWidth(0);
                        cellCountry.setLeading(5.0f);
                        partCountry.addCell(cellCountry);

                        chk = new Chunk(headerDOB.getCustomerName(),
                                FontFactory.getFont("ARIAL", 14, Font.BOLD, Color.RED));
                        cellCountry = new Cell(chk);
                        cellCountry.setHeader(true);
                        cellCountry.setWidth("100");
                        cellCountry.setBorderWidth(0);
                        cellCountry.setNoWrap(true);
                        cellCountry.setLeading(10.0f);
                        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
                        partCountry.addCell(cellCountry);
                        //Logger.info(FILE_NAME,"attentionTo.toString():"+attentionTo.toString());

                        chk = new Chunk("ATTENTION TO: " + toTitleCase(attentionTo.toString()),
                                FontFactory.getFont("ARIAL", 14, Font.BOLD, Color.RED));
                        cellCountry = new Cell(chk);
                        cellCountry.setWidth("100");
                        cellCountry.setBorderWidth(0);
                        cellCountry.setNoWrap(true);
                        cellCountry.setLeading(10.0f);
                        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
                        partCountry.addCell(cellCountry);

                        cellCountry = new Cell("");
                        cellCountry.setBorderWidth(0);
                        cellCountry.setLeading(5.0f);
                        partCountry.addCell(cellCountry);
                    }
                    chk = new Chunk("QUOTE REFERENCE: " + masterDOB.getQuoteId(),
                            FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.BLACK));
                    cellCountry = new Cell(chk);
                    cellCountry.setWidth("100");
                    cellCountry.setBorderWidth(0);
                    cellCountry.setNoWrap(true);
                    cellCountry.setLeading(10.0f);
                    cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
                    partCountry.addCell(cellCountry);
                    chk = new Chunk("DATE OF QUOTATION: " + strDate[0],
                            FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.BLACK));
                    cellCountry = new Cell(chk);
                    cellCountry.setWidth("100");
                    cellCountry.setBorderWidth(0);
                    cellCountry.setNoWrap(true);
                    cellCountry.setLeading(10.0f);
                    cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
                    partCountry.addCell(cellCountry);

                    document.add(partCountry);

                }

                if (dc > 0) {
                    document.newPage();

                }

                Table partZone = null;
                Cell cellZone;

                if (pickUpQuoteCartageRates != null && pickUpQuoteCartageRates.size() > 0) {
                    /*Set keys = null;            
                    for(int i=0;i<pickUpQuoteCartageRates.size();i++)
                    {              
                      if(i==0)
                      { 
                        pickBreaks = new TreeSet();//@@This is needed as only a new Set Implementation obj supports addAll() 
                      }
                      pickQuoteCartageRates = (QuoteCartageRates) pickUpQuoteCartageRates.get(i);
                      keys = pickQuoteCartageRates.getRates().keySet();
                      pickBreaks.addAll(keys);
                    }*/

                    //if(pickBreaks!=null && pickBreaks.size()>0)
                    //if(pickupWeightBreaks != null && pickupWeightBreaksSize>0)
                    partZone = new Table(pickupWeightBreaksSize + 2);
                    partZone.setOffset(30);
                    partZone.setDefaultHorizontalAlignment(partZone.ALIGN_CENTER);
                    partZone.setBorderWidth(1);
                    partZone.setBorderColor(Color.black);
                    partZone.setPadding(1);
                    partZone.setSpacing(1);
                    partZone.setAutoFillEmptyCells(true);
                    partZone.setWidth(100);
                    //partZone.setTableFitsPage(true);
                    //@@ Added by subrahmanyam for the enhancement #147062 on 09/12/2008
                    chk = new Chunk("PICKUP CARTAGE RATES AT: " + headerDOB.getOriginLocName()[dc],
                            FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.RED));
                    cellZone = new Cell(chk);
                    cellZone.setNoWrap(true);
                    cellZone.setHeader(true);
                    cellZone.setVerticalAlignment(cellZone.ALIGN_BOTTOM);
                    cellZone.setLeading(10.0f);
                    cellZone.setBackgroundColor(Color.WHITE);
                    cellZone.setColspan(pickupWeightBreaksSize + 2);
                    partZone.addCell(cellZone);
                    //@@ Ended by subrahmanyam for the enhancement #147062 on 09/12/2008
                    chk = new Chunk("PICKUP CARTAGE RATES",
                            FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.BLACK));
                    cellZone = new Cell(chk);
                    cellZone.setNoWrap(true);
                    cellZone.setHeader(true);
                    cellZone.setVerticalAlignment(cellZone.ALIGN_BOTTOM);
                    cellZone.setLeading(10.0f);
                    cellZone.setBackgroundColor(Color.ORANGE);
                    cellZone.setColspan(pickupWeightBreaksSize + 2);
                    partZone.addCell(cellZone);

                    chk = new Chunk("Zone", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                    cellZone = new Cell(chk);
                    //cellZone.setNoWrap(true);
                    cellZone.setLeading(8.0f);
                    cellZone.setHeader(true);
                    cellZone.setBackgroundColor(Color.LIGHT_GRAY);
                    partZone.addCell(cellZone);

                    chk = new Chunk("Currency", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                    cellZone = new Cell(chk);
                    //cellZone.setNoWrap(true);
                    cellZone.setHeader(true);
                    cellZone.setLeading(8.0f);
                    cellZone.setBackgroundColor(Color.LIGHT_GRAY);
                    partZone.addCell(cellZone);
                    //breaksSet = pickBreaks.iterator();  // logger.info("breaksSetbreaksSet::"+breaksSet);
                    /*while(breaksSet.hasNext())
                    {              
                      chk = new Chunk((String)breaksSet.next(),FontFactory.getFont("ARIAL", 8, Font.BOLD,Color.BLACK));
                      cellZone = new Cell(chk);              
                      cellZone.setNoWrap(true);
                      cellZone.setHeader(true);
                      partZone.addCell(cellZone);
                    }*/
                    //if(pickupWeightBreaks!=null)
                    //{
                    //logger.info("pickupWeightBreaks"+pickupWeightBreaks);
                    for (int i = 0; i < pickupWeightBreaksSize; i++) {
                        chk = new Chunk((String) pickupWeightBreaks.get(i),
                                FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                        cellZone = new Cell(chk);
                        //cellZone.setNoWrap(true);
                        cellZone.setLeading(8.0f);
                        cellZone.setHeader(true);
                        cellZone.setBackgroundColor(Color.LIGHT_GRAY);
                        partZone.addCell(cellZone);
                    }
                    //}
                    partZone.endHeaders();

                    chk = new Chunk("");
                    cellZone = new Cell(chk);
                    cellZone.setLeading(8.0f);
                    // cellZone.setHeader(true);
                    // cellZone.setBackgroundColor(Color.LIGHT_GRAY);
                    partZone.addCell(cellZone);

                    chk = new Chunk("");
                    cellZone = new Cell(chk);
                    cellZone.setLeading(8.0f);
                    //cellZone.setHeader(true);
                    //cellZone.setBackgroundColor(Color.LIGHT_GRAY);
                    partZone.addCell(cellZone);

                    for (int i = 0; i < pickupChargeBasisSize; i++) {
                        chk = new Chunk(toTitleCase((String) pickupChargeBasisList.get(i)),
                                FontFactory.getFont("ARIAL", 7, Font.BOLD, Color.BLACK));
                        cellZone = new Cell(chk);
                        //cellZone.setNoWrap(true);
                        cellZone.setLeading(8.0f);
                        cellZone.setHeader(true);
                        //cellZone.setBackgroundColor(Color.LIGHT_GRAY);
                        partZone.addCell(cellZone);
                    }

                    int pikupQuoteCartRatSize = pickUpQuoteCartageRates.size();
                    label0: for (int i = 0; i < pikupQuoteCartRatSize; i++) {
                        pickQuoteCartageRates = (MultiQuoteCartageRates) pickUpQuoteCartageRates.get(i); // By Kishore For Multiple Zone Code
                        chk = new Chunk(pickQuoteCartageRates.getZone(),
                                FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                        cellZone = new Cell(chk);
                        cellZone.setLeading(8.0f);
                        //cellZone.setNoWrap(true);            
                        partZone.addCell(cellZone);

                        chk = new Chunk(pickQuoteCartageRates.getCurrency(),
                                FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                        cellZone = new Cell(chk);
                        cellZone.setLeading(8.0f);
                        //cellZone.setNoWrap(true);            
                        partZone.addCell(cellZone);

                        pickUpZoneCodeMap = pickQuoteCartageRates.getRates();

                        /*breaksSet = pickBreaks.iterator();
                        while(breaksSet.hasNext())
                         {
                           String wBreak = (String)breaksSet.next();
                           if(pickUpZoneCodeMap.containsKey(wBreak))
                           {
                            chargeRate = (String)pickUpZoneCodeMap.get(wBreak);
                            chargeRate  = df.format(Double.parseDouble(chargeRate));
                           }
                           else
                           {
                            chargeRate = "--";              
                           }
                          chk = new Chunk(chargeRate,FontFactory.getFont("ARIAL", 8, Font.BOLD,Color.BLACK));
                          cellZone = new Cell(chk);
                          cellZone.setNoWrap(true);            
                          partZone.addCell(cellZone); 
                         }*/

                        // ------------------------------------------------------  //added by Brahmaiah.R on 31/5/2012 for WPBN issue 304241
                        if (pickupWeightBreaks == null) {
                            continue;
                        }
                        String wBreak = null;
                        int k = 0;
                        do {
                            if (k >= pickupWeightBreaksSize) {
                                continue label0;
                            }
                            wBreak = (String) pickupWeightBreaks.get(k);
                            if (wBreak != null && pickUpZoneCodeMap.containsKey(wBreak)) {
                                chargeRate = (String) pickUpZoneCodeMap.get(wBreak);
                                chargeRate = df.format(Double.parseDouble(chargeRate));
                            } else {
                                chargeRate = "--";
                            }
                            chk = new Chunk(chargeRate, FontFactory.getFont("ARIAL", 8F, 1, Color.BLACK));
                            cellZone = new Cell(chk);
                            cellZone.setLeading(8F);
                            partZone.addCell(cellZone);
                            k++;
                        } while (true);
                    }
                    document.add(partZone);
                }
                if (deliveryQuoteCartageRates != null && deliveryQuoteCartageRates.size() > 0) {
                    /*Set dkeys         = null;
                    for(int i=0;i<deliveryQuoteCartageRates.size();i++)
                    {       
                     if(i==0)
                     { 
                       deliBreaks = new TreeSet();//@@This is needed as only a new Set Implementation obj supports addAll() 
                     }
                     deliQuoteCartageRates = (QuoteCartageRates) deliveryQuoteCartageRates.get(i);
                     dkeys = deliQuoteCartageRates.getRates().keySet();
                     deliBreaks.addAll(dkeys);
                     //System.out.println("Before zone header------------------------------>"+deliBreaks);
                     //System.out.println("Before zone header------------------------------>"+deliBreaks.size());              
                    }*/

                    partZone = new Table(delWeightBreaksSize + 2);
                    partZone.setOffset(30);
                    partZone.setDefaultHorizontalAlignment(partZone.ALIGN_CENTER);
                    partZone.setBorderWidth(1);
                    partZone.setWidth(100);
                    partZone.setBorderColor(Color.black);
                    partZone.setPadding(1);
                    partZone.setSpacing(1);
                    partZone.setAutoFillEmptyCells(true);
                    //partZone.setTableFitsPage(true);
                    //@@ Added by subrahmanyam for the enhancement #147062 on 08/12/2008
                    chk = new Chunk("DELIVERY CARTAGE RATES AT: " + headerDOB.getDestLocName()[dc],
                            FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.RED));
                    cellZone = new Cell(chk);
                    cellZone.setNoWrap(true);
                    cellZone.setLeading(10.0f);
                    cellZone.setHeader(true);
                    cellZone.setBackgroundColor(Color.WHITE);
                    cellZone.setVerticalAlignment(cellZone.ALIGN_BOTTOM);
                    cellZone.setColspan(delWeightBreaksSize + 2);
                    partZone.addCell(cellZone);
                    //@@ Ended by subrahmanyam for the enhancement #147062 on 08/12/2008
                    chk = new Chunk("DELIVERY CARTAGE RATES",
                            FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.BLACK));
                    cellZone = new Cell(chk);
                    cellZone.setNoWrap(true);
                    cellZone.setLeading(10.0f);
                    cellZone.setHeader(true);
                    cellZone.setBackgroundColor(Color.ORANGE);
                    cellZone.setVerticalAlignment(cellZone.ALIGN_BOTTOM);
                    cellZone.setColspan(delWeightBreaksSize + 2);
                    partZone.addCell(cellZone);

                    chk = new Chunk("Zone", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                    cellZone = new Cell(chk);
                    cellZone.setLeading(8.0f);
                    //cellZone.setNoWrap(true);
                    cellZone.setHeader(true);
                    cellZone.setBackgroundColor(Color.LIGHT_GRAY);
                    partZone.addCell(cellZone);

                    chk = new Chunk("Currency", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                    cellZone = new Cell(chk);
                    cellZone.setLeading(8.0f);
                    //cellZone.setNoWrap(true);
                    cellZone.setHeader(true);
                    cellZone.setBackgroundColor(Color.LIGHT_GRAY);
                    partZone.addCell(cellZone);

                    //breaksSet = deliBreaks.iterator();

                    /*while(breaksSet.hasNext())
                    {              
                      String breaks = (String)breaksSet.next();
                            
                      chk = new Chunk(breaks,FontFactory.getFont("ARIAL", 8, Font.BOLD,Color.BLACK));
                      cellZone = new Cell(chk);              
                      cellZone.setNoWrap(true);
                      cellZone.setHeader(true);
                      partZone.addCell(cellZone);
                    }*/
                    for (int i = 0; i < delWeightBreaksSize; i++) {
                        chk = new Chunk((String) delWeightBreaks.get(i),
                                FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                        cellZone = new Cell(chk);
                        cellZone.setLeading(8.0f);
                        //cellZone.setNoWrap(true);
                        cellZone.setHeader(true);
                        cellZone.setBackgroundColor(Color.LIGHT_GRAY);
                        partZone.addCell(cellZone);
                    }
                    partZone.endHeaders();

                    chk = new Chunk("");
                    cellZone = new Cell(chk);
                    cellZone.setLeading(8.0f);
                    //cellZone.setHeader(true);
                    //cellZone.setBackgroundColor(Color.LIGHT_GRAY);
                    partZone.addCell(cellZone);

                    chk = new Chunk("");
                    cellZone = new Cell(chk);
                    cellZone.setLeading(8.0f);
                    //cellZone.setHeader(true);
                    //cellZone.setBackgroundColor(Color.LIGHT_GRAY);
                    partZone.addCell(cellZone);

                    for (int i = 0; i < delChargeBasisSize; i++) {
                        chk = new Chunk(toTitleCase((String) delChargeBasisList.get(i)),
                                FontFactory.getFont("ARIAL", 7, Font.BOLD, Color.BLACK));
                        cellZone = new Cell(chk);
                        //cellZone.setNoWrap(true);
                        cellZone.setLeading(8.0f);
                        cellZone.setHeader(true);
                        //cellZone.setBackgroundColor(Color.LIGHT_GRAY);
                        partZone.addCell(cellZone);
                    }

                    int delQuoteCartRtSize = deliveryQuoteCartageRates.size();
                    for (int i = 0; i < delQuoteCartRtSize; i++) {
                        deliQuoteCartageRates = (MultiQuoteCartageRates) deliveryQuoteCartageRates.get(i); // By Kishore For Multiple Zone Code

                        chk = new Chunk(deliQuoteCartageRates.getZone(),
                                FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                        cellZone = new Cell(chk);
                        cellZone.setLeading(8.0f);
                        //cellZone.setNoWrap(true);            
                        partZone.addCell(cellZone);

                        chk = new Chunk(deliQuoteCartageRates.getCurrency(),
                                FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                        cellZone = new Cell(chk);
                        cellZone.setLeading(8.0f);
                        //cellZone.setNoWrap(true);            
                        partZone.addCell(cellZone);
                        // String charge_type=deliQuoteCartageRates.getBuyOrSellRate();  //@@Added by kiran.v

                        deliveryZoneCodeMap = deliQuoteCartageRates.getRates();

                        //breaksSet = deliBreaks.iterator();
                        /*while(breaksSet.hasNext())
                         {
                           String wBreak = (String)breaksSet.next();
                           if(deliveryZoneCodeMap.containsKey(wBreak))
                           {
                            chargeRate = (String)deliveryZoneCodeMap.get(wBreak);  
                            chargeRate  = df.format(Double.parseDouble(chargeRate));
                           }
                           else
                           {
                            chargeRate = "--";              
                           }
                          chk = new Chunk(chargeRate,FontFactory.getFont("ARIAL", 8, Font.BOLD,Color.BLACK));
                          cellZone = new Cell(chk);
                          cellZone.setNoWrap(true);            
                          partZone.addCell(cellZone); 
                         }*/
                        String wBreak = null;
                        for (int k = 0; k < delWeightBreaksSize; k++) {
                            wBreak = (String) delWeightBreaks.get(k);
                            if (wBreak != null && deliveryZoneCodeMap.containsKey(wBreak)) {
                                chargeRate = (String) deliveryZoneCodeMap.get(wBreak);
                                chargeRate = df.format(Double.parseDouble(chargeRate));
                            } else {
                                chargeRate = "--";
                            }
                            chk = new Chunk(chargeRate,
                                    FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                            cellZone = new Cell(chk);
                            cellZone.setLeading(8.0f);
                            //cellZone.setNoWrap(true);            
                            partZone.addCell(cellZone);
                        }
                    }
                    //System.out.println("After zone header------------------------------>");
                    document.add(partZone);

                }

                pickUpZoneZipMap = legDestCharges.getPickZoneZipMap();
                //@@For Sorting the Zone Codes in an Order.
                List list = new ArrayList();
                Set zoneSet;
                //@@End of Declarations - Sorting
                if (pickUpZoneZipMap != null && pickUpZoneZipMap.size() > 0) {
                    //System.out.println("Before zipCode header--------Set size------->"+pickUpZoneZipMap.keySet().size());
                    //@@Sorting the Zone Codes (as TreeSet implements java.util.SortedSet)
                    list.addAll(pickUpZoneZipMap.keySet());
                    zoneSet = new TreeSet(list);
                    //@@End of Sorting- Added by Yuvraj

                    zones = zoneSet.iterator();

                    partZone = new Table(2);
                    partZone.setOffset(30);
                    partZone.setDefaultHorizontalAlignment(partZone.ALIGN_CENTER);
                    partZone.setBorderWidth(1);
                    partZone.setBorderColor(Color.black);
                    partZone.setPadding(1);
                    partZone.setSpacing(1);
                    partZone.setWidth(100);
                    //partZone.setAutoFillEmptyCells(true);
                    //partZone.setTableFitsPage(true);
                    //@@ Added by subrahmanyam for the enhancement #147062 on 08/12/2008
                    chk = new Chunk("PICKUP CHARGES AT: " + headerDOB.getOriginLocName()[dc],
                            FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.RED));
                    cellZone = new Cell(chk);
                    cellZone.setLeading(10.0f);
                    //cellZone.setNoWrap(true);
                    cellZone.setHeader(true);
                    cellZone.setBackgroundColor(Color.WHITE);
                    cellZone.setVerticalAlignment(cellZone.ALIGN_BOTTOM);
                    cellZone.setColspan(2);
                    partZone.addCell(cellZone);

                    //@@ Ended by subrahmanyam for the enhancement #147062 on  08/12/2008
                    chk = new Chunk("PICKUP ZONE ZIP MAPPING",
                            FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.BLACK));
                    cellZone = new Cell(chk);
                    cellZone.setLeading(10.0f);
                    //cellZone.setNoWrap(true);
                    cellZone.setHeader(true);
                    cellZone.setBackgroundColor(Color.ORANGE);
                    cellZone.setVerticalAlignment(cellZone.ALIGN_BOTTOM);
                    cellZone.setColspan(2);
                    partZone.addCell(cellZone);

                    chk = new Chunk("Zone", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                    cellZone = new Cell(chk);
                    cellZone.setLeading(8.0f);
                    //cellZone.setNoWrap(true);
                    cellZone.setHeader(true);
                    cellZone.setBackgroundColor(Color.LIGHT_GRAY);
                    partZone.addCell(cellZone);
                    chk = new Chunk("Zip Code", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                    cellZone = new Cell(chk);
                    cellZone.setLeading(8.0f);
                    cellZone.setNoWrap(true);
                    cellZone.setHeader(true);
                    partZone.addCell(cellZone);
                    partZone.endHeaders();
                    // System.out.println("Before zipCode Body------------------------------>");

                    while (zones.hasNext()) {
                        String zone = (String) zones.next();
                        // System.out.println("zone------------------------------>"+zone);
                        zipList = (ArrayList) pickUpZoneZipMap.get(zone);
                        //System.out.println("zipList--------------------------->"+zipList);
                        int zipListSize = zipList.size();
                        for (int i = 0; i < zipListSize; i++) {
                            //System.out.println("zone for ------------------------------>"+zone);
                            if (zone != null && !zone.equals("null") && zipList.get(i) != null
                                    && !((String) zipList.get(i)).equals("null")) {
                                chk = new Chunk(zone, FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                                cellZone = new Cell(chk);
                                cellZone.setBackgroundColor(Color.LIGHT_GRAY);
                                cellZone.setLeading(8.0f);
                                //cellZone.setNoWrap(true);            
                                partZone.addCell(cellZone);
                                //System.out.println("zipList.get(i)--------------------------->"+(String)zipList.get(i));
                                chk = new Chunk((String) zipList.get(i),
                                        FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                                cellZone = new Cell(chk);
                                cellZone.setLeading(8.0f);
                                cellZone.setNoWrap(true);
                                partZone.addCell(cellZone);
                            }
                        }
                    }
                    document.add(partZone);
                }

                deliveryZoneZipMap = legDestCharges.getDeliveryZoneZipMap();

                list = new ArrayList();
                zoneSet = null;

                if (deliveryZoneZipMap != null && deliveryZoneZipMap.size() > 0) {
                    //System.out.println("Before zipCode header--------Set size------->"+deliveryZoneZipMap.keySet().size());
                    list.addAll(deliveryZoneZipMap.keySet());
                    zoneSet = new TreeSet(list);
                    zones = zoneSet.iterator();

                    partZone = new Table(2);
                    partZone.setOffset(30);
                    partZone.setDefaultHorizontalAlignment(partZone.ALIGN_CENTER);
                    partZone.setBorderWidth(1);
                    partZone.setBorderColor(Color.black);
                    partZone.setPadding(1);
                    partZone.setSpacing(1);
                    partZone.setWidth(100);
                    //partZone.setAutoFillEmptyCells(true);
                    //partZone.setTableFitsPage(true);
                    //@@ Added by subrahmanyam for the enhancement #147062 on 08/12/2008
                    chk = new Chunk("DELIVERY CHARGES AT: " + headerDOB.getDestLocName()[dc],
                            FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.RED));
                    cellZone = new Cell(chk);
                    cellZone.setLeading(10.0f);
                    //cellZone.setNoWrap(true);
                    cellZone.setHeader(true);
                    cellZone.setBackgroundColor(Color.WHITE);
                    cellZone.setVerticalAlignment(cellZone.ALIGN_BOTTOM);
                    cellZone.setColspan(2);
                    partZone.addCell(cellZone);
                    //@@ Ended by subrahmanyam for the enhancement #147062 on 08/12/2008 
                    chk = new Chunk("DELIVERY ZONE ZIP MAPPING",
                            FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.BLACK));
                    cellZone = new Cell(chk);
                    cellZone.setLeading(10.0f);
                    //cellZone.setNoWrap(true);
                    cellZone.setHeader(true);
                    cellZone.setBackgroundColor(Color.ORANGE);
                    cellZone.setVerticalAlignment(cellZone.ALIGN_BOTTOM);

                    cellZone.setColspan(2);
                    partZone.addCell(cellZone);

                    chk = new Chunk("Zone", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                    cellZone = new Cell(chk);
                    cellZone.setLeading(8.0f);
                    cellZone.setNoWrap(true);
                    cellZone.setHeader(true);
                    cellZone.setBackgroundColor(Color.LIGHT_GRAY);
                    partZone.addCell(cellZone);
                    chk = new Chunk("Zip Code", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                    cellZone = new Cell(chk);
                    cellZone.setLeading(8.0f);
                    cellZone.setNoWrap(true);
                    cellZone.setHeader(true);
                    partZone.addCell(cellZone);
                    partZone.endHeaders();
                    //System.out.println("Before zipCode Body------------------------------>");

                    while (zones.hasNext()) {
                        String zone = (String) zones.next();
                        //System.out.println("zone------------------------------>"+zone);
                        zipList = (ArrayList) deliveryZoneZipMap.get(zone);
                        if (zipList != null) {
                            //System.out.println("zipList--------------------------->"+zipList);
                            //logger.info("zipList--------------------------->"+zipList);
                            int zipListSize = zipList.size();
                            for (int i = 0; i < zipListSize; i++) {
                                //System.out.println("zone for ------------------------------>"+zone);
                                if (zone != null && !zone.equals("null") && zipList.get(i) != null
                                        && !((String) zipList.get(i)).equals("null")) {
                                    chk = new Chunk(zone,
                                            FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                                    cellZone = new Cell(chk);
                                    cellZone.setLeading(8.0f);
                                    cellZone.setBackgroundColor(Color.LIGHT_GRAY);
                                    cellZone.setNoWrap(true);
                                    partZone.addCell(cellZone);
                                    //System.out.println("zipList.get(i)--------------------------->"+(String)zipList.get(i));
                                    chk = new Chunk((String) zipList.get(i),
                                            FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                                    cellZone = new Cell(chk);
                                    cellZone.setLeading(8.0f);
                                    cellZone.setNoWrap(true);
                                    partZone.addCell(cellZone);
                                }
                            }
                        }
                    }
                    document.add(partZone);
                }

                // Commmented by Kishore to move the code after the for loop for Multiple lanes 

                //System.out.println("After zipCode header------------------------------>");

                /*document.close();
                //System.out.println("After     document Close----------------------------------------->");               
                File f = new File("Cartage.pdf");
                FileOutputStream  fileOutputStream= new FileOutputStream(f);
                baos.writeTo(fileOutputStream);
                fileOutputStream.close();//added by sanjay on 20/03/2006
                //@@Added by Kameswari for the WPBN issue-80440
                PdfReader reader = new PdfReader("Cartage.pdf");
                int n = reader.getNumberOfPages();
                File fs = new File(fileName);
                String   space = " ";
                // we create a stamper that will copy the document to a new file
                PdfStamper stamp = new PdfStamper(reader, new FileOutputStream(fs));
                        
                // adding some metadata
                // adding content to each page
                        
                int k = 0;
                PdfContentByte under;
                PdfContentByte over=null;
                BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED);
                while (k < n) {
                k++;
                   over = stamp.getOverContent(k);
                over.beginText();
                over.setFontAndSize(bf, 8);
                over.setTextMatrix(15, 15);
                over.showText("page " + k+" of "+n);
                        
                if(k>1)
                {
                over.setFontAndSize(bf, 7);
                over.showText("                                                                                                       QUOTE REFERENCE:"+masterDOB.getQuoteId());
                //@@Added by subrahmanyam for the WPBN:146452 on 12/12/2008
                over.endText();
                over.beginText();
                over.showText("                                                                                                                                    CUSTOMER NAME: "+headerDOB.getCustomerName());//subrahmanyam 12/12/2008
                //@@ Ended by subrahmanyam for the WPBM:146452 on 12/12/2008               
                }
                over.endText();
                }
                stamp.close();
                //@@WPBN issue-80440    
                //@@ Commented by subrahmanyam for 146460         
                if("on".equalsIgnoreCase(request.getParameter("print")))
                {
                        
                   request.getSession().setAttribute("CartageOuptutStream",fs);
                }
                //@@ Added by subrahmanyam for  146460                
                        
                 if("on".equalsIgnoreCase(request.getParameter("print"))||"PDF".equalsIgnoreCase(request.getParameter("pdf")))
                {
                           
                   request.getSession().setAttribute("CartageOuptutStream",fs);
                }
                        
                //@@ Ended by subrahmanyam for 146460
                //f.delete();
                baos.close();*/
                //}
            }
            //} //Added by Anil.k   kishore Charges
        }
        //System.out.println("End of generation header------------------------------>");
        //Added By Kishore Podili fpr multiple Zone Codes
        if (document != null) {

            document.close();
            // System.out.println("After document
            // Close----------------------------------------->");
            File f = new File("Cartage.pdf");
            FileOutputStream fileOutputStream = new FileOutputStream(f);
            baos.writeTo(fileOutputStream);
            fileOutputStream.close();// added by sanjay on 20/03/2006
            // @@Added by Kameswari for the WPBN issue-80440
            PdfReader reader = new PdfReader("Cartage.pdf");
            int n = reader.getNumberOfPages();
            File fs = new File(fileName);
            String space = " ";
            // we create a stamper that will copy the document to a new file
            PdfStamper stamp = new PdfStamper(reader, new FileOutputStream(fs));

            // adding some metadata
            // adding content to each page

            int k = 0;
            PdfContentByte under;
            PdfContentByte over = null;
            BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED);
            while (k < n) {
                k++;
                over = stamp.getOverContent(k);
                //jyothi
                //over.rectangle(30, 30, 550, 800);
                over.rectangle(document.left(), document.bottom(), document.right() - document.left(),
                        document.top() - document.bottom());
                over.stroke();
                //jyothi
                over.beginText();
                over.setFontAndSize(bf, 8);
                over.setTextMatrix(15, 15);
                over.showText("page " + k + " of " + n);

                if (k > 1) {
                    over.setFontAndSize(bf, 7);
                    over.showText("QUOTE REFERENCE:" + masterDOB.getQuoteId());
                    // @@Added by subrahmanyam for the WPBN:146452 on
                    // 12/12/2008
                    over.endText();
                    over.beginText();
                    over.showText("CUSTOMER NAME: " + headerDOB.getCustomerName());// subrahmanyam
                    // 12/12/2008
                    // @@ Ended by subrahmanyam for the WPBM:146452 on
                    // 12/12/2008
                }
                over.endText();
            }
            stamp.close();
            // @@WPBN issue-80440
            // @@ Commented by subrahmanyam for 146460
            /*
             * if("on".equalsIgnoreCase(request.getParameter("print"))) {
             * 
             * request.getSession().setAttribute("CartageOuptutStream",fs); }
             */
            // @@ Added by subrahmanyam for 146460
            if ("on".equalsIgnoreCase(request.getParameter("print"))
                    || "PDF".equalsIgnoreCase(request.getParameter("pdf"))) {

                request.getSession().setAttribute("CartageOuptutStream", fs);
            }

            // @@ Ended by subrahmanyam for 146460
            // f.delete();
            baos.close();

            // Added by Kishore Podili For Cartage PDF Attachement in the MAIL.  
            FileInputStream fis = new FileInputStream(fileName);
            // PdfReader preader = new PdfReader()
            ArrayList attachmentDOBList = finalDOB.getAttachmentDOBList();

            if (attachmentDOBList == null)
                attachmentDOBList = new ArrayList();

            MultiQuoteAttachmentDOB attachementDOB = new MultiQuoteAttachmentDOB();
            attachementDOB.setFileName(fileName);
            byte[] buffer = new byte[fis.available()];
            fis.read(buffer);
            attachementDOB.setPdfFile(buffer);

            attachmentDOBList.add(attachementDOB);
            finalDOB.setAttachmentDOBList(attachmentDOBList);
            fis.close();
        }

        // System.out.println("End of generation
        // header------------------------------>");
    } catch (Exception e) {
        e.printStackTrace();
        //Logger.error(FILE_NAME,"Error while generating the PDF"+e.toString());
        logger.error(FILE_NAME + "Error while generating the PDF" + e.toString());
        throw new Exception("Error while generating PDF format");
    }
    return 1;
}

From source file:QMSMultiQuoteController.java

License:Open Source License

private ArrayList doPDFGenerationForQuoteGroup(ArrayList mainDtl, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    String[] contents = null;/*from   w  ww.j  a v  a2 s.  c  om*/
    String[] levels = null;
    String[] aligns = null;
    String[] headFoot = null;
    Table content = null;
    String[] contactPersons = null;
    String contactName = null;
    ArrayList contactList = new ArrayList();
    ArrayList contactEmailList = new ArrayList();
    ArrayList contactFaxList = new ArrayList();
    ArrayList returnList = new ArrayList();
    ArrayList sentEmailsList = new ArrayList();
    ArrayList unsentEmailsList = new ArrayList();
    ArrayList sentFaxList = new ArrayList();
    ArrayList unsentFaxList = new ArrayList();
    ArrayList filesDOBList = new ArrayList();
    ArrayList filesList = new ArrayList();
    HttpSession session = null;

    try {
        //System.out.println("PDF Generation Startd----------------------------------->");
        MultiQuoteFinalDOB finalDOB = null;
        ESupplyDateUtility eSupplyDateUtility = new ESupplyDateUtility();
        MultiQuoteHeader headerDOB = null;
        MultiQuoteMasterDOB masterDOB = null;
        CostingMasterDOB costingMasterDOB = null;
        CostingChargeDetailsDOB detailsDOB = null;
        CostingLegDetailsDOB legDetails = null;
        CostingRateInfoDOB rateDetailsDOB = null;
        ArrayList rateDetails = new ArrayList();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        String formMailId = "";
        String to_emailIds = "";
        String to_FaxIds = "";
        String faxMailIds = "";
        Document document = new Document(PageSize.A4);
        String PDF_FILE_NAME = "Approved.pdf";
        document.addTitle("Approved Report");
        document.addSubject("Report PDF");
        document.addKeywords("Test, Key Words");
        document.addAuthor("DHL");
        document.addCreator("Auto Generated through 4S DHL");
        document.addCreationDate();
        PdfWriter writer = PdfWriter.getInstance(document, baos);
        document.open();
        Table partCountry;
        Chunk chk;
        Cell cellCountry;
        if (mainDtl != null && mainDtl.size() > 0) {

            finalDOB = (MultiQuoteFinalDOB) mainDtl.get(0);
            headerDOB = finalDOB.getHeaderDOB();
            masterDOB = finalDOB.getMasterDOB();
            formMailId = "webmaster@four-soft.com";
            ESupplyGlobalParameters loginbean = (ESupplyGlobalParameters) request.getSession()
                    .getAttribute("loginbean");
            eSupplyDateUtility.setPatternWithTime("DD-MONTH-YYYY");
            //eSupplyDateUtility.setPatternWithTime(loginbean.getUserPreferences().getDateFormat());

            String[] strDate = eSupplyDateUtility.getDisplayStringArray(headerDOB.getDateOfQuotation());
            String[] effDate = eSupplyDateUtility.getDisplayStringArray(headerDOB.getEffDate());
            String[] validDate;

            // System.out.println("Before Document Objec--------------------------->");

            //document.setMargins(10,10,10,10);

            Table mainT = new Table(8);
            mainT.setWidth(100);
            mainT.setBorderColor(Color.white);
            mainT.setPadding(1);
            mainT.setSpacing(0);

            Phrase headingPhrase = new Phrase("", FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.BLACK));
            Cell cellHeading = new Cell(headingPhrase);
            cellHeading.setBorderColor(new Color(255, 255, 255));
            cellHeading.setHorizontalAlignment(cellHeading.ALIGN_CENTER);
            cellHeading.setColspan(7);
            mainT.addCell(cellHeading);

            Cell imageCell = new Cell();
            java.net.URL url = getServletConfig().getServletContext().getResource("/images/DHLlogo.gif");
            Image img0 = Image.getInstance(url);
            imageCell.add(img0);
            imageCell.setHorizontalAlignment(imageCell.ALIGN_RIGHT);
            imageCell.setBorderWidth(0);
            imageCell.setNoWrap(true);
            mainT.addCell(imageCell);
            mainT.setAlignment(mainT.ALIGN_CENTER);
            document.add(mainT);

            //Default Header Content Starts
            contents = masterDOB.getDefaultContent();
            headFoot = masterDOB.getDefaultHeaderFooter();

            if (contents != null && contents.length > 0) {
                content = new Table(1);
                content.setOffset(5);
                content.setWidth(100);
                content.setPadding(1);
                content.setSpacing(0);
                content.setBackgroundColor(Color.WHITE);
                content.setBorderColor(Color.black);
                content.setBorderWidth(1f);
                Cell cellContent = null;
                chk = null;
                int hFLen = headFoot.length;
                for (int i = 0; i < hFLen; i++) {
                    if (headFoot[i] != null && "H".equalsIgnoreCase(headFoot[i])) {
                        chk = new Chunk(contents[i], FontFactory.getFont("ARIAL", 7, Font.ITALIC, Color.BLACK));
                        cellContent = new Cell(chk);
                        cellContent.setBorder(0);
                        cellContent.setLeading(6.0f);
                        cellContent.setBackgroundColor(Color.LIGHT_GRAY);
                        cellContent.setHorizontalAlignment(cellContent.ALIGN_LEFT);//Default content is left aligned                                    
                        content.addCell(cellContent);
                    }
                }
                document.add(content);
                contents = null;
                headFoot = null;
                content = null;
            }
            //End Default Header Content

            //System.out.println("After Heading --------------------------->");
        }
        String validUptoStr = null;
        String[] strDate = null;
        String[] effDate = null;
        String[] validDate = null;
        StringBuffer attentionTo = null;
        int mainDtlSize = mainDtl.size();
        for (int m = 0; m < mainDtlSize; m++) {

            finalDOB = (MultiQuoteFinalDOB) mainDtl.get(m);
            headerDOB = finalDOB.getHeaderDOB();
            masterDOB = finalDOB.getMasterDOB();
            //formMailId             =   "webmaster@four-soft.com";
            ESupplyGlobalParameters loginbean = (ESupplyGlobalParameters) request.getSession()
                    .getAttribute("loginbean");
            eSupplyDateUtility.setPatternWithTime("DD-MONTH-YYYY");
            //eSupplyDateUtility.setPatternWithTime(loginbean.getUserPreferences().getDateFormat());

            strDate = eSupplyDateUtility.getDisplayStringArray(headerDOB.getDateOfQuotation());
            effDate = eSupplyDateUtility.getDisplayStringArray(headerDOB.getEffDate());
            attentionTo = new StringBuffer("");

            if (headerDOB.getValidUpto() != null) {
                validDate = eSupplyDateUtility.getDisplayStringArray(headerDOB.getValidUpto());
                validUptoStr = validDate[0];
            }
            if (masterDOB.getCustContactNames() != null) {
                for (int i = 0; i < masterDOB.getCustContactNames().length; i++) {
                    // Logger.info(FILE_NAME,"headerDOB.getAttentionTo()::"+masterDOB.getCustomerContacts()[i]);
                    attentionTo.append(
                            masterDOB.getCustContactNames()[i] != null ? masterDOB.getCustContactNames()[i]
                                    : "");
                    if (i != masterDOB.getCustContactNames().length)
                        attentionTo.append(",");
                }
            }
            partCountry = new Table(1, 5);
            partCountry.setBorderWidth(0);
            partCountry.setWidth(100);
            partCountry.setBorderColor(Color.black);
            //partCountry.setBackgroundColor(Color.ORANGE);
            partCountry.setPadding(1);
            partCountry.setBorder(0);//Modified by silpa.p on 3-06-11
            partCountry.setSpacing(0);
            partCountry.setAutoFillEmptyCells(true);
            //partCountry.setTableFitsPage(true);
            partCountry.setAlignment(partCountry.ALIGN_CENTER);
            // partCountry.setWidth(100.0f);

            String shipmentMode = "";
            if (finalDOB.getMasterDOB().getShipmentMode() == 1)
                shipmentMode = "AIR FREIGHT PROPOSAL";
            else if (finalDOB.getMasterDOB().getShipmentMode() == 2)
                shipmentMode = "SEA FREIGHT PROPOSAL";
            else if (finalDOB.getMasterDOB().getShipmentMode() == 4)
                shipmentMode = "TRUCK FREIGHT PROPOSAL";

            chk = new Chunk(shipmentMode, FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setWidth("100");
            cellCountry.setBorderWidth(0);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(10.0f);
            cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
            partCountry.addCell(cellCountry);
            //@@Modified for the WPBN Change Request-71229
            if ("MY".equalsIgnoreCase(masterDOB.getCountryId())) {
                chk = new Chunk(headerDOB.getOriginCountry() + " TO " + headerDOB.getDestinationCountry(),
                        FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.RED));
                cellCountry = new Cell(chk);
                cellCountry.setWidth("100");
                cellCountry.setBorderWidth(0);
                cellCountry.setNoWrap(true);
                cellCountry.setLeading(10.0f);
                cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
                partCountry.addCell(cellCountry);

                chk = new Chunk(headerDOB.getCustomerName() == null ? "" : headerDOB.getCustomerName(),
                        FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.RED));
                cellCountry = new Cell(chk);
                cellCountry.setHeader(true);
                cellCountry.setWidth("100");
                cellCountry.setBorderWidth(0);
                cellCountry.setNoWrap(true);
                cellCountry.setLeading(10.0f);
                cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
                partCountry.addCell(cellCountry);

                chk = new Chunk("ATTENTION TO: " + toTitleCase(attentionTo.toString()),
                        FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.RED));
                cellCountry = new Cell(chk);
                cellCountry.setWidth("100");
                cellCountry.setBorderWidth(0);
                cellCountry.setNoWrap(true);
                cellCountry.setLeading(10.0f);
                cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
                partCountry.addCell(cellCountry);
            } else {
                chk = new Chunk(headerDOB.getOriginCountry() + " TO " + headerDOB.getDestinationCountry(),
                        FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.RED));
                cellCountry = new Cell(chk);
                cellCountry.setWidth("100");
                cellCountry.setBorderWidth(0);
                cellCountry.setNoWrap(true);
                cellCountry.setLeading(10.0f);
                cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
                partCountry.addCell(cellCountry);

                chk = new Chunk(headerDOB.getCustomerName() == null ? "" : headerDOB.getCustomerName(),
                        FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.RED));
                cellCountry = new Cell(chk);
                cellCountry.setHeader(true);
                cellCountry.setWidth("100");
                cellCountry.setBorderWidth(0);
                cellCountry.setNoWrap(true);
                cellCountry.setLeading(10.0f);
                cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
                partCountry.addCell(cellCountry);

                chk = new Chunk("ATTENTION TO: " + toTitleCase(attentionTo.toString()),
                        FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.RED));
                cellCountry = new Cell(chk);
                cellCountry.setWidth("100");
                cellCountry.setBorderWidth(0);
                cellCountry.setNoWrap(true);
                cellCountry.setLeading(10.0f);
                cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
                partCountry.addCell(cellCountry);
            }
            //@@WPBN Change Request-71229
            chk = new Chunk("QUOTE REFERENCE: " + masterDOB.getQuoteId(),
                    FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setWidth("100");
            cellCountry.setBorderWidth(0);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(10.0f);
            cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
            partCountry.addCell(cellCountry);
            chk = new Chunk("DATE OF QUOTATION: " + strDate[0],
                    FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setWidth("100");
            cellCountry.setBorderWidth(0);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(10.0f);
            cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
            partCountry.addCell(cellCountry);

            contents = masterDOB.getContentOnQuote();
            levels = masterDOB.getLevels();
            aligns = masterDOB.getAlign();
            headFoot = masterDOB.getHeaderFooter();

            if (contents != null && contents.length > 0) {
                content = new Table(1);
                content.setOffset(5);
                content.setWidth(100);
                content.setPadding(1);
                content.setSpacing(0);
                content.setBackgroundColor(Color.WHITE);
                content.setBorderColor(Color.black);
                content.setBorderWidth(1f);
                Cell cellContent = null;
                chk = null;
                int hFlen = headFoot.length;
                for (int i = 0; i < hFlen; i++) {
                    if (headFoot[i] != null && "H".equalsIgnoreCase(headFoot[i])) {
                        chk = new Chunk(contents[i], FontFactory.getFont("ARIAL", 7, Font.ITALIC, Color.BLACK));
                        cellContent = new Cell(chk);
                        cellContent.setBorder(0);
                        cellContent.setLeading(6.0f);
                        cellContent.setBackgroundColor(Color.LIGHT_GRAY);
                        if ("L".equalsIgnoreCase(aligns[i]))
                            cellContent.setHorizontalAlignment(cellContent.ALIGN_LEFT);
                        else if ("C".equalsIgnoreCase(aligns[i]))
                            cellContent.setHorizontalAlignment(cellContent.ALIGN_CENTER);
                        else if ("R".equalsIgnoreCase(aligns[i]))
                            cellContent.setHorizontalAlignment(cellContent.ALIGN_RIGHT);
                        content.addCell(cellContent);
                    }
                }
                document.add(content);
            }

            partCountry = new Table(2, 15);
            partCountry.setOffset(2);
            partCountry.setWidth(100);
            partCountry.setPadding(1);
            partCountry.setSpacing(0);
            partCountry.setBackgroundColor(Color.WHITE);
            partCountry.setBorderColor(Color.black);
            partCountry.setBorderWidth(1);
            //added by subrahmanyam for 182516
            partCountry.setTableFitsPage(true);
            partCountry.setCellsFitPage(true);
            //ended for 182516

            chk = new Chunk("SERVICE INFORMATION: ", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cellCountry = new Cell(chk);

            cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
            cellCountry.setBackgroundColor(Color.ORANGE);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            //@@ Commented by subrahmanyam for the enhancement #146970 & #146971            
            /*chk = new Chunk("QUOTE ID:"+new Long(masterDOB.getQuoteId()).toString(),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
            cellCountry.setBackgroundColor(Color.ORANGE);
            cellCountry.setNoWrap(true); cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);*/
            //@@ Added by subrahmanyam for the enhancement #146970 & #146971            
            chk = new Chunk("QUOTE ID:" + masterDOB.getQuoteId(),
                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
            cellCountry.setBackgroundColor(Color.ORANGE);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            /** chk = new Chunk("Origin : ",FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
             cellCountry = new Cell(chk); 
             cellCountry.setBackgroundColor(Color.lightGray);
             cellCountry.setNoWrap(true); cellCountry.setLeading(8.0f);
             partCountry.addCell(cellCountry);
                     
             chk = new Chunk("   "+(headerDOB.getOriginLocName()!=null?headerDOB.getOriginLocName():""),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
             cellCountry = new Cell(chk);
             cellCountry.setNoWrap(true); cellCountry.setLeading(8.0f);
             partCountry.addCell(cellCountry);
                     
             chk = new Chunk("Destination : ",FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
             cellCountry = new Cell(chk); 
             cellCountry.setBackgroundColor(Color.lightGray);
             cellCountry.setNoWrap(true); cellCountry.setLeading(8.0f);
             partCountry.addCell(cellCountry);
                     
             chk = new Chunk("   "+(headerDOB.getDestLocName()!=null?headerDOB.getDestLocName():""),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
             cellCountry = new Cell(chk);
             cellCountry.setNoWrap(true); cellCountry.setLeading(8.0f);
             partCountry.addCell(cellCountry);**/

            chk = new Chunk("Customer : ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setBackgroundColor(Color.lightGray);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk("   " + (headerDOB.getCustomerName() != null ? headerDOB.getCustomerName() : ""),
                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk("Agent: ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setBackgroundColor(Color.lightGray);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk("   " + (headerDOB.getAgent() != null ? headerDOB.getAgent() : ""),
                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            //@@ Added by subrahmanyam for the WPBN ISSUE: 150460 ON 23/12/2008                

            //@@ Ended by subrahmanyam for the WPBN ISSUE: 150460 ON 23/12/2008  

            // @@Commented by subrahmanyam for the enhancement #148546 on 09/12/2008            
            /* chk = new Chunk("Routing: ",FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
             cellCountry = new Cell(chk);
             cellCountry.setBackgroundColor(Color.lightGray);
             cellCountry.setNoWrap(true); cellCountry.setLeading(8.0f);
             partCountry.addCell(cellCountry);          
             chk = new Chunk("   "+(headerDOB.getRouting()!=null?headerDOB.getRouting():""),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
             cellCountry = new Cell(chk);
             cellCountry.setNoWrap(true); cellCountry.setLeading(8.0f);
             partCountry.addCell(cellCountry);*/
            //@@ Ended by subrahmanyam for the enhanement #148546 on 09/12/2008 

            chk = new Chunk("Commodity or Product: ",
                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setBackgroundColor(Color.lightGray);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            //chk = new Chunk("   "+(headerDOB.getCommodity()!=null?toTitleCase(headerDOB.getCommodity()):""),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));//commented by silpa.p on 21-06-11
            chk = new Chunk("   " + (headerDOB.getCommodity() != null ? (headerDOB.getCommodity()) : ""),
                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));//modified by silpa.p on 21-06-11
            cellCountry = new Cell(chk);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk("Type of service quoted: ",
                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setBackgroundColor(Color.lightGray);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk("   " + (headerDOB.getTypeOfService() != null ? headerDOB.getTypeOfService() : ""),
                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk("Notes: ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setBackgroundColor(Color.lightGray);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            //@@ Commented by subrahmanyam for WPBN ISSUE:-145510                                      
            /* chk = new Chunk("   "+(headerDOB.getNotes()!=null?headerDOB.getNotes().toUpperCase()+'\n'+"nnnnnnnnnn":""),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
            Commented by subrahmanyam for WPBN ISSUE:-145510   
            cellCountry = new Cell(chk);
            cellCountry.setNoWrap(true); cellCountry.setLeading(8.0f);
                    
            partCountry.addCell(cellCountry);
            */
            //@@ Ended by subrahmanyam for WPBN ISSUE:-145510  
            //@@ Added by subrahmanyam for WPBN ISSUE:-145510  
            chk = new Chunk("   " + (headerDOB.getNotes() != null ? headerDOB.getNotes().toUpperCase() : " "),
                    FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);
            //@@ Ended by subrahmanyam for WPBN ISSUE:-145510   

            chk = new Chunk("Date Effective: ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setBackgroundColor(Color.lightGray);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk("   " + effDate[0], FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk("Validity of Quote: ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setBackgroundColor(Color.lightGray);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk("   " + (validUptoStr != null ? validUptoStr : "VALID UNTIL FURTHER NOTICE"),
                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            document.add(partCountry);
            partCountry.complete();
        }
        int originCount = 0;
        int freightCount = 0;
        int destCount = 0;
        for (int m = 0; m < mainDtlSize; m++) {

            finalDOB = (MultiQuoteFinalDOB) mainDtl.get(m);
            // added by kiran.v on 16/09/2011
            //added by Anusha V.
            session = request.getSession();
            session.setAttribute("finalDOBPdf", finalDOB);
            headerDOB = finalDOB.getHeaderDOB();
            masterDOB = finalDOB.getMasterDOB();
            // System.out.println("After Page Country-------------------------------->");
            //Origin Charges

            costingMasterDOB = finalDOB.getCostingMasterDOB();

            ArrayList originCharges = (ArrayList) costingMasterDOB.getOriginList();

            int[] originIndices = finalDOB.getSelectedOriginChargesListIndices();
            int originChargesSize = 0;

            if (originCharges != null)
                originChargesSize = originCharges.size();
            else
                originChargesSize = 0;

            //Destination
            ArrayList destCharges = new ArrayList();
            int[] destIndices = finalDOB.getSelctedDestChargesListIndices();
            int destChargesSize = 0;
            if (destIndices != null)
                destChargesSize = destIndices.length;
            else
                destChargesSize = 0;

            ArrayList frieghtChargeDetails = new ArrayList();
            destCharges = (ArrayList) costingMasterDOB.getDestinationList();
            ArrayList costingLegDetailsList = new ArrayList();
            costingLegDetailsList = (ArrayList) costingMasterDOB.getCostingLegDetailsList();
            //////////////////////////////
            int orgChargSize = originCharges.size();
            for (int i = 0; i < orgChargSize; i++) {
                detailsDOB = (CostingChargeDetailsDOB) originCharges.get(i);
                rateDetails = (ArrayList) detailsDOB.getCostingRateInfoDOB();
                int rateDtlSize = rateDetails.size();
                for (int k = 0; k < rateDtlSize; k++) {
                    originCount++;
                }
            }
            int destChargSize = destCharges.size();
            for (int i = 0; i < destChargSize; i++) {
                detailsDOB = (CostingChargeDetailsDOB) destCharges.get(i);
                rateDetails = (ArrayList) detailsDOB.getCostingRateInfoDOB();
                int rateDtlSize = rateDetails.size();
                for (int k = 0; k < rateDtlSize; k++) {
                    destCount++;
                }
            }
            int costLegDtlSize = costingLegDetailsList.size();
            for (int s = 0; s < costLegDtlSize; s++) {
                legDetails = (CostingLegDetailsDOB) costingLegDetailsList.get(s);
                frieghtChargeDetails = (ArrayList) legDetails.getCostingChargeDetailList();
                int frtChargDtlSize = frieghtChargeDetails.size();
                for (int n = 0; n < frtChargDtlSize; n++) {
                    detailsDOB = (CostingChargeDetailsDOB) frieghtChargeDetails.get(n);
                    rateDetails = (ArrayList) detailsDOB.getCostingRateInfoDOB();
                    int rateDtlSize = rateDetails.size();
                    for (int j = 0; j < rateDtlSize; j++) {
                        freightCount++;
                    }
                }
            }

        }

        //////////////////////////////
        ArrayList charges = finalDOB.getLegDetails();
        int chargesSize = charges.size();
        if (originCount > 0) {
            Table chargeCountry = new Table(7, originCount);
            chargeCountry.setWidth(100);
            chargeCountry.setPadding(1);
            chargeCountry.setSpacing(0);
            chargeCountry.setOffset(25);
            chargeCountry.setBackgroundColor(Color.WHITE);
            chargeCountry.setBorderColor(Color.black);
            chargeCountry.setDefaultHorizontalAlignment(Element.ALIGN_CENTER);
            chargeCountry.setBorderWidth(1);
            //@@ Added by subrahmanyam for wpbn id: 181349 on 07-sep-09
            chargeCountry.setTableFitsPage(true);
            chargeCountry.setCellsFitPage(true);
            // @@ Ended for wpbn id: 181349 on 07-sep-09

            Cell cell;
            String wBslab = "";
            chk = new Chunk("QUOTEID ", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell = new Cell(chk);
            cell.setBackgroundColor(Color.ORANGE);
            cell.setNoWrap(true);
            cell.setLeading(8.0f);
            //cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
            chargeCountry.addCell(cell);

            chk = new Chunk("CHARGE NAME ", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell = new Cell(chk);
            cell.setBackgroundColor(Color.ORANGE);
            cell.setNoWrap(true);
            cell.setLeading(8.0f);
            // cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
            chargeCountry.addCell(cell);

            chk = new Chunk("BREAKPOINT", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell = new Cell(chk);
            cell.setBackgroundColor(Color.ORANGE);
            cell.setNoWrap(true);
            cell.setLeading(8.0f);
            // cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
            chargeCountry.addCell(cell);

            chk = new Chunk("CURRENCY", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell = new Cell(chk);
            cell.setBackgroundColor(Color.ORANGE);
            cell.setNoWrap(true);
            cell.setLeading(8.0f);
            // cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
            chargeCountry.addCell(cell);

            chk = new Chunk("RATE", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell = new Cell(chk);
            cell.setBackgroundColor(Color.ORANGE);
            cell.setNoWrap(true);
            cell.setLeading(8.0f);
            // cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
            chargeCountry.addCell(cell);

            chk = new Chunk("BASIS", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell = new Cell(chk);
            cell.setBackgroundColor(Color.ORANGE);
            cell.setNoWrap(true);
            cell.setLeading(8.0f);
            //cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
            chargeCountry.addCell(cell);

            chk = new Chunk("RATIO", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell = new Cell(chk);
            cell.setBackgroundColor(Color.ORANGE);
            cell.setNoWrap(true);
            cell.setLeading(8.0f);
            //cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
            chargeCountry.addCell(cell);

            chk = new Chunk("ORIGIN CHARGES", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell = new Cell(chk);
            cell.setColspan(7);
            cell.setBackgroundColor(Color.ORANGE);
            cell.setNoWrap(true);
            cell.setLeading(8.0f);
            // cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
            chargeCountry.addCell(cell);
            for (int m = 0; m < mainDtlSize; m++) {

                finalDOB = (MultiQuoteFinalDOB) mainDtl.get(m);
                headerDOB = finalDOB.getHeaderDOB();
                masterDOB = finalDOB.getMasterDOB();

                costingMasterDOB = finalDOB.getCostingMasterDOB();
                ArrayList originCharges = (ArrayList) costingMasterDOB.getOriginList();

                MultiQuoteCharges chargesDOB = null;
                ArrayList originChargeInfo = null;
                int originChargesInfoSize = 0;
                MultiQuoteChargeInfo chargeInfo = null;
                if (originCharges.size() > 0) {

                    int orgChargSize = originCharges.size();
                    for (int i = 0; i < orgChargSize; i++) {
                        detailsDOB = (CostingChargeDetailsDOB) originCharges.get(i);
                        rateDetails = (ArrayList) detailsDOB.getCostingRateInfoDOB();

                        originChargesInfoSize = rateDetails.size();
                        for (int k = 0; k < originChargesInfoSize; k++) {
                            CostingRateInfoDOB crateDetailsDOB = (CostingRateInfoDOB) rateDetails.get(k);
                            if (k == 0) {
                                //@@ Commented by subrahmanyam for the enhancement #146971 and #146970 on 10/12/2008                    
                                /*chk = new Chunk(new Long(masterDOB.getQuoteId()).toString(),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                                cell = new Cell(chk);
                                //cell.setRowspan(originChargesInfoSize);
                                cell.setBackgroundColor(Color.lightGray);
                                cell.setNoWrap(true); cell.setLeading(8.0f);
                                //cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
                                chargeCountry.addCell(cell);*/
                                //@@ Added by subrahmanyam for the enhancement #146971 and 146970 on 10/12/2008    
                                chk = new Chunk(masterDOB.getQuoteId(),
                                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                                cell = new Cell(chk);
                                cell.setBackgroundColor(Color.lightGray);
                                cell.setNoWrap(true);
                                cell.setLeading(8.0f);
                                chargeCountry.addCell(cell);
                                //@@ Ended by subrahmanyam for the enhanemenet #146971 and #146970 on 10/12/2008 

                                //@@ commented and modified by subrahmanyam for 181349  on 07-sep-09 & 202166 on 7-apr-10
                                // chk = new Chunk(detailsDOB.getChargeDescId(),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                                chk = new Chunk(
                                        detailsDOB.getExternalName() != null ? detailsDOB.getExternalName()
                                                : detailsDOB.getChargeDescId(),
                                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));//ended for 181349
                                cell = new Cell(chk);
                                //cell.setRowspan(originChargesInfoSize);
                                cell.setBackgroundColor(Color.lightGray);
                                // cell.setNoWrap(true); //commented for 181349
                                cell.setLeading(8.0f);
                                //cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
                                chargeCountry.addCell(cell);
                            } else {
                                cell = new Cell("");
                                //cell.setRowspan(originChargesInfoSize);
                                cell.setBackgroundColor(Color.lightGray);
                                cell.setNoWrap(true);
                                cell.setLeading(8.0f);
                                cell.setBorderWidth(0f);
                                //cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
                                chargeCountry.addCell(cell);

                                cell = new Cell("");
                                //cell.setRowspan(originChargesInfoSize);
                                cell.setBackgroundColor(Color.lightGray);
                                cell.setNoWrap(true);
                                cell.setLeading(8.0f);
                                cell.setBorderWidth(0f);
                                //cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
                                chargeCountry.addCell(cell);
                            }
                            chk = new Chunk(crateDetailsDOB.getWeightBreakSlab(),
                                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                            cell = new Cell(chk);
                            cell.setBackgroundColor(Color.lightGray);
                            cell.setNoWrap(true);
                            cell.setLeading(8.0f);
                            chargeCountry.addCell(cell);

                            chk = new Chunk(detailsDOB.getCurrency(),
                                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                            cell = new Cell(chk);
                            cell.setBackgroundColor(Color.lightGray);
                            cell.setNoWrap(true);
                            cell.setLeading(8.0f);
                            chargeCountry.addCell(cell);

                            chk = new Chunk(crateDetailsDOB.getRate() + "",
                                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                            cell = new Cell(chk);
                            cell.setNoWrap(true);
                            cell.setLeading(8.0f);
                            chargeCountry.addCell(cell);

                            //added by subrahmanyam for 183812
                            if (crateDetailsDOB.getWeightBreakSlab().equalsIgnoreCase("Min")
                                    || ("BOTH".equalsIgnoreCase(detailsDOB.getRateType())
                                            && "F".equalsIgnoreCase(crateDetailsDOB.getRateIndicator()))) {
                                wBslab = "MIN";
                            } else
                                wBslab = detailsDOB.getChargeBasisDesc();
                            // @@ Commented & Added by subrahmanyam for the wpbn id: 182516 on 10/09/09
                            //chk = new Chunk(crateDetailsDOB.getWeightBreakSlab().equalsIgnoreCase("Min")?"Pershipment ":detailsDOB.getChargeBasisDesc(),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                            //chk = new Chunk(crateDetailsDOB.getWeightBreakSlab().equalsIgnoreCase("Min")?" Per Shipment ":detailsDOB.getChargeBasisDesc(),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                            chk = new Chunk(
                                    wBslab.equalsIgnoreCase("Min") ? " Per Shipment "
                                            : detailsDOB.getChargeBasisDesc(),
                                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                            cell = new Cell(chk);
                            cell.setNoWrap(true);
                            cell.setLeading(8.0f);
                            chargeCountry.addCell(cell);

                            chk = new Chunk(
                                    detailsDOB.getDensityRatio() == null ? "" : detailsDOB.getDensityRatio(),
                                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                            cell = new Cell(chk);
                            cell.setNoWrap(true);
                            cell.setLeading(8.0f);
                            chargeCountry.addCell(cell);

                        }
                    }
                }
            }
            document.add(chargeCountry);
        }
        if (freightCount > 0) {
            Table chargeCountry1 = new Table(7, freightCount);
            chargeCountry1.setWidth(100);
            chargeCountry1.setPadding(1);
            chargeCountry1.setSpacing(0);
            chargeCountry1.setOffset(25);
            chargeCountry1.setBackgroundColor(Color.WHITE);
            chargeCountry1.setBorderColor(Color.black);
            chargeCountry1.setDefaultHorizontalAlignment(Element.ALIGN_CENTER);
            chargeCountry1.setBorderWidth(1);
            //@@ Added by subrahmanyam for wpbn id: 181349 on 07-sep-09
            chargeCountry1.setTableFitsPage(true);
            chargeCountry1.setCellsFitPage(true);
            // @@ Ended for wpbn id: 181349 on 07-sep-09

            Cell cell1;
            chk = new Chunk(" QUOTEID", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell1 = new Cell(chk);
            cell1.setBackgroundColor(Color.ORANGE);
            cell1.setNoWrap(true);
            cell1.setLeading(8.0f);
            //cell1.setVerticalAlignment(cell1.ALIGN_MIDDLE);
            chargeCountry1.addCell(cell1);
            chk = new Chunk("CHARGE NAME ", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell1 = new Cell(chk);
            cell1.setBackgroundColor(Color.ORANGE);
            cell1.setNoWrap(true);
            cell1.setLeading(8.0f);
            //cell1.setVerticalAlignment(cell1.ALIGN_MIDDLE);
            chargeCountry1.addCell(cell1);

            chk = new Chunk("BREAKPOINT", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell1 = new Cell(chk);
            cell1.setBackgroundColor(Color.ORANGE);
            cell1.setNoWrap(true);
            cell1.setLeading(8.0f);
            //cell1.setVerticalAlignment(cell1.ALIGN_MIDDLE);
            chargeCountry1.addCell(cell1);

            chk = new Chunk("CURRENCY", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell1 = new Cell(chk);
            cell1.setBackgroundColor(Color.ORANGE);
            cell1.setNoWrap(true);
            cell1.setLeading(8.0f);
            //cell1.setVerticalAlignment(cell1.ALIGN_MIDDLE);
            chargeCountry1.addCell(cell1);

            chk = new Chunk("RATE", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell1 = new Cell(chk);
            cell1.setBackgroundColor(Color.ORANGE);
            cell1.setNoWrap(true);
            cell1.setLeading(8.0f);
            // cell1.setVerticalAlignment(cell1.ALIGN_MIDDLE);
            chargeCountry1.addCell(cell1);

            chk = new Chunk("BASIS", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell1 = new Cell(chk);
            cell1.setBackgroundColor(Color.ORANGE);
            cell1.setNoWrap(true);
            cell1.setLeading(8.0f);
            //cell1.setVerticalAlignment(cell1.ALIGN_MIDDLE);
            chargeCountry1.addCell(cell1);

            chk = new Chunk("RATIO", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell1 = new Cell(chk);
            cell1.setBackgroundColor(Color.ORANGE);
            cell1.setNoWrap(true);
            cell1.setLeading(8.0f);
            // cell1.setVerticalAlignment(cell1.ALIGN_MIDDLE);
            chargeCountry1.addCell(cell1);

            chk = new Chunk("FREIGHT CHARGES", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell1 = new Cell(chk);
            cell1.setColspan(7);
            cell1.setNoWrap(true);
            cell1.setLeading(8.0f);
            cell1.setBackgroundColor(Color.ORANGE);
            //cell1.setVerticalAlignment(cell1.ALIGN_MIDDLE);
            chargeCountry1.addCell(cell1);
            //Freight Charges
            // System.out.println("After         Origin Charges --------------------------------->");
            int freightChargesSize = 0;
            int freightChargesInfoSize = 0;
            int[] frtIndices = null;
            MultiQuoteFreightLegSellRates legCharges = null;
            String wBSlab = "";//added by subrahmanyam for 182516 on 10-sep-09             
            int mDtlSize = mainDtl.size();
            for (int m = 0; m < mDtlSize; m++) {

                finalDOB = (MultiQuoteFinalDOB) mainDtl.get(m);
                headerDOB = finalDOB.getHeaderDOB();
                masterDOB = finalDOB.getMasterDOB();
                ArrayList costingLegDetailsList = new ArrayList();
                costingMasterDOB = finalDOB.getCostingMasterDOB();
                costingLegDetailsList = (ArrayList) costingMasterDOB.getCostingLegDetailsList();
                ArrayList frieghtChargeDetails = new ArrayList();
                String rDescription = ""; // Added by subrahmanyam for 182516 on 10/09/09
                if (costingLegDetailsList.size() > 0) {

                    int costLegDtlSize = costingLegDetailsList.size();
                    for (int s = 0; s < costLegDtlSize; s++) {
                        legDetails = (CostingLegDetailsDOB) costingLegDetailsList.get(s);
                        frieghtChargeDetails = (ArrayList) legDetails.getCostingChargeDetailList();
                        int frtLegDtlSize = frieghtChargeDetails.size();
                        int frtChargDtlSize = frieghtChargeDetails.size();
                        for (int n = 0; n < frtChargDtlSize; n++) {
                            detailsDOB = (CostingChargeDetailsDOB) frieghtChargeDetails.get(n);
                            rateDetails = (ArrayList) detailsDOB.getCostingRateInfoDOB();
                            int rateDtlSize = rateDetails.size();
                            for (int j = 0; j < rateDtlSize; j++) {
                                rateDetailsDOB = (CostingRateInfoDOB) rateDetails.get(j);

                                if (j == 0) {

                                    chk = new Chunk(legDetails.getOrigin() + "-" + legDetails.getDestination(),
                                            FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                                    cell1 = new Cell(chk);
                                    cell1.setColspan(7);
                                    cell1.setBackgroundColor(Color.WHITE);
                                    cell1.setLeading(8.0f);
                                    chargeCountry1.addCell(cell1);

                                    //@@ Commented by subrahmanyam for the enhancement #146971 and 1469710 on 10/12/2008                      
                                    /*chk = new Chunk(new Long(masterDOB.getQuoteId()).toString(),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                                    cell1 = new Cell(chk);
                                    //cell1.setRowspan(rateDetails.size());
                                    cell1.setNoWrap(true); cell2.setLeading(8.0f);
                                    cell1.setBackgroundColor(Color.lightGray);
                                    chargeCountry1.addCell(cell1);*/
                                    //@@ Added by subrahmanyam for the enhancement #146971 and #146970 on 10/12/2008
                                    chk = new Chunk(masterDOB.getQuoteId(),
                                            FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                                    cell1 = new Cell(chk);
                                    cell1.setNoWrap(true);
                                    cell1.setLeading(8.0f);
                                    cell1.setBackgroundColor(Color.lightGray);
                                    chargeCountry1.addCell(cell1);
                                    //@@ Ended by subrahmanyam for the enhancement #146971 and 146970 on 10/12/2008    
                                    // COMMENTED AND MODIFIED BY SUBRAHMANYAM FOR 182516
                                    //chk = new Chunk(detailsDOB.getChargeDescId()==null?"":detailsDOB.getChargeDescId(),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                                    chk = new Chunk(
                                            rateDetailsDOB.getRateDescription() == null ? ""
                                                    : rateDetailsDOB.getRateDescription(),
                                            FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                                    cell1 = new Cell(chk);
                                    //cell1.setRowspan(rateDetails.size());
                                    cell1.setNoWrap(true);
                                    cell1.setLeading(8.0f);
                                    cell1.setBackgroundColor(Color.lightGray);
                                    chargeCountry1.addCell(cell1);
                                    rDescription = rateDetailsDOB.getRateDescription();
                                } else {
                                    cell1 = new Cell("");
                                    //cell1.setRowspan(rateDetails.size());
                                    cell1.setNoWrap(true);
                                    cell1.setLeading(8.0f);
                                    cell1.setBorderWidth(0f);
                                    cell1.setBackgroundColor(Color.lightGray);
                                    chargeCountry1.addCell(cell1);

                                    //@@ Commented by subrahmanyam for 182516 on 10/09/09
                                    /*
                                     cell1 = new Cell("");
                                     //cell1.setRowspan(rateDetails.size());
                                     cell1.setNoWrap(true); cell1.setLeading(8.0f);
                                     cell1.setBackgroundColor(Color.lightGray);
                                     cell1.setBorderWidth(0f);
                                     chargeCountry1.addCell(cell1);
                                     */
                                    //@@ added by subrahmanyam for 182516 on 10/09/09
                                    if (rDescription.equalsIgnoreCase(rateDetailsDOB.getRateDescription())) {
                                        chk = new Chunk("",
                                                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                                        cell1 = new Cell(chk);
                                        //cell1.setRowspan(rateDetails.size());
                                        cell1.setNoWrap(true);
                                        cell1.setLeading(8.0f);
                                        cell1.setBackgroundColor(Color.lightGray);
                                        cell1.setBorderWidth(0f);
                                        chargeCountry1.addCell(cell1);
                                    } else {
                                        chk = new Chunk(
                                                rateDetailsDOB.getRateDescription() == null ? ""
                                                        : rateDetailsDOB.getRateDescription(),
                                                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                                        cell1 = new Cell(chk);
                                        //cell1.setRowspan(rateDetails.size());
                                        //cell1.setNoWrap(true);
                                        cell1.setLeading(8.0f);
                                        cell1.setBackgroundColor(Color.lightGray);
                                        chargeCountry1.addCell(cell1);
                                        rDescription = rateDetailsDOB.getRateDescription();
                                    }
                                    //ended by subrahmanyam for 182516 on 10/09/09

                                }
                                if ("FSBASIC".equalsIgnoreCase(rateDetailsDOB.getWeightBreakSlab())
                                        || "SSBASIC".equalsIgnoreCase(rateDetailsDOB.getWeightBreakSlab()))
                                    rateDetailsDOB.setWeightBreakSlab("Basic Charge");
                                if ("FSMIN".equalsIgnoreCase(rateDetailsDOB.getWeightBreakSlab())
                                        || "SSMIN".equalsIgnoreCase(rateDetailsDOB.getWeightBreakSlab()))
                                    rateDetailsDOB.setWeightBreakSlab("Minimum");
                                if ("FSKG".equalsIgnoreCase(rateDetailsDOB.getWeightBreakSlab())
                                        || "SSKG".equalsIgnoreCase(rateDetailsDOB.getWeightBreakSlab()))
                                    rateDetailsDOB.setWeightBreakSlab("Flat Rate");

                                chk = new Chunk(rateDetailsDOB.getWeightBreakSlab(),
                                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                                cell1 = new Cell(chk);
                                cell1.setNoWrap(true);
                                cell1.setLeading(8.0f);
                                cell1.setBackgroundColor(Color.lightGray);
                                chargeCountry1.addCell(cell1);

                                chk = new Chunk(detailsDOB.getCurrency(),
                                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                                cell1 = new Cell(chk);
                                cell1.setNoWrap(true);
                                cell1.setLeading(8.0f);
                                cell1.setBackgroundColor(Color.lightGray);
                                chargeCountry1.addCell(cell1);

                                chk = new Chunk(rateDetailsDOB.getRate() + "",
                                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                                cell1 = new Cell(chk);
                                cell1.setNoWrap(true);
                                cell1.setLeading(8.0f);
                                chargeCountry1.addCell(cell1);

                                //@@ Added by subrahmanyam for wpbn id: 182516
                                // MODIFIED BY SUBRAHMANYAM FOR 183812
                                if (rateDetailsDOB.getWeightBreakSlab().equalsIgnoreCase("Min")
                                        || rateDetailsDOB.getWeightBreakSlab().equalsIgnoreCase("Minimum")
                                        || ("BOTH".equalsIgnoreCase(detailsDOB.getRateType()) && "FLAT"
                                                .equalsIgnoreCase(rateDetailsDOB.getRateIndicator()))) {
                                    wBSlab = "MIN";
                                } else {
                                    wBSlab = rateDetailsDOB.getWeightBreakSlab();
                                }
                                //@@ commented by subrahmanyam for wpbn id: 182516
                                //chk = new Chunk(rateDetailsDOB.getWeightBreakSlab().equalsIgnoreCase("Min")?"Pershipment ":detailsDOB.getChargeBasisDesc(),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                                //@@ Added by subrahmanyam for wpbn id: 182516
                                chk = new Chunk(
                                        wBSlab.equalsIgnoreCase("Min") ? " Per Shipment "
                                                : detailsDOB.getChargeBasisDesc(),
                                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                                //@@ Ended  for wpbn id: 182516
                                cell1 = new Cell(chk);
                                cell1.setNoWrap(true);
                                cell1.setLeading(8.0f);
                                chargeCountry1.addCell(cell1);

                                chk = new Chunk(
                                        detailsDOB.getDensityRatio() == null ? ""
                                                : detailsDOB.getDensityRatio(),
                                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                                cell1 = new Cell(chk);
                                cell1.setNoWrap(true);
                                cell1.setLeading(8.0f);
                                chargeCountry1.addCell(cell1);

                            }
                        }
                    }
                }
            }
            document.add(chargeCountry1);
        }
        // System.out.println("After Charges--------------------------------->");
        ArrayList destChargeInfo = null;
        //int[]      destChargeInfo        =  null;
        int destChargesInfoSize = 0;
        if (destCount > 0) {
            Table chargeCountry2 = new Table(7, destCount);
            chargeCountry2.setWidth(100);
            chargeCountry2.setPadding(1);
            chargeCountry2.setSpacing(0);
            chargeCountry2.setOffset(25);
            chargeCountry2.setBackgroundColor(Color.WHITE);
            chargeCountry2.setBorderColor(Color.black);
            chargeCountry2.setDefaultHorizontalAlignment(Element.ALIGN_CENTER);
            chargeCountry2.setBorderWidth(1);
            //@@ Added by subrahmanyam for wpbn id: 181349 on 07-sep-09
            chargeCountry2.setTableFitsPage(true);
            chargeCountry2.setCellsFitPage(true);
            // @@ Ended for wpbn id: 181349 on 07-sep-09

            Cell cell2;
            String wBslab = "";
            chk = new Chunk("QUOTEID", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell2 = new Cell(chk);
            cell2.setNoWrap(true);
            cell2.setLeading(8.0f);
            cell2.setBackgroundColor(Color.ORANGE);
            //cell2.setVerticalAlignment(cell2.ALIGN_MIDDLE);
            chargeCountry2.addCell(cell2);

            chk = new Chunk("CHARGE NAME", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell2 = new Cell(chk);
            cell2.setNoWrap(true);
            cell2.setLeading(8.0f);
            cell2.setBackgroundColor(Color.ORANGE);
            //cell2.setVerticalAlignment(cell2.ALIGN_MIDDLE);
            chargeCountry2.addCell(cell2);

            chk = new Chunk("BREAKPOINT", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell2 = new Cell(chk);
            cell2.setNoWrap(true);
            cell2.setLeading(8.0f);
            cell2.setBackgroundColor(Color.ORANGE);
            //cell2.setVerticalAlignment(cell2.ALIGN_MIDDLE);
            chargeCountry2.addCell(cell2);

            chk = new Chunk("CURRENCY", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell2 = new Cell(chk);
            cell2.setNoWrap(true);
            cell2.setLeading(8.0f);
            cell2.setBackgroundColor(Color.ORANGE);
            //cell2.setVerticalAlignment(cell2.ALIGN_MIDDLE);
            chargeCountry2.addCell(cell2);

            chk = new Chunk("RATE", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell2 = new Cell(chk);
            cell2.setNoWrap(true);
            cell2.setLeading(8.0f);
            cell2.setBackgroundColor(Color.ORANGE);
            //cell2.setVerticalAlignment(cell2.ALIGN_MIDDLE);
            chargeCountry2.addCell(cell2);

            chk = new Chunk("BASIS", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell2 = new Cell(chk);
            cell2.setNoWrap(true);
            cell2.setLeading(8.0f);
            cell2.setBackgroundColor(Color.ORANGE);
            //cell2.setVerticalAlignment(cell2.ALIGN_MIDDLE);
            chargeCountry2.addCell(cell2);

            chk = new Chunk("RATIO", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell2 = new Cell(chk);
            cell2.setNoWrap(true);
            cell2.setLeading(8.0f);
            cell2.setBackgroundColor(Color.ORANGE);
            //cell2.setVerticalAlignment(cell2.ALIGN_MIDDLE);
            chargeCountry2.addCell(cell2);

            chk = new Chunk("DESTINATION CHARGES", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell2 = new Cell(chk);
            cell2.setNoWrap(true);
            cell2.setLeading(8.0f);
            cell2.setColspan(7);
            cell2.setBackgroundColor(Color.ORANGE);
            //cell2.setVerticalAlignment(cell2.ALIGN_MIDDLE);
            chargeCountry2.addCell(cell2);
            int mDtlSize = mainDtl.size();
            for (int m = 0; m < mDtlSize; m++) {

                finalDOB = (MultiQuoteFinalDOB) mainDtl.get(m);
                headerDOB = finalDOB.getHeaderDOB();
                masterDOB = finalDOB.getMasterDOB();
                costingMasterDOB = finalDOB.getCostingMasterDOB();
                ArrayList destCharges = (ArrayList) costingMasterDOB.getDestinationList();
                if (destCharges.size() > 0) {

                    int destChargSize = destCharges.size();

                    for (int i = 0; i < destChargSize; i++) {

                        detailsDOB = (CostingChargeDetailsDOB) destCharges.get(i);
                        rateDetails = (ArrayList) detailsDOB.getCostingRateInfoDOB();

                        //originChargesInfoSize   = rateDetails.size();
                        int rDtlSize = rateDetails.size();
                        for (int k = 0; k < rDtlSize; k++) {
                            CostingRateInfoDOB crateDetailsDOB = (CostingRateInfoDOB) rateDetails.get(k);

                            if (k == 0) {

                                //@@ Commented by subrahmanyam for the enhancement #146971 and 1469710 on 10/12/2008                      
                                /*chk = new Chunk(new Long(masterDOB.getQuoteId()).toString(),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                                cell2 = new Cell(chk);
                                //cell2.setRowspan(rateDetails.size());
                                cell2.setNoWrap(true); cell2.setLeading(8.0f);
                                cell2.setBackgroundColor(Color.lightGray);
                                chargeCountry2.addCell(cell2);*/
                                //@@ Added by subrahmanyam for the enhancement #146971 and #146970 on 10/12/2008
                                chk = new Chunk(masterDOB.getQuoteId(),
                                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                                cell2 = new Cell(chk);
                                cell2.setNoWrap(true);
                                cell2.setLeading(8.0f);
                                cell2.setBackgroundColor(Color.lightGray);
                                chargeCountry2.addCell(cell2);
                                //@@ Ended by subrahmanyam for the enhancement #146971 and 146970 on 10/12/2008    

                                //  chk = new Chunk(detailsDOB.getChargeDescId(),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                                //@@ Added by subrahmanyam for the wpbn id: 181349  on 07-sep-09
                                chk = new Chunk(
                                        detailsDOB.getExternalName() != null ? detailsDOB.getExternalName()
                                                : detailsDOB.getChargeDescId(),
                                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));//ended for 181349
                                cell2 = new Cell(chk);
                                //cell2.setRowspan(rateDetails.size());
                                //cell2.setNoWrap(true); //commented for 181349
                                cell2.setLeading(8.0f);
                                cell2.setBackgroundColor(Color.lightGray);
                                chargeCountry2.addCell(cell2);
                            } else {
                                cell2 = new Cell("");
                                //cell2.setRowspan(rateDetails.size());
                                cell2.setNoWrap(true);
                                cell2.setLeading(8.0f);
                                cell2.setBackgroundColor(Color.lightGray);
                                cell2.setBorderWidth(0f);
                                chargeCountry2.addCell(cell2);

                                cell2 = new Cell("");
                                //cell2.setRowspan(rateDetails.size());
                                cell2.setNoWrap(true);
                                cell2.setLeading(8.0f);
                                cell2.setBackgroundColor(Color.lightGray);
                                cell2.setBorderWidth(0f);
                                chargeCountry2.addCell(cell2);
                            }
                            chk = new Chunk(crateDetailsDOB.getWeightBreakSlab(),
                                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                            cell2 = new Cell(chk);
                            cell2.setNoWrap(true);
                            cell2.setLeading(8.0f);
                            cell2.setBackgroundColor(Color.lightGray);
                            chargeCountry2.addCell(cell2);

                            chk = new Chunk(detailsDOB.getCurrency(),
                                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                            cell2 = new Cell(chk);
                            cell2.setNoWrap(true);
                            cell2.setLeading(8.0f);
                            cell2.setBackgroundColor(Color.lightGray);
                            chargeCountry2.addCell(cell2);

                            chk = new Chunk(crateDetailsDOB.getRate() + "",
                                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                            cell2 = new Cell(chk);
                            cell2.setNoWrap(true);
                            cell2.setLeading(8.0f);
                            chargeCountry2.addCell(cell2);

                            //@@ Commented & Added  by subrahmanyam for 182516 on 10/09/09
                            // chk = new Chunk(crateDetailsDOB.getWeightBreakSlab().equalsIgnoreCase("Min")?"Pershipment ":detailsDOB.getChargeBasisDesc(),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                            //ADDED BY SUBRAHMANYAM FOR 183812
                            if (crateDetailsDOB.getWeightBreakSlab().equalsIgnoreCase("Min")
                                    || ("BOTH".equalsIgnoreCase(detailsDOB.getRateType())
                                            && "F".equalsIgnoreCase(crateDetailsDOB.getRateIndicator()))) {
                                wBslab = "MIN";
                            } else
                                wBslab = detailsDOB.getChargeBasisDesc();
                            // COMMENTED & added FOR 183812 ON 24-09-09
                            //chk = new Chunk(crateDetailsDOB.getWeightBreakSlab().equalsIgnoreCase("Min")?" Per Shipment ":detailsDOB.getChargeBasisDesc(),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                            chk = new Chunk(
                                    wBslab.equalsIgnoreCase("Min") ? " Per Shipment "
                                            : detailsDOB.getChargeBasisDesc(),
                                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                            cell2 = new Cell(chk);
                            cell2.setNoWrap(true);
                            cell2.setLeading(8.0f);
                            chargeCountry2.addCell(cell2);

                            chk = new Chunk(
                                    detailsDOB.getDensityRatio() == null ? "" : detailsDOB.getDensityRatio(),
                                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                            cell2 = new Cell(chk);
                            cell2.setNoWrap(true);
                            cell2.setLeading(8.0f);
                            chargeCountry2.addCell(cell2);
                        }
                    }
                }
            }
            document.add(chargeCountry2);
        }

        Table notes = new Table(2, mainDtl.size());
        boolean displayFlag = false;
        notes.setWidth(100);
        notes.setPadding(1);
        notes.setSpacing(0);
        notes.setOffset(5);
        notes.setBackgroundColor(Color.WHITE);
        notes.setBorderColor(Color.black);
        notes.setDefaultHorizontalAlignment(Element.ALIGN_CENTER);
        notes.setBorderWidth(1);
        notes.setTableFitsPage(true);// added by subrahmanyam for quoteGrouping issue 184848
        notes.setCellsFitPage(true);// added by subrahmanyam for quoteGrouping issue 184848

        Cell cell3;
        chk = new Chunk("QUOTEID ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
        cell3 = new Cell(chk);
        cell3.setNoWrap(true);
        cell3.setLeading(8.0f);
        cell3.setBackgroundColor(Color.ORANGE);
        //cell3.setVerticalAlignment(cell3.ALIGN_MIDDLE);
        //cell3.setBackgroundColor(Color.lightGray);
        notes.addCell(cell3);

        chk = new Chunk("NOTES", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
        cell3 = new Cell(chk);
        cell3.setNoWrap(true);
        cell3.setLeading(8.0f);
        cell3.setBackgroundColor(Color.ORANGE);
        //cell3.setVerticalAlignment(cell3.ALIGN_MIDDLE);

        notes.addCell(cell3);
        int mDtlSize = mainDtl.size();
        for (int m = 0; m < mDtlSize; m++) {

            finalDOB = (MultiQuoteFinalDOB) mainDtl.get(m);
            headerDOB = finalDOB.getHeaderDOB();
            masterDOB = finalDOB.getMasterDOB();
            costingMasterDOB = finalDOB.getCostingMasterDOB();
            if (costingMasterDOB != null) {
            }
            //@@ Commented by subrahmanyam for the enhancement #146971 and 1469710 on 10/12/2008                      
            /*chk = new Chunk(new Long(masterDOB.getQuoteId()).toString(),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
            cell3 = new Cell(chk);
            //cell3.setRowspan(rateDetails.size());
            cell3.setNoWrap(true); cell3.setLeading(8.0f);
            cell3.setBackgroundColor(Color.lightGray);
            notes.addCell(cell3);*/
            //@@ Added by subrahmanyam for the enhancement #146971 and #146970 on 10/12/2008
            //commented by subrahmanyam for quote grouping issue
            /*
                 chk = new Chunk(masterDOB.getQuoteId(),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
            cell3 = new Cell(chk);
            cell3.setNoWrap(true); cell3.setLeading(8.0f);
            cell3.setBackgroundColor(Color.lightGray);
            notes.addCell(cell3);
                //@@ Ended by subrahmanyam for the enhancement #146971 and 146970 on 10/12/2008
                    
            chk = new Chunk(" ",FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
            cell3 = new Cell(chk);
            //cell3.setRowspan();
            cell3.setNoWrap(true); cell3.setLeading(8.0f);
            cell3.setBackgroundColor(Color.lightGray);
            notes.addCell(cell3);
            */
            //@@ Added by subrahmanyam for Quote Grouping Issue 184848 on 30/sep/09
            if (finalDOB.getExternalNotes() != null && finalDOB.getExternalNotes().length > 0) {
                int notesLength = finalDOB.getExternalNotes().length;
                for (int n = 0; n < notesLength; n++) {
                    if (n == 0) {
                        chk = new Chunk(masterDOB.getQuoteId(),
                                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                        cell3 = new Cell(chk);
                        cell3.setNoWrap(true);
                        cell3.setLeading(8.0f);
                        cell3.setBackgroundColor(Color.lightGray);
                        notes.addCell(cell3);
                        //@@ Ended by subrahmanyam for the enhancement #146971 and 146970 on 10/12/2008

                        chk = new Chunk(finalDOB.getExternalNotes()[n],
                                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                        cell3 = new Cell(chk);
                        //cell3.setRowspan();
                        //cell3.setNoWrap(true);
                        cell3.setHorizontalAlignment(cell3.ALIGN_LEFT);
                        cell3.setLeading(8.0f);
                        cell3.setBackgroundColor(Color.lightGray);
                        notes.addCell(cell3);
                    } else {
                        chk = new Chunk("", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                        cell3 = new Cell(chk);
                        cell3.setNoWrap(true);
                        cell3.setLeading(8.0f);
                        cell3.setBackgroundColor(Color.lightGray);
                        notes.addCell(cell3);
                        //@@ Ended by subrahmanyam for the enhancement #146971 and 146970 on 10/12/2008

                        chk = new Chunk(finalDOB.getExternalNotes()[n],
                                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                        cell3 = new Cell(chk);
                        //cell3.setRowspan();
                        // cell3.setNoWrap(true);
                        cell3.setHorizontalAlignment(cell3.ALIGN_LEFT);
                        cell3.setLeading(8.0f);
                        cell3.setBackgroundColor(Color.lightGray);
                        notes.addCell(cell3);
                    }
                }
            } else {
                chk = new Chunk(masterDOB.getQuoteId(),
                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                cell3 = new Cell(chk);
                cell3.setNoWrap(true);
                cell3.setLeading(8.0f);
                cell3.setBackgroundColor(Color.lightGray);
                notes.addCell(cell3);

                chk = new Chunk(" ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                cell3 = new Cell(chk);
                //cell3.setRowspan();
                cell3.setNoWrap(true);
                cell3.setLeading(8.0f);
                cell3.setBackgroundColor(Color.lightGray);
                notes.addCell(cell3);
            }
            //@@ Ended by subrahmanyam for Quote Grouping Issue 184848 on 30/09/09

            contents = masterDOB.getContentOnQuote();
            levels = masterDOB.getLevels();
            aligns = masterDOB.getAlign();
            headFoot = masterDOB.getHeaderFooter();

            if (contents != null && contents.length > 0) {
                int hFLen = headFoot.length;
                for (int i = 0; i < hFLen; i++) {
                    if (headFoot[i] != null && "F".equalsIgnoreCase(headFoot[i])) {
                        displayFlag = true;
                        break;
                    }
                }
                if (displayFlag) {
                    content = new Table(1);
                    content.setOffset(5);
                    content.setWidth(100);
                    content.setPadding(1);
                    content.setSpacing(0);
                    content.setBackgroundColor(Color.WHITE);
                    content.setBorderColor(Color.black);
                    content.setBorderWidth(1f);
                    Cell cellContent = null;
                    chk = new Chunk("QUOTEID : " + masterDOB.getQuoteId(),
                            FontFactory.getFont("ARIAL", 7, Font.ITALIC, Color.BLACK));
                    cellContent = new Cell(chk);
                    cellContent.setBorder(0);
                    cellContent.setLeading(6.0f);
                    cellContent.setHorizontalAlignment(cellContent.ALIGN_CENTER);
                    cellContent.setBackgroundColor(Color.ORANGE);
                    content.addCell(cellContent);
                    for (int i = 0; i < hFLen; i++) {
                        if (headFoot[i] != null && "F".equalsIgnoreCase(headFoot[i])) {
                            chk = new Chunk(contents[i] != null ? contents[i].toUpperCase() : "",
                                    FontFactory.getFont("ARIAL", 7, Font.ITALIC, Color.BLACK));
                            cellContent = new Cell(chk);
                            cellContent.setBorder(0);
                            cellContent.setLeading(6.0f);
                            cellContent.setBackgroundColor(Color.LIGHT_GRAY);
                            if ("L".equalsIgnoreCase(aligns[i]))
                                cellContent.setHorizontalAlignment(cellContent.ALIGN_LEFT);
                            else if ("C".equalsIgnoreCase(aligns[i]))
                                cellContent.setHorizontalAlignment(cellContent.ALIGN_CENTER);
                            else if ("R".equalsIgnoreCase(aligns[i]))
                                cellContent.setHorizontalAlignment(cellContent.ALIGN_RIGHT);
                            content.addCell(cellContent);
                        }
                    }
                    document.add(content);
                }
            }
        }
        document.add(notes);
        //Default Footer Content Starts
        contents = masterDOB.getDefaultContent();
        headFoot = masterDOB.getDefaultHeaderFooter();
        int hFLen = 0;
        if (headFoot != null)
            hFLen = headFoot.length;
        if (contents != null && contents.length > 0) {
            content = new Table(1);
            content.setOffset(5);
            content.setWidth(100);
            content.setPadding(1);
            content.setSpacing(0);
            content.setBackgroundColor(Color.WHITE);
            content.setBorderColor(Color.black);
            content.setBorderWidth(1f);
            Cell cellContent = null;
            chk = null;
            for (int i = 0; i < hFLen; i++) {
                if (headFoot[i] != null && "F".equalsIgnoreCase(headFoot[i])) {
                    chk = new Chunk(contents[i], FontFactory.getFont("ARIAL", 7, Font.ITALIC, Color.BLACK));
                    cellContent = new Cell(chk);
                    cellContent.setBorder(0);
                    cellContent.setLeading(6.0f);
                    cellContent.setBackgroundColor(Color.LIGHT_GRAY);
                    cellContent.setHorizontalAlignment(cellContent.ALIGN_LEFT);//Default content is left aligned                                    
                    content.addCell(cellContent);

                }
            }
            document.add(content);
        }
        //End Default Footer Content

        // System.out.println("After     document Close----------------------------------------->");

        document.close();
        // Thread.sleep(100);
        //logger.info("thread");
        //String file_tsmp = ""+new java.sql.Timestamp((new java.util.Date()).getTime()+masterDOB.getQuoteId());  //@@ Commented by subrahmanyam for the Enhancement #146971 on 2/12/08
        // String file_tsmp = ""+new java.sql.Timestamp((new java.util.Date()).getTime()+Long.parseLong(masterDOB.getQuoteId()));  //@@ Added by subrahmanyam for the Enhancement #146971 on 2/12/08
        //Commenetd by Anusha V 
        //String file_tsmp = ""+new java.sql.Timestamp((new java.util.Date()).getTime())+masterDOB.getQuoteId(); //@@ Added by subrahmanyam for the Enhancement #146971 on 2/12/08
        //Added by Anusha V
        String file_tsmp = "" + new java.sql.Timestamp((new java.util.Date()).getTime());
        file_tsmp = file_tsmp.replaceAll("\\:", "");
        file_tsmp = file_tsmp.replaceAll("\\.", "");
        file_tsmp = file_tsmp.replaceAll("\\-", "");
        file_tsmp = file_tsmp.replaceAll(" ", "");
        File f = new File("Quote" + file_tsmp + ".pdf");
        FileOutputStream fileOutputStream = new FileOutputStream(f);
        baos.writeTo(fileOutputStream);
        fileOutputStream.close();
        //  logger.info("masterDOB.getUserId()"+masterDOB.getUserId());
        if ("on".equalsIgnoreCase(request.getParameter("print"))) {

            request.getSession().setAttribute("QuoteOuptutStream", f);
        }
        //  session.setAttribute("UserId",masterDOB.getUserId());

        int noOfQuotes = mainDtl.size();
        StringBuffer quoteIds = new StringBuffer("");
        String quoteType = "";
        String terminalAddress = "";
        String creatorDetails = "";
        String fromEmailId = "";
        String body = "";
        String countryCode = "";
        for (int i = 0; i < noOfQuotes; i++) {
            finalDOB = (MultiQuoteFinalDOB) mainDtl.get(i);
            /*  //@@Added for the WPBN issue-
              filesDOBList           =   finalDOB.getAttachmentDOBList(); 
              for(int j=0;j<filesDOBList.size();j++)
              {
               filesList.add(filesDOBList.get(j));
              } //@@Added for the WPBN issue-*/

            if (i == 0) {
                quoteType = "" + finalDOB.getMasterDOB().getShipmentMode();
                terminalAddress = finalDOB.getMasterDOB().getTerminalAddress();
                creatorDetails = finalDOB.getMasterDOB().getCreatorDetails();
                fromEmailId = finalDOB.getMasterDOB().getUserEmailId();
                countryCode = finalDOB.getHeaderDOB().getCustCountyCode();
                to_FaxIds = finalDOB.getHeaderDOB().getCustFaxNo();
                to_emailIds = finalDOB.getHeaderDOB().getCustEmailId();
            }
            quoteIds.append(finalDOB.getMasterDOB().getQuoteId());
            if (i != noOfQuotes - 1)
                quoteIds.append(",");

            contactPersons = finalDOB.getMasterDOB().getCustContactNames();
            if (contactPersons != null) {
                int contPersLen = contactPersons.length;
                for (int k = 0; k < contPersLen; k++) {
                    if (!contactList.contains(finalDOB.getMasterDOB().getCustContactNames()[k])) {
                        contactList.add(finalDOB.getMasterDOB().getCustContactNames()[k]);
                        contactEmailList.add(finalDOB.getMasterDOB().getCustomerContactsEmailIds()[k]);
                        contactFaxList.add(finalDOB.getMasterDOB().getCustomerContactsFax()[k]);
                    }
                }

            }

        }

        if ("1".equalsIgnoreCase(quoteType))
            quoteType = "Airfreight";
        else if ("2".equalsIgnoreCase(quoteType))
            quoteType = "Seafreight";
        else if ("4".equalsIgnoreCase(quoteType))
            quoteType = "Truckfreight";

        String subject = "DHL Global Forwarding Quotation, Multiple " + quoteType + ", Quote References "
                + quoteIds.toString();
        String message = "";
        //finalDOB.getFlagsDOB().setQuoteStatusFlag("PEN");//@@Quote is Pending
        //ReportsSessionBeanHome home      = (ReportsSessionBeanHome)LookUpBean.getEJBHome("ReportsSessionBean");
        //ReportsSession remote   = (ReportsSession)home.create();
        //if(contactList.size()==0)
        //{
        to_emailIds = to_emailIds.replaceAll(";", ",");
        /*message  = "Dear Customer,\n\nThank you for the opportunity to provide this quotation.  All information is contained within the attachment."+
                    "  Should you have any queries please do not hesitate to contact us.\n\n\nRegards,\n"+creatorDetails+"\n"+terminalAddress;*/
        //message   = "Dear Customer,\n\n"+finalDOB.getEmailText()+"\n\n\nRegards,\n"+creatorDetails+"\n"+terminalAddress+"\n"+;       
        if (finalDOB.getUpdatedReportDOB() != null) {
            body = "Dear Customer,\n\nThis is a replacement quotation reference "
                    + request.getAttribute("quoteId") + ",replacing "
                    + finalDOB.getUpdatedReportDOB().getQuoteId() + ", due to a change in "
                    + (finalDOB.getEmailChargeName() != null ? finalDOB.getEmailChargeName()
                            : finalDOB.getUpdatedReportDOB().getChangeDesc())
                    + ",\n\n" + (finalDOB.getEmailText() != null ? finalDOB.getEmailText() : "") + "\n\n\n"
                    + (masterDOB.getCreatorDetails() != null ? masterDOB.getCreatorDetails() : "") + "\n\n"
                    + (masterDOB.getCompanyName() != null ? masterDOB.getCompanyName() : "") + "\n"
                    + (masterDOB.getTerminalAddress() != null ? masterDOB.getTerminalAddress() : "") + "\n\n"
                    + "Phone  " + (masterDOB.getPhoneNo() != null ? masterDOB.getPhoneNo() : "") + "\n"
                    + "Fax    " + (masterDOB.getFaxNo() != null ? masterDOB.getFaxNo() : "") + "\n" + "Mobile "
                    + (masterDOB.getMobileNo() != null ? masterDOB.getMobileNo() : "") + "\n\nEmail "
                    + (masterDOB.getUserEmailId() != null ? masterDOB.getUserEmailId() : ""); //@@Modified by Kameswari for the WPBN issue-61303
        } else {
            body = "Dear Customer,\n\n" + (finalDOB.getEmailText() != null ? finalDOB.getEmailText() : "")
                    + "\n\n\n" + (masterDOB.getCreatorDetails() != null ? masterDOB.getCreatorDetails() : "")
                    + "\n\n" + (masterDOB.getCompanyName() != null ? masterDOB.getCompanyName() : "") + "\n"
                    + (masterDOB.getTerminalAddress() != null ? masterDOB.getTerminalAddress() : "") + "\n\n"
                    + "Phone  " + (masterDOB.getPhoneNo() != null ? masterDOB.getPhoneNo() : "") + "\n"
                    + "Fax    " + (masterDOB.getFaxNo() != null ? masterDOB.getFaxNo() : "") + "\n" + "Mobile "
                    + (masterDOB.getMobileNo() != null ? masterDOB.getMobileNo() : "") + "\n\nEmail "
                    + (masterDOB.getUserEmailId() != null ? masterDOB.getUserEmailId() : ""); //@@Modified by Kameswari for the WPBN issue-61303
        }
        if ("on".equalsIgnoreCase(request.getParameter("email"))) {
            try {
                sendMail(fromEmailId, to_emailIds, subject, message, "Quote" + file_tsmp + ".pdf", null);
                sentEmailsList.add(to_emailIds);
            } catch (FoursoftException fs) {
                //Logger.error(FILE_NAME,"Error While Sending Mail.."+fs.getMessage());
                logger.error(FILE_NAME + "Error While Sending Mail.." + fs.getMessage());
                fs.printStackTrace();
                unsentEmailsList.add(to_emailIds);
            }
        }
        if ("on".equalsIgnoreCase(request.getParameter("fax"))) {
            if ("SG".equalsIgnoreCase(countryCode))
                faxMailIds = "fax#" + to_FaxIds + "@tcdhl.com";
            else
                faxMailIds = "ifax#" + to_FaxIds + "@tcdhl.com";
            try {
                sendMail(fromEmailId, faxMailIds, subject, message, "Quote" + file_tsmp + ".pdf", null);
                sentFaxList.add(to_FaxIds);
            } catch (FoursoftException fs) {
                //Logger.error(FILE_NAME,"Error While Sending Fax.."+fs.getMessage());
                logger.error(FILE_NAME + "Error While Sending Fax.." + fs.getMessage());
                fs.printStackTrace();
                unsentFaxList.add(to_FaxIds);
            }
        }
        //}
        //else
        //{
        int contactSize = contactList.size();
        for (int i = 0; i < contactSize; i++) {
            contactName = (String) contactList.get(i);
            /*message = "Dear "+contactName+",\n\nThank you for the opportunity to provide this Quotation. All information is contained within the attachment."+
             " Should you have any queries, please do not hesitate to contact us.\n\n\nRegards,\n"+creatorDetails+"\n"+terminalAddress;*/
            // message = "Dear "+contactName+",\n\n"+finalDOB.getEmailText()+"\n\n\nRegards,\n"+creatorDetails+"\n"+terminalAddress;         
            if (finalDOB.getUpdatedReportDOB() != null) {
                body = "Dear " + (contactName != null ? contactName : "")
                        + ",\n\nThis is a replacement quotation reference " + request.getAttribute("quoteId")
                        + ",replacing " + finalDOB.getUpdatedReportDOB().getQuoteId() + ", due to a change in "
                        + (finalDOB.getEmailChargeName() != null ? finalDOB.getEmailChargeName()
                                : finalDOB.getUpdatedReportDOB().getChangeDesc())
                        + ",\n\n" + finalDOB.getEmailText() != null
                                ? finalDOB.getEmailText()
                                : "" + "\n\n\n" + masterDOB.getCreatorDetails() != null
                                        ? masterDOB.getCreatorDetails()
                                        : "" + "\n\n" + masterDOB.getCompanyName() != null
                                                ? masterDOB.getCompanyName()
                                                : "" + "\n" + masterDOB.getTerminalAddress() != null
                                                        ? masterDOB.getTerminalAddress()
                                                        : "" + "\n\n" + "Phone  "
                                                                + masterDOB.getPhoneNo() != null
                                                                        ? masterDOB.getPhoneNo()
                                                                        : "" + "\n" + "Fax    "
                                                                                + masterDOB.getFaxNo() != null
                                                                                        ? masterDOB.getFaxNo()
                                                                                        : "" + "\n" + "Mobile "
                                                                                                + masterDOB
                                                                                                        .getMobileNo() != null
                                                                                                                ? masterDOB
                                                                                                                        .getMobileNo()
                                                                                                                : "" + "\n\nEmail "
                                                                                                                        + masterDOB
                                                                                                                                .getUserEmailId() != null
                                                                                                                                        ? masterDOB
                                                                                                                                                .getUserEmailId()
                                                                                                                                        : ""; //@@Modified by Kameswari for the WPBN issue-61303
            } else {
                body = "Dear " + (contactName != null ? contactName : "") + ",\n\n"
                        + finalDOB.getEmailText() != null
                                ? finalDOB.getEmailText()
                                : "" + "\n\n\n" + masterDOB.getCreatorDetails() != null
                                        ? masterDOB.getCreatorDetails()
                                        : "" + "\n\n" + masterDOB.getCompanyName() != null
                                                ? masterDOB.getCompanyName()
                                                : "" + "\n" + masterDOB.getTerminalAddress() != null
                                                        ? masterDOB.getTerminalAddress()
                                                        : "" + "\n\n" + "Phone  "
                                                                + masterDOB.getPhoneNo() != null
                                                                        ? masterDOB.getPhoneNo()
                                                                        : "" + "\n" + "Fax    "
                                                                                + masterDOB.getFaxNo() != null
                                                                                        ? masterDOB.getFaxNo()
                                                                                        : "" + "\n" + "Mobile "
                                                                                                + masterDOB
                                                                                                        .getMobileNo() != null
                                                                                                                ? masterDOB
                                                                                                                        .getMobileNo()
                                                                                                                : "" + "\n\nEmail "
                                                                                                                        + masterDOB
                                                                                                                                .getUserEmailId() != null
                                                                                                                                        ? masterDOB
                                                                                                                                                .getUserEmailId()
                                                                                                                                        : ""; //@@Modified by Kameswari for the WPBN issue-61303

            }
            if ("on".equalsIgnoreCase(request.getParameter("email"))) {
                try {
                    sendMail(fromEmailId, (String) contactEmailList.get(i), subject, message,
                            "Quote" + file_tsmp + ".pdf", null);
                    sentEmailsList.add(contactEmailList.get(i));
                } catch (FoursoftException fs) {
                    //Logger.error(FILE_NAME,"Error While Sending Mail.."+fs.getMessage());
                    logger.error(FILE_NAME + "Error While Sending Mail.." + fs.getMessage());
                    fs.printStackTrace();
                    unsentEmailsList.add(contactEmailList.get(i));
                }
            }
            if ("on".equalsIgnoreCase(request.getParameter("fax"))) {
                if ("SG".equalsIgnoreCase(countryCode))
                    to_FaxIds = "fax#" + contactFaxList.get(i) + "@tcdhl.com";
                else
                    to_FaxIds = "ifax#" + contactFaxList.get(i) + "@tcdhl.com";
                try {
                    sendMail(fromEmailId, to_FaxIds, subject, message, "Quote" + file_tsmp + ".pdf", null);
                    sentFaxList.add(contactFaxList.get(i));
                } catch (FoursoftException fs) {
                    //Logger.error(FILE_NAME,"Error While Sending Fax.."+fs.getMessage());
                    logger.error(FILE_NAME + "Error While Sending Fax.." + fs.getMessage());
                    fs.printStackTrace();
                    unsentFaxList.add(
                            contactFaxList.get(i) != null ? contactFaxList.get(i) : "No Fax Number Provided");
                }
            }
        }
        //}
        returnList.add(sentEmailsList);
        returnList.add(unsentEmailsList);
        returnList.add(sentFaxList);
        returnList.add(unsentFaxList);

        // System.out.println("Before Sending Mail------------------------------>");

        // System.out.println("End of mail sending and PDF Generation --------------------------------->");

    } catch (Exception e) {
        e.printStackTrace();
        //Logger.error(FILE_NAME,"Error while generating the PDF"+e.toString());
        logger.error(FILE_NAME + "Error while generating the PDF" + e.toString());
        //return 0;
        //throw new Exception("Error while generating PDF format");
    }
    return returnList;
}

From source file:QMSQuoteController.java

License:Open Source License

private int doPDFGeneration(QuoteFinalDOB finalDOB, HttpServletRequest request, HttpServletResponse response)
        throws Exception {

    int mailFlag = 0;
    int faxFlag = 0;
    int printFlag = 0;
    int returnFlag = 3;
    String transitTime = null;//w w  w  .  jav a  2 s  . c  om
    String[] contents = null;
    String[] levels = null;
    String[] aligns = null;
    String[] headFoot = null;
    //@@Added by Kameswari for the WPBN issue-61289
    ArrayList dobList = new ArrayList();
    QuoteAttachmentDOB attachmentDOB = null;
    //@@Added by Kameswari for the WPBN issue-146448
    ArrayList charges = null;
    int chargesSize = 0;
    QuoteCharges chargesDOB = null;
    ArrayList freightCharges = null;
    QuoteFreightLegSellRates legCharges = null;
    String str1[] = null;
    ArrayList frequency = new ArrayList();
    ArrayList carrier = new ArrayList();
    ArrayList transittime = new ArrayList();
    ArrayList ratevalidity = new ArrayList();
    ArrayList frequency_o = new ArrayList();
    ArrayList frequency_d = new ArrayList();
    ArrayList carrier_o = new ArrayList();
    ArrayList carrier_d = new ArrayList();
    ArrayList transit_o = new ArrayList();
    ArrayList transit_d = new ArrayList();
    ArrayList validity_o = new ArrayList();
    ArrayList validity_d = new ArrayList();
    int size = 0;
    //@@WPBN issue-146448
    ArrayList filesList = new ArrayList();
    File file = null;
    byte[] buffer = null;
    ArrayList bufferList = new ArrayList();
    ArrayList pdfFilesList = new ArrayList();
    HttpSession session = null;
    String percent = "";//Added by kiranv on 16/11/2011
    PdfWriter writer = null; //Method: doPDFGeneration Defect: PdfWriter is not closedSuggestion: Close and nullify the writer in the finally block.
    //@@ Added by subrahmanyam for the WPBN ISSUE: 146460 on 29/01/2009    
    QMSQuoteSessionHome home = null;
    QMSQuoteSession remote = null;
    //@@ Ended by subrahmanyam for the WPBN ISSUE: 146460 on 29/01/2009   

    //@@ WPBN issue-61289
    try {

        DecimalFormat df = new DecimalFormat("###,###,###,##0.00");
        QuoteHeader headerDOB = finalDOB.getHeaderDOB();
        QuoteMasterDOB masterDOB = finalDOB.getMasterDOB();
        ESupplyDateUtility eSupplyDateUtility = new ESupplyDateUtility();
        ESupplyGlobalParameters loginbean = (ESupplyGlobalParameters) request.getSession()
                .getAttribute("loginbean");
        eSupplyDateUtility.setPatternWithTime("DD-MONTH-YYYY");
        //eSupplyDateUtility.setPatternWithTime(loginbean.getUserPreferences().getDateFormat());
        //@@ Commented & Added by subrahmanyam for the Effective pbn Issue 212006 on # 26-Jul-10
        /* String[] strDate  = eSupplyDateUtility.getDisplayStringArray(headerDOB.getDateOfQuotation());
        String[] effDate  = eSupplyDateUtility.getDisplayStringArray(headerDOB.getEffDate());
        */
        String[] strDate = null;
        String[] effDate = null;
        if ("View".equalsIgnoreCase(request.getParameter("Operation"))) {
            //@@Modified by kiran.v on 05/08/2011 for Wpbn Issue-   256087
            if ("PDF".equalsIgnoreCase(request.getParameter("pdf"))) {
                strDate = eSupplyDateUtility.getDisplayStringArray(masterDOB.getCreatedDate());
                //   effDate  = eSupplyDateUtility.getDisplayStringArray(headerDOB.getEffDate());
                effDate = eSupplyDateUtility.getDisplayStringArray(headerDOB.getEffDate());
            } else {

                strDate = eSupplyDateUtility.getDisplayStringArray(masterDOB.getCreatedDate());
                effDate = eSupplyDateUtility.getDisplayStringArray(headerDOB.getEffDate());

            } //@@Ended by kiran.v

        } else {
            strDate = eSupplyDateUtility.getDisplayStringArray(headerDOB.getDateOfQuotation());
            effDate = eSupplyDateUtility.getDisplayStringArray(headerDOB.getEffDate());

        }

        String[] validDate;
        String validUptoStr = null;
        if (headerDOB.getValidUpto() != null) {
            validDate = eSupplyDateUtility.getDisplayStringArray(headerDOB.getValidUpto());
            validUptoStr = validDate[0];
        }

        StringBuffer attentionTo = new StringBuffer("");
        if (masterDOB.getCustContactNames() != null) {
            for (int i = 0; i < masterDOB.getCustContactNames().length; i++) {
                attentionTo.append(
                        masterDOB.getCustContactNames()[i] != null ? masterDOB.getCustContactNames()[i] : "");
                if (i != (masterDOB.getCustContactNames().length - 1))
                    attentionTo.append(",");
            }
        }
        charges = finalDOB.getLegDetails();

        chargesSize = charges.size();
        // System.out.println("Before Document Objec--------------------------->");
        Document document = new Document(PageSize.A4, 54f, 54f, 68.4f, 68.4f);//@@ 36 points represent 0.5 inch
        String PDF_FILE_NAME = "Approved.pdf";
        document.addTitle("Approved Report");
        document.addSubject("Report PDF");
        document.addKeywords("Test, Key Words");
        document.addAuthor("QuoteShop");
        document.addCreator("QuoteShop");
        document.addCreationDate();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ByteArrayOutputStream baosFile = new ByteArrayOutputStream();
        writer = PdfWriter.getInstance(document, baos);
        // int b = writer.getPageNumber();
        baos.close();

        document.open();
        // PdfFileStamp fileStamp = new PdfFileStamp("Approved.pdf");

        //PdfPageEventHelper helper

        //writer.setPageEvent(new PdfPageEventHelper());

        //document.setMargins(15,15,15,15);            
        // Draw a rectangle inside the page's margins.
        //PdfContentByte cb = writer.getDirectContent();
        //cb.rectangle (document.left (), document.bottom (), document.right ()-document.left (),document.top ()-document.bottom ());
        //cb.stroke ();
        int[] widths = { 12, 12, 12, 12, 12, 12, 28 };
        Table mainT = new Table(7);
        mainT.setWidth(100);
        mainT.setWidths(widths);
        mainT.setBorderColor(Color.white);
        mainT.setPadding(1);
        mainT.setSpacing(0);

        Phrase headingPhrase = new Phrase("", FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.BLACK));
        Cell cellHeading = new Cell(headingPhrase);
        cellHeading.setBorderColor(new Color(255, 255, 255));
        cellHeading.setHorizontalAlignment(cellHeading.ALIGN_CENTER);
        cellHeading.setBorderWidth(0);
        cellHeading.setColspan(6);
        mainT.addCell(cellHeading);

        Cell imageCell = new Cell();
        java.net.URL url = getServletConfig().getServletContext().getResource("/images/DHLlogo.gif");
        Image img0 = Image.getInstance(url);
        img0.setAlignment(Image.ALIGN_RIGHT);

        //imageCell.setWidth("");
        imageCell.setColspan(1);
        imageCell.setHorizontalAlignment(imageCell.ALIGN_RIGHT);
        imageCell.add(img0);
        imageCell.setBorderWidth(0);
        imageCell.setBorderWidth(0);
        imageCell.setNoWrap(true);
        mainT.addCell(imageCell);
        mainT.setAlignment(mainT.ALIGN_CENTER);
        document.add(mainT);

        // System.out.println("After Image && Before Content--------------------------->");

        Table partCountry = new Table(1, 6);
        partCountry.setBorderWidth(0);
        partCountry.setWidth(100);
        partCountry.setBorderColor(Color.black);
        partCountry.setPadding(1);
        partCountry.setSpacing(0);
        partCountry.setAutoFillEmptyCells(true);
        //partCountry.setTableFitsPage(true);
        partCountry.setAlignment(partCountry.ALIGN_CENTER);
        partCountry.setBorderWidth(0);
        ;
        Cell cellCountry;

        String shipmentMode = "";
        if (!finalDOB.isMultiModalQuote()) {
            if (finalDOB.getMasterDOB().getShipmentMode() == 1) {
                shipmentMode = "AIR FREIGHT PROPOSAL";
                transitTime = "Approximate Transit Time";
            } else if (finalDOB.getMasterDOB().getShipmentMode() == 2) {
                shipmentMode = "SEA FREIGHT PROPOSAL";
                transitTime = "Approximate Transit Days";
            } else if (finalDOB.getMasterDOB().getShipmentMode() == 4) {
                shipmentMode = "TRUCK FREIGHT PROPOSAL";
                transitTime = "Approximate Transit Time";
            }
        } else {
            shipmentMode = " MULTI-MODAL FREIGHT PROPOSAL ";
            transitTime = "Approximate Transit time and Days";

        }

        Chunk chk = new Chunk(shipmentMode, FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setWidth("100");
        cellCountry.setBorderWidth(0);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(10.0f);
        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
        partCountry.addCell(cellCountry);

        if ("MY".equalsIgnoreCase(masterDOB.getCountryId())) {
            chk = new Chunk(
                    (headerDOB.getOriginCountry() != null ? headerDOB.getOriginCountry().toUpperCase() : "")
                            + " TO "
                            + (headerDOB.getDestinationCountry() != null
                                    ? headerDOB.getDestinationCountry().toUpperCase()
                                    : ""),
                    FontFactory.getFont("ARIAL", 16, Font.BOLD, Color.BLUE));
            cellCountry = new Cell(chk);
            cellCountry.setWidth("100");
            cellCountry.setBorderWidth(0);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(13.0f);//@@Do Not Decrease.
            cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
            partCountry.addCell(cellCountry);

            cellCountry = new Cell("");
            cellCountry.setBorderWidth(0);
            cellCountry.setLeading(5.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk(headerDOB.getCustomerName(),
                    FontFactory.getFont("ARIAL", 14, Font.BOLD, Color.BLUE));
            cellCountry = new Cell(chk);
            cellCountry.setHeader(true);
            cellCountry.setWidth("100");
            cellCountry.setBorderWidth(0);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(10.0f);
            cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
            partCountry.addCell(cellCountry);

            chk = new Chunk("ATTENTION TO: " + attentionTo.toString(),
                    FontFactory.getFont("ARIAL", 14, Font.BOLD, Color.BLUE));
            cellCountry = new Cell(chk);
            cellCountry.setWidth("100");
            cellCountry.setBorderWidth(0);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(10.0f);
            cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
            partCountry.addCell(cellCountry);
        } else {
            chk = new Chunk(
                    (headerDOB.getOriginCountry() != null ? headerDOB.getOriginCountry().toUpperCase() : "")
                            + " TO "
                            + (headerDOB.getDestinationCountry() != null
                                    ? headerDOB.getDestinationCountry().toUpperCase()
                                    : ""),
                    FontFactory.getFont("ARIAL", 16, Font.BOLD, Color.RED));
            cellCountry = new Cell(chk);
            cellCountry.setWidth("100");
            cellCountry.setBorderWidth(0);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(13.0f);//@@Do Not Decrease.
            cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
            partCountry.addCell(cellCountry);

            cellCountry = new Cell("");
            cellCountry.setBorderWidth(0);
            cellCountry.setLeading(5.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk(headerDOB.getCustomerName(),
                    FontFactory.getFont("ARIAL", 14, Font.BOLD, Color.RED));
            cellCountry = new Cell(chk);
            cellCountry.setHeader(true);
            cellCountry.setWidth("100");
            cellCountry.setBorderWidth(0);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(10.0f);
            cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
            partCountry.addCell(cellCountry);

            chk = new Chunk("ATTENTION TO: " + attentionTo.toString(),
                    FontFactory.getFont("ARIAL", 14, Font.BOLD, Color.RED));
            cellCountry = new Cell(chk);
            cellCountry.setWidth("100");
            cellCountry.setBorderWidth(0);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(10.0f);
            cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
            partCountry.addCell(cellCountry);
        }
        cellCountry = new Cell("");
        cellCountry.setBorderWidth(0);
        cellCountry.setLeading(5.0f);
        partCountry.addCell(cellCountry);

        chk = new Chunk("QUOTE REFERENCE: " + masterDOB.getQuoteId(),
                FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setWidth("100");
        cellCountry.setBorderWidth(0);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(10.0f);
        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
        partCountry.addCell(cellCountry);
        chk = new Chunk("DATE OF QUOTATION: " + strDate[0],
                FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setWidth("100");
        cellCountry.setBorderWidth(0);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(10.0f);
        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
        partCountry.addCell(cellCountry);

        document.add(partCountry);

        contents = masterDOB.getContentOnQuote();
        levels = masterDOB.getLevels();
        aligns = masterDOB.getAlign();
        headFoot = masterDOB.getHeaderFooter();
        Table content = null;
        if (contents != null && contents.length > 0) {
            content = new Table(1);
            content.setOffset(5);
            content.setWidth(100);
            content.setPadding(1);
            content.setSpacing(0);
            content.setBackgroundColor(Color.WHITE);
            content.setBorderColor(Color.black);
            content.setBorderWidth(1f);
            Cell cellContent = null;
            chk = null;
            int headFootLen = headFoot.length;
            for (int i = 0; i < headFootLen; i++) {
                if (headFoot[i] != null && "H".equalsIgnoreCase(headFoot[i])) {
                    chk = new Chunk(contents[i], FontFactory.getFont("ARIAL", 7, Font.ITALIC, Color.BLACK));
                    cellContent = new Cell(chk);
                    cellContent.setBorder(0);
                    cellContent.setLeading(8.0f);
                    cellContent.setBackgroundColor(Color.LIGHT_GRAY);
                    if ("L".equalsIgnoreCase(aligns[i]))
                        cellContent.setHorizontalAlignment(cellContent.ALIGN_LEFT);
                    else if ("C".equalsIgnoreCase(aligns[i]))
                        cellContent.setHorizontalAlignment(cellContent.ALIGN_CENTER);
                    else if ("R".equalsIgnoreCase(aligns[i]))
                        cellContent.setHorizontalAlignment(cellContent.ALIGN_RIGHT);
                    content.addCell(cellContent);
                }
            }
            document.add(content);
        }
        //@@Added by Kameswari for the WPBN issue-146448 on 03/12/08
        for (int i = 0; i < chargesSize; i++) {
            legCharges = (QuoteFreightLegSellRates) charges.get(i);

            freightCharges = legCharges.getFreightChargesList();
            chargesDOB = (QuoteCharges) freightCharges.get(0);
            if (chargesDOB.getValidUpto() != null) {
                str1 = eSupplyDateUtility.getDisplayStringArray(chargesDOB.getValidUpto());
            }
            ///////////////////////////////////////////Second Table////////////////////////////
            if (chargesSize > 1) {
                if ("Y".equalsIgnoreCase(chargesDOB.getFrequencyChecked())
                        || "on".equalsIgnoreCase(chargesDOB.getFrequencyChecked())) {
                    frequency.add(chargesDOB.getFrequency());
                    frequency_o.add(legCharges.getOrigin());
                    frequency_d.add(legCharges.getDestination());
                }
                if ("Y".equalsIgnoreCase(chargesDOB.getTransitTimeChecked())
                        || "on".equalsIgnoreCase(chargesDOB.getTransitTimeChecked())) {
                    transittime.add(chargesDOB.getTransitTime());
                    transit_o.add(legCharges.getOrigin());
                    transit_d.add(legCharges.getDestination());
                }
                if ("Y".equalsIgnoreCase(chargesDOB.getCarrierChecked())
                        || "on".equalsIgnoreCase(chargesDOB.getCarrierChecked())) {
                    carrier.add(chargesDOB.getCarrier());
                    carrier_o.add(legCharges.getOrigin());
                    carrier_d.add(legCharges.getDestination());
                }
                if ("Y".equalsIgnoreCase(chargesDOB.getRateValidityChecked())
                        || "on".equalsIgnoreCase(chargesDOB.getRateValidityChecked())) {
                    if (chargesDOB.getValidUpto() != null) {
                        str1 = eSupplyDateUtility.getDisplayStringArray(chargesDOB.getValidUpto());
                    }
                    ratevalidity.add(str1[0]);
                    validity_o.add(legCharges.getOrigin());
                    validity_d.add(legCharges.getDestination());
                }
            } else {

                if ("Y".equalsIgnoreCase(chargesDOB.getFrequencyChecked())
                        || "on".equalsIgnoreCase(chargesDOB.getFrequencyChecked())) {
                    frequency.add(chargesDOB.getFrequency());
                }
                if ("Y".equalsIgnoreCase(chargesDOB.getTransitTimeChecked())
                        || "on".equalsIgnoreCase(chargesDOB.getTransitTimeChecked())) {
                    transittime.add(chargesDOB.getTransitTime());
                }
                if ("Y".equalsIgnoreCase(chargesDOB.getCarrierChecked())
                        || "on".equalsIgnoreCase(chargesDOB.getCarrierChecked())) {
                    carrier.add(chargesDOB.getCarrier());
                }
                if ("Y".equalsIgnoreCase(chargesDOB.getRateValidityChecked())
                        || "on".equalsIgnoreCase(chargesDOB.getRateValidityChecked())) {
                    if (chargesDOB.getValidUpto() != null) {
                        str1 = eSupplyDateUtility.getDisplayStringArray(chargesDOB.getValidUpto());
                        ratevalidity.add(str1[0]);
                    }

                }

            }
        } // partCountry  =  new Table(2,13);
        size = frequency.size() + transittime.size() + carrier.size() + ratevalidity.size();

        partCountry = new Table(2, 13 + size);
        //@@WPBN issue-146448 on 03/12/08
        partCountry.setOffset(5);
        partCountry.setWidth(100);
        partCountry.setPadding(1);
        partCountry.setSpacing(0);
        partCountry.setBackgroundColor(Color.WHITE);
        partCountry.setBorderColor(Color.black);
        partCountry.setBorderWidth(1f);

        chk = new Chunk("Prepared By: ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setBackgroundColor(Color.lightGray);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(8.0f);
        partCountry.addCell(cellCountry);

        chk = new Chunk(
                "   " + (headerDOB.getPreparedBy() != null ? headerDOB.getPreparedBy().toUpperCase() : ""),
                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(8.0f);
        partCountry.addCell(cellCountry);

        chk = new Chunk("SERVICE INFORMATION: ", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setColspan(2);
        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
        cellCountry.setBackgroundColor(Color.ORANGE);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(8.0f);
        partCountry.addCell(cellCountry);

        chk = new Chunk("Agent: ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setBackgroundColor(Color.lightGray);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(8.0f);
        partCountry.addCell(cellCountry);

        chk = new Chunk("   " + (headerDOB.getAgent() != null ? headerDOB.getAgent().toUpperCase() : ""),
                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(8.0f);
        partCountry.addCell(cellCountry);

        //@@ Added by subrahmanyam for the WPBN ISSUE: 150460 ON 23/12/2008                
        if ("EXW".equalsIgnoreCase(headerDOB.getIncoTerms()) || "FAS".equalsIgnoreCase(headerDOB.getIncoTerms())
                || "FCA".equalsIgnoreCase(headerDOB.getIncoTerms())
                || "FOB".equalsIgnoreCase(headerDOB.getIncoTerms())) {
            chk = new Chunk("Place Of Acceptance: ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setBackgroundColor(Color.lightGray);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);
        } else {
            chk = new Chunk("Place Of Delivery: ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setBackgroundColor(Color.lightGray);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);
        }
        //@@ Ended by subrahmanyam for the WPBN ISSUE: 150460 ON 23/12/2008    

        chk = new Chunk("   " + (headerDOB.getCargoAcceptancePlace() != null
                ? headerDOB.getCargoAcceptancePlace().toUpperCase()
                : ""), FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(8.0f);
        partCountry.addCell(cellCountry);

        chk = new Chunk("Origin Port: ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setBackgroundColor(Color.lightGray);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(8.0f);
        partCountry.addCell(cellCountry);

        chk = new Chunk("   "
                + ((headerDOB.getOriginPortName() != null ? headerDOB.getOriginPortName().toUpperCase() + ", "
                        : ""))
                + (headerDOB.getOriginPortCountry() != null ? headerDOB.getOriginPortCountry().toUpperCase()
                        : ""),
                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(8.0f);
        partCountry.addCell(cellCountry);

        chk = new Chunk("Destination Port: ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setBackgroundColor(Color.lightGray);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(8.0f);
        partCountry.addCell(cellCountry);

        chk = new Chunk("   "
                + ((headerDOB.getDestPortName() != null ? headerDOB.getDestPortName().toUpperCase() + ", "
                        : ""))
                + (headerDOB.getDestPortCountry() != null ? headerDOB.getDestPortCountry().toUpperCase() : ""),
                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(8.0f);
        partCountry.addCell(cellCountry);

        // @@Commented by subrahmanyam for the enhancement #148546 on 09/12/2008            
        /* chk = new Chunk("Routing: ",FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
         cellCountry = new Cell(chk);
         cellCountry.setBackgroundColor(Color.lightGray);
         cellCountry.setNoWrap(true); cellCountry.setLeading(8.0f);
         partCountry.addCell(cellCountry);          
         chk = new Chunk("   "+(headerDOB.getRouting()!=null?headerDOB.getRouting():""),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
         cellCountry = new Cell(chk);
         cellCountry.setNoWrap(true); cellCountry.setLeading(8.0f);
         partCountry.addCell(cellCountry);
                
                
         chk = new Chunk("   "+(headerDOB.getRouting()!=null?headerDOB.getRouting().toUpperCase():""),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
         cellCountry = new Cell(chk);
         cellCountry.setNoWrap(true); cellCountry.setLeading(8.0f);
         partCountry.addCell(cellCountry);*/
        //@@ Ended by subrahmanyam for the enhanement #148546 on 09/12/2008             

        chk = new Chunk("Commodity or Product: ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setBackgroundColor(Color.lightGray);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(8.0f);
        partCountry.addCell(cellCountry);

        chk = new Chunk(
                "   " + (headerDOB.getCommodity() != null ? headerDOB.getCommodity().toUpperCase() : ""),
                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(8.0f);
        partCountry.addCell(cellCountry);

        chk = new Chunk("Type Of Service Quoted: ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setBackgroundColor(Color.lightGray);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(8.0f);
        partCountry.addCell(cellCountry);
        //@@Added by kiran.v on 04/11/2011 for Wpbn Issue -277534
        int index = headerDOB.getTypeOfService() != null ? headerDOB.getTypeOfService().length() : 0;
        if (index < 47)
            chk = new Chunk("   "
                    + (headerDOB.getTypeOfService() != null ? headerDOB.getTypeOfService().toUpperCase() : ""),
                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
        else
            chk = new Chunk(
                    "   " + (headerDOB.getTypeOfService() != null
                            ? headerDOB.getTypeOfService().toUpperCase().substring(0, 47) + "\n   "
                                    + headerDOB.getTypeOfService().toUpperCase().substring(47)
                            : ""),
                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
        // ended by kiran.v
        cellCountry = new Cell(chk);
        //@@commented by kiran.v on 03/11/2011 for Wpbn Issue
        //cellCountry.setNoWrap(true); 
        cellCountry.setLeading(8.0f);
        partCountry.addCell(cellCountry);

        //@@Added by Kameswari for the WPBN issue-146448 on 03/12/08
        int freqSize = frequency.size();
        for (int i = 0; i < freqSize; i++) {
            if (chargesSize > 1) {
                chk = new Chunk("Frequency (" + frequency_o.get(i) + "-" + frequency_d.get(i) + ")",
                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                cellCountry = new Cell(chk);
                cellCountry.setBackgroundColor(Color.lightGray);
                cellCountry.setNoWrap(true);
                cellCountry.setLeading(8.0f);
                partCountry.addCell(cellCountry);
                chk = new Chunk("   " + frequency.get(i).toString().toUpperCase(),
                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                cellCountry = new Cell(chk);
                cellCountry.setNoWrap(true);
                cellCountry.setLeading(8.0f);
                partCountry.addCell(cellCountry);
            } else {
                chk = new Chunk("Frequency ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                cellCountry = new Cell(chk);
                cellCountry.setBackgroundColor(Color.lightGray);
                cellCountry.setNoWrap(true);
                cellCountry.setLeading(8.0f);
                partCountry.addCell(cellCountry);
                chk = new Chunk("   " + frequency.get(i).toString().toUpperCase(),
                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                cellCountry = new Cell(chk);
                cellCountry.setNoWrap(true);
                cellCountry.setLeading(8.0f);
                partCountry.addCell(cellCountry);
            }
        }
        int carierSize = carrier.size();
        for (int i = 0; i < carierSize; i++) {
            if (chargesSize > 1) {
                chk = new Chunk("Carrier (" + carrier_o.get(i) + "-" + carrier_d.get(i) + ")",
                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                cellCountry = new Cell(chk);
                cellCountry.setBackgroundColor(Color.lightGray);
                cellCountry.setNoWrap(true);
                cellCountry.setLeading(8.0f);
                partCountry.addCell(cellCountry);
                chk = new Chunk("   " + carrier.get(i).toString().toUpperCase(),
                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                cellCountry = new Cell(chk);
                cellCountry.setNoWrap(true);
                cellCountry.setLeading(8.0f);
                partCountry.addCell(cellCountry);
            } else {
                chk = new Chunk("Carrier ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                cellCountry = new Cell(chk);
                cellCountry.setBackgroundColor(Color.lightGray);
                cellCountry.setNoWrap(true);
                cellCountry.setLeading(8.0f);
                partCountry.addCell(cellCountry);
                chk = new Chunk("   " + carrier.get(i).toString().toUpperCase(),
                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                cellCountry = new Cell(chk);
                cellCountry.setNoWrap(true);
                cellCountry.setLeading(8.0f);
                partCountry.addCell(cellCountry);
            }
        }
        int tTimeSize = transittime.size();
        for (int i = 0; i < tTimeSize; i++) {
            if (chargesSize > 1) {
                chk = new Chunk(transitTime + "(" + transit_o.get(i) + "-" + transit_d.get(i) + ")",
                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                cellCountry = new Cell(chk);
                cellCountry.setBackgroundColor(Color.lightGray);
                cellCountry.setNoWrap(true);
                cellCountry.setLeading(8.0f);
                partCountry.addCell(cellCountry);
                chk = new Chunk("   " + transittime.get(i).toString().toUpperCase(),
                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                cellCountry = new Cell(chk);
                cellCountry.setNoWrap(true);
                cellCountry.setLeading(8.0f);
                partCountry.addCell(cellCountry);
            } else {
                chk = new Chunk(transitTime + " ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                cellCountry = new Cell(chk);
                cellCountry.setBackgroundColor(Color.lightGray);
                cellCountry.setNoWrap(true);
                cellCountry.setLeading(8.0f);
                partCountry.addCell(cellCountry);
                chk = new Chunk("   " + transittime.get(i).toString().toUpperCase(),
                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                cellCountry = new Cell(chk);
                cellCountry.setNoWrap(true);
                cellCountry.setLeading(8.0f);
                partCountry.addCell(cellCountry);
            }
        }
        int rTvalSize = ratevalidity.size();
        for (int i = 0; i < rTvalSize; i++) {
            if (chargesSize > 1) {
                chk = new Chunk("Freight Rate Validity(" + validity_o.get(i) + "-" + validity_d.get(i) + ")",
                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                cellCountry = new Cell(chk);
                cellCountry.setBackgroundColor(Color.lightGray);
                cellCountry.setNoWrap(true);
                cellCountry.setLeading(8.0f);
                partCountry.addCell(cellCountry);
                chk = new Chunk("   " + ratevalidity.get(i).toString().toUpperCase(),
                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                cellCountry = new Cell(chk);
                cellCountry.setNoWrap(true);
                cellCountry.setLeading(8.0f);
                partCountry.addCell(cellCountry);
            } else {
                chk = new Chunk("Freight Rate Validity ",
                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                cellCountry = new Cell(chk);
                cellCountry.setBackgroundColor(Color.lightGray);
                cellCountry.setNoWrap(true);
                cellCountry.setLeading(8.0f);
                partCountry.addCell(cellCountry);
                chk = new Chunk("   " + ratevalidity.get(i).toString().toUpperCase(),
                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                cellCountry = new Cell(chk);
                cellCountry.setNoWrap(true);
                cellCountry.setLeading(8.0f);
                partCountry.addCell(cellCountry);
            }
        }
        //@@WPBN issue-146448 on 03/12/08
        chk = new Chunk("Incoterms: ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setBackgroundColor(Color.lightGray);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(8.0f);
        partCountry.addCell(cellCountry);

        chk = new Chunk(
                "   " + (headerDOB.getIncoTerms() != null ? headerDOB.getIncoTerms().toUpperCase() : ""),
                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(8.0f);
        partCountry.addCell(cellCountry);

        chk = new Chunk("Notes: ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setBackgroundColor(Color.lightGray);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(8.0f);
        partCountry.addCell(cellCountry);

        //@@ COmmented by subrahmanyam for the wpbn issue:145510  on 10/12/2008     
        /*  chk = new Chunk("   "+(headerDOB.getNotes()!=null?headerDOB.getNotes().toUpperCase()+'\n'+"nnnnnnnnnn":""),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setNoWrap(true); cellCountry.setLeading(8.0f);
        partCountry.addCell(cellCountry);*/
        //@@ Added by subrahmanyam for the wpbn issue: 145510on 10/12/2008          
        chk = new Chunk(" " + (headerDOB.getNotes() != null ? headerDOB.getNotes().toUpperCase() + '\n' : ""),
                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setLeading(8.0f);
        partCountry.addCell(cellCountry);
        //@@ ended by subrahmanyam for the wpbn issue: 145510  on 10/12/2008 

        chk = new Chunk("Date Effective: ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setBackgroundColor(Color.lightGray);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(8.0f);
        partCountry.addCell(cellCountry);

        chk = new Chunk("   " + (effDate[0] != null ? effDate[0] : ""),
                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(8.0f);
        partCountry.addCell(cellCountry);

        chk = new Chunk("Validity Of Quote: ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setBackgroundColor(Color.lightGray);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(8.0f);
        partCountry.addCell(cellCountry);

        chk = new Chunk("   " + (validUptoStr != null ? validUptoStr : "VALID UNTIL FURTHER NOTICE"),
                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(8.0f);
        partCountry.addCell(cellCountry);

        if (headerDOB.getPaymentTerms() != null && headerDOB.getPaymentTerms().trim().length() != 0) {
            chk = new Chunk("Payment Terms: ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setBackgroundColor(Color.lightGray);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk("   " + headerDOB.getPaymentTerms(),
                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);
        }

        document.add(partCountry);
        partCountry.complete();
        //System.out.println("After Page Country-------------------------------->");
        //Origin Charges
        //document.setMargins(10,10,10,10);
        // b1= writer.getPageNumber();

        ArrayList originCharges = finalDOB.getOriginChargesList();

        int[] originIndices = finalDOB.getSelectedOriginChargesListIndices();
        int originChargesSize = 0;
        if (originIndices != null)
            originChargesSize = originIndices.length;
        else
            originChargesSize = 0;

        //Destination
        ArrayList destCharges = finalDOB.getDestChargesList();
        int[] destIndices = finalDOB.getSelctedDestChargesListIndices();
        int destChargesSize = 0;
        if (destIndices != null)
            destChargesSize = destIndices.length;
        else
            destChargesSize = 0;

        //@@Added by Kameswari for the WPBN issue-146448
        charges = finalDOB.getLegDetails();
        chargesSize = charges.size();

        Table chargeCountry = null;
        //Table chargeCountry1= null;
        Cell cell = null;
        // float cellWidths[]   = {40,20,10,15,25};//@@Added by Kameswari for the WPBN issue - on 12/11/08
        float cellWidths[] = { 40, 20, 10, 15, 25, 15 };
        float cellWidths1 = 40;

        /* chk = new Chunk("Charge Name",FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
         Cell cell = new Cell(chk);
         cell.setHeader(true);
         cell.setBackgroundColor(Color.ORANGE);
         cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
         chargeCountry.addCell(cell);
                 
         chk = new Chunk("Breakpoint",FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
          cell = new Cell(chk);
         cell.setHeader(true);
         cell.setBackgroundColor(Color.ORANGE);
         cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
         chargeCountry.addCell(cell);
                 
         chk = new Chunk("Currency",FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
          cell = new Cell(chk);
         cell.setHeader(true);
         cell.setBackgroundColor(Color.ORANGE);
         cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
         chargeCountry.addCell(cell);
                 
         chk = new Chunk("Rate",FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
          cell = new Cell(chk);
         cell.setHeader(true);
         cell.setBackgroundColor(Color.ORANGE);
         cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
         chargeCountry.addCell(cell);
                 
         chk = new Chunk("Basis",FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
          cell = new Cell(chk);
         cell.setHeader(true);
         cell.setBackgroundColor(Color.ORANGE);
         cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
         chargeCountry.addCell(cell);           
                 
         chargeCountry.endHeaders();
         System.out.println("End of Charge Headers--------------------------------->");
         System.out.println("");*/
        //    boolean b3 = document.newPage();
        //  QuoteCharges chargesDOB           = null;
        ArrayList originChargeInfo = null;
        int originChargesInfoSize = 0;
        QuoteChargeInfo chargeInfo = null;
        if (originChargesSize > 0) {
            /*  if(b1>1)
             {
              chk = new Chunk("QUOTE REFERENCE:"+masterDOB.getQuoteId(),FontFactory.getFont("ARIAL", 10, Font.BOLD,Color.BLACK));
             cell = new Cell(chk);
             cell.setColspan(5);cell.setLeading(10.0f);
             cell.setBackgroundColor(Color.WHITE);                
             cell.setHeader(true);
             cell.setBorder(0);
             chargeCountry.addCell(cell); 
             }*/
            // chargeCountry  = new Table(5);
            chargeCountry = new Table(6);
            chargeCountry.setWidth(100);
            chargeCountry.setWidths(cellWidths);
            chargeCountry.setPadding(1);
            chargeCountry.setSpacing(0);
            chargeCountry.setOffset(5);
            chargeCountry.setBackgroundColor(Color.WHITE);
            chargeCountry.setBorderColor(Color.black);
            chargeCountry.setDefaultHorizontalAlignment(Element.ALIGN_CENTER);
            chargeCountry.setBorderWidth(1f);

            //@@Commented and Modified by Kameswari for the internal issue on 09/04/09
            /*chk = new Chunk("ORIGIN CHARGES",FontFactory.getFont("ARIAL", 8, Font.BOLD,Color.BLACK));
            cell = new Cell(chk);
            //cell.setColspan(5);/@@Added by Kameswari for the WPBN issue - on 12/11/08
            cell.setColspan(6);
            cell.setLeading(10.0f);
            cell.setBackgroundColor(Color.ORANGE);                
            cell.setHeader(true);
            chargeCountry.addCell(cell);*/
            //   boolean b = document.newPage();

            chk = new Chunk("Origin Charges", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cell = new Cell(chk);
            //cell.setColspan(5);/@@Added by Kameswari for the WPBN issue - on 12/11/08
            // cell.setColspan(6);
            cell.setLeading(10.0f);
            cell.setBackgroundColor(Color.ORANGE);
            cell.setHeader(true);
            chargeCountry.addCell(cell);
            chk = new Chunk("Weight Break Slab", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cell = new Cell(chk);
            //cell.setColspan(5);/@@Added by Kameswari for the WPBN issue - on 12/11/08
            // cell.setColspan(6);
            cell.setLeading(10.0f);
            cell.setBackgroundColor(Color.ORANGE);
            cell.setHeader(true);
            chargeCountry.addCell(cell);
            chk = new Chunk("Currency", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cell = new Cell(chk);
            //cell.setColspan(5);/@@Added by Kameswari for the WPBN issue - on 12/11/08
            // cell.setColspan(6);
            cell.setLeading(10.0f);
            cell.setBackgroundColor(Color.ORANGE);
            cell.setHeader(true);
            chargeCountry.addCell(cell);
            chk = new Chunk("Charge Rate", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cell = new Cell(chk);
            //cell.setColspan(5);/@@Added by Kameswari for the WPBN issue - on 12/11/08
            // cell.setColspan(6);
            cell.setLeading(10.0f);
            cell.setBackgroundColor(Color.ORANGE);
            cell.setHeader(true);
            chargeCountry.addCell(cell);
            chk = new Chunk("Basis", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell = new Cell(chk);
            //cell.setColspan(5);/@@Added by Kameswari for the WPBN issue - on 12/11/08
            // cell.setColspan(6);
            cell.setLeading(10.0f);
            cell.setBackgroundColor(Color.ORANGE);
            cell.setHeader(true);
            chargeCountry.addCell(cell);
            chk = new Chunk("Density Ratio", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cell = new Cell(chk);
            //cell.setColspan(5);/@@Added by Kameswari for the WPBN issue - on 12/11/08
            // cell.setColspan(6);
            cell.setLeading(10.0f);
            cell.setBackgroundColor(Color.ORANGE);
            cell.setHeader(true);
            chargeCountry.addCell(cell);

            //chargeCountry.endHeaders();

            for (int i = 0; i < originChargesSize; i++) {
                if (originIndices[i] != -1) {
                    chargesDOB = (QuoteCharges) originCharges.get(originIndices[i]);
                    logger.info("Origin Charges doPDFGeneration::" + i + ":" + chargesDOB); // newly added                  
                    originChargeInfo = chargesDOB.getChargeInfoList();
                    originChargesInfoSize = originChargeInfo.size();
                    int m = 0;//146455
                    String breakPoint = null;//146455
                    for (int k = 0; k < originChargesInfoSize; k++) {
                        chargeInfo = (QuoteChargeInfo) originChargeInfo.get(k);
                        if (k == 0) {
                            if ("B".equalsIgnoreCase(chargesDOB.getSellBuyFlag())
                                    || "S".equalsIgnoreCase(chargesDOB.getSellBuyFlag()))
                                chk = new Chunk(
                                        chargesDOB.getExternalName() != null ? chargesDOB.getExternalName()
                                                : "",
                                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                            else
                                chk = new Chunk(
                                        chargesDOB.getChargeDescriptionId() != null
                                                ? chargesDOB.getChargeDescriptionId()
                                                : "",
                                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));

                            cell = new Cell(chk);
                            cell.setLeading(9.0f);
                            //cell.setRowspan(originChargesInfoSize);
                            //cell.setBorderWidth(0);
                            cell.setBackgroundColor(Color.lightGray);
                            cell.setHeader(true);
                            cell.setHorizontalAlignment(cell.ALIGN_LEFT);
                            chargeCountry.addCell(cell);
                        } else {
                            cell = new Cell("");
                            cell.setLeading(8.0f);
                            cell.setBackgroundColor(Color.lightGray);
                            cell.setHeader(true);
                            cell.setBorderWidth(0);
                            chargeCountry.addCell(cell);
                        }
                        //@@ Commented by subrahmanyam for 146455 on 19/02/09
                        /* chk = new Chunk((chargeInfo.getBreakPoint()!=null && !"Absolute".equalsIgnoreCase(chargeInfo.getBreakPoint()) && !"Percent".equalsIgnoreCase(chargeInfo.getBreakPoint()))?chargeInfo.getBreakPoint().toUpperCase():"",FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                         cell = new Cell(chk);cell.setLeading(8.0f);
                         cell.setBackgroundColor(Color.lightGray);
                         cell.setHeader(true);
                         chargeCountry.addCell(cell);*/
                        //@@ Added by subrahmanyam for 146455 on 19/02/09                      

                        if (chargeInfo.getBreakPoint().equalsIgnoreCase("MIN")) {
                            breakPoint = "Min";
                        }

                        else if (chargeInfo.getBreakPoint().equalsIgnoreCase("FLAT")) {
                            breakPoint = "Flat";
                        }

                        else if (chargeInfo.getBreakPoint().equalsIgnoreCase("MAX")) {
                            breakPoint = "Max";
                        } else if (chargeInfo.getBreakPoint().equalsIgnoreCase("CSF")) {
                            breakPoint = "Absolute";
                        } else if (chargeInfo.getBreakPoint().equalsIgnoreCase("SURCHARGE")) {
                            breakPoint = "Percent";
                        } else if (chargeInfo.getBreakPoint().equalsIgnoreCase("BASE")) {
                            breakPoint = "Base";
                        }

                        else {
                            breakPoint = chargeInfo.getBreakPoint();
                        }

                        chk = new Chunk(
                                breakPoint != null && !"Absolute".equalsIgnoreCase(breakPoint)
                                        && !"Percent".equalsIgnoreCase(breakPoint) ? breakPoint : "",
                                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                        cell = new Cell(chk);
                        cell.setLeading(8.0f);
                        cell.setBackgroundColor(Color.lightGray);
                        cell.setHeader(true);
                        chargeCountry.addCell(cell);
                        //@@ Ended by subrahmanyam for 146455 on 19/02/09                

                        chk = new Chunk(chargeInfo.getCurrency(),
                                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                        cell = new Cell(chk);
                        cell.setHeader(true);
                        cell.setLeading(8.0f);
                        //cell.setBackgroundColor(Color.lightGray);
                        chargeCountry.addCell(cell);
                        //@@Modified by kiran.v on 03/11/2011 for Wpbn Issue
                        // chk = new Chunk(df.format(chargeInfo.getSellRate())+(chargeInfo.isPercentValue()?" %":""),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                        //@@Added by kiran.v on 16/11/2011
                        percent = chargeInfo.isPercentValue() ? "%" : "";
                        chk = new Chunk(round1(chargeInfo.getSellRate(), percent) + (percent),
                                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                        cell = new Cell(chk);
                        cell.setHeader(true);
                        cell.setLeading(8.0f);
                        chargeCountry.addCell(cell);

                        chk = new Chunk(chargeInfo.getBasis() != null ? chargeInfo.getBasis() : "",
                                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                        cell = new Cell(chk);
                        cell.setHeader(true);
                        cell.setLeading(8.0f);
                        cell.setHorizontalAlignment(cell.ALIGN_LEFT);
                        chargeCountry.addCell(cell);

                        //@@Added by Kameswari for the WPBN issue- on 12/11/08
                        chk = new Chunk(chargeInfo.getRatio() != null ? "1:" + chargeInfo.getRatio() : "",
                                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                        cell = new Cell(chk);
                        cell.setHeader(true);
                        cell.setLeading(8.0f);
                        cell.setHorizontalAlignment(cell.ALIGN_LEFT);
                        chargeCountry.addCell(cell);

                    }
                }
            }
            document.add(chargeCountry);
        }

        // boolean b1 = document.newPage();

        //Freight Charges
        //document.setMargins(10,10,10,10);
        //System.out.println("After         Origin Charges --------------------------------->");
        int freightChargesSize = 0;
        int freightChargesInfoSize = 0;
        int[] frtIndices = null;
        //QuoteFreightLegSellRates       legCharges       = null;
        // ArrayList                      freightCharges = null;
        ArrayList freightChargeInfo = null;
        int m = 0;
        String breakPoint = null;
        String space = "";
        Table country = null;
        // b2= writer.getPageNumber();

        if (chargesSize > 0) {
            // chargeCountry  = new Table(5);//@@Added by Kameswari for the WPBN issue - on 12/11/08
            chargeCountry = new Table(6);
            chargeCountry.setWidth(100);
            chargeCountry.setWidths(cellWidths);
            chargeCountry.setPadding(1);
            chargeCountry.setSpacing(0);
            chargeCountry.setOffset(5);
            chargeCountry.setBackgroundColor(Color.WHITE);
            chargeCountry.setBorderColor(Color.black);
            chargeCountry.setDefaultHorizontalAlignment(Element.ALIGN_CENTER);
            chargeCountry.setBorderWidth(1f);
            chargeCountry.setTableFitsPage(true);//@@Added by kameswari 

            for (int i = 0; i < chargesSize; i++) {
                legCharges = (QuoteFreightLegSellRates) charges.get(i);
                freightCharges = legCharges.getFreightChargesList();

                frtIndices = legCharges.getSelectedFreightChargesListIndices();

                if (frtIndices != null)
                    freightChargesSize = frtIndices.length;
                else
                    freightChargesSize = 0;

                if (i == 0 && freightChargesSize > 0) {
                    //@@Commented and Modified by Kameswari for the internal issue on 09/04/09
                    /* chk = new Chunk("FREIGHT CHARGES",FontFactory.getFont("ARIAL", 8, Font.BOLD,Color.BLACK));
                     cell = new Cell(chk);
                     cell.setLeading(8.0f);
                     cell.setBackgroundColor(Color.ORANGE);
                    //cell.setColspan(5);//@@Added by Kameswari for the WPBN issue - on 12/11/08
                     cell.setColspan(6);
                     cell.setHeader(true);
                     chargeCountry.addCell(cell);*/
                    chk = new Chunk("Freight Charges",
                            FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                    cell = new Cell(chk);
                    //cell.setColspan(5);/@@Added by Kameswari for the WPBN issue - on 12/11/08
                    // cell.setColspan(6);
                    cell.setLeading(10.0f);
                    cell.setBackgroundColor(Color.ORANGE);
                    cell.setHeader(true);
                    chargeCountry.addCell(cell);
                    chk = new Chunk("Weight Break Slab",
                            FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                    cell = new Cell(chk);
                    //cell.setColspan(5);/@@Added by Kameswari for the WPBN issue - on 12/11/08
                    // cell.setColspan(6);
                    cell.setLeading(10.0f);
                    cell.setBackgroundColor(Color.ORANGE);
                    cell.setHeader(true);
                    chargeCountry.addCell(cell);
                    chk = new Chunk("Currency", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                    cell = new Cell(chk);
                    //cell.setColspan(5);/@@Added by Kameswari for the WPBN issue - on 12/11/08
                    // cell.setColspan(6);
                    cell.setLeading(10.0f);
                    cell.setBackgroundColor(Color.ORANGE);
                    cell.setHeader(true);
                    chargeCountry.addCell(cell);
                    chk = new Chunk("Charge Rate", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                    cell = new Cell(chk);
                    //cell.setColspan(5);/@@Added by Kameswari for the WPBN issue - on 12/11/08
                    // cell.setColspan(6);
                    cell.setLeading(10.0f);
                    cell.setBackgroundColor(Color.ORANGE);
                    cell.setHeader(true);
                    chargeCountry.addCell(cell);
                    chk = new Chunk("Basis", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                    cell = new Cell(chk);
                    //cell.setColspan(5);/@@Added by Kameswari for the WPBN issue - on 12/11/08
                    // cell.setColspan(6);
                    cell.setLeading(10.0f);
                    cell.setBackgroundColor(Color.ORANGE);
                    cell.setHeader(true);
                    chargeCountry.addCell(cell);
                    chk = new Chunk("Density Ratio", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                    cell = new Cell(chk);
                    //cell.setColspan(5);/@@Added by Kameswari for the WPBN issue - on 12/11/08
                    // cell.setColspan(6);
                    cell.setLeading(10.0f);
                    cell.setBackgroundColor(Color.ORANGE);
                    cell.setHeader(true);
                    chargeCountry.addCell(cell);

                    //chargeCountry.endHeaders();
                }
                for (int j = 0; j < freightChargesSize; j++) {
                    chargesDOB = (QuoteCharges) freightCharges.get(frtIndices[j]);
                    logger.info("Freight Charges doPDFGeneration::" + j + ":" + chargesDOB); // newly added
                    freightChargeInfo = chargesDOB.getChargeInfoList();
                    freightChargesInfoSize = freightChargeInfo.size();
                    int count = 0; //Added by subrahmanyam for 181430
                    String tempDesc = "";//Added by subrahmanyam for 181430
                    for (int k = 0; k < freightChargesInfoSize; k++) {
                        String temp = "";
                        if (k > 0) {
                            chargeInfo = (QuoteChargeInfo) freightChargeInfo.get(k - 1);
                            temp = chargeInfo.getRateDescription();

                        }
                        chargeInfo = (QuoteChargeInfo) freightChargeInfo.get(k);
                        if (k == 0) {
                            chk = new Chunk(legCharges.getOrigin() + "-" + legCharges.getDestination(),
                                    FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                            cell = new Cell(chk);
                            // cell.setColspan(5);//@@Added by Kameswari for the WPBN issue - on 12/11/08
                            cell.setColspan(6);
                            cell.setBackgroundColor(Color.WHITE);
                            cell.setLeading(8.0f);
                            chargeCountry.addCell(cell);
                            //@@ Commented by subrahmanyam for 146455 on 19/02/09                      
                            /*//chk = new Chunk(chargesDOB.getChargeDescriptionId()!=null?chargesDOB.getChargeDescriptionId():"Freight Rate",FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                            chk = new Chunk(chargeInfo.getRateDescription(),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                            cell = new Cell(chk);cell.setHeader(true);
                            //cell.setRowspan(freightChargesInfoSize);
                            //cell.setBorderWidth(0);
                            cell.setBackgroundColor(Color.lightGray);
                            cell.setHorizontalAlignment(cell.ALIGN_LEFT);
                            cell.setLeading(9.0f);                         
                            chargeCountry.addCell(cell);*/
                            //@@Added by subrahmanyam for 146455 on 18/02/09
                            String fRate = "";
                            if ("FREIGHT RATE".equalsIgnoreCase(chargeInfo.getRateDescription())) {
                                fRate = "Freight Rate";
                            } else
                                fRate = chargeInfo.getRateDescription();
                            chk = new Chunk(fRate != null ? fRate : "",
                                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                            cell = new Cell(chk);
                            cell.setHeader(true);
                            //cell.setRowspan(freightChargesInfoSize);
                            //cell.setBorderWidth(0);
                            cell.setBackgroundColor(Color.lightGray);
                            cell.setHorizontalAlignment(cell.ALIGN_LEFT);
                            cell.setLeading(9.0f);
                            chargeCountry.addCell(cell);
                            //@@ Ended by subrahmanym for 146455 on 18/02/09
                        } else if (temp.equalsIgnoreCase(chargeInfo.getRateDescription())) {
                            cell = new Cell("");
                            cell.setBackgroundColor(Color.lightGray);
                            cell.setHeader(true);
                            cell.setBorderWidth(0);
                            cell.setLeading(9.0f);
                            chargeCountry.addCell(cell);
                        } else {
                            //@@ Commented by subrahmanyam for 146455 on 19/02/09  
                            /* chk = new Chunk(chargeInfo.getRateDescription(),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                               cell = new Cell(chk);cell.setHeader(true);
                               //cell.setRowspan(freightChargesInfoSize);
                               //cell.setBorderWidth(0);
                               cell.setBackgroundColor(Color.lightGray);
                               cell.setHorizontalAlignment(cell.ALIGN_LEFT);
                               cell.setLeading(9.0f);                         
                               chargeCountry.addCell(cell);*/
                            //@@Added by subrahmanyam for 146455 on 18/02/09                          
                            String rateDes = "";
                            if ("FUEL SURCHARGE".equalsIgnoreCase(chargeInfo.getRateDescription())) {
                                rateDes = "Fuel Surcharge";
                            } else if ("SECURITY SURCHARGE".equalsIgnoreCase(chargeInfo.getRateDescription())) {
                                rateDes = "Security Surcharge";
                            } else if ("C.A.F%".equalsIgnoreCase(chargeInfo.getRateDescription())
                                    || "CAF%".equalsIgnoreCase(chargeInfo.getRateDescription())) {
                                rateDes = "C.a.f%";
                            } else if ("B.A.F".equalsIgnoreCase(chargeInfo.getRateDescription())
                                    || "BAF".equalsIgnoreCase(chargeInfo.getRateDescription())) {
                                rateDes = "B.a.f";
                            } else if ("P.S.S".equalsIgnoreCase(chargeInfo.getRateDescription())
                                    || "PSS".equalsIgnoreCase(chargeInfo.getRateDescription())) {
                                rateDes = "P.s.s";
                            } else if ("C.S.F".equalsIgnoreCase(chargeInfo.getRateDescription())
                                    || "CSF".equalsIgnoreCase(chargeInfo.getRateDescription())) {
                                rateDes = "C.s.f";
                            } else {

                                rateDes = chargeInfo.getRateDescription();
                                rateDes = rateDes != null && rateDes.indexOf(".") != -1
                                        ? rateDes.substring(0, rateDes.length() - 3)
                                        : (rateDes != null && rateDes.indexOf("-") == -1) ? rateDes
                                                : rateDes.substring(0, rateDes.length() - 3); // Added by Gowtham to trim surcharge Description
                            }

                            chk = new Chunk(rateDes != null ? rateDes : "",
                                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                            cell = new Cell(chk);
                            cell.setHeader(true);
                            //cell.setRowspan(freightChargesInfoSize);
                            //cell.setBorderWidth(0);
                            cell.setBackgroundColor(Color.lightGray);
                            cell.setHorizontalAlignment(cell.ALIGN_LEFT);
                            cell.setLeading(9.0f);
                            chargeCountry.addCell(cell);
                            //@@ Ended by subrahmanym for 146455 on 18/02/09
                        }
                        /*if("FSBASIC".equalsIgnoreCase(chargeInfo.getBreakPoint())||"SSBASIC".equalsIgnoreCase(chargeInfo.getBreakPoint()))
                            chargeInfo.setBreakPoint("Basic Charge");
                        if("FSMIN".equalsIgnoreCase(chargeInfo.getBreakPoint())||"SSMIN".equalsIgnoreCase(chargeInfo.getBreakPoint()))
                            chargeInfo.setBreakPoint("Minimum");
                        if("FSKG".equalsIgnoreCase(chargeInfo.getBreakPoint())||"SSKG".equalsIgnoreCase(chargeInfo.getBreakPoint()))
                            chargeInfo.setBreakPoint("Flat Rate");*/

                        if (chargeInfo.getBreakPoint().equalsIgnoreCase("BAFM3")
                                || chargeInfo.getBreakPoint().equalsIgnoreCase("PSSM3")) {
                            //breakPoint = "Or";   // commented by subrahmanyam for the wpbn id: 181430 on 08-sep-09
                            // added by subrahmanyam for the wpbn id: 181430 on 08-sep-09
                            if (count == 0 || (count == 1
                                    && tempDesc.equalsIgnoreCase(chargeInfo.getRateDescription()))) {
                                breakPoint = "Flat";
                                count = 0;
                            } else
                                breakPoint = "Absolute";
                            //ended for 181430

                        } else if (chargeInfo.getBreakPoint().equalsIgnoreCase("CAF%")
                                || chargeInfo.getBreakPoint().equalsIgnoreCase("CAFPFPERCENT")) {
                            if (count == 0 || (count == 1
                                    && tempDesc.equalsIgnoreCase(chargeInfo.getRateDescription()))) {
                                breakPoint = "Percent";
                                count = 0;
                            } else
                                breakPoint = "Absolute";

                        }
                        //@@ Commented by subrahmanyam for 146455 on 19/02/09  
                        /*else if(chargeInfo.getBreakPoint().equalsIgnoreCase("BAFMIN")||chargeInfo.getBreakPoint().equalsIgnoreCase("CAFMIN")
                                   ||chargeInfo.getBreakPoint().equalsIgnoreCase("PSSMIN")||chargeInfo.getBreakPoint().equalsIgnoreCase("FSMIN")||chargeInfo.getBreakPoint().equalsIgnoreCase("SSMIN")
                                   )
                         {
                                breakPoint = "Min";
                         }*/
                        //@@Added by subrahmanyam for 146455 on 18/02/09  
                        else if (chargeInfo.getBreakPoint().equalsIgnoreCase("BAFMIN")
                                || chargeInfo.getBreakPoint().equalsIgnoreCase("CAFMIN")
                                || chargeInfo.getBreakPoint().equalsIgnoreCase("PSSMIN")
                                || chargeInfo.getBreakPoint().equalsIgnoreCase("FSMIN")
                                || chargeInfo.getBreakPoint().equalsIgnoreCase("SSMIN")
                                || chargeInfo.getBreakPoint().equalsIgnoreCase("MIN")
                                || chargeInfo.getBreakPoint().toUpperCase().endsWith("MIN")) // Added by gowtham to show surcharge description as min
                        {
                            // added by subrahmanyam for the wpbn id: 181430 on 08-sep-09
                            if (chargeInfo.getBreakPoint().equalsIgnoreCase("BAFMIN")
                                    || chargeInfo.getBreakPoint().equalsIgnoreCase("CAFMIN")
                                    || chargeInfo.getBreakPoint().equalsIgnoreCase("PSSMIN")) {
                                count = 1;
                                tempDesc = chargeInfo.getRateDescription();
                            }
                            //ended for 181430

                            breakPoint = "Min";
                        } else if (chargeInfo.getBreakPoint().equalsIgnoreCase("FSBASIC")
                                || chargeInfo.getBreakPoint().equalsIgnoreCase("SSBASIC")
                                || chargeInfo.getBreakPoint().toUpperCase().endsWith("BASIC")) //Added by gowtham to show surcharge description as min
                        {
                            breakPoint = "Basic";
                        }
                        /* else if(chargeInfo.getBreakPoint().equalsIgnoreCase("FSKG")||chargeInfo.getBreakPoint().equalsIgnoreCase("SSKG"))
                           {
                                  breakPoint = "Flat";
                        }*/
                        //Added by subrahmanyam for 154381
                        else if (chargeInfo.getBreakPoint().equalsIgnoreCase("FSKG")
                                || chargeInfo.getBreakPoint().equalsIgnoreCase("SSKG")
                                || chargeInfo.getBreakPoint().equalsIgnoreCase("FLAT")
                                || chargeInfo.getBreakPoint().toUpperCase().endsWith("FLAT"))//Added by gowtham to show surcharge description as min
                        {
                            breakPoint = "Flat";
                        } else if (chargeInfo.getBreakPoint().equalsIgnoreCase("CSF")
                                || chargeInfo.getBreakPoint().toUpperCase().endsWith("ABSOLUTE"))// Added by Gowtham on 18-Feb2011
                        {
                            breakPoint = "Absolute";
                        } else if (chargeInfo.getBreakPoint().equalsIgnoreCase("SURCHARGE")
                                || chargeInfo.getBreakPoint().toUpperCase().endsWith("PERCENT"))// Added by Gowtham on 18-Feb2011)
                        {
                            breakPoint = "Percent";
                        } else if (chargeInfo.getBreakPoint().endsWith("CAF")
                                || chargeInfo.getBreakPoint().endsWith("BAF")
                                || chargeInfo.getBreakPoint().endsWith("CSF")
                                || chargeInfo.getBreakPoint().endsWith("PSS")
                                || chargeInfo.getBreakPoint().endsWith("caf")
                                || chargeInfo.getBreakPoint().endsWith("baf")
                                || chargeInfo.getBreakPoint().endsWith("csf")
                                || chargeInfo.getBreakPoint().endsWith("pss")) {
                            m = chargeInfo.getBreakPoint().length() - 3;
                            breakPoint = chargeInfo.getBreakPoint().substring(0, m);

                        }
                        //@@Added by subrahmanyam for 146455 on 18/02/09  
                        else if (chargeInfo.getBreakPoint().toUpperCase().equalsIgnoreCase("MAX")) // Added by Gowtham on18-Feb-2011
                        {
                            breakPoint = "Max";
                        } else {
                            breakPoint = chargeInfo.getBreakPoint().length() > 5
                                    ? chargeInfo.getBreakPoint().substring(0, 4)
                                    : chargeInfo.getBreakPoint(); // Modified by Gowtham for Quote View Issue on 17 Feb2011
                        }
                        /* chk = new Chunk(chargeInfo.getBreakPoint()!=null?chargeInfo.getBreakPoint().toUpperCase():"",FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                         cell = new Cell(chk);cell.setHeader(true);
                         cell.setBackgroundColor(Color.lightGray);cell.setLeading(8.0f);
                         chargeCountry.addCell(cell);*/
                        //chk = new Chunk(breakPoint!=null?breakPoint.toUpperCase():"",FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                        chk = new Chunk(breakPoint != null ? breakPoint : "",
                                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                        cell = new Cell(chk);
                        cell.setHeader(true);
                        cell.setBackgroundColor(Color.lightGray);
                        cell.setLeading(8.0f);
                        chargeCountry.addCell(cell);

                        chk = new Chunk(chargeInfo.getCurrency(),
                                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                        cell = new Cell(chk);
                        cell.setHeader(true);
                        cell.setLeading(8.0f);
                        //cell.setBackgroundColor(Color.lightGray);
                        chargeCountry.addCell(cell);

                        chk = new Chunk(df.format(chargeInfo.getSellRate()),
                                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                        cell = new Cell(chk);
                        cell.setHeader(true);
                        cell.setLeading(8.0f);
                        chargeCountry.addCell(cell);

                        chk = new Chunk(chargeInfo.getBasis() != null ? chargeInfo.getBasis() : "",
                                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                        cell = new Cell(chk);
                        cell.setHeader(true);
                        cell.setLeading(8.0f);
                        cell.setHorizontalAlignment(cell.ALIGN_LEFT);
                        chargeCountry.addCell(cell);
                        //@@Added by Kameswari for the WPBN issue- on 12/11/08
                        chk = new Chunk(chargeInfo.getRatio() != null ? "1:" + chargeInfo.getRatio() : "",
                                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                        cell = new Cell(chk);
                        cell.setHeader(true);
                        cell.setLeading(8.0f);
                        cell.setHorizontalAlignment(cell.ALIGN_LEFT);
                        chargeCountry.addCell(cell);

                    }
                }
            }
            document.add(chargeCountry);

        } //end of if(charge)
          //  boolean b2 = document.newPage();

        //System.out.println("After Charges--------------------------------->");
        //document.setMargins(10,10,10,10);
        ArrayList destChargeInfo = null;
        //int[]      destChargeInfo        =  null;
        int destChargesInfoSize = 0;
        if (destChargesSize > 0) {
            //chargeCountry  = new Table(5);
            chargeCountry = new Table(6);
            chargeCountry.setWidth(100);
            chargeCountry.setWidths(cellWidths);
            chargeCountry.setPadding(1);
            chargeCountry.setSpacing(0);
            chargeCountry.setOffset(5);
            chargeCountry.setBackgroundColor(Color.WHITE);
            chargeCountry.setBorderColor(Color.black);
            chargeCountry.setDefaultHorizontalAlignment(Element.ALIGN_CENTER);
            chargeCountry.setBorderWidth(1f);
            chargeCountry.setTableFitsPage(true);

            //    b2 = writer.getPageNumber();

            /*   if(b2-b1>0)
               {
                chk = new Chunk("QUOTE REFERENCE:"+masterDOB.getQuoteId(),FontFactory.getFont("ARIAL", 10, Font.BOLD,Color.BLACK));
               cell = new Cell(chk);
               cell.setColspan(5);cell.setLeading(10.0f);
               cell.setBackgroundColor(Color.WHITE);                
               cell.setHeader(true);
               cell.setBorder(0);
               chargeCountry.addCell(cell); 
               }*/
            //@@Commented and Modified by Kameswari for the internal issue on 09/04/09
            /* chk = new Chunk("DESTINATION CHARGES",FontFactory.getFont("ARIAL", 8, Font.BOLD,Color.BLACK));
            cell = new Cell(chk);
            cell.setBackgroundColor(Color.ORANGE);
            // cell.setColspan(5);/@@Added by Kameswari for the WPBN issue - on 12/11/08
            cell.setColspan(6);
            cell.setLeading(8.0f);
            cell.setHeader(true);
            chargeCountry.addCell(cell);*/
            //chargeCountry.endHeaders();
            chk = new Chunk("Destination Charges", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cell = new Cell(chk);
            //cell.setColspan(5);/@@Added by Kameswari for the WPBN issue - on 12/11/08
            // cell.setColspan(6);
            cell.setLeading(10.0f);
            cell.setBackgroundColor(Color.ORANGE);
            cell.setHeader(true);
            chargeCountry.addCell(cell);
            chk = new Chunk("Weight Break Slab", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cell = new Cell(chk);
            //cell.setColspan(5);/@@Added by Kameswari for the WPBN issue - on 12/11/08
            // cell.setColspan(6);
            cell.setLeading(10.0f);
            cell.setBackgroundColor(Color.ORANGE);
            cell.setHeader(true);
            chargeCountry.addCell(cell);
            chk = new Chunk("Currency", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cell = new Cell(chk);
            //cell.setColspan(5);/@@Added by Kameswari for the WPBN issue - on 12/11/08
            // cell.setColspan(6);
            cell.setLeading(10.0f);
            cell.setBackgroundColor(Color.ORANGE);
            cell.setHeader(true);
            chargeCountry.addCell(cell);
            chk = new Chunk("Charge Rate", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cell = new Cell(chk);
            //cell.setColspan(5);/@@Added by Kameswari for the WPBN issue - on 12/11/08
            // cell.setColspan(6);
            cell.setLeading(10.0f);
            cell.setBackgroundColor(Color.ORANGE);
            cell.setHeader(true);
            chargeCountry.addCell(cell);
            chk = new Chunk("Basis", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cell = new Cell(chk);
            //cell.setColspan(5);/@@Added by Kameswari for the WPBN issue - on 12/11/08
            // cell.setColspan(6);
            cell.setLeading(10.0f);
            cell.setBackgroundColor(Color.ORANGE);
            cell.setHeader(true);
            chargeCountry.addCell(cell);
            chk = new Chunk("Density Ratio", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cell = new Cell(chk);
            //cell.setColspan(5);/@@Added by Kameswari for the WPBN issue - on 12/11/08
            // cell.setColspan(6);
            cell.setLeading(10.0f);
            cell.setBackgroundColor(Color.ORANGE);
            cell.setHeader(true);
            chargeCountry.addCell(cell);

            for (int j = 0; j < destChargesSize; j++) {
                if (destIndices[j] != -1) {
                    chargesDOB = (QuoteCharges) destCharges.get(destIndices[j]);
                    logger.info("Destination Charges doPDFGeneration::" + j + ":" + chargesDOB); // newly added                      
                    destChargeInfo = chargesDOB.getChargeInfoList();
                    destChargesInfoSize = destChargeInfo.size();
                    for (int k = 0; k < destChargesInfoSize; k++) {
                        chargeInfo = (QuoteChargeInfo) destChargeInfo.get(k);
                        if (k == 0) {
                            if ("B".equalsIgnoreCase(chargesDOB.getSellBuyFlag())
                                    || "S".equalsIgnoreCase(chargesDOB.getSellBuyFlag()))
                                chk = new Chunk(
                                        chargesDOB.getExternalName() != null ? chargesDOB.getExternalName()
                                                : "",
                                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                            else
                                chk = new Chunk(
                                        chargesDOB.getChargeDescriptionId() != null
                                                ? chargesDOB.getChargeDescriptionId()
                                                : "",
                                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                            cell = new Cell(chk);
                            cell.setLeading(9.0f);
                            //cell.setRowspan(destChargesInfoSize);
                            //cell.setBorderWidth(0);
                            cell.setBackgroundColor(Color.lightGray);
                            cell.setHeader(true);
                            cell.setHorizontalAlignment(cell.ALIGN_LEFT);
                            chargeCountry.addCell(cell);
                        } else {
                            cell = new Cell("");
                            cell.setBackgroundColor(Color.lightGray);
                            cell.setHeader(true);
                            cell.setBorderWidth(0);
                            cell.setLeading(9.0f);
                            chargeCountry.addCell(cell);
                        }

                        //@@Commented by subrahmanyam for 146455 on 18/02/09                   
                        /* chk = new Chunk((chargeInfo.getBreakPoint()!=null && !"Absolute".equalsIgnoreCase(chargeInfo.getBreakPoint()) && !"Percent".equalsIgnoreCase(chargeInfo.getBreakPoint()))?chargeInfo.getBreakPoint().toUpperCase():"",FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                         cell = new Cell(chk);cell.setLeading(8.0f);
                         cell.setBackgroundColor(Color.lightGray);
                         cell.setHeader(true);
                         chargeCountry.addCell(cell);*/
                        //@@Added by subrahmanyam for 146455 on 18/02/09                        
                        if (chargeInfo.getBreakPoint().equalsIgnoreCase("MIN")) {
                            breakPoint = "Min";
                        }

                        else if (chargeInfo.getBreakPoint().equalsIgnoreCase("FLAT")) {
                            breakPoint = "Flat";
                        } else if (chargeInfo.getBreakPoint().equalsIgnoreCase("CSF")) {
                            breakPoint = "Absolute";
                        } else if (chargeInfo.getBreakPoint().equalsIgnoreCase("SURCHARGE")) {
                            breakPoint = "Percent";
                        } else if (chargeInfo.getBreakPoint().equalsIgnoreCase("MAX")) {
                            breakPoint = "Max";
                        } else if (chargeInfo.getBreakPoint().equalsIgnoreCase("BASE")) {
                            breakPoint = "Base";
                        }

                        else {
                            breakPoint = chargeInfo.getBreakPoint();
                        }

                        chk = new Chunk(
                                breakPoint != null && !"Absolute".equalsIgnoreCase(breakPoint)
                                        && !"Percent".equalsIgnoreCase(breakPoint) ? breakPoint : "",
                                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                        cell = new Cell(chk);
                        cell.setLeading(8.0f);
                        cell.setBackgroundColor(Color.lightGray);
                        cell.setHeader(true);
                        chargeCountry.addCell(cell);
                        //@@Ended by subrahmanyam for 146455 on 18/02/09   

                        chk = new Chunk(chargeInfo.getCurrency(),
                                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                        cell = new Cell(chk);
                        cell.setHeader(true);
                        cell.setLeading(8.0f);
                        //cell.setBackgroundColor(Color.lightGray);
                        chargeCountry.addCell(cell);
                        //@@Modified by kiran.v on 03/11/2011 for Wpbn Issue
                        // chk = new Chunk(df.format(chargeInfo.getSellRate())+(chargeInfo.isPercentValue()?" %":""),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                        //@@Added by kiran.v on 16/11/2011
                        percent = chargeInfo.isPercentValue() ? "%" : "";
                        chk = new Chunk(round1(chargeInfo.getSellRate(), percent) + (percent),
                                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                        cell = new Cell(chk);
                        cell.setHeader(true);
                        cell.setLeading(8.0f);
                        chargeCountry.addCell(cell);

                        chk = new Chunk(chargeInfo.getBasis() != null ? chargeInfo.getBasis() : "",
                                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                        cell = new Cell(chk);
                        cell.setHorizontalAlignment(cell.ALIGN_LEFT);
                        cell.setHeader(true);
                        cell.setLeading(8.0f);
                        chargeCountry.addCell(cell);
                        //@@Added by Kameswari for the WPBN issue- on 12/11/08
                        chk = new Chunk(chargeInfo.getRatio() != null ? "1:" + chargeInfo.getRatio() : "",
                                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                        cell = new Cell(chk);
                        cell.setHeader(true);
                        cell.setLeading(8.0f);
                        cell.setHorizontalAlignment(cell.ALIGN_LEFT);
                        chargeCountry.addCell(cell);
                    }
                }
            }
            document.add(chargeCountry);
        }
        if (finalDOB.getExternalNotes() != null && finalDOB.getExternalNotes().length > 0) {
            Table notes = new Table(1, finalDOB.getExternalNotes().length + 1);
            notes.setWidth(100);
            notes.setPadding(1);
            notes.setSpacing(0);
            notes.setOffset(5);
            notes.setBackgroundColor(Color.WHITE);
            notes.setBorderColor(Color.black);
            //@@Commented and Modified by Kameswari for the internal issue on 08/04/09
            notes.setDefaultHorizontalAlignment(Element.ALIGN_LEFT);
            notes.setBorderWidth(1f);
            Cell notesCell;

            chk = new Chunk("NOTES", FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.BLACK));
            notesCell = new Cell(chk);
            notesCell.setHeader(true);
            notesCell.setLeading(8.0f);
            notesCell.setBackgroundColor(Color.WHITE);
            notes.addCell(notesCell);
            for (int i = 0; i < finalDOB.getExternalNotes().length; i++) {
                chk = new Chunk(finalDOB.getExternalNotes()[i] != null ? finalDOB.getExternalNotes()[i] : "",
                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                notesCell = new Cell(chk);
                notesCell.setLeading(8.0f);
                notes.addCell(notesCell);
            }
            document.add(notes);
        }

        if (contents != null && contents.length > 0) {
            content = new Table(1);
            content.setOffset(5);
            content.setWidth(100);
            content.setPadding(1);
            content.setSpacing(0);
            content.setBackgroundColor(Color.WHITE);
            content.setBorderColor(Color.black);
            content.setBorderWidth(1f);
            content.setTableFitsPage(true);
            Cell cellContent = null;
            int hFLen = headFoot.length;

            for (int i = 0; i < hFLen; i++) {
                if (headFoot[i] != null && "F".equalsIgnoreCase(headFoot[i])) {
                    chk = new Chunk(contents[i], FontFactory.getFont("ARIAL", 7, Font.ITALIC, Color.BLACK));
                    /////////////////chk.setUnderline(+1f,-2f);

                    cellContent = new Cell(chk);
                    cellContent.setBorder(0);
                    cellContent.setLeading(8.0f);
                    cellContent.setBackgroundColor(Color.LIGHT_GRAY);
                    if ("L".equalsIgnoreCase(aligns[i]))
                        cellContent.setHorizontalAlignment(cellContent.ALIGN_LEFT);
                    else if ("C".equalsIgnoreCase(aligns[i]))
                        cellContent.setHorizontalAlignment(cellContent.ALIGN_CENTER);
                    else if ("R".equalsIgnoreCase(aligns[i]))
                        cellContent.setHorizontalAlignment(cellContent.ALIGN_RIGHT);
                    content.addCell(cellContent);
                }
            }
            document.add(content);
        }

        document.close();

        //System.out.println("After     document Close----------------------------------------->");
        // write ByteArrayOutputStream to the ServletOutputStream            
        // ServletOutputStream sout = response.getOutputStream();
        //baos.writeTo(sout);
        //System.out.println("after writer");
        // sout.flush();
        //dataList  = (ArrayList)  remote.sendEmail(dataList);
        // Thread.sleep(1000);

        String file_tsmp = "" + new java.sql.Timestamp((new java.util.Date()).getTime())
                + masterDOB.getQuoteId();
        file_tsmp = file_tsmp.replaceAll("\\:", "");
        file_tsmp = file_tsmp.replaceAll("\\.", "");
        file_tsmp = file_tsmp.replaceAll("\\-", "");
        file_tsmp = file_tsmp.replaceAll(" ", "");
        File f = new File("Quote.pdf");
        FileOutputStream fileOutputStream = new FileOutputStream(f);
        baos.writeTo(fileOutputStream);
        //@@Added by Kameswari for the WPBN issue-80440
        PdfReader reader = new PdfReader("Quote.pdf");
        int n = reader.getNumberOfPages();
        File fs = new File("Quote" + file_tsmp + ".pdf");

        // we create a stamper that will copy the document to a new file
        PdfStamper stamp = new PdfStamper(reader, new FileOutputStream(fs));

        // adding some metadata
        // adding content to each page

        int k = 0;
        PdfContentByte under = null;
        PdfContentByte over = null;
        BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED);
        while (k < n) {
            k++;
            over = stamp.getOverContent(k);
            under = stamp.getOverContent(k);
            over.beginText();
            over.setFontAndSize(bf, 8);
            over.setTextMatrix(15, 15);
            over.showText("page " + k + " of " + n);
            if (k > 1) {
                // over.setFontAndSize(bf, 10);
                over.setFontAndSize(bf, 7);
                over.showText(
                        "                                                                                                    QUOTE REFERENCE:"
                                + masterDOB.getQuoteId());
                //@@ Added by subrahmanyam for WPBN:146452 on 12/12/2008               
                over.endText();
                over.beginText();
                over.showText(
                        "                                                                                                                                CUSTOMER NAME: "
                                + headerDOB.getCustomerName() + "\n\n\n");//subrahmanyam 12/12/2008

                //@@ Ended by subrahmanyam for WPBN ISSUE:146452 on 12/12/2008               

            }
            over.endText();
        }
        stamp.close();
        //@@WPBN issue-80440    
        file = new File("Concatenated.pdf" + file_tsmp);
        pdfFilesList.add((String) file.getName());
        //@@Added by Kameswari for the WPBN issue-61289
        //@@ Added by subrahmanyam for the  WPBN ISSUE:146460 on 29/01/09             
        if (finalDOB.getAttachmentDOBList().size() == 0
                && "View".equalsIgnoreCase(request.getParameter("Operation"))) {

            home = (QMSQuoteSessionHome) LookUpBean.getEJBHome("QMSQuoteSessionBean");//146460
            remote = home.create();//146460
            filesList = remote.getQuoteAttachmentDtls(finalDOB);
            if (filesList != null) {
                finalDOB.setAttachmentDOBList(filesList);
            }
        }
        //@@ Ended by subrahmanyam for the WPBN ISSUE: 146460 on 29/01/09   
        if (finalDOB.getAttachmentDOBList() != null) {
            //filesList = finalDOB.getAttachmentDOBList(); // commented for for 192431 on 16-dec-09
            //@@ Added by subrahmanyam for 192431 on 16-dec-09
            if ("pdf".equalsIgnoreCase(request.getParameter("pdf"))) {
                home = (QMSQuoteSessionHome) LookUpBean.getEJBHome("QMSQuoteSessionBean");
                remote = home.create();//146460
                filesList = remote.getQuoteAttachmentDtls(finalDOB);
            } else
                filesList = finalDOB.getAttachmentDOBList();
            // ended for 192431 on 16-dec-09

            int fileListSize = filesList.size();
            for (int i = 0; i < fileListSize; i++) {
                attachmentDOB = (QuoteAttachmentDOB) filesList.get(i);
                FileOutputStream fileStream = new FileOutputStream(attachmentDOB.getFileName());
                fileStream.write(attachmentDOB.getPdfFile());
                pdfFilesList.add((String) attachmentDOB.getFileName());
            }
        }
        if (pdfFilesList.size() > 1) {
            for (int l = 1; l < pdfFilesList.size(); l++) {
                FileInputStream inputStream = new FileInputStream((String) pdfFilesList.get(l));
                buffer = new byte[inputStream.available()];
                inputStream.read(buffer);
                bufferList.add(buffer);
                inputStream.close();
            }
        }

        // buffer = concatPDF(pdfFilesList);GOVIND COMMENTED 
        //@@WPBN issue-61289  

        //@@ Commented By Subrahmanyam for enhancement 146460           
        /* if("on".equalsIgnoreCase(request.getParameter("print")))
        {     
                
                
                 
                  
            request.getSession().setAttribute("QuoteOuptutStream",fs);
            request.getSession().setAttribute("filepdf",buffer); //@@Added by Kameswari for the WPBN issue-61289
                
                
          }*/
        //@@ Added by subrahmanyam for the enhancement 146460
        if ("PDF".equalsIgnoreCase(request.getParameter("pdf"))
                || "on".equalsIgnoreCase(request.getParameter("print"))) {
            request.getSession().setAttribute("QuoteOuptutStream", fs);
            request.getSession().setAttribute("filepdf", bufferList);
        }
        //@@ Ended by subrahmanyam for the enhancement 146460
        //f.delete();
        //baos.close();

        String[] contactPersons = masterDOB.getCustContactNames();
        String contactName = "";

        String filename = "Annexure" + file_tsmp + ".pdf";
        StringBuffer subject = new StringBuffer("DHL Global Forwarding Quotation,");
        String body = "";

        if (!finalDOB.isMultiModalQuote()) {
            if (masterDOB.getShipmentMode() == 1)
                subject.append(" Airfreight ");
            if (masterDOB.getShipmentMode() == 2)
                subject.append(" Seafreight ");
            else if (masterDOB.getShipmentMode() == 4)
                subject.append(" Truckfreight ");
        } else {
            subject.append(" Multi-Modal ");
        }

        subject.append((headerDOB.getOriginCountry() != null ? headerDOB.getOriginCountry().toUpperCase() : ""))
                .append(" to ")
                .append((headerDOB.getDestinationCountry() != null
                        ? headerDOB.getDestinationCountry().toUpperCase()
                        : ""));
        subject.append(" Quote Reference ");
        if (finalDOB.getUpdatedReportDOB() != null)
            subject.append(request.getAttribute("quoteId")).append(" Replacing ")
                    .append(finalDOB.getUpdatedReportDOB().getQuoteId());
        else
            subject.append(masterDOB.getQuoteId() != null ? masterDOB.getQuoteId() + ""
                    : request.getAttribute("quoteId"));
        //Commented By Kishore Podili For Multiple Zone Codes: 236286
        //if(masterDOB.getShipperZipCode()==null || masterDOB.getConsigneeZipCode()==null)
        // {
        if ((finalDOB.getPickZoneZipMap() != null && finalDOB.getPickZoneZipMap().size() > 0)
                || (finalDOB.getDeliveryZoneZipMap() != null && finalDOB.getDeliveryZoneZipMap().size() > 0))

            doGenerateCartagePDF(filename, finalDOB, request, response);
        //}
        try {
            if ("Y".equalsIgnoreCase(finalDOB.getFlagsDOB().getEmailFlag())) {
                // mailFlag  = 1;
                //finalDOB.getFlagsDOB().setQuoteStatusFlag("PEN");//@@Quote is Pending
                //ReportsSessionBeanHome home      = (ReportsSessionBeanHome)LookUpBean.getEJBHome("ReportsSessionBean");
                //ReportsSession remote   = (ReportsSession)home.create();
                //@@Modified by kameswari for the WPBN issue-61289
                //String to_emailIds = finalDOB.getHeaderDOB().getCustEmailId();
                String to_emailIds = null;
                if ("Y".equalsIgnoreCase(masterDOB.getSalesPersonFlag()))
                    to_emailIds = finalDOB.getHeaderDOB().getCustEmailId() + ','
                            + masterDOB.getSalesPersonEmail();
                else
                    to_emailIds = finalDOB.getHeaderDOB().getCustEmailId();
                //@@WPBN issue-61289
                to_emailIds = to_emailIds.replaceAll(";", ",");

                //System.out.println("Before Sending Mail------------------------------>");

                if (contactPersons != null) {
                    int contPersonLen = contactPersons.length;
                    for (int i = 0; i < contPersonLen; i++) {
                        mailFlag = 1;

                        // if(i<contactPersons.length)//@@Added by Kameswari for the WPBN issue-61289
                        //    {
                        if (masterDOB.getCustomerContactsEmailIds()[i] != null
                                && masterDOB.getCustomerContactsEmailIds()[i].trim().length() != 0) {

                            contactName = masterDOB.getCustContactNames()[i];
                            if (masterDOB.getCustContactNames()[i].indexOf("[") != -1)
                                contactName = contactName.substring(0,
                                        masterDOB.getCustContactNames()[i].indexOf("["));
                            /* if(finalDOB.getUpdatedReportDOB()!=null)
                             {
                                        
                                         
                                body = "Dear "+contactName+",\n\nThis is a replacement quotation reference "+request.getAttribute("quoteId")+",replacing "+finalDOB.getUpdatedReportDOB().getQuoteId()+
                                  ", due to a change in "+(finalDOB.getEmailChargeName()!=null?finalDOB.getEmailChargeName():finalDOB.getUpdatedReportDOB().getChangeDesc())+". All information is contained within the attachment. "+
                                 "Should you have any queries, please do not hesitate to contact us.\n\n\nRegards,\n"+masterDOB.getCreatorDetails()+"\n"+masterDOB.getTerminalAddress();
                             }
                             else
                             {
                               body = "Dear "+contactName+",\n\nThank you for the opportunity to provide this Quotation. All information is contained within the attachment."+
                                    " Should you have any queries, please do not hesitate to contact us.\n\n\nRegards,\n"+masterDOB.getCreatorDetails()+"\n"+masterDOB.getTerminalAddress();
                             }*/
                            //body  = "Dear "+contactName+",\n\n"+finalDOB.getEmailText()+"\n\n\nRegards,\n"+masterDOB.getCreatorDetails()+"\n"+masterDOB.getTerminalAddress();
                            if (finalDOB.getUpdatedReportDOB() != null) {
                                body = "Dear " + (contactName != null ? contactName : "")
                                        + ",\n\nThis is a replacement quotation reference "
                                        + request.getAttribute("quoteId") + ",replacing "
                                        + finalDOB.getUpdatedReportDOB().getQuoteId() + ", due to a change in "
                                        + (finalDOB.getEmailChargeName() != null ? finalDOB.getEmailChargeName()
                                                : finalDOB.getUpdatedReportDOB().getChangeDesc())
                                        + ",\n\n"
                                        + (finalDOB.getEmailText() != null ? finalDOB.getEmailText() : "")
                                        + "\n\n\n"
                                        + (masterDOB.getCreatorDetails() != null ? masterDOB.getCreatorDetails()
                                                : "")
                                        + "\n\n"
                                        + (masterDOB.getCompanyName() != null ? masterDOB.getCompanyName() : "")
                                        + "\n"
                                        + (masterDOB.getTerminalAddress() != null
                                                ? masterDOB.getTerminalAddress()
                                                : "")
                                        + "\n\n" + "Phone  "
                                        + (masterDOB.getPhoneNo() != null ? masterDOB.getPhoneNo() : "") + "\n"
                                        + "Fax    " + (masterDOB.getFaxNo() != null ? masterDOB.getFaxNo() : "")
                                        + "\n" + "Mobile "
                                        + (masterDOB.getMobileNo() != null ? masterDOB.getMobileNo() : "")
                                        + "\n\nEmail "
                                        + (masterDOB.getUserEmailId() != null ? masterDOB.getUserEmailId()
                                                : ""); //@@Modified by Kameswari for the WPBN issue-61303

                            } else {
                                body = "Dear " + (contactName != null ? contactName : "") + ",\n\n"
                                        + (finalDOB.getEmailText() != null ? finalDOB.getEmailText() : "")
                                        + "\n\n\n"
                                        + (masterDOB.getCreatorDetails() != null ? masterDOB.getCreatorDetails()
                                                : "")
                                        + "\n\n"
                                        + (masterDOB.getCompanyName() != null ? masterDOB.getCompanyName() : "")
                                        + "\n"
                                        + (masterDOB.getTerminalAddress() != null
                                                ? masterDOB.getTerminalAddress()
                                                : "")
                                        + "\n\n" + "Phone  "
                                        + (masterDOB.getPhoneNo() != null ? masterDOB.getPhoneNo() : "") + "\n"
                                        + "Fax    " + (masterDOB.getFaxNo() != null ? masterDOB.getFaxNo() : "")
                                        + "\n" + "Mobile "
                                        + (masterDOB.getMobileNo() != null ? masterDOB.getMobileNo() : "")
                                        + "\n\nEmail "
                                        + (masterDOB.getUserEmailId() != null ? masterDOB.getUserEmailId()
                                                : ""); //@@Modified by Kameswari for the WPBN issue-61303

                            }
                            if (masterDOB.getShipperZipCode() == null
                                    || masterDOB.getConsigneeZipCode() == null) {
                                if ((finalDOB.getPickZoneZipMap() != null
                                        && finalDOB.getPickZoneZipMap().size() > 0)
                                        || (finalDOB.getDeliveryZoneZipMap() != null
                                                && finalDOB.getDeliveryZoneZipMap().size() > 0))
                                    sendMail(finalDOB.getMasterDOB().getUserEmailId(),
                                            masterDOB.getCustomerContactsEmailIds()[i], subject.toString(),
                                            body, "Quote" + file_tsmp + ".pdf,Annexure" + file_tsmp + ".pdf",
                                            finalDOB.getAttachmentDOBList());
                                else
                                    sendMail(finalDOB.getMasterDOB().getUserEmailId(),
                                            masterDOB.getCustomerContactsEmailIds()[i], subject.toString(),
                                            body, "Quote" + file_tsmp + ".pdf",
                                            finalDOB.getAttachmentDOBList());
                            } else
                                sendMail(finalDOB.getMasterDOB().getUserEmailId(),
                                        masterDOB.getCustomerContactsEmailIds()[i], subject.toString(), body,
                                        "Quote" + file_tsmp + ".pdf", finalDOB.getAttachmentDOBList());
                            //  }
                            //@@Added by Kameswari for the WPBN issue-61289
                        }
                    }
                    if ("Y".equalsIgnoreCase(masterDOB.getSalesPersonFlag())) {
                        if (masterDOB.getShipperZipCode() == null || masterDOB.getConsigneeZipCode() == null) {
                            if ((finalDOB.getPickZoneZipMap() != null
                                    && finalDOB.getPickZoneZipMap().size() > 0)
                                    || (finalDOB.getDeliveryZoneZipMap() != null
                                            && finalDOB.getDeliveryZoneZipMap().size() > 0))

                                sendMail(finalDOB.getMasterDOB().getUserEmailId(),
                                        masterDOB.getSalesPersonEmail(), subject.toString(), body,
                                        "Quote" + file_tsmp + ".pdf,Annexure" + file_tsmp + ".pdf",
                                        finalDOB.getAttachmentDOBList());
                            else
                                sendMail(finalDOB.getMasterDOB().getUserEmailId(),
                                        masterDOB.getSalesPersonEmail(), subject.toString(), body,
                                        "Quote" + file_tsmp + ".pdf", finalDOB.getAttachmentDOBList());
                        } else
                            sendMail(finalDOB.getMasterDOB().getUserEmailId(), masterDOB.getSalesPersonEmail(),
                                    subject.toString(), body, "Quote" + file_tsmp + ".pdf",
                                    finalDOB.getAttachmentDOBList());

                    }
                    //@@ the WPBN issue-61289

                } else {
                    mailFlag = 0;

                    /*if(finalDOB.getUpdatedReportDOB()!=null)
                    {
                              
                      body = "Dear Customer,\n\nThis is a replacement quotation reference "+request.getAttribute("quoteId")+",replacing "+finalDOB.getUpdatedReportDOB().getQuoteId()+
                      ", due to a change in "+(finalDOB.getEmailChargeName()!=null?finalDOB.getEmailChargeName():finalDOB.getUpdatedReportDOB().getChangeDesc())+". All information is contained within the attachment. "+
                      "Should you have any queries, please do not hesitate to contact us.\n\n\nRegards,\n"+masterDOB.getCreatorDetails()+"\n"+masterDOB.getTerminalAddress();
                    }
                    else
                    {
                      body = "Dear Customer,\n\nThank you for the opportunity to provide this Quotation. All information is contained within the attachment."+
                         " Should you have any queries, please do not hesitate to contact us.\n\n\nRegards,\n"+masterDOB.getCreatorDetails()+"\n"+masterDOB.getTerminalAddress();
                    }*/
                    //
                    //body  ="Dear Customer,\n\n"+finalDOB.getEmailText()+"\n\n\nRegards,\n"+masterDOB.getCreatorDetails()+"\n"+masterDOB.getTerminalAddress();
                    /*body  = "Dear Customer,\n\n"+finalDOB.getEmailText()+"\n\n\n"+masterDOB.getCreatorDetails()+"\n\n"+masterDOB.getCompanyName()+
                    "\n"+masterDOB.getTerminalAddress()+"\n\n"+"Phone  "+masterDOB.getPhoneNo()+"\n"+"Fax    "+masterDOB.getFaxNo()+"\n"+"Mobile "+masterDOB.getMobileNo()+"\n\nEmail "+masterDOB.getUserEmailId(); */
                    //@@Modified by Kameswari for the WPBN issue-61303

                    if (finalDOB.getUpdatedReportDOB() != null) {
                        body = "Dear Customer,\n\nThis is a replacement quotation reference "
                                + request.getAttribute("quoteId") + ",replacing "
                                + finalDOB.getUpdatedReportDOB().getQuoteId() + ", due to a change in "
                                + (finalDOB.getEmailChargeName() != null ? finalDOB.getEmailChargeName()
                                        : finalDOB.getUpdatedReportDOB().getChangeDesc())
                                + ",\n\n" + (finalDOB.getEmailText() != null ? finalDOB.getEmailText() : "")
                                + "\n\n\n"
                                + (masterDOB.getCreatorDetails() != null ? masterDOB.getCreatorDetails() : "")
                                + "\n\n"
                                + (masterDOB.getCompanyName() != null ? masterDOB.getCompanyName() : "") + "\n"
                                + (masterDOB.getTerminalAddress() != null ? masterDOB.getTerminalAddress() : "")
                                + "\n\n" + "Phone  "
                                + (masterDOB.getPhoneNo() != null ? masterDOB.getPhoneNo() : "") + "\n"
                                + "Fax    " + (masterDOB.getFaxNo() != null ? masterDOB.getFaxNo() : "") + "\n"
                                + "Mobile " + (masterDOB.getMobileNo() != null ? masterDOB.getMobileNo() : "")
                                + "\n\nEmail "
                                + (masterDOB.getUserEmailId() != null ? masterDOB.getUserEmailId() : ""); //@@Modified by Kameswari for the WPBN issue-61303
                    } else {
                        body = "Dear Customer,\n\n"
                                + (finalDOB.getEmailText() != null ? finalDOB.getEmailText() : "") + "\n\n\n"
                                + (masterDOB.getCreatorDetails() != null ? masterDOB.getCreatorDetails() : "")
                                + "\n\n"
                                + (masterDOB.getCompanyName() != null ? masterDOB.getCompanyName() : "") + "\n"
                                + (masterDOB.getTerminalAddress() != null ? masterDOB.getTerminalAddress() : "")
                                + "\n\n" + "Phone  "
                                + (masterDOB.getPhoneNo() != null ? masterDOB.getPhoneNo() : "") + "\n"
                                + "Fax    " + (masterDOB.getFaxNo() != null ? masterDOB.getFaxNo() : "") + "\n"
                                + "Mobile " + (masterDOB.getMobileNo() != null ? masterDOB.getMobileNo() : "")
                                + "\n\nEmail "
                                + (masterDOB.getUserEmailId() != null ? masterDOB.getUserEmailId() : ""); //@@Modified by Kameswari for the WPBN issue-61303
                    }
                    if (masterDOB.getShipperZipCode() == null || masterDOB.getConsigneeZipCode() == null) {
                        if ((finalDOB.getPickZoneZipMap() != null && finalDOB.getPickZoneZipMap().size() > 0)
                                || (finalDOB.getDeliveryZoneZipMap() != null
                                        && finalDOB.getDeliveryZoneZipMap().size() > 0))
                            sendMail(finalDOB.getMasterDOB().getUserEmailId(), to_emailIds, subject.toString(),
                                    body, "Quote" + file_tsmp + ".pdf,Annexure" + file_tsmp + ".pdf",
                                    finalDOB.getAttachmentDOBList());
                        else
                            sendMail(finalDOB.getMasterDOB().getUserEmailId(), to_emailIds, subject.toString(),
                                    body, "Quote" + file_tsmp + ".pdf", finalDOB.getAttachmentDOBList());
                    } else
                        sendMail(finalDOB.getMasterDOB().getUserEmailId(), to_emailIds, subject.toString(),
                                body, "Quote" + file_tsmp + ".pdf", finalDOB.getAttachmentDOBList());
                }

                //System.out.println("End of mail sending and PDF Generation --------------------------------->");
            }
        } catch (Exception e) {
            //Logger.error(FILE_NAME,"Error while sending mail "+e); 
            logger.error(FILE_NAME + "Error while sending mail " + e);
            e.printStackTrace();
            mailFlag = 0;
        }
        try {
            if ("Y".equalsIgnoreCase(finalDOB.getFlagsDOB().getFaxFlag())) {
                //faxFlag   = 2;
                //finalDOB.getFlagsDOB().setQuoteStatusFlag("PEN");//@@Quote is Pending
                //ReportsSessionBeanHome home      = (ReportsSessionBeanHome)LookUpBean.getEJBHome("ReportsSessionBean");
                //ReportsSession  remote   = (ReportsSession)home.create();
                String customerFax = headerDOB.getCustFaxNo() != null ? headerDOB.getCustFaxNo() : "";
                String countrycode = headerDOB.getCustCountyCode() != null ? headerDOB.getCustCountyCode() : "";
                String contactFax = null;
                if ("SG".equalsIgnoreCase(countrycode)) {
                    if (customerFax != null && customerFax.length() > 0)
                        customerFax = "fax#" + customerFax + "@tcdhl.com";
                } else {
                    if (customerFax != null && customerFax.length() > 0)
                        customerFax = "ifax#" + customerFax + "@tcdhl.com";
                }

                if (contactPersons != null) {
                    int contPersonLen = contactPersons.length;
                    for (int i = 0; i < contPersonLen; i++) {
                        faxFlag = 2;
                        contactName = masterDOB.getCustContactNames()[i];
                        if (masterDOB.getCustContactNames()[i].indexOf("[") != -1)
                            contactName = contactName.substring(0,
                                    masterDOB.getCustContactNames()[i].indexOf("["));
                        if (masterDOB.getCustomerContactsFax()[i] != null
                                && masterDOB.getCustomerContactsFax()[i].trim().length() != 0) {
                            if ("SG".equalsIgnoreCase(countrycode))
                                contactFax = "fax#" + masterDOB.getCustomerContactsFax()[i] + "@tcdhl.com";
                            else
                                contactFax = "ifax#" + masterDOB.getCustomerContactsFax()[i] + "@tcdhl.com";

                            /*if(finalDOB.getUpdatedReportDOB()!=null)
                            {
                              body = "Dear "+contactName+",\n\nThis is a replacement quotation reference "+request.getAttribute("quoteId")+",replacing "+finalDOB.getUpdatedReportDOB().getQuoteId()+
                                 ", due to a change in "+(finalDOB.getEmailChargeName()!=null?finalDOB.getEmailChargeName():finalDOB.getUpdatedReportDOB().getChangeDesc())+". All information is contained within the attachment. "+
                                "Should you have any queries, please do not hesitate to contact us.\n\n\nRegards,\n"+masterDOB.getCreatorDetails()+"\n"+masterDOB.getTerminalAddress();
                             }
                            else
                            {
                              body = "Dear "+contactName+",\n\nThank you for the opportunity to provide this Quotation. All information is contained within the attachment."+
                                   " Should you have any queries, please do not hesitate to contact us.\n\n\nRegards,\n"+masterDOB.getCreatorDetails()+"\n"+masterDOB.getTerminalAddress();
                            }*/
                            // body  = "Dear "+contactName+",\n\n"+finalDOB.getEmailText()+"\n\n\nRegards,\n"+masterDOB.getCreatorDetails()+"\n"+masterDOB.getTerminalAddress();
                            if (finalDOB.getUpdatedReportDOB() != null) {
                                body = "Dear " + (contactName != null ? contactName : "")
                                        + ",\n\nThis is a replacement quotation reference "
                                        + request.getAttribute("quoteId") + ",replacing "
                                        + finalDOB.getUpdatedReportDOB().getQuoteId() + ", due to a change in "
                                        + (finalDOB.getEmailChargeName() != null ? finalDOB.getEmailChargeName()
                                                : finalDOB.getUpdatedReportDOB().getChangeDesc())
                                        + ",\n\n"
                                        + (finalDOB.getEmailText() != null ? finalDOB.getEmailText() : "")
                                        + "\n\n\n"
                                        + (masterDOB.getCreatorDetails() != null ? masterDOB.getCreatorDetails()
                                                : "")
                                        + "\n\n"
                                        + (masterDOB.getCompanyName() != null ? masterDOB.getCompanyName() : "")
                                        + "\n"
                                        + (masterDOB.getTerminalAddress() != null
                                                ? masterDOB.getTerminalAddress()
                                                : "")
                                        + "\n\n" + "Phone  "
                                        + (masterDOB.getPhoneNo() != null ? masterDOB.getPhoneNo() : "") + "\n"
                                        + "Fax    " + (masterDOB.getFaxNo() != null ? masterDOB.getFaxNo() : "")
                                        + "\n" + "Mobile "
                                        + (masterDOB.getMobileNo() != null ? masterDOB.getMobileNo() : "")
                                        + "\n\nEmail "
                                        + (masterDOB.getUserEmailId() != null ? masterDOB.getUserEmailId()
                                                : ""); //@@Modified by Kameswari for the WPBN issue-61303
                            } else {
                                body = "Dear " + (contactName != null ? contactName : "") + ",\n\n"
                                        + (finalDOB.getEmailText() != null ? finalDOB.getEmailText() : "")
                                        + "\n\n\n"
                                        + (masterDOB.getCreatorDetails() != null ? masterDOB.getCreatorDetails()
                                                : "")
                                        + "\n\n"
                                        + (masterDOB.getCompanyName() != null ? masterDOB.getCompanyName() : "")
                                        + "\n"
                                        + (masterDOB.getTerminalAddress() != null
                                                ? masterDOB.getTerminalAddress()
                                                : "")
                                        + "\n\n" + "Phone  "
                                        + (masterDOB.getPhoneNo() != null ? masterDOB.getPhoneNo() : "") + "\n"
                                        + "Fax    " + (masterDOB.getFaxNo() != null ? masterDOB.getFaxNo() : "")
                                        + "\n" + "Mobile "
                                        + (masterDOB.getMobileNo() != null ? masterDOB.getMobileNo() : "")
                                        + "\n\nEmail "
                                        + (masterDOB.getUserEmailId() != null ? masterDOB.getUserEmailId()
                                                : ""); //@@Modified by Kameswari for the WPBN issue-61303

                            }
                            if (masterDOB.getShipperZipCode() == null
                                    || masterDOB.getConsigneeZipCode() == null) {
                                if ((finalDOB.getPickZoneZipMap() != null
                                        && finalDOB.getPickZoneZipMap().size() > 0)
                                        || (finalDOB.getDeliveryZoneZipMap() != null
                                                && finalDOB.getDeliveryZoneZipMap().size() > 0))
                                    sendMail(finalDOB.getMasterDOB().getUserEmailId(), contactFax,
                                            subject.toString(), body,
                                            "Quote" + file_tsmp + ".pdf,Annexure" + file_tsmp + ".pdf",
                                            finalDOB.getAttachmentDOBList());
                                else
                                    sendMail(finalDOB.getMasterDOB().getUserEmailId(), contactFax,
                                            subject.toString(), body, "Quote" + file_tsmp + ".pdf",
                                            finalDOB.getAttachmentDOBList());
                            } else
                                sendMail(finalDOB.getMasterDOB().getUserEmailId(), contactFax,
                                        subject.toString(), body, "Quote" + file_tsmp + ".pdf",
                                        finalDOB.getAttachmentDOBList());
                        } else
                            faxFlag = 0;
                    }
                } else {
                    if (customerFax != null && customerFax.length() > 0) {
                        /* if(finalDOB.getUpdatedReportDOB()!=null)
                        {
                         body = "Dear Customer,\n\nThis is a replacement quotation reference "+request.getAttribute("quoteId")+",replacing "+finalDOB.getUpdatedReportDOB().getQuoteId()+
                               ", due to a change in "+(finalDOB.getEmailChargeName()!=null?finalDOB.getEmailChargeName():finalDOB.getUpdatedReportDOB().getChangeDesc())+". All information is contained within the attachment. "+
                               "Should you have any queries, please do not hesitate to contact us.\n\n\nRegards,\n"+masterDOB.getCreatorDetails()+"\n"+masterDOB.getTerminalAddress();
                        }
                        else
                        {
                         body = "Dear Customer,\n\nThank you for the opportunity to provide this Quotation. All information is contained within the attachment."+
                         " Should you have any queries, please do not hesitate to contact us.\n\n\nRegards,\n"+masterDOB.getCreatorDetails()+"\n"+masterDOB.getTerminalAddress();
                        }*/
                        // body  = "Dear Customer,\n\n"+finalDOB.getEmailText()+"\n\n\nRegards,\n"+masterDOB.getCreatorDetails()+"\n"+masterDOB.getTerminalAddress(); 
                        if (finalDOB.getUpdatedReportDOB() != null) {
                            body = "Dear Customer,\n\nThis is a replacement quotation reference "
                                    + request.getAttribute("quoteId") + ",replacing "
                                    + finalDOB.getUpdatedReportDOB().getQuoteId() + ", due to a change in "
                                    + (finalDOB.getEmailChargeName() != null ? finalDOB.getEmailChargeName()
                                            : finalDOB.getUpdatedReportDOB().getChangeDesc())
                                    + ",\n\n" + (finalDOB.getEmailText() != null ? finalDOB.getEmailText() : "")
                                    + "\n\n\n"
                                    + (masterDOB.getCreatorDetails() != null ? masterDOB.getCreatorDetails()
                                            : "")
                                    + "\n\n"
                                    + (masterDOB.getCompanyName() != null ? masterDOB.getCompanyName() : "")
                                    + "\n"
                                    + (masterDOB.getTerminalAddress() != null ? masterDOB.getTerminalAddress()
                                            : "")
                                    + "\n\n" + "Phone  "
                                    + (masterDOB.getPhoneNo() != null ? masterDOB.getPhoneNo() : "") + "\n"
                                    + "Fax    " + (masterDOB.getFaxNo() != null ? masterDOB.getFaxNo() : "")
                                    + "\n" + "Mobile "
                                    + (masterDOB.getMobileNo() != null ? masterDOB.getMobileNo() : "")
                                    + "\n\nEmail "
                                    + (masterDOB.getUserEmailId() != null ? masterDOB.getUserEmailId() : ""); //@@Modified by Kameswari for the WPBN issue-61303
                        } else {
                            body = "Dear Customer,\n\n"
                                    + (finalDOB.getEmailText() != null ? finalDOB.getEmailText() : "")
                                    + "\n\n\n"
                                    + (masterDOB.getCreatorDetails() != null ? masterDOB.getCreatorDetails()
                                            : "")
                                    + "\n\n"
                                    + (masterDOB.getCompanyName() != null ? masterDOB.getCompanyName() : "")
                                    + "\n"
                                    + (masterDOB.getTerminalAddress() != null ? masterDOB.getTerminalAddress()
                                            : "")
                                    + "\n\n" + "Phone  "
                                    + (masterDOB.getPhoneNo() != null ? masterDOB.getPhoneNo() : "") + "\n"
                                    + "Fax    " + (masterDOB.getFaxNo() != null ? masterDOB.getFaxNo() : "")
                                    + "\n" + "Mobile "
                                    + (masterDOB.getMobileNo() != null ? masterDOB.getMobileNo() : "")
                                    + "\n\nEmail "
                                    + (masterDOB.getUserEmailId() != null ? masterDOB.getUserEmailId() : ""); //@@Modified by Kameswari for the WPBN issue-61303
                        }
                        if (masterDOB.getShipperZipCode() == null || masterDOB.getConsigneeZipCode() == null) {
                            if ((finalDOB.getPickZoneZipMap() != null
                                    && finalDOB.getPickZoneZipMap().size() > 0)
                                    || (finalDOB.getDeliveryZoneZipMap() != null
                                            && finalDOB.getDeliveryZoneZipMap().size() > 0))
                                sendMail(finalDOB.getMasterDOB().getUserEmailId(), customerFax,
                                        subject.toString(), body,
                                        "Quote" + file_tsmp + ".pdf,Annexure" + file_tsmp + ".pdf",
                                        finalDOB.getAttachmentDOBList());
                            else
                                sendMail(finalDOB.getMasterDOB().getUserEmailId(), customerFax,
                                        subject.toString(), body, "Quote" + file_tsmp + ".pdf",
                                        finalDOB.getAttachmentDOBList());
                        } else
                            sendMail(finalDOB.getMasterDOB().getUserEmailId(), customerFax, subject.toString(),
                                    body, "Quote" + file_tsmp + ".pdf", finalDOB.getAttachmentDOBList());
                    } else
                        faxFlag = 0;
                }
            }
        } catch (Exception e) {
            //Logger.error(FILE_NAME,"Error while sending fax "+e); 
            logger.error(FILE_NAME + "Error while sending fax " + e);
            e.printStackTrace();
            faxFlag = 0;
        }
        if ("Y".equalsIgnoreCase(finalDOB.getFlagsDOB().getPrintFlag())) {
            //finalDOB.getFlagsDOB().setQuoteStatusFlag("PEN");//@@Quote is Pending
            printFlag = 4;
        } else {
            f.delete();
            File annexure = new File(filename);
            annexure.delete();
        }
        returnFlag = mailFlag + faxFlag + printFlag;
    } catch (Exception e) {
        e.printStackTrace();
        //Logger.error(FILE_NAME,"Error while generating the PDF"+e.toString());
        logger.error(FILE_NAME + "Error while generating the PDF" + e.toString());
        returnFlag = 0;
        //throw new Exception("Error while generating PDF format");
    } finally {
        try {
            //Method: doPDFGeneration Defect: PdfWriter is not closedSuggestion: Close and nullify the writer in the finally block.
            if (writer != null) {
                writer.close();
                writer = null;
            }
            charges = null;
            freightCharges = null;
            frequency = null;
            carrier = null;
            transittime = null;
            ratevalidity = null;
            frequency_o = null;
            frequency_d = null;
            carrier_o = null;
            carrier_d = null;
            transit_o = null;
            transit_d = null;
            validity_o = null;
            validity_d = null;
            filesList = null;

        } catch (Exception ex) {
            //Logger.error(FILE_NAME,"Exception caught :: finally :: insertFclValues() " + ex.toString() );
            logger.error(FILE_NAME + "Error while generating the PDF" + ex.toString());
        }
    }
    return returnFlag;
}

From source file:QMSQuoteController.java

License:Open Source License

private int doGenerateCartagePDF(String fileName, QuoteFinalDOB finalDOB, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    try { //System.out.println("Starting zone PDF Generation------------------------------>");
        DecimalFormat df = new DecimalFormat("###,###,###,##0.00");
        QuoteCartageRates pickQuoteCartageRates = null;
        QuoteCartageRates deliQuoteCartageRates = null;
        ArrayList pickUpQuoteCartageRates = null;
        ArrayList deliveryQuoteCartageRates = null;
        Set pickBreaks = null;//from   ww  w.  java 2s  .  com
        Set deliBreaks = null;
        Set pickUpZoneCodeSet = null;
        Set deliveryZoneCodeSet = null;
        HashMap pickUpZoneCodeMap = null;
        HashMap deliveryZoneCodeMap = null;
        HashMap pickUpZoneZipMap = null;
        HashMap deliveryZoneZipMap = null;
        ArrayList zipList = null;
        ArrayList pickupWeightBreaks = null;
        ArrayList delWeightBreaks = null;
        Iterator zones = null;
        Iterator breaksSet = null;
        int pickupWeightBreaksSize = 0;
        int delWeightBreaksSize = 0;
        HttpSession session = null;

        // Added by Kishore Podili For Charge Basis in the CartagePDF
        ArrayList pickupChargeBasisList = null;
        ArrayList delChargeBasisList = null;
        int pickupChargeBasisSize = 0;
        int delChargeBasisSize = 0;

        pickupChargeBasisList = finalDOB.getPickupChargeBasisList();
        delChargeBasisList = finalDOB.getDelChargeBasisList();

        if (pickupChargeBasisList != null)
            pickupChargeBasisSize = pickupChargeBasisList.size();
        if (delChargeBasisList != null)
            delChargeBasisSize = delChargeBasisList.size();

        //End Of Kishore Podili For Charge Basis in the CartagePDF

        pickUpQuoteCartageRates = finalDOB.getPickUpCartageRatesList();

        deliveryQuoteCartageRates = finalDOB.getDeliveryCartageRatesList();
        pickupWeightBreaks = finalDOB.getPickupWeightBreaks();
        // ArrayList pickupWeightBreaksFOr = finalDOB.getOriginChargesList();
        delWeightBreaks = finalDOB.getDeliveryWeightBreaks();

        if (pickupWeightBreaks != null)
            pickupWeightBreaksSize = pickupWeightBreaks.size();
        if (delWeightBreaks != null)
            delWeightBreaksSize = delWeightBreaks.size();

        QuoteHeader headerDOB = finalDOB.getHeaderDOB();
        QuoteMasterDOB masterDOB = finalDOB.getMasterDOB();
        ESupplyDateUtility eSupplyDateUtility = new ESupplyDateUtility();
        ESupplyGlobalParameters loginbean = (ESupplyGlobalParameters) request.getSession()
                .getAttribute("loginbean");
        eSupplyDateUtility.setPatternWithTime("DD-MONTH-YYYY");
        //eSupplyDateUtility.setPatternWithTime(loginbean.getUserPreferences().getDateFormat());
        //@@ Commented and added by subrahmanyam for the pbn issue 212006 on #26-jul-10
        /*          String[] strDate  = eSupplyDateUtility.getDisplayStringArray(headerDOB.getDateOfQuotation());
        String[] effDate  = eSupplyDateUtility.getDisplayStringArray(headerDOB.getEffDate());
        */
        String[] strDate = null;
        String[] effDate = null;
        if ("View".equalsIgnoreCase(request.getParameter("Operation"))) {
            if ("PDF".equalsIgnoreCase(request.getParameter("PDF"))) {
                strDate = eSupplyDateUtility.getDisplayStringArray(masterDOB.getModifiedDate());
                effDate = eSupplyDateUtility.getDisplayStringArray(masterDOB.getEffDate());
            } else {
                strDate = eSupplyDateUtility.getDisplayStringArray(masterDOB.getModifiedDate());
                effDate = eSupplyDateUtility.getDisplayStringArray(masterDOB.getCreatedDate());
            }

        } else {
            strDate = eSupplyDateUtility.getDisplayStringArray(headerDOB.getDateOfQuotation());
            effDate = eSupplyDateUtility.getDisplayStringArray(headerDOB.getEffDate());

        }

        String[] validDate;
        String validUptoStr = "";
        if (headerDOB.getValidUpto() != null) {
            validDate = eSupplyDateUtility.getDisplayStringArray(headerDOB.getValidUpto());
            validUptoStr = validDate[0];
        }

        StringBuffer attentionTo = new StringBuffer("");
        if (masterDOB.getCustContactNames() != null) {
            for (int i = 0; i < masterDOB.getCustContactNames().length; i++) {
                //Logger.info(FILE_NAME,"masterDOB.getCustContactNames()[i]::"+masterDOB.getCustomerContacts()[i]);
                attentionTo.append(
                        masterDOB.getCustContactNames()[i] != null ? masterDOB.getCustContactNames()[i] : "");
                if (i != (masterDOB.getCustContactNames().length - 1))
                    attentionTo.append(",");
            }
        }

        String chargeRate = null;

        //System.out.println("After getting data------------------------------>"+pickUpQuoteCartageRates.size());
        Document document = new Document(PageSize.A4, 54f, 54f, 68.4f, 68.4f);//@@ 36 points represent 0.5 inch            
        document.addTitle("Approved Report");
        document.addSubject("Report PDF");
        document.addKeywords("Test, Key Words");
        document.addAuthor("DHL");
        document.addCreator("Auto Generated through 4S DHL");
        document.addCreationDate();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PdfWriter writer = PdfWriter.getInstance(document, baos);
        document.open();

        int[] widths = { 10, 10, 10, 10, 10, 10, 12, 28 };

        Table mainT = new Table(8);
        mainT.setWidth(100);
        mainT.setWidths(widths);
        mainT.setBorderColor(Color.white);
        mainT.setPadding(1);
        mainT.setSpacing(0);

        Phrase headingPhrase = new Phrase("", FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.BLACK));
        Cell cellHeading = new Cell(headingPhrase);
        cellHeading.setBorderColor(new Color(255, 255, 255));
        cellHeading.setHorizontalAlignment(cellHeading.ALIGN_CENTER);
        cellHeading.setColspan(7);
        mainT.addCell(cellHeading);

        Cell imageCell = new Cell();
        java.net.URL url = getServletConfig().getServletContext().getResource("/images/DHLlogo.gif");
        Image img0 = Image.getInstance(url);
        //img0.scalePercent(75);
        imageCell.add(img0);
        imageCell.setHorizontalAlignment(imageCell.ALIGN_RIGHT);
        imageCell.setBorderWidth(0);
        imageCell.setNoWrap(true);
        imageCell.setColspan(1);
        mainT.addCell(imageCell);
        mainT.setAlignment(mainT.ALIGN_CENTER);
        document.add(mainT);

        //pickBreaks = pickQuoteCartageRates.getRates().keySet();
        //System.out.println("After Heading ----------------pickBreaks----------->");            
        Table partCountry = new Table(1, 4);
        partCountry.setBorderWidth(0);
        partCountry.setWidth(100);
        partCountry.setBorderColor(Color.black);
        //partCountry.setBackgroundColor(Color.ORANGE);
        partCountry.setPadding(1);
        partCountry.setSpacing(1);
        partCountry.setAutoFillEmptyCells(true);
        //partCountry.setTableFitsPage(true);
        partCountry.setAlignment(partCountry.ALIGN_CENTER);
        // partCountry.setWidth(100.0f);
        Cell cellCountry;
        Chunk chk;

        chk = new Chunk("ANNEXURE", FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setWidth("100");
        cellCountry.setBorderWidth(0);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(10.0f);
        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
        partCountry.addCell(cellCountry);

        if ("MY".equalsIgnoreCase(masterDOB.getCountryId())) {
            chk = new Chunk(
                    (headerDOB.getOriginCountry() != null ? headerDOB.getOriginCountry().toUpperCase() : "")
                            + " TO "
                            + (headerDOB.getDestinationCountry() != null
                                    ? headerDOB.getDestinationCountry().toUpperCase()
                                    : ""),
                    FontFactory.getFont("ARIAL", 16, Font.BOLD, Color.BLUE));
            cellCountry = new Cell(chk);
            cellCountry.setWidth("100");
            cellCountry.setBorderWidth(0);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(10.0f);
            cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
            partCountry.addCell(cellCountry);

            cellCountry = new Cell("");
            cellCountry.setBorderWidth(0);
            cellCountry.setLeading(5.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk(headerDOB.getCustomerName(),
                    FontFactory.getFont("ARIAL", 14, Font.BOLD, Color.BLUE));
            cellCountry = new Cell(chk);
            cellCountry.setHeader(true);
            cellCountry.setWidth("100");
            cellCountry.setBorderWidth(0);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(10.0f);
            cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
            partCountry.addCell(cellCountry);
            //Logger.info(FILE_NAME,"attentionTo.toString():"+attentionTo.toString());

            chk = new Chunk("ATTENTION TO: " + attentionTo.toString(),
                    FontFactory.getFont("ARIAL", 14, Font.BOLD, Color.BLUE));
            cellCountry = new Cell(chk);
            cellCountry.setWidth("100");
            cellCountry.setBorderWidth(0);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(10.0f);
            cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
            partCountry.addCell(cellCountry);

            cellCountry = new Cell("");
            cellCountry.setBorderWidth(0);
            cellCountry.setLeading(5.0f);
            partCountry.addCell(cellCountry);
        } else {
            chk = new Chunk(
                    (headerDOB.getOriginCountry() != null ? headerDOB.getOriginCountry().toUpperCase() : "")
                            + " TO "
                            + (headerDOB.getDestinationCountry() != null
                                    ? headerDOB.getDestinationCountry().toUpperCase()
                                    : ""),
                    FontFactory.getFont("ARIAL", 16, Font.BOLD, Color.RED));
            cellCountry = new Cell(chk);
            cellCountry.setWidth("100");
            cellCountry.setBorderWidth(0);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(10.0f);
            cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
            partCountry.addCell(cellCountry);

            cellCountry = new Cell("");
            cellCountry.setBorderWidth(0);
            cellCountry.setLeading(5.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk(headerDOB.getCustomerName(),
                    FontFactory.getFont("ARIAL", 14, Font.BOLD, Color.RED));
            cellCountry = new Cell(chk);
            cellCountry.setHeader(true);
            cellCountry.setWidth("100");
            cellCountry.setBorderWidth(0);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(10.0f);
            cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
            partCountry.addCell(cellCountry);
            //Logger.info(FILE_NAME,"attentionTo.toString():"+attentionTo.toString());

            chk = new Chunk("ATTENTION TO: " + attentionTo.toString(),
                    FontFactory.getFont("ARIAL", 14, Font.BOLD, Color.RED));
            cellCountry = new Cell(chk);
            cellCountry.setWidth("100");
            cellCountry.setBorderWidth(0);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(10.0f);
            cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
            partCountry.addCell(cellCountry);

            cellCountry = new Cell("");
            cellCountry.setBorderWidth(0);
            cellCountry.setLeading(5.0f);
            partCountry.addCell(cellCountry);
        }
        chk = new Chunk("QUOTE REFERENCE: " + masterDOB.getQuoteId(),
                FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setWidth("100");
        cellCountry.setBorderWidth(0);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(10.0f);
        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
        partCountry.addCell(cellCountry);
        chk = new Chunk("DATE OF QUOTATION: " + strDate[0],
                FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setWidth("100");
        cellCountry.setBorderWidth(0);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(10.0f);
        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
        partCountry.addCell(cellCountry);

        document.add(partCountry);

        Table partZone = null;
        Cell cellZone;
        if (pickUpQuoteCartageRates != null && pickUpQuoteCartageRates.size() > 0) {
            /*Set keys = null;            
            for(int i=0;i<pickUpQuoteCartageRates.size();i++)
            {              
              if(i==0)
              { 
                pickBreaks = new TreeSet();//@@This is needed as only a new Set Implementation obj supports addAll() 
              }
              pickQuoteCartageRates = (QuoteCartageRates) pickUpQuoteCartageRates.get(i);
              keys = pickQuoteCartageRates.getRates().keySet();
              pickBreaks.addAll(keys);
            }*/

            //if(pickBreaks!=null && pickBreaks.size()>0)
            //if(pickupWeightBreaks != null && pickupWeightBreaksSize>0)
            partZone = new Table(pickupWeightBreaksSize + 2);
            partZone.setOffset(30);
            partZone.setDefaultHorizontalAlignment(partZone.ALIGN_CENTER);
            partZone.setBorderWidth(1);
            partZone.setBorderColor(Color.black);
            partZone.setPadding(1);
            partZone.setSpacing(1);
            partZone.setAutoFillEmptyCells(true);
            partZone.setWidth(100);
            //partZone.setTableFitsPage(true);
            //@@ Added by subrahmanyam for the enhancement #147062 on 09/12/2008
            chk = new Chunk("PICKUP CARTAGE RATES AT: " + headerDOB.getOriginLocName(),
                    FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.RED));
            cellZone = new Cell(chk);
            cellZone.setNoWrap(true);
            cellZone.setHeader(true);
            cellZone.setVerticalAlignment(cellZone.ALIGN_BOTTOM);
            cellZone.setLeading(10.0f);
            cellZone.setBackgroundColor(Color.WHITE);
            cellZone.setColspan(pickupWeightBreaksSize + 2);
            partZone.addCell(cellZone);
            //@@ Ended by subrahmanyam for the enhancement #147062 on 09/12/2008
            chk = new Chunk("PICKUP CARTAGE RATES", FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.BLACK));
            cellZone = new Cell(chk);
            cellZone.setNoWrap(true);
            cellZone.setHeader(true);
            cellZone.setVerticalAlignment(cellZone.ALIGN_BOTTOM);
            cellZone.setLeading(10.0f);
            cellZone.setBackgroundColor(Color.ORANGE);
            cellZone.setColspan(pickupWeightBreaksSize + 2);
            partZone.addCell(cellZone);

            chk = new Chunk("Zone", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cellZone = new Cell(chk);
            //cellZone.setNoWrap(true);
            cellZone.setLeading(8.0f);
            cellZone.setHeader(true);
            cellZone.setBackgroundColor(Color.LIGHT_GRAY);
            partZone.addCell(cellZone);

            chk = new Chunk("Currency", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cellZone = new Cell(chk);
            //cellZone.setNoWrap(true);
            cellZone.setHeader(true);
            cellZone.setLeading(8.0f);
            cellZone.setBackgroundColor(Color.LIGHT_GRAY);
            partZone.addCell(cellZone);
            //breaksSet = pickBreaks.iterator();  // logger.info("breaksSetbreaksSet::"+breaksSet);
            /*while(breaksSet.hasNext())
            {              
              chk = new Chunk((String)breaksSet.next(),FontFactory.getFont("ARIAL", 8, Font.BOLD,Color.BLACK));
              cellZone = new Cell(chk);              
              cellZone.setNoWrap(true);
              cellZone.setHeader(true);
              partZone.addCell(cellZone);
            }*/
            //if(pickupWeightBreaks!=null)
            //{
            //logger.info("pickupWeightBreaks"+pickupWeightBreaks);
            for (int i = 0; i < pickupWeightBreaksSize; i++) {
                chk = new Chunk((String) pickupWeightBreaks.get(i),
                        FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                cellZone = new Cell(chk);
                //cellZone.setNoWrap(true);
                cellZone.setLeading(8.0f);
                cellZone.setHeader(true);
                cellZone.setBackgroundColor(Color.LIGHT_GRAY);
                partZone.addCell(cellZone);
            }

            //Added By Kishore For the ChargeBasis in the Annexure PDF on 06-Jun-11
            chk = new Chunk("");
            cellZone = new Cell(chk);
            cellZone.setLeading(8.0f);
            // cellZone.setHeader(true);
            // cellZone.setBackgroundColor(Color.LIGHT_GRAY);
            partZone.addCell(cellZone);

            chk = new Chunk("");
            cellZone = new Cell(chk);
            cellZone.setLeading(8.0f);
            //cellZone.setHeader(true);
            //cellZone.setBackgroundColor(Color.LIGHT_GRAY);
            partZone.addCell(cellZone);

            for (int i = 0; i < pickupChargeBasisSize; i++)////commented by Brahmaiah.R on 31/5/2012 for WPBN issue 304241
            {
                chk = new Chunk(toTitleCase((String) pickupChargeBasisList.get(i)),
                        FontFactory.getFont("ARIAL", 7, Font.BOLD, Color.BLACK));

                cellZone = new Cell(chk);
                //cellZone.setNoWrap(true);
                cellZone.setLeading(8.0f);
                cellZone.setHeader(true);
                //cellZone.setBackgroundColor(Color.LIGHT_GRAY);
                partZone.addCell(cellZone);
            }
            ////added by Brahmaiah.R on 31/5/2012 for WPBN issue 304241
            /*    for(int J=0;J<originChargesSize;J++)
                {
                  if(originIndices[J] !=-1)
                  {
                  chargesDOB                = (QuoteCharges)originCharges.get(originIndices[J]);
                   logger.info("Origin Charges doPDFGeneration::"+J+":"+chargesDOB); // newly added                  
                  originChargeInfo        = chargesDOB.getChargeInfoList();
                  originChargesInfoSize   = originChargeInfo.size();
                  int m =0;
              String breakPoint = null;
                  for(int k=0;k<originChargesInfoSize;k++)
                  {
                    chargeInfo = (QuoteChargeInfo)originChargeInfo.get(k);
                    String chargeBasis = (String)(chargeInfo.getBasis());
                   // chargeBasis  = df.format(Double.parseDouble(chargeBasis));
                    chk = new Chunk(chargeBasis,FontFactory.getFont("ARIAL", 8, Font.BOLD,Color.BLACK));
                    cellZone = new Cell(chk);              
                    //cellZone.setNoWrap(true);
                    cellZone.setLeading(8.0f);
                    //cellZone.setHeader(true);
                  //  cellZone.setBackgroundColor(Color.LIGHT_GRAY);
                    partZone.addCell(cellZone);
                            
                  }
                  }
                }//ended by Brahmaiah .R */
            //Added By Kishore For the ChargeBasis in the Annexure PDF on 06-Jun-11 

            //}
            partZone.endHeaders();
            int pikupQuoteCartRatSize = pickUpQuoteCartageRates.size();
            for (int i = 0; i < pikupQuoteCartRatSize; i++) {
                pickQuoteCartageRates = (QuoteCartageRates) pickUpQuoteCartageRates.get(i);
                chk = new Chunk(pickQuoteCartageRates.getZone(),
                        FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                cellZone = new Cell(chk);
                cellZone.setLeading(8.0f);
                //cellZone.setNoWrap(true);            
                partZone.addCell(cellZone);

                chk = new Chunk(pickQuoteCartageRates.getCurrency(),
                        FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                cellZone = new Cell(chk);
                cellZone.setLeading(8.0f);
                //cellZone.setNoWrap(true);            
                partZone.addCell(cellZone);

                pickUpZoneCodeMap = pickQuoteCartageRates.getRates();
                /*breaksSet = pickBreaks.iterator();
                while(breaksSet.hasNext())
                 {
                   String wBreak = (String)breaksSet.next();
                   if(pickUpZoneCodeMap.containsKey(wBreak))
                   {
                    chargeRate = (String)pickUpZoneCodeMap.get(wBreak);
                    chargeRate  = df.format(Double.parseDouble(chargeRate));
                   }
                   else
                   {
                    chargeRate = "--";              
                   }
                  chk = new Chunk(chargeRate,FontFactory.getFont("ARIAL", 8, Font.BOLD,Color.BLACK));
                  cellZone = new Cell(chk);
                  cellZone.setNoWrap(true);            
                  partZone.addCell(cellZone); 
                 }*/
                //-------------------------------------------Commented  by Brahmaiah.R on 31/5/2012 for WPBN issue 304241
                if (pickupWeightBreaks != null) {
                    String wBreak = null;
                    for (int k = 0; k < pickupWeightBreaksSize; k++) {
                        wBreak = (String) pickupWeightBreaks.get(k);

                        if (wBreak != null && pickUpZoneCodeMap.containsKey(wBreak)) {
                            chargeRate = (String) pickUpZoneCodeMap.get(wBreak);
                            chargeRate = df.format(Double.parseDouble(chargeRate));

                        } else {
                            chargeRate = "--";
                        }
                        chk = new Chunk(chargeRate, FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                        cellZone = new Cell(chk);
                        cellZone.setLeading(8.0f);
                        //cellZone.setNoWrap(true);            
                        partZone.addCell(cellZone);
                    }
                }
            }
            ////added by Brahmaiah.R on 31/5/2012 for WPBN issue 304241
            /* for(int J=0;J<originChargesSize;J++)
            {
             if(originIndices[J] !=-1)
             {
             chargesDOB                = (QuoteCharges)originCharges.get(originIndices[J]);
              logger.info("Origin Charges doPDFGeneration::"+J+":"+chargesDOB); // newly added                  
             originChargeInfo        = chargesDOB.getChargeInfoList();
             originChargesInfoSize   = originChargeInfo.size();
             int m =0;
            String breakPoint = null;
             for(int k=0;k<originChargesInfoSize;k++)
             {
               chargeInfo = (QuoteChargeInfo)originChargeInfo.get(k);
               chargeRate =  ((Double)chargeInfo.getSellRate()).toString();
               chargeRate  = df.format(Double.parseDouble(chargeRate));
               chk = new Chunk(chargeRate,FontFactory.getFont("ARIAL", 8, Font.BOLD,Color.BLACK));
               cellZone = new Cell(chk);              
               //cellZone.setNoWrap(true);
               cellZone.setLeading(8.0f);
              // cellZone.setHeader(true);
               //cellZone.setBackgroundColor(Color.LIGHT_GRAY);
               partZone.addCell(cellZone);
             }
             }
            }
            }//ended by Brahmaiah.R */
            //System.out.println("After zone header------------------------------>");
            document.add(partZone);
        }

        if (deliveryQuoteCartageRates != null && deliveryQuoteCartageRates.size() > 0) {
            /*Set dkeys         = null;
            for(int i=0;i<deliveryQuoteCartageRates.size();i++)
            {       
             if(i==0)
             { 
               deliBreaks = new TreeSet();//@@This is needed as only a new Set Implementation obj supports addAll() 
             }
             deliQuoteCartageRates = (QuoteCartageRates) deliveryQuoteCartageRates.get(i);
             dkeys = deliQuoteCartageRates.getRates().keySet();
             deliBreaks.addAll(dkeys);
             //System.out.println("Before zone header------------------------------>"+deliBreaks);
             //System.out.println("Before zone header------------------------------>"+deliBreaks.size());              
            }*/

            partZone = new Table(delWeightBreaksSize + 2);
            partZone.setOffset(30);
            partZone.setDefaultHorizontalAlignment(partZone.ALIGN_CENTER);
            partZone.setBorderWidth(1);
            partZone.setWidth(100);
            partZone.setBorderColor(Color.black);
            partZone.setPadding(1);
            partZone.setSpacing(1);
            partZone.setAutoFillEmptyCells(true);
            //partZone.setTableFitsPage(true);
            //@@ Added by subrahmanyam for the enhancement #147062 on 08/12/2008
            chk = new Chunk("DELIVERY CARTAGE RATES AT: " + headerDOB.getDestLocName(),
                    FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.RED));
            cellZone = new Cell(chk);
            cellZone.setNoWrap(true);
            cellZone.setLeading(10.0f);
            cellZone.setHeader(true);
            cellZone.setBackgroundColor(Color.WHITE);
            cellZone.setVerticalAlignment(cellZone.ALIGN_BOTTOM);
            cellZone.setColspan(delWeightBreaksSize + 2);
            partZone.addCell(cellZone);
            //@@ Ended by subrahmanyam for the enhancement #147062 on 08/12/2008
            chk = new Chunk("DELIVERY CARTAGE RATES", FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.BLACK));
            cellZone = new Cell(chk);
            cellZone.setNoWrap(true);
            cellZone.setLeading(10.0f);
            cellZone.setHeader(true);
            cellZone.setBackgroundColor(Color.ORANGE);
            cellZone.setVerticalAlignment(cellZone.ALIGN_BOTTOM);
            cellZone.setColspan(delWeightBreaksSize + 2);
            partZone.addCell(cellZone);

            chk = new Chunk("Zone", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cellZone = new Cell(chk);
            cellZone.setLeading(8.0f);
            //cellZone.setNoWrap(true);
            cellZone.setHeader(true);
            cellZone.setBackgroundColor(Color.LIGHT_GRAY);
            partZone.addCell(cellZone);

            chk = new Chunk("Currency", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cellZone = new Cell(chk);
            cellZone.setLeading(8.0f);
            //cellZone.setNoWrap(true);
            cellZone.setHeader(true);
            cellZone.setBackgroundColor(Color.LIGHT_GRAY);
            partZone.addCell(cellZone);

            //breaksSet = deliBreaks.iterator();

            /*while(breaksSet.hasNext())
            {              
              String breaks = (String)breaksSet.next();
                    
              chk = new Chunk(breaks,FontFactory.getFont("ARIAL", 8, Font.BOLD,Color.BLACK));
              cellZone = new Cell(chk);              
              cellZone.setNoWrap(true);
              cellZone.setHeader(true);
              partZone.addCell(cellZone);
            }*/
            for (int i = 0; i < delWeightBreaksSize; i++) {
                chk = new Chunk((String) delWeightBreaks.get(i),
                        FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                cellZone = new Cell(chk);
                cellZone.setLeading(8.0f);
                //cellZone.setNoWrap(true);
                cellZone.setHeader(true);
                cellZone.setBackgroundColor(Color.LIGHT_GRAY);
                partZone.addCell(cellZone);
            }
            partZone.endHeaders();

            //Added By Kishore For the ChargeBasis in the Annexure PDF on 06-Jun-11

            chk = new Chunk("");
            cellZone = new Cell(chk);
            cellZone.setLeading(8.0f);
            //cellZone.setHeader(true);
            //cellZone.setBackgroundColor(Color.LIGHT_GRAY);
            partZone.addCell(cellZone);

            chk = new Chunk("");
            cellZone = new Cell(chk);
            cellZone.setLeading(8.0f);
            //cellZone.setHeader(true);
            //cellZone.setBackgroundColor(Color.LIGHT_GRAY);
            partZone.addCell(cellZone);
            ////commented  by Brahmaiah.R on 31/5/2012 for WPBN issue 304241 
            for (int i = 0; i < delChargeBasisSize; i++) {
                chk = new Chunk(toTitleCase((String) delChargeBasisList.get(i)),
                        FontFactory.getFont("ARIAL", 7, Font.BOLD, Color.BLACK));
                cellZone = new Cell(chk);
                //cellZone.setNoWrap(true);
                cellZone.setLeading(8.0f);
                cellZone.setHeader(true);
                //cellZone.setBackgroundColor(Color.LIGHT_GRAY);
                partZone.addCell(cellZone);
            }
            //added by Brahmaiah.R on 31/5/2012 for WPBN issue 304241
            /*    for(int J=0;J<destChargesSize;J++)
                {
                  if(destIndices[J] !=-1)
                  {
                  chargesDOB                = (QuoteCharges)destCharges.get(destIndices[J]);
                   logger.info("Dest Charges doPDFGeneration::"+J+":"+chargesDOB); // newly added                  
                  ArrayList destChargeInfo = chargesDOB.getChargeInfoList();
                  int destChargesInfoSize = destChargeInfo.size();
                  int m =0;
              String breakPoint = null;
                  for(int k=0;k<destChargesInfoSize;k++)
                  {
                    chargeInfo = (QuoteChargeInfo)destChargeInfo.get(k);
                    String chargeDestBasis = (String)chargeInfo.getBasis();
                    //chargeRate  = df.format(Double.parseDouble(chargeRate));
                    chk = new Chunk(chargeDestBasis,FontFactory.getFont("ARIAL", 8, Font.BOLD,Color.BLACK));
                    cellZone = new Cell(chk);              
                    //cellZone.setNoWrap(true);
                    cellZone.setLeading(8.0f);
                   // cellZone.setHeader(true);
                    //cellZone.setBackgroundColor(Color.LIGHT_GRAY);
                    partZone.addCell(cellZone);
                  }
                  }
                }
                }//ended by Brahmaiah.R  */
            //End of Kishore For the ChargeBasis in the Annexure PDF on 06-Jun-11

            int delQuoteCartRtSize = deliveryQuoteCartageRates.size();
            for (int i = 0; i < delQuoteCartRtSize; i++) {
                deliQuoteCartageRates = (QuoteCartageRates) deliveryQuoteCartageRates.get(i);

                chk = new Chunk(deliQuoteCartageRates.getZone(),
                        FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                cellZone = new Cell(chk);
                cellZone.setLeading(8.0f);
                //cellZone.setNoWrap(true);            
                partZone.addCell(cellZone);

                chk = new Chunk(deliQuoteCartageRates.getCurrency(),
                        FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                cellZone = new Cell(chk);
                cellZone.setLeading(8.0f);
                //cellZone.setNoWrap(true);            
                partZone.addCell(cellZone);

                deliveryZoneCodeMap = deliQuoteCartageRates.getRates();

                //breaksSet = deliBreaks.iterator();
                /*while(breaksSet.hasNext())
                 {
                   String wBreak = (String)breaksSet.next();
                   if(deliveryZoneCodeMap.containsKey(wBreak))
                   {
                    chargeRate = (String)deliveryZoneCodeMap.get(wBreak);  
                    chargeRate  = df.format(Double.parseDouble(chargeRate));
                   }
                   else
                   {
                    chargeRate = "--";              
                   }
                  chk = new Chunk(chargeRate,FontFactory.getFont("ARIAL", 8, Font.BOLD,Color.BLACK));
                  cellZone = new Cell(chk);
                  cellZone.setNoWrap(true);            
                  partZone.addCell(cellZone); 
                 }*/
                //commented  by Brahmaiah.R on 31/5/2012 for WPBN issue 304241
                String wBreak = null;
                for (int k = 0; k < delWeightBreaksSize; k++) {
                    wBreak = (String) delWeightBreaks.get(k);
                    if (wBreak != null && deliveryZoneCodeMap.containsKey(wBreak)) {
                        chargeRate = (String) deliveryZoneCodeMap.get(wBreak);
                        chargeRate = df.format(Double.parseDouble(chargeRate));
                    } else {
                        chargeRate = "--";
                    }
                    chk = new Chunk(chargeRate, FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                    cellZone = new Cell(chk);
                    cellZone.setLeading(8.0f);
                    //cellZone.setNoWrap(true);            
                    partZone.addCell(cellZone);
                }
            }
            //added by Brahmaiah.R on 31/5/2012 for WPBN issue 304241
            /*     for(int J=0;J<destChargesSize;J++)
                 {
                   if(destIndices[J] !=-1)
                   {
                   chargesDOB                = (QuoteCharges)destCharges.get(destIndices[J]);
                    logger.info("Dest Charges doPDFGeneration::"+J+":"+chargesDOB); // newly added                  
                   ArrayList destChargeInfo = chargesDOB.getChargeInfoList();
                   int destChargesInfoSize = destChargeInfo.size();
                   int m =0;
               String breakPoint = null;
                   for(int k=0;k<destChargesInfoSize;k++)
                   {
                     chargeInfo = (QuoteChargeInfo)destChargeInfo.get(k);
                     String percent = chargeInfo.isPercentValue()?"%":"";
                     String chargeDestRate = round1(((Double)chargeInfo.getSellRate()),percent).toString();
                     chargeDestRate  = df.format(Double.parseDouble(chargeDestRate));
                     chk = new Chunk(chargeDestRate,FontFactory.getFont("ARIAL", 8, Font.BOLD,Color.BLACK));
                     cellZone = new Cell(chk);              
                     //cellZone.setNoWrap(true);
                     cellZone.setLeading(8.0f);
                    // cellZone.setHeader(true);
                     //cellZone.setBackgroundColor(Color.LIGHT_GRAY);
                     partZone.addCell(cellZone);
                   }
                   }
                 }*/
            document.add(partZone);
        }
        //ended by Brahmaiah.R 
        //System.out.println("After zone header------------------------------>");

        pickUpZoneZipMap = finalDOB.getPickZoneZipMap();
        //@@For Sorting the Zone Codes in an Order.
        List list = new ArrayList();
        Set zoneSet;
        //@@End of Declarations - Sorting
        if (pickUpZoneZipMap != null && pickUpZoneZipMap.size() > 0) {
            //System.out.println("Before zipCode header--------Set size------->"+pickUpZoneZipMap.keySet().size());
            //@@Sorting the Zone Codes (as TreeSet implements java.util.SortedSet)
            list.addAll(pickUpZoneZipMap.keySet());
            zoneSet = new TreeSet(list);
            //@@End of Sorting- Added by Yuvraj

            zones = zoneSet.iterator();

            partZone = new Table(2);
            partZone.setOffset(30);
            partZone.setDefaultHorizontalAlignment(partZone.ALIGN_CENTER);
            partZone.setBorderWidth(1);
            partZone.setBorderColor(Color.black);
            partZone.setPadding(1);
            partZone.setSpacing(1);
            partZone.setWidth(100);
            //partZone.setAutoFillEmptyCells(true);
            //partZone.setTableFitsPage(true);
            //@@ Added by subrahmanyam for the enhancement #147062 on 08/12/2008
            chk = new Chunk("PICKUP CHARGES AT: " + headerDOB.getOriginLocName(),
                    FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.RED));
            cellZone = new Cell(chk);
            cellZone.setLeading(10.0f);
            //cellZone.setNoWrap(true);
            cellZone.setHeader(true);
            cellZone.setBackgroundColor(Color.WHITE);
            cellZone.setVerticalAlignment(cellZone.ALIGN_BOTTOM);
            cellZone.setColspan(2);
            partZone.addCell(cellZone);

            //@@ Ended by subrahmanyam for the enhancement #147062 on  08/12/2008
            chk = new Chunk("PICKUP ZONE ZIP MAPPING",
                    FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.BLACK));
            cellZone = new Cell(chk);
            cellZone.setLeading(10.0f);
            //cellZone.setNoWrap(true);
            cellZone.setHeader(true);
            cellZone.setBackgroundColor(Color.ORANGE);
            cellZone.setVerticalAlignment(cellZone.ALIGN_BOTTOM);
            cellZone.setColspan(2);
            partZone.addCell(cellZone);

            chk = new Chunk("Zone", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cellZone = new Cell(chk);
            cellZone.setLeading(8.0f);
            //cellZone.setNoWrap(true);
            cellZone.setHeader(true);
            cellZone.setBackgroundColor(Color.LIGHT_GRAY);
            partZone.addCell(cellZone);
            chk = new Chunk("Zip Code", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cellZone = new Cell(chk);
            cellZone.setLeading(8.0f);
            cellZone.setNoWrap(true);
            cellZone.setHeader(true);
            partZone.addCell(cellZone);
            partZone.endHeaders();
            // System.out.println("Before zipCode Body------------------------------>");

            while (zones.hasNext()) {
                String zone = (String) zones.next();
                // System.out.println("zone------------------------------>"+zone);
                zipList = (ArrayList) pickUpZoneZipMap.get(zone);
                //System.out.println("zipList--------------------------->"+zipList);
                int zipListSize = zipList.size();
                for (int i = 0; i < zipListSize; i++) {
                    //System.out.println("zone for ------------------------------>"+zone);
                    if (zone != null && !zone.equals("null") && zipList.get(i) != null
                            && !((String) zipList.get(i)).equals("null")) {
                        chk = new Chunk(zone, FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                        cellZone = new Cell(chk);
                        cellZone.setBackgroundColor(Color.LIGHT_GRAY);
                        cellZone.setLeading(8.0f);
                        //cellZone.setNoWrap(true);            
                        partZone.addCell(cellZone);
                        //System.out.println("zipList.get(i)--------------------------->"+(String)zipList.get(i));
                        chk = new Chunk((String) zipList.get(i),
                                FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                        cellZone = new Cell(chk);
                        cellZone.setLeading(8.0f);
                        cellZone.setNoWrap(true);
                        partZone.addCell(cellZone);
                    }
                }
            }
            document.add(partZone);
        }

        deliveryZoneZipMap = finalDOB.getDeliveryZoneZipMap();

        list = new ArrayList();
        zoneSet = null;

        if (deliveryZoneZipMap != null && deliveryZoneZipMap.size() > 0) {
            //System.out.println("Before zipCode header--------Set size------->"+deliveryZoneZipMap.keySet().size());
            list.addAll(deliveryZoneZipMap.keySet());
            zoneSet = new TreeSet(list);
            zones = zoneSet.iterator();

            partZone = new Table(2);
            partZone.setOffset(30);
            partZone.setDefaultHorizontalAlignment(partZone.ALIGN_CENTER);
            partZone.setBorderWidth(1);
            partZone.setBorderColor(Color.black);
            partZone.setPadding(1);
            partZone.setSpacing(1);
            partZone.setWidth(100);
            //partZone.setAutoFillEmptyCells(true);
            //partZone.setTableFitsPage(true);
            //@@ Added by subrahmanyam for the enhancement #147062 on 08/12/2008
            chk = new Chunk("DELIVERY CHARGES AT: " + headerDOB.getDestLocName(),
                    FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.RED));
            cellZone = new Cell(chk);
            cellZone.setLeading(10.0f);
            //cellZone.setNoWrap(true);
            cellZone.setHeader(true);
            cellZone.setBackgroundColor(Color.WHITE);
            cellZone.setVerticalAlignment(cellZone.ALIGN_BOTTOM);
            cellZone.setColspan(2);
            partZone.addCell(cellZone);
            //@@ Ended by subrahmanyam for the enhancement #147062 on 08/12/2008 
            chk = new Chunk("DELIVERY ZONE ZIP MAPPING",
                    FontFactory.getFont("ARIAL", 10, Font.BOLD, Color.BLACK));
            cellZone = new Cell(chk);
            cellZone.setLeading(10.0f);
            //cellZone.setNoWrap(true);
            cellZone.setHeader(true);
            cellZone.setBackgroundColor(Color.ORANGE);
            cellZone.setVerticalAlignment(cellZone.ALIGN_BOTTOM);

            cellZone.setColspan(2);
            partZone.addCell(cellZone);

            chk = new Chunk("Zone", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cellZone = new Cell(chk);
            cellZone.setLeading(8.0f);
            cellZone.setNoWrap(true);
            cellZone.setHeader(true);
            cellZone.setBackgroundColor(Color.LIGHT_GRAY);
            partZone.addCell(cellZone);
            chk = new Chunk("Zip Code", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cellZone = new Cell(chk);
            cellZone.setLeading(8.0f);
            cellZone.setNoWrap(true);
            cellZone.setHeader(true);
            partZone.addCell(cellZone);
            partZone.endHeaders();
            //System.out.println("Before zipCode Body------------------------------>");

            while (zones.hasNext()) {
                String zone = (String) zones.next();
                //System.out.println("zone------------------------------>"+zone);
                zipList = (ArrayList) deliveryZoneZipMap.get(zone);
                if (zipList != null) {
                    //System.out.println("zipList--------------------------->"+zipList);
                    //logger.info("zipList--------------------------->"+zipList);
                    int zipListSize = zipList.size();
                    for (int i = 0; i < zipListSize; i++) {
                        //System.out.println("zone for ------------------------------>"+zone);
                        if (zone != null && !zone.equals("null") && zipList.get(i) != null
                                && !((String) zipList.get(i)).equals("null")) {
                            chk = new Chunk(zone, FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                            cellZone = new Cell(chk);
                            cellZone.setLeading(8.0f);
                            cellZone.setBackgroundColor(Color.LIGHT_GRAY);
                            cellZone.setNoWrap(true);
                            partZone.addCell(cellZone);
                            //System.out.println("zipList.get(i)--------------------------->"+(String)zipList.get(i));
                            chk = new Chunk((String) zipList.get(i),
                                    FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                            cellZone = new Cell(chk);
                            cellZone.setLeading(8.0f);
                            cellZone.setNoWrap(true);
                            partZone.addCell(cellZone);
                        }
                    }
                }
            }
            document.add(partZone);
        }
        //System.out.println("After zipCode header------------------------------>");

        document.close();
        //System.out.println("After     document Close----------------------------------------->");               
        File f = new File("Cartage.pdf");
        FileOutputStream fileOutputStream = new FileOutputStream(f);
        baos.writeTo(fileOutputStream);
        fileOutputStream.close();//added by sanjay on 20/03/2006
        //@@Added by Kameswari for the WPBN issue-80440
        PdfReader reader = new PdfReader("Cartage.pdf");
        int n = reader.getNumberOfPages();
        File fs = new File(fileName);
        String space = " ";
        // we create a stamper that will copy the document to a new file
        PdfStamper stamp = new PdfStamper(reader, new FileOutputStream(fs));

        // adding some metadata
        // adding content to each page

        int k = 0;
        PdfContentByte under;
        PdfContentByte over = null;
        BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED);
        while (k < n) {
            k++;
            over = stamp.getOverContent(k);
            over.beginText();
            over.setFontAndSize(bf, 8);
            over.setTextMatrix(15, 15);
            over.showText("page " + k + " of " + n);

            if (k > 1) {
                over.setFontAndSize(bf, 7);
                over.showText(
                        "                                                                                                       QUOTE REFERENCE:"
                                + masterDOB.getQuoteId());
                //@@Added by subrahmanyam for the WPBN:146452 on 12/12/2008
                over.endText();
                over.beginText();
                over.showText(
                        "                                                                                                                                    CUSTOMER NAME: "
                                + headerDOB.getCustomerName());//subrahmanyam 12/12/2008
                //@@ Ended by subrahmanyam for the WPBM:146452 on 12/12/2008               
            }
            over.endText();
        }
        stamp.close();
        //@@WPBN issue-80440    
        //@@ Commented by subrahmanyam for 146460         
        /* if("on".equalsIgnoreCase(request.getParameter("print")))
        {
                
           request.getSession().setAttribute("CartageOuptutStream",fs);
        }*/
        //@@ Added by subrahmanyam for  146460                

        if ("on".equalsIgnoreCase(request.getParameter("print"))
                || "PDF".equalsIgnoreCase(request.getParameter("pdf"))) {

            request.getSession().setAttribute("CartageOuptutStream", fs);
        }
        //@@ Ended by subrahmanyam for 146460
        //f.delete();
        baos.close();
        //System.out.println("End of generation header------------------------------>");

    } catch (Exception e) {
        e.printStackTrace();
        //Logger.error(FILE_NAME,"Error while generating the PDF"+e.toString());
        logger.error(FILE_NAME + "Error while generating the PDF" + e.toString());
        throw new Exception("Error while generating PDF format");
    }
    return 1;
}

From source file:QMSQuoteController.java

License:Open Source License

private ArrayList doPDFGenerationForQuoteGroup(ArrayList mainDtl, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    String[] contents = null;//  w w  w.ja v  a 2s  .co  m
    String[] levels = null;
    String[] aligns = null;
    String[] headFoot = null;
    Table content = null;
    String[] contactPersons = null;
    String contactName = null;
    ArrayList contactList = new ArrayList();
    ArrayList contactEmailList = new ArrayList();
    ArrayList contactFaxList = new ArrayList();
    ArrayList returnList = new ArrayList();
    ArrayList sentEmailsList = new ArrayList();
    ArrayList unsentEmailsList = new ArrayList();
    ArrayList sentFaxList = new ArrayList();
    ArrayList unsentFaxList = new ArrayList();
    ArrayList filesDOBList = new ArrayList();
    ArrayList filesList = new ArrayList();
    HttpSession session = null;

    try {
        //System.out.println("PDF Generation Startd----------------------------------->");
        QuoteFinalDOB finalDOB = null;
        ESupplyDateUtility eSupplyDateUtility = new ESupplyDateUtility();
        QuoteHeader headerDOB = null;
        QuoteMasterDOB masterDOB = null;
        CostingMasterDOB costingMasterDOB = null;
        CostingChargeDetailsDOB detailsDOB = null;
        CostingLegDetailsDOB legDetails = null;
        CostingRateInfoDOB rateDetailsDOB = null;
        ArrayList rateDetails = new ArrayList();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        String formMailId = "";
        String to_emailIds = "";
        String to_FaxIds = "";
        String faxMailIds = "";
        Document document = new Document(PageSize.A4);
        String PDF_FILE_NAME = "Approved.pdf";
        document.addTitle("Approved Report");
        document.addSubject("Report PDF");
        document.addKeywords("Test, Key Words");
        document.addAuthor("DHL");
        document.addCreator("Auto Generated through 4S DHL");
        document.addCreationDate();
        PdfWriter writer = PdfWriter.getInstance(document, baos);
        document.open();
        Table partCountry;
        Chunk chk;
        Cell cellCountry;
        if (mainDtl != null && mainDtl.size() > 0) {

            finalDOB = (QuoteFinalDOB) mainDtl.get(0);
            headerDOB = finalDOB.getHeaderDOB();
            masterDOB = finalDOB.getMasterDOB();
            formMailId = "webmaster@four-soft.com";
            ESupplyGlobalParameters loginbean = (ESupplyGlobalParameters) request.getSession()
                    .getAttribute("loginbean");
            eSupplyDateUtility.setPatternWithTime("DD-MONTH-YYYY");
            //eSupplyDateUtility.setPatternWithTime(loginbean.getUserPreferences().getDateFormat());

            String[] strDate = eSupplyDateUtility.getDisplayStringArray(headerDOB.getDateOfQuotation());
            String[] effDate = eSupplyDateUtility.getDisplayStringArray(headerDOB.getEffDate());
            String[] validDate;

            // System.out.println("Before Document Objec--------------------------->");

            //document.setMargins(10,10,10,10);

            Table mainT = new Table(8);
            mainT.setWidth(100);
            mainT.setBorderColor(Color.white);
            mainT.setPadding(1);
            mainT.setSpacing(0);

            Phrase headingPhrase = new Phrase("", FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.BLACK));
            Cell cellHeading = new Cell(headingPhrase);
            cellHeading.setBorderColor(new Color(255, 255, 255));
            cellHeading.setHorizontalAlignment(cellHeading.ALIGN_CENTER);
            cellHeading.setColspan(7);
            mainT.addCell(cellHeading);

            Cell imageCell = new Cell();
            java.net.URL url = getServletConfig().getServletContext().getResource("/images/DHLlogo.gif");
            Image img0 = Image.getInstance(url);
            imageCell.add(img0);
            imageCell.setHorizontalAlignment(imageCell.ALIGN_RIGHT);
            imageCell.setBorderWidth(0);
            imageCell.setNoWrap(true);
            mainT.addCell(imageCell);
            mainT.setAlignment(mainT.ALIGN_CENTER);
            document.add(mainT);

            //Default Header Content Starts
            contents = masterDOB.getDefaultContent();
            headFoot = masterDOB.getDefaultHeaderFooter();

            if (contents != null && contents.length > 0) {
                content = new Table(1);
                content.setOffset(5);
                content.setWidth(100);
                content.setPadding(1);
                content.setSpacing(0);
                content.setBackgroundColor(Color.WHITE);
                content.setBorderColor(Color.black);
                content.setBorderWidth(1f);
                Cell cellContent = null;
                chk = null;
                int hFLen = headFoot.length;
                for (int i = 0; i < hFLen; i++) {
                    if (headFoot[i] != null && "H".equalsIgnoreCase(headFoot[i])) {
                        chk = new Chunk(contents[i], FontFactory.getFont("ARIAL", 7, Font.ITALIC, Color.BLACK));
                        cellContent = new Cell(chk);
                        cellContent.setBorder(0);
                        cellContent.setLeading(6.0f);
                        cellContent.setBackgroundColor(Color.LIGHT_GRAY);
                        cellContent.setHorizontalAlignment(cellContent.ALIGN_LEFT);//Default content is left aligned                                    
                        content.addCell(cellContent);
                    }
                }
                document.add(content);
                contents = null;
                headFoot = null;
                content = null;
            }
            //End Default Header Content

            //System.out.println("After Heading --------------------------->");
        }
        String validUptoStr = null;
        String[] strDate = null;
        String[] effDate = null;
        String[] validDate = null;
        StringBuffer attentionTo = null;
        int mainDtlSize = mainDtl.size();
        for (int m = 0; m < mainDtlSize; m++) {

            finalDOB = (QuoteFinalDOB) mainDtl.get(m);
            headerDOB = finalDOB.getHeaderDOB();
            masterDOB = finalDOB.getMasterDOB();
            //formMailId             =   "webmaster@four-soft.com";
            ESupplyGlobalParameters loginbean = (ESupplyGlobalParameters) request.getSession()
                    .getAttribute("loginbean");
            eSupplyDateUtility.setPatternWithTime("DD-MONTH-YYYY");
            //eSupplyDateUtility.setPatternWithTime(loginbean.getUserPreferences().getDateFormat());

            strDate = eSupplyDateUtility.getDisplayStringArray(headerDOB.getDateOfQuotation());
            effDate = eSupplyDateUtility.getDisplayStringArray(headerDOB.getEffDate());
            attentionTo = new StringBuffer("");

            if (headerDOB.getValidUpto() != null) {
                validDate = eSupplyDateUtility.getDisplayStringArray(headerDOB.getValidUpto());
                validUptoStr = validDate[0];
            }
            if (masterDOB.getCustContactNames() != null) {
                for (int i = 0; i < masterDOB.getCustContactNames().length; i++) {
                    // Logger.info(FILE_NAME,"headerDOB.getAttentionTo()::"+masterDOB.getCustomerContacts()[i]);
                    attentionTo.append(
                            masterDOB.getCustContactNames()[i] != null ? masterDOB.getCustContactNames()[i]
                                    : "");
                    if (i != masterDOB.getCustContactNames().length)
                        attentionTo.append(",");
                }
            }
            partCountry = new Table(1, 5);
            partCountry.setBorderWidth(0);
            partCountry.setWidth(100);
            partCountry.setBorderColor(Color.black);
            //partCountry.setBackgroundColor(Color.ORANGE);
            partCountry.setPadding(1);
            partCountry.setSpacing(0);
            partCountry.setAutoFillEmptyCells(true);
            //partCountry.setTableFitsPage(true);
            partCountry.setAlignment(partCountry.ALIGN_CENTER);
            // partCountry.setWidth(100.0f);

            String shipmentMode = "";
            if (finalDOB.getMasterDOB().getShipmentMode() == 1)
                shipmentMode = "AIR FREIGHT PROPOSAL";
            else if (finalDOB.getMasterDOB().getShipmentMode() == 2)
                shipmentMode = "SEA FREIGHT PROPOSAL";
            else if (finalDOB.getMasterDOB().getShipmentMode() == 4)
                shipmentMode = "TRUCK FREIGHT PROPOSAL";

            chk = new Chunk(shipmentMode, FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setWidth("100");
            cellCountry.setBorderWidth(0);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(10.0f);
            cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
            partCountry.addCell(cellCountry);
            //@@Modified for the WPBN Change Request-71229
            if ("MY".equalsIgnoreCase(masterDOB.getCountryId())) {
                chk = new Chunk(headerDOB.getOriginCountry() + " TO " + headerDOB.getDestinationCountry(),
                        FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.RED));
                cellCountry = new Cell(chk);
                cellCountry.setWidth("100");
                cellCountry.setBorderWidth(0);
                cellCountry.setNoWrap(true);
                cellCountry.setLeading(10.0f);
                cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
                partCountry.addCell(cellCountry);

                chk = new Chunk(headerDOB.getCustomerName() == null ? "" : headerDOB.getCustomerName(),
                        FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.RED));
                cellCountry = new Cell(chk);
                cellCountry.setHeader(true);
                cellCountry.setWidth("100");
                cellCountry.setBorderWidth(0);
                cellCountry.setNoWrap(true);
                cellCountry.setLeading(10.0f);
                cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
                partCountry.addCell(cellCountry);

                chk = new Chunk("ATTENTION TO: " + attentionTo.toString(),
                        FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.RED));
                cellCountry = new Cell(chk);
                cellCountry.setWidth("100");
                cellCountry.setBorderWidth(0);
                cellCountry.setNoWrap(true);
                cellCountry.setLeading(10.0f);
                cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
                partCountry.addCell(cellCountry);
            } else {
                chk = new Chunk(headerDOB.getOriginCountry() + " TO " + headerDOB.getDestinationCountry(),
                        FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.RED));
                cellCountry = new Cell(chk);
                cellCountry.setWidth("100");
                cellCountry.setBorderWidth(0);
                cellCountry.setNoWrap(true);
                cellCountry.setLeading(10.0f);
                cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
                partCountry.addCell(cellCountry);

                chk = new Chunk(headerDOB.getCustomerName() == null ? "" : headerDOB.getCustomerName(),
                        FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.RED));
                cellCountry = new Cell(chk);
                cellCountry.setHeader(true);
                cellCountry.setWidth("100");
                cellCountry.setBorderWidth(0);
                cellCountry.setNoWrap(true);
                cellCountry.setLeading(10.0f);
                cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
                partCountry.addCell(cellCountry);

                chk = new Chunk("ATTENTION TO: " + attentionTo.toString(),
                        FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.RED));
                cellCountry = new Cell(chk);
                cellCountry.setWidth("100");
                cellCountry.setBorderWidth(0);
                cellCountry.setNoWrap(true);
                cellCountry.setLeading(10.0f);
                cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
                partCountry.addCell(cellCountry);
            }
            //@@WPBN Change Request-71229
            chk = new Chunk("QUOTE REFERENCE: " + masterDOB.getQuoteId(),
                    FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setWidth("100");
            cellCountry.setBorderWidth(0);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(10.0f);
            cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
            partCountry.addCell(cellCountry);
            chk = new Chunk("DATE OF QUOTATION: " + strDate[0],
                    FontFactory.getFont("ARIAL", 12, Font.BOLD, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setWidth("100");
            cellCountry.setBorderWidth(0);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(10.0f);
            cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
            partCountry.addCell(cellCountry);

            contents = masterDOB.getContentOnQuote();
            levels = masterDOB.getLevels();
            aligns = masterDOB.getAlign();
            headFoot = masterDOB.getHeaderFooter();

            if (contents != null && contents.length > 0) {
                content = new Table(1);
                content.setOffset(5);
                content.setWidth(100);
                content.setPadding(1);
                content.setSpacing(0);
                content.setBackgroundColor(Color.WHITE);
                content.setBorderColor(Color.black);
                content.setBorderWidth(1f);
                Cell cellContent = null;
                chk = null;
                int hFlen = headFoot.length;
                for (int i = 0; i < hFlen; i++) {
                    if (headFoot[i] != null && "H".equalsIgnoreCase(headFoot[i])) {
                        chk = new Chunk(contents[i], FontFactory.getFont("ARIAL", 7, Font.ITALIC, Color.BLACK));
                        cellContent = new Cell(chk);
                        cellContent.setBorder(0);
                        cellContent.setLeading(6.0f);
                        cellContent.setBackgroundColor(Color.LIGHT_GRAY);
                        if ("L".equalsIgnoreCase(aligns[i]))
                            cellContent.setHorizontalAlignment(cellContent.ALIGN_LEFT);
                        else if ("C".equalsIgnoreCase(aligns[i]))
                            cellContent.setHorizontalAlignment(cellContent.ALIGN_CENTER);
                        else if ("R".equalsIgnoreCase(aligns[i]))
                            cellContent.setHorizontalAlignment(cellContent.ALIGN_RIGHT);
                        content.addCell(cellContent);
                    }
                }
                document.add(content);
            }

            partCountry = new Table(2, 15);
            partCountry.setOffset(2);
            partCountry.setWidth(100);
            partCountry.setPadding(1);
            partCountry.setSpacing(0);
            partCountry.setBackgroundColor(Color.WHITE);
            partCountry.setBorderColor(Color.black);
            partCountry.setBorderWidth(1);
            //added by subrahmanyam for 182516
            partCountry.setTableFitsPage(true);
            partCountry.setCellsFitPage(true);
            //ended for 182516

            chk = new Chunk("SERVICE INFORMATION: ", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cellCountry = new Cell(chk);

            cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
            cellCountry.setBackgroundColor(Color.ORANGE);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            //@@ Commented by subrahmanyam for the enhancement #146970 & #146971            
            /*chk = new Chunk("QUOTE ID:"+new Long(masterDOB.getQuoteId()).toString(),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
            cellCountry.setBackgroundColor(Color.ORANGE);
            cellCountry.setNoWrap(true); cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);*/
            //@@ Added by subrahmanyam for the enhancement #146970 & #146971            
            chk = new Chunk("QUOTE ID:" + masterDOB.getQuoteId(),
                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
            cellCountry.setBackgroundColor(Color.ORANGE);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk("Origin : ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setBackgroundColor(Color.lightGray);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk("   " + (headerDOB.getOriginLocName() != null ? headerDOB.getOriginLocName() : ""),
                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk("Destination : ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setBackgroundColor(Color.lightGray);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk("   " + (headerDOB.getDestLocName() != null ? headerDOB.getDestLocName() : ""),
                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk("Customer : ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setBackgroundColor(Color.lightGray);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk("   " + (headerDOB.getCustomerName() != null ? headerDOB.getCustomerName() : ""),
                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk("Agent: ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setBackgroundColor(Color.lightGray);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk("   " + (headerDOB.getAgent() != null ? headerDOB.getAgent() : ""),
                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            //@@ Added by subrahmanyam for the WPBN ISSUE: 150460 ON 23/12/2008                
            if ("EXW".equalsIgnoreCase(headerDOB.getIncoTerms())
                    || "FAS".equalsIgnoreCase(headerDOB.getIncoTerms())
                    || "FCA".equalsIgnoreCase(headerDOB.getIncoTerms())
                    || "FOB".equalsIgnoreCase(headerDOB.getIncoTerms())) {
                chk = new Chunk("Place Of Acceptance: ",
                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                cellCountry = new Cell(chk);
                cellCountry.setBackgroundColor(Color.lightGray);
                cellCountry.setNoWrap(true);
                cellCountry.setLeading(8.0f);
                partCountry.addCell(cellCountry);
            } else {
                chk = new Chunk("Place Of Delivery: ",
                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                cellCountry = new Cell(chk);
                cellCountry.setBackgroundColor(Color.lightGray);
                cellCountry.setNoWrap(true);
                cellCountry.setLeading(8.0f);
                partCountry.addCell(cellCountry);
            }
            //@@ Ended by subrahmanyam for the WPBN ISSUE: 150460 ON 23/12/2008  

            chk = new Chunk("   " + (headerDOB.getCargoAcceptancePlace() != null
                    ? headerDOB.getCargoAcceptancePlace().toUpperCase()
                    : ""), FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk("Origin Port: ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setBackgroundColor(Color.lightGray);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk("   "
                    + ((headerDOB.getOriginPortName() != null
                            ? headerDOB.getOriginPortName().toUpperCase() + ", "
                            : ""))
                    + (headerDOB.getOriginPortCountry() != null ? headerDOB.getOriginPortCountry().toUpperCase()
                            : ""),
                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk("Destination Port: ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setBackgroundColor(Color.lightGray);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk("   "
                    + ((headerDOB.getDestPortName() != null ? headerDOB.getDestPortName().toUpperCase() + ", "
                            : ""))
                    + (headerDOB.getDestPortCountry() != null ? headerDOB.getDestPortCountry().toUpperCase()
                            : ""),
                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            // @@Commented by subrahmanyam for the enhancement #148546 on 09/12/2008            
            /* chk = new Chunk("Routing: ",FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
             cellCountry = new Cell(chk);
             cellCountry.setBackgroundColor(Color.lightGray);
             cellCountry.setNoWrap(true); cellCountry.setLeading(8.0f);
             partCountry.addCell(cellCountry);          
             chk = new Chunk("   "+(headerDOB.getRouting()!=null?headerDOB.getRouting():""),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
             cellCountry = new Cell(chk);
             cellCountry.setNoWrap(true); cellCountry.setLeading(8.0f);
             partCountry.addCell(cellCountry);*/
            //@@ Ended by subrahmanyam for the enhanement #148546 on 09/12/2008 

            chk = new Chunk("Commodity or Product: ",
                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setBackgroundColor(Color.lightGray);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk("   " + (headerDOB.getCommodity() != null ? headerDOB.getCommodity() : ""),
                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk("Type of service quoted: ",
                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setBackgroundColor(Color.lightGray);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk("   " + (headerDOB.getTypeOfService() != null ? headerDOB.getTypeOfService() : ""),
                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk("Incoterms: ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setBackgroundColor(Color.lightGray);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk("   " + (headerDOB.getIncoTerms() != null ? headerDOB.getIncoTerms() : ""),
                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk("Notes: ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setBackgroundColor(Color.lightGray);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            //@@ Commented by subrahmanyam for WPBN ISSUE:-145510                                      
            /* chk = new Chunk("   "+(headerDOB.getNotes()!=null?headerDOB.getNotes().toUpperCase()+'\n'+"nnnnnnnnnn":""),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
            Commented by subrahmanyam for WPBN ISSUE:-145510   
            cellCountry = new Cell(chk);
            cellCountry.setNoWrap(true); cellCountry.setLeading(8.0f);
                    
            partCountry.addCell(cellCountry);
            */
            //@@ Ended by subrahmanyam for WPBN ISSUE:-145510  
            //@@ Added by subrahmanyam for WPBN ISSUE:-145510  
            chk = new Chunk("   " + (headerDOB.getNotes() != null ? headerDOB.getNotes().toUpperCase() : " "),
                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);
            //@@ Ended by subrahmanyam for WPBN ISSUE:-145510   

            chk = new Chunk("Date Effective: ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setBackgroundColor(Color.lightGray);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk("   " + effDate[0], FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk("Validity of Quote: ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setBackgroundColor(Color.lightGray);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            chk = new Chunk("   " + (validUptoStr != null ? validUptoStr : "VALID UNTIL FURTHER NOTICE"),
                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
            cellCountry = new Cell(chk);
            cellCountry.setNoWrap(true);
            cellCountry.setLeading(8.0f);
            partCountry.addCell(cellCountry);

            document.add(partCountry);
            partCountry.complete();
        }
        int originCount = 0;
        int freightCount = 0;
        int destCount = 0;
        for (int m = 0; m < mainDtlSize; m++) {

            finalDOB = (QuoteFinalDOB) mainDtl.get(m);
            headerDOB = finalDOB.getHeaderDOB();
            masterDOB = finalDOB.getMasterDOB();
            // System.out.println("After Page Country-------------------------------->");
            //Origin Charges

            costingMasterDOB = finalDOB.getCostingMasterDOB();

            ArrayList originCharges = (ArrayList) costingMasterDOB.getOriginList();

            int[] originIndices = finalDOB.getSelectedOriginChargesListIndices();
            int originChargesSize = 0;

            if (originCharges != null)
                originChargesSize = originCharges.size();
            else
                originChargesSize = 0;

            //Destination
            ArrayList destCharges = new ArrayList();
            int[] destIndices = finalDOB.getSelctedDestChargesListIndices();
            int destChargesSize = 0;
            if (destIndices != null)
                destChargesSize = destIndices.length;
            else
                destChargesSize = 0;

            ArrayList frieghtChargeDetails = new ArrayList();
            destCharges = (ArrayList) costingMasterDOB.getDestinationList();
            ArrayList costingLegDetailsList = new ArrayList();
            costingLegDetailsList = (ArrayList) costingMasterDOB.getCostingLegDetailsList();
            //////////////////////////////
            int orgChargSize = originCharges.size();
            for (int i = 0; i < orgChargSize; i++) {
                detailsDOB = (CostingChargeDetailsDOB) originCharges.get(i);
                rateDetails = (ArrayList) detailsDOB.getCostingRateInfoDOB();
                int rateDtlSize = rateDetails.size();
                for (int k = 0; k < rateDtlSize; k++) {
                    originCount++;
                }
            }
            int destChargSize = destCharges.size();
            for (int i = 0; i < destChargSize; i++) {
                detailsDOB = (CostingChargeDetailsDOB) destCharges.get(i);
                rateDetails = (ArrayList) detailsDOB.getCostingRateInfoDOB();
                int rateDtlSize = rateDetails.size();
                for (int k = 0; k < rateDtlSize; k++) {
                    destCount++;
                }
            }
            int costLegDtlSize = costingLegDetailsList.size();
            for (int s = 0; s < costLegDtlSize; s++) {
                legDetails = (CostingLegDetailsDOB) costingLegDetailsList.get(s);
                frieghtChargeDetails = (ArrayList) legDetails.getCostingChargeDetailList();
                int frtChargDtlSize = frieghtChargeDetails.size();
                for (int n = 0; n < frtChargDtlSize; n++) {
                    detailsDOB = (CostingChargeDetailsDOB) frieghtChargeDetails.get(n);
                    rateDetails = (ArrayList) detailsDOB.getCostingRateInfoDOB();
                    int rateDtlSize = rateDetails.size();
                    for (int j = 0; j < rateDtlSize; j++) {
                        freightCount++;
                    }
                }
            }

        }

        //////////////////////////////
        ArrayList charges = finalDOB.getLegDetails();
        int chargesSize = charges.size();
        if (originCount > 0) {
            Table chargeCountry = new Table(7, originCount);
            chargeCountry.setWidth(100);
            chargeCountry.setPadding(1);
            chargeCountry.setSpacing(0);
            chargeCountry.setOffset(25);
            chargeCountry.setBackgroundColor(Color.WHITE);
            chargeCountry.setBorderColor(Color.black);
            chargeCountry.setDefaultHorizontalAlignment(Element.ALIGN_CENTER);
            chargeCountry.setBorderWidth(1);
            //@@ Added by subrahmanyam for wpbn id: 181349 on 07-sep-09
            chargeCountry.setTableFitsPage(true);
            chargeCountry.setCellsFitPage(true);
            // @@ Ended for wpbn id: 181349 on 07-sep-09

            Cell cell;
            String wBslab = "";
            chk = new Chunk("QUOTEID ", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell = new Cell(chk);
            cell.setBackgroundColor(Color.ORANGE);
            cell.setNoWrap(true);
            cell.setLeading(8.0f);
            //cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
            chargeCountry.addCell(cell);

            chk = new Chunk("CHARGE NAME ", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell = new Cell(chk);
            cell.setBackgroundColor(Color.ORANGE);
            cell.setNoWrap(true);
            cell.setLeading(8.0f);
            // cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
            chargeCountry.addCell(cell);

            chk = new Chunk("BREAKPOINT", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell = new Cell(chk);
            cell.setBackgroundColor(Color.ORANGE);
            cell.setNoWrap(true);
            cell.setLeading(8.0f);
            // cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
            chargeCountry.addCell(cell);

            chk = new Chunk("CURRENCY", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell = new Cell(chk);
            cell.setBackgroundColor(Color.ORANGE);
            cell.setNoWrap(true);
            cell.setLeading(8.0f);
            // cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
            chargeCountry.addCell(cell);

            chk = new Chunk("RATE", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell = new Cell(chk);
            cell.setBackgroundColor(Color.ORANGE);
            cell.setNoWrap(true);
            cell.setLeading(8.0f);
            // cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
            chargeCountry.addCell(cell);

            chk = new Chunk("BASIS", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell = new Cell(chk);
            cell.setBackgroundColor(Color.ORANGE);
            cell.setNoWrap(true);
            cell.setLeading(8.0f);
            //cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
            chargeCountry.addCell(cell);

            chk = new Chunk("RATIO", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell = new Cell(chk);
            cell.setBackgroundColor(Color.ORANGE);
            cell.setNoWrap(true);
            cell.setLeading(8.0f);
            //cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
            chargeCountry.addCell(cell);

            chk = new Chunk("ORIGIN CHARGES", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell = new Cell(chk);
            cell.setColspan(7);
            cell.setBackgroundColor(Color.ORANGE);
            cell.setNoWrap(true);
            cell.setLeading(8.0f);
            // cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
            chargeCountry.addCell(cell);
            for (int m = 0; m < mainDtlSize; m++) {

                finalDOB = (QuoteFinalDOB) mainDtl.get(m);
                headerDOB = finalDOB.getHeaderDOB();
                masterDOB = finalDOB.getMasterDOB();

                costingMasterDOB = finalDOB.getCostingMasterDOB();
                ArrayList originCharges = (ArrayList) costingMasterDOB.getOriginList();

                QuoteCharges chargesDOB = null;
                ArrayList originChargeInfo = null;
                int originChargesInfoSize = 0;
                QuoteChargeInfo chargeInfo = null;
                if (originCharges.size() > 0) {

                    int orgChargSize = originCharges.size();
                    for (int i = 0; i < orgChargSize; i++) {
                        detailsDOB = (CostingChargeDetailsDOB) originCharges.get(i);
                        rateDetails = (ArrayList) detailsDOB.getCostingRateInfoDOB();

                        originChargesInfoSize = rateDetails.size();
                        for (int k = 0; k < originChargesInfoSize; k++) {
                            CostingRateInfoDOB crateDetailsDOB = (CostingRateInfoDOB) rateDetails.get(k);
                            if (k == 0) {
                                //@@ Commented by subrahmanyam for the enhancement #146971 and #146970 on 10/12/2008                    
                                /*chk = new Chunk(new Long(masterDOB.getQuoteId()).toString(),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                                cell = new Cell(chk);
                                //cell.setRowspan(originChargesInfoSize);
                                cell.setBackgroundColor(Color.lightGray);
                                cell.setNoWrap(true); cell.setLeading(8.0f);
                                //cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
                                chargeCountry.addCell(cell);*/
                                //@@ Added by subrahmanyam for the enhancement #146971 and 146970 on 10/12/2008    
                                chk = new Chunk(masterDOB.getQuoteId(),
                                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                                cell = new Cell(chk);
                                cell.setBackgroundColor(Color.lightGray);
                                cell.setNoWrap(true);
                                cell.setLeading(8.0f);
                                chargeCountry.addCell(cell);
                                //@@ Ended by subrahmanyam for the enhanemenet #146971 and #146970 on 10/12/2008 

                                //@@ commented and modified by subrahmanyam for 181349  on 07-sep-09 & 202166 on 7-apr-10
                                // chk = new Chunk(detailsDOB.getChargeDescId(),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                                chk = new Chunk(
                                        detailsDOB.getExternalName() != null ? detailsDOB.getExternalName()
                                                : detailsDOB.getChargeDescId(),
                                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));//ended for 181349
                                cell = new Cell(chk);
                                //cell.setRowspan(originChargesInfoSize);
                                cell.setBackgroundColor(Color.lightGray);
                                // cell.setNoWrap(true); //commented for 181349
                                cell.setLeading(8.0f);
                                //cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
                                chargeCountry.addCell(cell);
                            } else {
                                cell = new Cell("");
                                //cell.setRowspan(originChargesInfoSize);
                                cell.setBackgroundColor(Color.lightGray);
                                cell.setNoWrap(true);
                                cell.setLeading(8.0f);
                                cell.setBorderWidth(0f);
                                //cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
                                chargeCountry.addCell(cell);

                                cell = new Cell("");
                                //cell.setRowspan(originChargesInfoSize);
                                cell.setBackgroundColor(Color.lightGray);
                                cell.setNoWrap(true);
                                cell.setLeading(8.0f);
                                cell.setBorderWidth(0f);
                                //cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
                                chargeCountry.addCell(cell);
                            }
                            chk = new Chunk(crateDetailsDOB.getWeightBreakSlab(),
                                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                            cell = new Cell(chk);
                            cell.setBackgroundColor(Color.lightGray);
                            cell.setNoWrap(true);
                            cell.setLeading(8.0f);
                            chargeCountry.addCell(cell);

                            chk = new Chunk(detailsDOB.getCurrency(),
                                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                            cell = new Cell(chk);
                            cell.setBackgroundColor(Color.lightGray);
                            cell.setNoWrap(true);
                            cell.setLeading(8.0f);
                            chargeCountry.addCell(cell);

                            chk = new Chunk(crateDetailsDOB.getRate() + "",
                                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                            cell = new Cell(chk);
                            cell.setNoWrap(true);
                            cell.setLeading(8.0f);
                            chargeCountry.addCell(cell);

                            //added by subrahmanyam for 183812
                            if (crateDetailsDOB.getWeightBreakSlab().equalsIgnoreCase("Min")
                                    || ("BOTH".equalsIgnoreCase(detailsDOB.getRateType())
                                            && "F".equalsIgnoreCase(crateDetailsDOB.getRateIndicator()))) {
                                wBslab = "MIN";
                            } else
                                wBslab = detailsDOB.getChargeBasisDesc();
                            // @@ Commented & Added by subrahmanyam for the wpbn id: 182516 on 10/09/09
                            //chk = new Chunk(crateDetailsDOB.getWeightBreakSlab().equalsIgnoreCase("Min")?"Pershipment ":detailsDOB.getChargeBasisDesc(),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                            //chk = new Chunk(crateDetailsDOB.getWeightBreakSlab().equalsIgnoreCase("Min")?" Per Shipment ":detailsDOB.getChargeBasisDesc(),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                            chk = new Chunk(
                                    wBslab.equalsIgnoreCase("Min") ? " Per Shipment "
                                            : detailsDOB.getChargeBasisDesc(),
                                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                            cell = new Cell(chk);
                            cell.setNoWrap(true);
                            cell.setLeading(8.0f);
                            chargeCountry.addCell(cell);

                            chk = new Chunk(
                                    detailsDOB.getDensityRatio() == null ? "" : detailsDOB.getDensityRatio(),
                                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                            cell = new Cell(chk);
                            cell.setNoWrap(true);
                            cell.setLeading(8.0f);
                            chargeCountry.addCell(cell);

                        }
                    }
                }
            }
            document.add(chargeCountry);
        }
        if (freightCount > 0) {
            Table chargeCountry1 = new Table(7, freightCount);
            chargeCountry1.setWidth(100);
            chargeCountry1.setPadding(1);
            chargeCountry1.setSpacing(0);
            chargeCountry1.setOffset(25);
            chargeCountry1.setBackgroundColor(Color.WHITE);
            chargeCountry1.setBorderColor(Color.black);
            chargeCountry1.setDefaultHorizontalAlignment(Element.ALIGN_CENTER);
            chargeCountry1.setBorderWidth(1);
            //@@ Added by subrahmanyam for wpbn id: 181349 on 07-sep-09
            chargeCountry1.setTableFitsPage(true);
            chargeCountry1.setCellsFitPage(true);
            // @@ Ended for wpbn id: 181349 on 07-sep-09

            Cell cell1;
            chk = new Chunk(" QUOTEID", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell1 = new Cell(chk);
            cell1.setBackgroundColor(Color.ORANGE);
            cell1.setNoWrap(true);
            cell1.setLeading(8.0f);
            //cell1.setVerticalAlignment(cell1.ALIGN_MIDDLE);
            chargeCountry1.addCell(cell1);
            chk = new Chunk("CHARGE NAME ", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell1 = new Cell(chk);
            cell1.setBackgroundColor(Color.ORANGE);
            cell1.setNoWrap(true);
            cell1.setLeading(8.0f);
            //cell1.setVerticalAlignment(cell1.ALIGN_MIDDLE);
            chargeCountry1.addCell(cell1);

            chk = new Chunk("BREAKPOINT", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell1 = new Cell(chk);
            cell1.setBackgroundColor(Color.ORANGE);
            cell1.setNoWrap(true);
            cell1.setLeading(8.0f);
            //cell1.setVerticalAlignment(cell1.ALIGN_MIDDLE);
            chargeCountry1.addCell(cell1);

            chk = new Chunk("CURRENCY", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell1 = new Cell(chk);
            cell1.setBackgroundColor(Color.ORANGE);
            cell1.setNoWrap(true);
            cell1.setLeading(8.0f);
            //cell1.setVerticalAlignment(cell1.ALIGN_MIDDLE);
            chargeCountry1.addCell(cell1);

            chk = new Chunk("RATE", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell1 = new Cell(chk);
            cell1.setBackgroundColor(Color.ORANGE);
            cell1.setNoWrap(true);
            cell1.setLeading(8.0f);
            // cell1.setVerticalAlignment(cell1.ALIGN_MIDDLE);
            chargeCountry1.addCell(cell1);

            chk = new Chunk("BASIS", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell1 = new Cell(chk);
            cell1.setBackgroundColor(Color.ORANGE);
            cell1.setNoWrap(true);
            cell1.setLeading(8.0f);
            //cell1.setVerticalAlignment(cell1.ALIGN_MIDDLE);
            chargeCountry1.addCell(cell1);

            chk = new Chunk("RATIO", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell1 = new Cell(chk);
            cell1.setBackgroundColor(Color.ORANGE);
            cell1.setNoWrap(true);
            cell1.setLeading(8.0f);
            // cell1.setVerticalAlignment(cell1.ALIGN_MIDDLE);
            chargeCountry1.addCell(cell1);

            chk = new Chunk("FREIGHT CHARGES", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell1 = new Cell(chk);
            cell1.setColspan(7);
            cell1.setNoWrap(true);
            cell1.setLeading(8.0f);
            cell1.setBackgroundColor(Color.ORANGE);
            //cell1.setVerticalAlignment(cell1.ALIGN_MIDDLE);
            chargeCountry1.addCell(cell1);
            //Freight Charges
            // System.out.println("After         Origin Charges --------------------------------->");
            int freightChargesSize = 0;
            int freightChargesInfoSize = 0;
            int[] frtIndices = null;
            QuoteFreightLegSellRates legCharges = null;
            String wBSlab = "";//added by subrahmanyam for 182516 on 10-sep-09             
            int mDtlSize = mainDtl.size();
            for (int m = 0; m < mDtlSize; m++) {

                finalDOB = (QuoteFinalDOB) mainDtl.get(m);
                headerDOB = finalDOB.getHeaderDOB();
                masterDOB = finalDOB.getMasterDOB();
                ArrayList costingLegDetailsList = new ArrayList();
                costingMasterDOB = finalDOB.getCostingMasterDOB();
                costingLegDetailsList = (ArrayList) costingMasterDOB.getCostingLegDetailsList();
                ArrayList frieghtChargeDetails = new ArrayList();
                String rDescription = ""; // Added by subrahmanyam for 182516 on 10/09/09
                if (costingLegDetailsList.size() > 0) {

                    int costLegDtlSize = costingLegDetailsList.size();
                    for (int s = 0; s < costLegDtlSize; s++) {
                        legDetails = (CostingLegDetailsDOB) costingLegDetailsList.get(s);
                        frieghtChargeDetails = (ArrayList) legDetails.getCostingChargeDetailList();
                        int frtLegDtlSize = frieghtChargeDetails.size();
                        int frtChargDtlSize = frieghtChargeDetails.size();
                        for (int n = 0; n < frtChargDtlSize; n++) {
                            detailsDOB = (CostingChargeDetailsDOB) frieghtChargeDetails.get(n);
                            rateDetails = (ArrayList) detailsDOB.getCostingRateInfoDOB();
                            int rateDtlSize = rateDetails.size();
                            for (int j = 0; j < rateDtlSize; j++) {
                                rateDetailsDOB = (CostingRateInfoDOB) rateDetails.get(j);

                                if (j == 0) {

                                    chk = new Chunk(legDetails.getOrigin() + "-" + legDetails.getDestination(),
                                            FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                                    cell1 = new Cell(chk);
                                    cell1.setColspan(7);
                                    cell1.setBackgroundColor(Color.WHITE);
                                    cell1.setLeading(8.0f);
                                    chargeCountry1.addCell(cell1);

                                    //@@ Commented by subrahmanyam for the enhancement #146971 and 1469710 on 10/12/2008                      
                                    /*chk = new Chunk(new Long(masterDOB.getQuoteId()).toString(),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                                    cell1 = new Cell(chk);
                                    //cell1.setRowspan(rateDetails.size());
                                    cell1.setNoWrap(true); cell2.setLeading(8.0f);
                                    cell1.setBackgroundColor(Color.lightGray);
                                    chargeCountry1.addCell(cell1);*/
                                    //@@ Added by subrahmanyam for the enhancement #146971 and #146970 on 10/12/2008
                                    chk = new Chunk(masterDOB.getQuoteId(),
                                            FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                                    cell1 = new Cell(chk);
                                    cell1.setNoWrap(true);
                                    cell1.setLeading(8.0f);
                                    cell1.setBackgroundColor(Color.lightGray);
                                    chargeCountry1.addCell(cell1);
                                    //@@ Ended by subrahmanyam for the enhancement #146971 and 146970 on 10/12/2008    
                                    // COMMENTED AND MODIFIED BY SUBRAHMANYAM FOR 182516
                                    //chk = new Chunk(detailsDOB.getChargeDescId()==null?"":detailsDOB.getChargeDescId(),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                                    chk = new Chunk(
                                            rateDetailsDOB.getRateDescription() == null ? ""
                                                    : rateDetailsDOB.getRateDescription(),
                                            FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                                    cell1 = new Cell(chk);
                                    //cell1.setRowspan(rateDetails.size());
                                    cell1.setNoWrap(true);
                                    cell1.setLeading(8.0f);
                                    cell1.setBackgroundColor(Color.lightGray);
                                    chargeCountry1.addCell(cell1);
                                    rDescription = rateDetailsDOB.getRateDescription();
                                } else {
                                    cell1 = new Cell("");
                                    //cell1.setRowspan(rateDetails.size());
                                    cell1.setNoWrap(true);
                                    cell1.setLeading(8.0f);
                                    cell1.setBorderWidth(0f);
                                    cell1.setBackgroundColor(Color.lightGray);
                                    chargeCountry1.addCell(cell1);

                                    //@@ Commented by subrahmanyam for 182516 on 10/09/09
                                    /*
                                     cell1 = new Cell("");
                                     //cell1.setRowspan(rateDetails.size());
                                     cell1.setNoWrap(true); cell1.setLeading(8.0f);
                                     cell1.setBackgroundColor(Color.lightGray);
                                     cell1.setBorderWidth(0f);
                                     chargeCountry1.addCell(cell1);
                                     */
                                    //@@ added by subrahmanyam for 182516 on 10/09/09
                                    if (rDescription.equalsIgnoreCase(rateDetailsDOB.getRateDescription())) {
                                        chk = new Chunk("",
                                                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                                        cell1 = new Cell(chk);
                                        //cell1.setRowspan(rateDetails.size());
                                        cell1.setNoWrap(true);
                                        cell1.setLeading(8.0f);
                                        cell1.setBackgroundColor(Color.lightGray);
                                        cell1.setBorderWidth(0f);
                                        chargeCountry1.addCell(cell1);
                                    } else {
                                        chk = new Chunk(
                                                rateDetailsDOB.getRateDescription() == null ? ""
                                                        : rateDetailsDOB.getRateDescription(),
                                                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                                        cell1 = new Cell(chk);
                                        //cell1.setRowspan(rateDetails.size());
                                        //cell1.setNoWrap(true);
                                        cell1.setLeading(8.0f);
                                        cell1.setBackgroundColor(Color.lightGray);
                                        chargeCountry1.addCell(cell1);
                                        rDescription = rateDetailsDOB.getRateDescription();
                                    }
                                    //ended by subrahmanyam for 182516 on 10/09/09

                                }
                                if ("FSBASIC".equalsIgnoreCase(rateDetailsDOB.getWeightBreakSlab())
                                        || "SSBASIC".equalsIgnoreCase(rateDetailsDOB.getWeightBreakSlab()))
                                    rateDetailsDOB.setWeightBreakSlab("Basic Charge");
                                if ("FSMIN".equalsIgnoreCase(rateDetailsDOB.getWeightBreakSlab())
                                        || "SSMIN".equalsIgnoreCase(rateDetailsDOB.getWeightBreakSlab()))
                                    rateDetailsDOB.setWeightBreakSlab("Minimum");
                                if ("FSKG".equalsIgnoreCase(rateDetailsDOB.getWeightBreakSlab())
                                        || "SSKG".equalsIgnoreCase(rateDetailsDOB.getWeightBreakSlab()))
                                    rateDetailsDOB.setWeightBreakSlab("Flat Rate");

                                chk = new Chunk(rateDetailsDOB.getWeightBreakSlab(),
                                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                                cell1 = new Cell(chk);
                                cell1.setNoWrap(true);
                                cell1.setLeading(8.0f);
                                cell1.setBackgroundColor(Color.lightGray);
                                chargeCountry1.addCell(cell1);

                                chk = new Chunk(detailsDOB.getCurrency(),
                                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                                cell1 = new Cell(chk);
                                cell1.setNoWrap(true);
                                cell1.setLeading(8.0f);
                                cell1.setBackgroundColor(Color.lightGray);
                                chargeCountry1.addCell(cell1);

                                chk = new Chunk(rateDetailsDOB.getRate() + "",
                                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                                cell1 = new Cell(chk);
                                cell1.setNoWrap(true);
                                cell1.setLeading(8.0f);
                                chargeCountry1.addCell(cell1);

                                //@@ Added by subrahmanyam for wpbn id: 182516
                                // MODIFIED BY SUBRAHMANYAM FOR 183812
                                if (rateDetailsDOB.getWeightBreakSlab().equalsIgnoreCase("Min")
                                        || rateDetailsDOB.getWeightBreakSlab().equalsIgnoreCase("Minimum")
                                        || ("BOTH".equalsIgnoreCase(detailsDOB.getRateType()) && "FLAT"
                                                .equalsIgnoreCase(rateDetailsDOB.getRateIndicator()))) {
                                    wBSlab = "MIN";
                                } else {
                                    wBSlab = rateDetailsDOB.getWeightBreakSlab();
                                }
                                //@@ commented by subrahmanyam for wpbn id: 182516
                                //chk = new Chunk(rateDetailsDOB.getWeightBreakSlab().equalsIgnoreCase("Min")?"Pershipment ":detailsDOB.getChargeBasisDesc(),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                                //@@ Added by subrahmanyam for wpbn id: 182516
                                chk = new Chunk(
                                        wBSlab.equalsIgnoreCase("Min") ? " Per Shipment "
                                                : detailsDOB.getChargeBasisDesc(),
                                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                                //@@ Ended  for wpbn id: 182516
                                cell1 = new Cell(chk);
                                cell1.setNoWrap(true);
                                cell1.setLeading(8.0f);
                                chargeCountry1.addCell(cell1);

                                chk = new Chunk(
                                        detailsDOB.getDensityRatio() == null ? ""
                                                : detailsDOB.getDensityRatio(),
                                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                                cell1 = new Cell(chk);
                                cell1.setNoWrap(true);
                                cell1.setLeading(8.0f);
                                chargeCountry1.addCell(cell1);

                            }
                        }
                    }
                }
            }
            document.add(chargeCountry1);
        }
        // System.out.println("After Charges--------------------------------->");
        ArrayList destChargeInfo = null;
        //int[]      destChargeInfo        =  null;
        int destChargesInfoSize = 0;
        if (destCount > 0) {
            Table chargeCountry2 = new Table(7, destCount);
            chargeCountry2.setWidth(100);
            chargeCountry2.setPadding(1);
            chargeCountry2.setSpacing(0);
            chargeCountry2.setOffset(25);
            chargeCountry2.setBackgroundColor(Color.WHITE);
            chargeCountry2.setBorderColor(Color.black);
            chargeCountry2.setDefaultHorizontalAlignment(Element.ALIGN_CENTER);
            chargeCountry2.setBorderWidth(1);
            //@@ Added by subrahmanyam for wpbn id: 181349 on 07-sep-09
            chargeCountry2.setTableFitsPage(true);
            chargeCountry2.setCellsFitPage(true);
            // @@ Ended for wpbn id: 181349 on 07-sep-09

            Cell cell2;
            String wBslab = "";
            chk = new Chunk("QUOTEID", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell2 = new Cell(chk);
            cell2.setNoWrap(true);
            cell2.setLeading(8.0f);
            cell2.setBackgroundColor(Color.ORANGE);
            //cell2.setVerticalAlignment(cell2.ALIGN_MIDDLE);
            chargeCountry2.addCell(cell2);

            chk = new Chunk("CHARGE NAME", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell2 = new Cell(chk);
            cell2.setNoWrap(true);
            cell2.setLeading(8.0f);
            cell2.setBackgroundColor(Color.ORANGE);
            //cell2.setVerticalAlignment(cell2.ALIGN_MIDDLE);
            chargeCountry2.addCell(cell2);

            chk = new Chunk("BREAKPOINT", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell2 = new Cell(chk);
            cell2.setNoWrap(true);
            cell2.setLeading(8.0f);
            cell2.setBackgroundColor(Color.ORANGE);
            //cell2.setVerticalAlignment(cell2.ALIGN_MIDDLE);
            chargeCountry2.addCell(cell2);

            chk = new Chunk("CURRENCY", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell2 = new Cell(chk);
            cell2.setNoWrap(true);
            cell2.setLeading(8.0f);
            cell2.setBackgroundColor(Color.ORANGE);
            //cell2.setVerticalAlignment(cell2.ALIGN_MIDDLE);
            chargeCountry2.addCell(cell2);

            chk = new Chunk("RATE", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell2 = new Cell(chk);
            cell2.setNoWrap(true);
            cell2.setLeading(8.0f);
            cell2.setBackgroundColor(Color.ORANGE);
            //cell2.setVerticalAlignment(cell2.ALIGN_MIDDLE);
            chargeCountry2.addCell(cell2);

            chk = new Chunk("BASIS", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell2 = new Cell(chk);
            cell2.setNoWrap(true);
            cell2.setLeading(8.0f);
            cell2.setBackgroundColor(Color.ORANGE);
            //cell2.setVerticalAlignment(cell2.ALIGN_MIDDLE);
            chargeCountry2.addCell(cell2);

            chk = new Chunk("RATIO", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell2 = new Cell(chk);
            cell2.setNoWrap(true);
            cell2.setLeading(8.0f);
            cell2.setBackgroundColor(Color.ORANGE);
            //cell2.setVerticalAlignment(cell2.ALIGN_MIDDLE);
            chargeCountry2.addCell(cell2);

            chk = new Chunk("DESTINATION CHARGES", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
            cell2 = new Cell(chk);
            cell2.setNoWrap(true);
            cell2.setLeading(8.0f);
            cell2.setColspan(7);
            cell2.setBackgroundColor(Color.ORANGE);
            //cell2.setVerticalAlignment(cell2.ALIGN_MIDDLE);
            chargeCountry2.addCell(cell2);
            int mDtlSize = mainDtl.size();
            for (int m = 0; m < mDtlSize; m++) {

                finalDOB = (QuoteFinalDOB) mainDtl.get(m);
                headerDOB = finalDOB.getHeaderDOB();
                masterDOB = finalDOB.getMasterDOB();
                costingMasterDOB = finalDOB.getCostingMasterDOB();
                ArrayList destCharges = (ArrayList) costingMasterDOB.getDestinationList();
                if (destCharges.size() > 0) {

                    int destChargSize = destCharges.size();

                    for (int i = 0; i < destChargSize; i++) {

                        detailsDOB = (CostingChargeDetailsDOB) destCharges.get(i);
                        rateDetails = (ArrayList) detailsDOB.getCostingRateInfoDOB();

                        //originChargesInfoSize   = rateDetails.size();
                        int rDtlSize = rateDetails.size();
                        for (int k = 0; k < rDtlSize; k++) {
                            CostingRateInfoDOB crateDetailsDOB = (CostingRateInfoDOB) rateDetails.get(k);

                            if (k == 0) {

                                //@@ Commented by subrahmanyam for the enhancement #146971 and 1469710 on 10/12/2008                      
                                /*chk = new Chunk(new Long(masterDOB.getQuoteId()).toString(),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                                cell2 = new Cell(chk);
                                //cell2.setRowspan(rateDetails.size());
                                cell2.setNoWrap(true); cell2.setLeading(8.0f);
                                cell2.setBackgroundColor(Color.lightGray);
                                chargeCountry2.addCell(cell2);*/
                                //@@ Added by subrahmanyam for the enhancement #146971 and #146970 on 10/12/2008
                                chk = new Chunk(masterDOB.getQuoteId(),
                                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                                cell2 = new Cell(chk);
                                cell2.setNoWrap(true);
                                cell2.setLeading(8.0f);
                                cell2.setBackgroundColor(Color.lightGray);
                                chargeCountry2.addCell(cell2);
                                //@@ Ended by subrahmanyam for the enhancement #146971 and 146970 on 10/12/2008    

                                //  chk = new Chunk(detailsDOB.getChargeDescId(),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                                //@@ Added by subrahmanyam for the wpbn id: 181349  on 07-sep-09
                                chk = new Chunk(
                                        detailsDOB.getExternalName() != null ? detailsDOB.getExternalName()
                                                : detailsDOB.getChargeDescId(),
                                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));//ended for 181349
                                cell2 = new Cell(chk);
                                //cell2.setRowspan(rateDetails.size());
                                //cell2.setNoWrap(true); //commented for 181349
                                cell2.setLeading(8.0f);
                                cell2.setBackgroundColor(Color.lightGray);
                                chargeCountry2.addCell(cell2);
                            } else {
                                cell2 = new Cell("");
                                //cell2.setRowspan(rateDetails.size());
                                cell2.setNoWrap(true);
                                cell2.setLeading(8.0f);
                                cell2.setBackgroundColor(Color.lightGray);
                                cell2.setBorderWidth(0f);
                                chargeCountry2.addCell(cell2);

                                cell2 = new Cell("");
                                //cell2.setRowspan(rateDetails.size());
                                cell2.setNoWrap(true);
                                cell2.setLeading(8.0f);
                                cell2.setBackgroundColor(Color.lightGray);
                                cell2.setBorderWidth(0f);
                                chargeCountry2.addCell(cell2);
                            }
                            chk = new Chunk(crateDetailsDOB.getWeightBreakSlab(),
                                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                            cell2 = new Cell(chk);
                            cell2.setNoWrap(true);
                            cell2.setLeading(8.0f);
                            cell2.setBackgroundColor(Color.lightGray);
                            chargeCountry2.addCell(cell2);

                            chk = new Chunk(detailsDOB.getCurrency(),
                                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                            cell2 = new Cell(chk);
                            cell2.setNoWrap(true);
                            cell2.setLeading(8.0f);
                            cell2.setBackgroundColor(Color.lightGray);
                            chargeCountry2.addCell(cell2);

                            chk = new Chunk(crateDetailsDOB.getRate() + "",
                                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                            cell2 = new Cell(chk);
                            cell2.setNoWrap(true);
                            cell2.setLeading(8.0f);
                            chargeCountry2.addCell(cell2);

                            //@@ Commented & Added  by subrahmanyam for 182516 on 10/09/09
                            // chk = new Chunk(crateDetailsDOB.getWeightBreakSlab().equalsIgnoreCase("Min")?"Pershipment ":detailsDOB.getChargeBasisDesc(),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                            //ADDED BY SUBRAHMANYAM FOR 183812
                            if (crateDetailsDOB.getWeightBreakSlab().equalsIgnoreCase("Min")
                                    || ("BOTH".equalsIgnoreCase(detailsDOB.getRateType())
                                            && "F".equalsIgnoreCase(crateDetailsDOB.getRateIndicator()))) {
                                wBslab = "MIN";
                            } else
                                wBslab = detailsDOB.getChargeBasisDesc();
                            // COMMENTED & added FOR 183812 ON 24-09-09
                            //chk = new Chunk(crateDetailsDOB.getWeightBreakSlab().equalsIgnoreCase("Min")?" Per Shipment ":detailsDOB.getChargeBasisDesc(),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                            chk = new Chunk(
                                    wBslab.equalsIgnoreCase("Min") ? " Per Shipment "
                                            : detailsDOB.getChargeBasisDesc(),
                                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                            cell2 = new Cell(chk);
                            cell2.setNoWrap(true);
                            cell2.setLeading(8.0f);
                            chargeCountry2.addCell(cell2);

                            chk = new Chunk(
                                    detailsDOB.getDensityRatio() == null ? "" : detailsDOB.getDensityRatio(),
                                    FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                            cell2 = new Cell(chk);
                            cell2.setNoWrap(true);
                            cell2.setLeading(8.0f);
                            chargeCountry2.addCell(cell2);
                        }
                    }
                }
            }
            document.add(chargeCountry2);
        }

        Table notes = new Table(2, mainDtl.size());
        boolean displayFlag = false;
        notes.setWidth(100);
        notes.setPadding(1);
        notes.setSpacing(0);
        notes.setOffset(5);
        notes.setBackgroundColor(Color.WHITE);
        notes.setBorderColor(Color.black);
        notes.setDefaultHorizontalAlignment(Element.ALIGN_CENTER);
        notes.setBorderWidth(1);
        notes.setTableFitsPage(true);// added by subrahmanyam for quoteGrouping issue 184848
        notes.setCellsFitPage(true);// added by subrahmanyam for quoteGrouping issue 184848

        Cell cell3;
        chk = new Chunk("QUOTEID ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
        cell3 = new Cell(chk);
        cell3.setNoWrap(true);
        cell3.setLeading(8.0f);
        cell3.setBackgroundColor(Color.ORANGE);
        //cell3.setVerticalAlignment(cell3.ALIGN_MIDDLE);
        //cell3.setBackgroundColor(Color.lightGray);
        notes.addCell(cell3);

        chk = new Chunk("NOTES", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
        cell3 = new Cell(chk);
        cell3.setNoWrap(true);
        cell3.setLeading(8.0f);
        cell3.setBackgroundColor(Color.ORANGE);
        //cell3.setVerticalAlignment(cell3.ALIGN_MIDDLE);

        notes.addCell(cell3);
        int mDtlSize = mainDtl.size();
        for (int m = 0; m < mDtlSize; m++) {

            finalDOB = (QuoteFinalDOB) mainDtl.get(m);
            headerDOB = finalDOB.getHeaderDOB();
            masterDOB = finalDOB.getMasterDOB();
            costingMasterDOB = finalDOB.getCostingMasterDOB();
            if (costingMasterDOB != null) {
            }
            //@@ Commented by subrahmanyam for the enhancement #146971 and 1469710 on 10/12/2008                      
            /*chk = new Chunk(new Long(masterDOB.getQuoteId()).toString(),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
            cell3 = new Cell(chk);
            //cell3.setRowspan(rateDetails.size());
            cell3.setNoWrap(true); cell3.setLeading(8.0f);
            cell3.setBackgroundColor(Color.lightGray);
            notes.addCell(cell3);*/
            //@@ Added by subrahmanyam for the enhancement #146971 and #146970 on 10/12/2008
            //commented by subrahmanyam for quote grouping issue
            /*
            chk = new Chunk(masterDOB.getQuoteId(),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
              cell3 = new Cell(chk);
              cell3.setNoWrap(true); cell3.setLeading(8.0f);
              cell3.setBackgroundColor(Color.lightGray);
              notes.addCell(cell3);
                //@@ Ended by subrahmanyam for the enhancement #146971 and 146970 on 10/12/2008
                    
            chk = new Chunk(" ",FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
            cell3 = new Cell(chk);
            //cell3.setRowspan();
            cell3.setNoWrap(true); cell3.setLeading(8.0f);
            cell3.setBackgroundColor(Color.lightGray);
            notes.addCell(cell3);
            */
            //@@ Added by subrahmanyam for Quote Grouping Issue 184848 on 30/sep/09
            if (finalDOB.getExternalNotes() != null && finalDOB.getExternalNotes().length > 0) {
                int notesLength = finalDOB.getExternalNotes().length;
                for (int n = 0; n < notesLength; n++) {
                    if (n == 0) {
                        chk = new Chunk(masterDOB.getQuoteId(),
                                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                        cell3 = new Cell(chk);
                        cell3.setNoWrap(true);
                        cell3.setLeading(8.0f);
                        cell3.setBackgroundColor(Color.lightGray);
                        notes.addCell(cell3);
                        //@@ Ended by subrahmanyam for the enhancement #146971 and 146970 on 10/12/2008

                        chk = new Chunk(finalDOB.getExternalNotes()[n],
                                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                        cell3 = new Cell(chk);
                        //cell3.setRowspan();
                        //cell3.setNoWrap(true);
                        cell3.setHorizontalAlignment(cell3.ALIGN_LEFT);
                        cell3.setLeading(8.0f);
                        cell3.setBackgroundColor(Color.lightGray);
                        notes.addCell(cell3);
                    } else {
                        chk = new Chunk("", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                        cell3 = new Cell(chk);
                        cell3.setNoWrap(true);
                        cell3.setLeading(8.0f);
                        cell3.setBackgroundColor(Color.lightGray);
                        notes.addCell(cell3);
                        //@@ Ended by subrahmanyam for the enhancement #146971 and 146970 on 10/12/2008

                        chk = new Chunk(finalDOB.getExternalNotes()[n],
                                FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                        cell3 = new Cell(chk);
                        //cell3.setRowspan();
                        // cell3.setNoWrap(true);
                        cell3.setHorizontalAlignment(cell3.ALIGN_LEFT);
                        cell3.setLeading(8.0f);
                        cell3.setBackgroundColor(Color.lightGray);
                        notes.addCell(cell3);
                    }
                }
            } else {
                chk = new Chunk(masterDOB.getQuoteId(),
                        FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                cell3 = new Cell(chk);
                cell3.setNoWrap(true);
                cell3.setLeading(8.0f);
                cell3.setBackgroundColor(Color.lightGray);
                notes.addCell(cell3);

                chk = new Chunk(" ", FontFactory.getFont("ARIAL", 8, Font.NORMAL, Color.BLACK));
                cell3 = new Cell(chk);
                //cell3.setRowspan();
                cell3.setNoWrap(true);
                cell3.setLeading(8.0f);
                cell3.setBackgroundColor(Color.lightGray);
                notes.addCell(cell3);
            }
            //@@ Ended by subrahmanyam for Quote Grouping Issue 184848 on 30/09/09

            contents = masterDOB.getContentOnQuote();
            levels = masterDOB.getLevels();
            aligns = masterDOB.getAlign();
            headFoot = masterDOB.getHeaderFooter();

            if (contents != null && contents.length > 0) {
                int hFLen = headFoot.length;
                for (int i = 0; i < hFLen; i++) {
                    if (headFoot[i] != null && "F".equalsIgnoreCase(headFoot[i])) {
                        displayFlag = true;
                        break;
                    }
                }
                if (displayFlag) {
                    content = new Table(1);
                    content.setOffset(5);
                    content.setWidth(100);
                    content.setPadding(1);
                    content.setSpacing(0);
                    content.setBackgroundColor(Color.WHITE);
                    content.setBorderColor(Color.black);
                    content.setBorderWidth(1f);
                    Cell cellContent = null;
                    chk = new Chunk("QUOTEID : " + masterDOB.getQuoteId(),
                            FontFactory.getFont("ARIAL", 7, Font.ITALIC, Color.BLACK));
                    cellContent = new Cell(chk);
                    cellContent.setBorder(0);
                    cellContent.setLeading(6.0f);
                    cellContent.setHorizontalAlignment(cellContent.ALIGN_CENTER);
                    cellContent.setBackgroundColor(Color.ORANGE);
                    content.addCell(cellContent);
                    for (int i = 0; i < hFLen; i++) {
                        if (headFoot[i] != null && "F".equalsIgnoreCase(headFoot[i])) {
                            chk = new Chunk(contents[i] != null ? contents[i].toUpperCase() : "",
                                    FontFactory.getFont("ARIAL", 7, Font.ITALIC, Color.BLACK));
                            cellContent = new Cell(chk);
                            cellContent.setBorder(0);
                            cellContent.setLeading(6.0f);
                            cellContent.setBackgroundColor(Color.LIGHT_GRAY);
                            if ("L".equalsIgnoreCase(aligns[i]))
                                cellContent.setHorizontalAlignment(cellContent.ALIGN_LEFT);
                            else if ("C".equalsIgnoreCase(aligns[i]))
                                cellContent.setHorizontalAlignment(cellContent.ALIGN_CENTER);
                            else if ("R".equalsIgnoreCase(aligns[i]))
                                cellContent.setHorizontalAlignment(cellContent.ALIGN_RIGHT);
                            content.addCell(cellContent);
                        }
                    }
                    document.add(content);
                }
            }
        }
        document.add(notes);
        //Default Footer Content Starts
        contents = masterDOB.getDefaultContent();
        //Added by Anusha V
        int hFLen = 0;
        headFoot = masterDOB.getDefaultHeaderFooter();
        //if(headFoot.length>0){
        //hFLen   =   headFoot.length;}
        //Commented by Anusha V
        //int hFLen = headFoot.length;
        if (contents != null && contents.length > 0) {
            content = new Table(1);
            content.setOffset(5);
            content.setWidth(100);
            content.setPadding(1);
            content.setSpacing(0);
            content.setBackgroundColor(Color.WHITE);
            content.setBorderColor(Color.black);
            content.setBorderWidth(1f);
            Cell cellContent = null;
            chk = null;

            for (int i = 0; i < headFoot.length; i++) {
                if (headFoot[i] != null && "F".equalsIgnoreCase(headFoot[i])) {
                    chk = new Chunk(contents[i], FontFactory.getFont("ARIAL", 7, Font.ITALIC, Color.BLACK));
                    cellContent = new Cell(chk);
                    cellContent.setBorder(0);
                    cellContent.setLeading(6.0f);
                    cellContent.setBackgroundColor(Color.LIGHT_GRAY);
                    cellContent.setHorizontalAlignment(cellContent.ALIGN_LEFT);//Default content is left aligned                                    
                    content.addCell(cellContent);

                }
            }
            document.add(content);
        }
        //End Default Footer Content

        // System.out.println("After     document Close----------------------------------------->");

        document.close();
        // Thread.sleep(100);
        //logger.info("thread");
        //String file_tsmp = ""+new java.sql.Timestamp((new java.util.Date()).getTime()+masterDOB.getQuoteId());  //@@ Commented by subrahmanyam for the Enhancement #146971 on 2/12/08
        // String file_tsmp = ""+new java.sql.Timestamp((new java.util.Date()).getTime()+Long.parseLong(masterDOB.getQuoteId()));  //@@ Added by subrahmanyam for the Enhancement #146971 on 2/12/08
        //Commented by Anusha V
        //String file_tsmp = ""+new java.sql.Timestamp((new java.util.Date()).getTime())+masterDOB.getQuoteId();//@@ Added by subrahmanyam for the Enhancement #146971 on 2/12/08
        //Added by Anusha V
        String file_tsmp = "" + new java.sql.Timestamp((new java.util.Date()).getTime());
        file_tsmp = file_tsmp.replaceAll("\\:", "");
        file_tsmp = file_tsmp.replaceAll("\\.", "");
        file_tsmp = file_tsmp.replaceAll("\\-", "");
        file_tsmp = file_tsmp.replaceAll(" ", "");
        File f = new File("Quote" + file_tsmp + ".pdf");
        FileOutputStream fileOutputStream = new FileOutputStream(f);
        baos.writeTo(fileOutputStream);
        fileOutputStream.close();
        //  logger.info("masterDOB.getUserId()"+masterDOB.getUserId());
        if ("on".equalsIgnoreCase(request.getParameter("print"))) {

            request.getSession().setAttribute("QuoteOuptutStream", f);
        }
        //  session.setAttribute("UserId",masterDOB.getUserId());

        int noOfQuotes = mainDtl.size();
        StringBuffer quoteIds = new StringBuffer("");
        String quoteType = "";
        String terminalAddress = "";
        String creatorDetails = "";
        String fromEmailId = "";
        String body = "";
        String countryCode = "";
        for (int i = 0; i < noOfQuotes; i++) {
            finalDOB = (QuoteFinalDOB) mainDtl.get(i);
            /*  //@@Added for the WPBN issue-
              filesDOBList           =   finalDOB.getAttachmentDOBList(); 
              for(int j=0;j<filesDOBList.size();j++)
              {
               filesList.add(filesDOBList.get(j));
              } //@@Added for the WPBN issue-*/

            if (i == 0) {
                quoteType = "" + finalDOB.getMasterDOB().getShipmentMode();
                terminalAddress = finalDOB.getMasterDOB().getTerminalAddress();
                creatorDetails = finalDOB.getMasterDOB().getCreatorDetails();
                fromEmailId = finalDOB.getMasterDOB().getUserEmailId();
                countryCode = finalDOB.getHeaderDOB().getCustCountyCode();
                to_FaxIds = finalDOB.getHeaderDOB().getCustFaxNo();
                to_emailIds = finalDOB.getHeaderDOB().getCustEmailId();
            }
            quoteIds.append(finalDOB.getMasterDOB().getQuoteId());
            if (i != noOfQuotes - 1)
                quoteIds.append(",");

            contactPersons = finalDOB.getMasterDOB().getCustContactNames();
            if (contactPersons != null) {
                int contPersLen = contactPersons.length;
                for (int k = 0; k < contPersLen; k++) {
                    if (!contactList.contains(finalDOB.getMasterDOB().getCustContactNames()[k])) {
                        contactList.add(finalDOB.getMasterDOB().getCustContactNames()[k]);
                        contactEmailList.add(finalDOB.getMasterDOB().getCustomerContactsEmailIds()[k]);
                        contactFaxList.add(finalDOB.getMasterDOB().getCustomerContactsFax()[k]);
                    }
                }

            }

        }

        if ("1".equalsIgnoreCase(quoteType))
            quoteType = "Airfreight";
        else if ("2".equalsIgnoreCase(quoteType))
            quoteType = "Seafreight";
        else if ("4".equalsIgnoreCase(quoteType))
            quoteType = "Truckfreight";

        String subject = "DHL Global Forwarding Quotation, Multiple " + quoteType + ", Quote References "
                + quoteIds.toString();
        String message = "";
        //finalDOB.getFlagsDOB().setQuoteStatusFlag("PEN");//@@Quote is Pending
        //ReportsSessionBeanHome home      = (ReportsSessionBeanHome)LookUpBean.getEJBHome("ReportsSessionBean");
        //ReportsSession remote   = (ReportsSession)home.create();
        //if(contactList.size()==0)
        //{
        to_emailIds = to_emailIds.replaceAll(";", ",");
        /*message  = "Dear Customer,\n\nThank you for the opportunity to provide this quotation.  All information is contained within the attachment."+
                    "  Should you have any queries please do not hesitate to contact us.\n\n\nRegards,\n"+creatorDetails+"\n"+terminalAddress;*/
        //message   = "Dear Customer,\n\n"+finalDOB.getEmailText()+"\n\n\nRegards,\n"+creatorDetails+"\n"+terminalAddress+"\n"+;       
        if (finalDOB.getUpdatedReportDOB() != null) {
            body = "Dear Customer,\n\nThis is a replacement quotation reference "
                    + request.getAttribute("quoteId") + ",replacing "
                    + finalDOB.getUpdatedReportDOB().getQuoteId() + ", due to a change in "
                    + (finalDOB.getEmailChargeName() != null ? finalDOB.getEmailChargeName()
                            : finalDOB.getUpdatedReportDOB().getChangeDesc())
                    + ",\n\n" + (finalDOB.getEmailText() != null ? finalDOB.getEmailText() : "") + "\n\n\n"
                    + (masterDOB.getCreatorDetails() != null ? masterDOB.getCreatorDetails() : "") + "\n\n"
                    + (masterDOB.getCompanyName() != null ? masterDOB.getCompanyName() : "") + "\n"
                    + (masterDOB.getTerminalAddress() != null ? masterDOB.getTerminalAddress() : "") + "\n\n"
                    + "Phone  " + (masterDOB.getPhoneNo() != null ? masterDOB.getPhoneNo() : "") + "\n"
                    + "Fax    " + (masterDOB.getFaxNo() != null ? masterDOB.getFaxNo() : "") + "\n" + "Mobile "
                    + (masterDOB.getMobileNo() != null ? masterDOB.getMobileNo() : "") + "\n\nEmail "
                    + (masterDOB.getUserEmailId() != null ? masterDOB.getUserEmailId() : ""); //@@Modified by Kameswari for the WPBN issue-61303
        } else {
            body = "Dear Customer,\n\n" + (finalDOB.getEmailText() != null ? finalDOB.getEmailText() : "")
                    + "\n\n\n" + (masterDOB.getCreatorDetails() != null ? masterDOB.getCreatorDetails() : "")
                    + "\n\n" + (masterDOB.getCompanyName() != null ? masterDOB.getCompanyName() : "") + "\n"
                    + (masterDOB.getTerminalAddress() != null ? masterDOB.getTerminalAddress() : "") + "\n\n"
                    + "Phone  " + (masterDOB.getPhoneNo() != null ? masterDOB.getPhoneNo() : "") + "\n"
                    + "Fax    " + (masterDOB.getFaxNo() != null ? masterDOB.getFaxNo() : "") + "\n" + "Mobile "
                    + (masterDOB.getMobileNo() != null ? masterDOB.getMobileNo() : "") + "\n\nEmail "
                    + (masterDOB.getUserEmailId() != null ? masterDOB.getUserEmailId() : ""); //@@Modified by Kameswari for the WPBN issue-61303
        }
        if ("on".equalsIgnoreCase(request.getParameter("email"))) {
            try {
                sendMail(fromEmailId, to_emailIds, subject, message, "Quote" + file_tsmp + ".pdf", null);
                sentEmailsList.add(to_emailIds);
            } catch (FoursoftException fs) {
                //Logger.error(FILE_NAME,"Error While Sending Mail.."+fs.getMessage());
                logger.error(FILE_NAME + "Error While Sending Mail.." + fs.getMessage());
                fs.printStackTrace();
                unsentEmailsList.add(to_emailIds);
            }
        }
        if ("on".equalsIgnoreCase(request.getParameter("fax"))) {
            if ("SG".equalsIgnoreCase(countryCode))
                faxMailIds = "fax#" + to_FaxIds + "@tcdhl.com";
            else
                faxMailIds = "ifax#" + to_FaxIds + "@tcdhl.com";
            try {
                sendMail(fromEmailId, faxMailIds, subject, message, "Quote" + file_tsmp + ".pdf", null);
                sentFaxList.add(to_FaxIds);
            } catch (FoursoftException fs) {
                //Logger.error(FILE_NAME,"Error While Sending Fax.."+fs.getMessage());
                logger.error(FILE_NAME + "Error While Sending Fax.." + fs.getMessage());
                fs.printStackTrace();
                unsentFaxList.add(to_FaxIds);
            }
        }
        //}
        //else
        //{
        int contactSize = contactList.size();
        for (int i = 0; i < contactSize; i++) {
            contactName = (String) contactList.get(i);
            /*message = "Dear "+contactName+",\n\nThank you for the opportunity to provide this Quotation. All information is contained within the attachment."+
             " Should you have any queries, please do not hesitate to contact us.\n\n\nRegards,\n"+creatorDetails+"\n"+terminalAddress;*/
            // message = "Dear "+contactName+",\n\n"+finalDOB.getEmailText()+"\n\n\nRegards,\n"+creatorDetails+"\n"+terminalAddress;         
            if (finalDOB.getUpdatedReportDOB() != null) {
                body = "Dear " + (contactName != null ? contactName : "")
                        + ",\n\nThis is a replacement quotation reference " + request.getAttribute("quoteId")
                        + ",replacing " + finalDOB.getUpdatedReportDOB().getQuoteId() + ", due to a change in "
                        + (finalDOB.getEmailChargeName() != null ? finalDOB.getEmailChargeName()
                                : finalDOB.getUpdatedReportDOB().getChangeDesc())
                        + ",\n\n" + finalDOB.getEmailText() != null
                                ? finalDOB.getEmailText()
                                : "" + "\n\n\n" + masterDOB.getCreatorDetails() != null
                                        ? masterDOB.getCreatorDetails()
                                        : "" + "\n\n" + masterDOB.getCompanyName() != null
                                                ? masterDOB.getCompanyName()
                                                : "" + "\n" + masterDOB.getTerminalAddress() != null
                                                        ? masterDOB.getTerminalAddress()
                                                        : "" + "\n\n" + "Phone  "
                                                                + masterDOB.getPhoneNo() != null
                                                                        ? masterDOB.getPhoneNo()
                                                                        : "" + "\n" + "Fax    "
                                                                                + masterDOB.getFaxNo() != null
                                                                                        ? masterDOB.getFaxNo()
                                                                                        : "" + "\n" + "Mobile "
                                                                                                + masterDOB
                                                                                                        .getMobileNo() != null
                                                                                                                ? masterDOB
                                                                                                                        .getMobileNo()
                                                                                                                : "" + "\n\nEmail "
                                                                                                                        + masterDOB
                                                                                                                                .getUserEmailId() != null
                                                                                                                                        ? masterDOB
                                                                                                                                                .getUserEmailId()
                                                                                                                                        : ""; //@@Modified by Kameswari for the WPBN issue-61303
            } else {
                body = "Dear " + (contactName != null ? contactName : "") + ",\n\n"
                        + finalDOB.getEmailText() != null
                                ? finalDOB.getEmailText()
                                : "" + "\n\n\n" + masterDOB.getCreatorDetails() != null
                                        ? masterDOB.getCreatorDetails()
                                        : "" + "\n\n" + masterDOB.getCompanyName() != null
                                                ? masterDOB.getCompanyName()
                                                : "" + "\n" + masterDOB.getTerminalAddress() != null
                                                        ? masterDOB.getTerminalAddress()
                                                        : "" + "\n\n" + "Phone  "
                                                                + masterDOB.getPhoneNo() != null
                                                                        ? masterDOB.getPhoneNo()
                                                                        : "" + "\n" + "Fax    "
                                                                                + masterDOB.getFaxNo() != null
                                                                                        ? masterDOB.getFaxNo()
                                                                                        : "" + "\n" + "Mobile "
                                                                                                + masterDOB
                                                                                                        .getMobileNo() != null
                                                                                                                ? masterDOB
                                                                                                                        .getMobileNo()
                                                                                                                : "" + "\n\nEmail "
                                                                                                                        + masterDOB
                                                                                                                                .getUserEmailId() != null
                                                                                                                                        ? masterDOB
                                                                                                                                                .getUserEmailId()
                                                                                                                                        : ""; //@@Modified by Kameswari for the WPBN issue-61303

            }
            if ("on".equalsIgnoreCase(request.getParameter("email"))) {
                try {
                    sendMail(fromEmailId, (String) contactEmailList.get(i), subject, message,
                            "Quote" + file_tsmp + ".pdf", null);
                    sentEmailsList.add(contactEmailList.get(i));
                } catch (FoursoftException fs) {
                    //Logger.error(FILE_NAME,"Error While Sending Mail.."+fs.getMessage());
                    logger.error(FILE_NAME + "Error While Sending Mail.." + fs.getMessage());
                    fs.printStackTrace();
                    unsentEmailsList.add(contactEmailList.get(i));
                }
            }
            if ("on".equalsIgnoreCase(request.getParameter("fax"))) {
                if ("SG".equalsIgnoreCase(countryCode))
                    to_FaxIds = "fax#" + contactFaxList.get(i) + "@tcdhl.com";
                else
                    to_FaxIds = "ifax#" + contactFaxList.get(i) + "@tcdhl.com";
                try {
                    sendMail(fromEmailId, to_FaxIds, subject, message, "Quote" + file_tsmp + ".pdf", null);
                    sentFaxList.add(contactFaxList.get(i));
                } catch (FoursoftException fs) {
                    //Logger.error(FILE_NAME,"Error While Sending Fax.."+fs.getMessage());
                    logger.error(FILE_NAME + "Error While Sending Fax.." + fs.getMessage());
                    fs.printStackTrace();
                    unsentFaxList.add(
                            contactFaxList.get(i) != null ? contactFaxList.get(i) : "No Fax Number Provided");
                }
            }
        }
        //}
        returnList.add(sentEmailsList);
        returnList.add(unsentEmailsList);
        returnList.add(sentFaxList);
        returnList.add(unsentFaxList);

        // System.out.println("Before Sending Mail------------------------------>");

        // System.out.println("End of mail sending and PDF Generation --------------------------------->");

    } catch (Exception e) {
        e.printStackTrace();
        //Logger.error(FILE_NAME,"Error while generating the PDF"+e.toString());
        logger.error(FILE_NAME + "Error while generating the PDF" + e.toString());
        //return 0;
        //throw new Exception("Error while generating PDF format");
    }
    return returnList;
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

/**
 * @author sunqichang//*from  ww w. ja  v a  2s.c  o  m*/
 * @param filename
 *            
 * @param type
 *            pdfdoc
 */
public void createReport_hardwareNew(String filename, String type) {
    try {
        int diskcount = Integer.parseInt(request.getParameter("diskcount"));
        String starttime = (String) reportHash.get("starttime");
        String totime = (String) reportHash.get("totime");
        List networkList = (List) reportHash.get("networkList");
        List serverList = (List) reportHash.get("serverList");
        List dbList = (List) reportHash.get("dbList");
        List midwareList = (List) reportHash.get("midwareList");
        Document document = new Document(PageSize.A4);
        if ("doc".equalsIgnoreCase(type)) {
            RtfWriter2.getInstance(document, new FileOutputStream(filename));
        } else {
            PdfWriter.getInstance(document, new FileOutputStream(filename));
        }
        BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
        Font fontChineseTitle = new Font(bfChinese, 14, Font.BOLD);
        Font fontChineseRow = new Font(bfChinese, 12, Font.NORMAL);
        fileName = filename;
        document.open();
        Paragraph title = new Paragraph("", fontChineseTitle);
        title.setAlignment(Element.ALIGN_CENTER);
        document.add(title);
        String contextString = ":" + impReport.getTimeStamp() + " \n"// 
                + ":" + starttime + "  " + totime;
        Paragraph context = new Paragraph(contextString, fontChineseTitle);
        context.setAlignment(Element.ALIGN_CENTER);
        // context.setFont(contextFont);
        // 
        context.setSpacingBefore(5);
        // 
        context.setFirstLineIndent(5);
        document.add(context);
        Iterator networkIt = null;
        if (networkList != null) {
            networkIt = networkList.iterator();
        }
        Iterator serverIt = null;
        if (serverList != null) {
            serverIt = serverList.iterator();
        }
        Iterator dbIt = null;
        if (dbList != null) {
            dbIt = dbList.iterator();
        }
        Iterator midwareIt = null;
        if (midwareList != null) {
            midwareIt = midwareList.iterator();
        }
        String[] networkTitle = { "", "", "", "", "IP", "" };
        String[] serverTitle = { "", "", "", "", "IP", "", "" };
        String[] dbTitle = { "", "", "", "IP" };
        String[] midwareTitle = { "", "", "", "IP" };
        Table table = new Table(9);
        table.setWidth(100);
        table.setAlignment(Element.ALIGN_CENTER);// 
        table.setAutoFillEmptyCells(true); // 
        table.setBorderWidth(1); // 
        table.setBorderColor(new Color(0, 125, 255)); // 
        table.setPadding(2);// 
        table.setSpacing(0);// 
        table.setBorder(2);// 
        for (int i = 0; i < networkTitle.length; i++) {
            Cell cell = new Cell();
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.addElement(new Paragraph(networkTitle[i], fontChineseTitle));
            if (i == 0) {
                cell.setRowspan(networkList.size() + 1);
            }
            if (i == 1 || i == 4 || i == 3) {
                cell.setColspan(2);
            }
            cell.setBackgroundColor(Color.LIGHT_GRAY);
            table.addCell(cell);
        }
        if (networkIt != null) {
            while (networkIt.hasNext()) {
                Cell cell1 = new Cell();
                Cell cell2 = new Cell();
                Cell cell3 = new Cell();
                Cell cell4 = new Cell();
                Cell cell5 = new Cell();
                cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell3.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell4.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell5.setVerticalAlignment(Element.ALIGN_MIDDLE);
                MonitorNodeDTO monitorNodeDTO = (MonitorNodeDTO) networkIt.next();
                cell1.addElement(new Paragraph(monitorNodeDTO.getAlias(), fontChineseRow));
                cell2.addElement(new Paragraph(monitorNodeDTO.getCategory(), fontChineseRow));
                cell3.addElement(new Paragraph(monitorNodeDTO.getType(), fontChineseRow));
                cell4.addElement(new Paragraph(monitorNodeDTO.getIpAddress(), fontChineseRow));
                cell5.addElement(
                        new Paragraph(String.valueOf(monitorNodeDTO.getEntityNumber()), fontChineseRow));
                cell1.setColspan(2);
                // cell2.setColspan(2);
                cell3.setColspan(2);
                cell4.setColspan(2);
                // cell5.setColspan(2);
                table.addCell(cell1);
                table.addCell(cell2);
                table.addCell(cell3);
                table.addCell(cell4);
                table.addCell(cell5);
            }
        }
        for (int i = 0; i < serverTitle.length; i++) {
            Cell cell = new Cell();
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.addElement(new Paragraph(serverTitle[i], fontChineseTitle));
            if (i == 0) {
                cell.setRowspan(diskcount + 1 + serverList.size());
            }
            if (i == 5 || i == 6) {
                cell.setColspan(2);
            }
            cell.setBackgroundColor(Color.LIGHT_GRAY);
            table.addCell(cell);
        }
        if (serverIt != null) {
            while (serverIt.hasNext()) {
                Cell cell1 = new Cell();
                Cell cell2 = new Cell();
                Cell cell3 = new Cell();
                Cell cell44 = new Cell();
                cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell3.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell44.setVerticalAlignment(Element.ALIGN_MIDDLE);
                MonitorNodeDTO monitorNodeDTO = (MonitorNodeDTO) serverIt.next();
                AssetHelper helper = new AssetHelper();
                List<StatisNumer> diskList = helper.getAssetList(monitorNodeDTO.getIpAddress(), "Disk");
                List<StatisNumer> memList = helper.getAssetList(monitorNodeDTO.getIpAddress(), "Memory");
                cell1.addElement(new Paragraph(monitorNodeDTO.getAlias(), fontChineseRow));
                cell2.addElement(new Paragraph(monitorNodeDTO.getCategory(), fontChineseRow));
                cell3.addElement(new Paragraph(monitorNodeDTO.getType(), fontChineseRow));
                cell44.addElement(new Paragraph(monitorNodeDTO.getIpAddress(), fontChineseRow));
                cell1.setRowspan(diskList.size() + 2);
                cell2.setRowspan(diskList.size() + 2);
                cell3.setRowspan(diskList.size() + 2);
                cell44.setRowspan(diskList.size() + 2);
                table.addCell(cell1);
                table.addCell(cell2);
                table.addCell(cell3);
                table.addCell(cell44);
                Iterator<StatisNumer> diskIt = diskList.iterator();
                int flag = 0;
                int rowspan = diskList.size() + 2;
                double sum = 0;
                while (diskIt.hasNext()) {
                    if (flag == 0 || flag == rowspan / 2) {
                        if (flag == 0) {
                            Cell cellt1 = new Cell();
                            Cell cellt2 = new Cell();
                            cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);
                            cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);
                            cellt1.add(new Paragraph("", fontChineseRow));
                            cellt2.add(new Paragraph("", fontChineseRow));
                            table.addCell(cellt1);
                            table.addCell(cellt2);
                        }
                        Iterator<StatisNumer> memIt = memList.iterator();
                        while (memIt.hasNext()) {
                            StatisNumer numer = memIt.next();
                            if (flag == rowspan / 2) {
                                flag++;
                                continue;
                            }
                            Cell cell6 = new Cell();
                            Cell cell7 = new Cell();
                            cell6.setVerticalAlignment(Element.ALIGN_MIDDLE);
                            cell7.setVerticalAlignment(Element.ALIGN_MIDDLE);
                            cell6.addElement(new Paragraph(numer.getName(), fontChineseRow));
                            cell7.addElement(new Paragraph(numer.getCurrent(), fontChineseRow));
                            if (flag == 0) {
                                cell6.setRowspan(rowspan / 2);
                                cell7.setRowspan(rowspan / 2);
                                table.addCell(cell6);
                                table.addCell(cell7);
                                break;
                            } else {
                                cell6.setRowspan(rowspan - rowspan / 2);
                                cell7.setRowspan(rowspan - rowspan / 2);
                                table.addCell(cell6);
                                table.addCell(cell7);
                            }
                        }
                    }
                    Cell cell4 = new Cell();
                    Cell cell5 = new Cell();
                    cell4.setVerticalAlignment(Element.ALIGN_MIDDLE);
                    cell5.setVerticalAlignment(Element.ALIGN_MIDDLE);
                    StatisNumer numer = diskIt.next();
                    cell4.addElement(new Paragraph(numer.getName(), fontChineseRow));
                    cell5.addElement(new Paragraph(numer.getCurrent(), fontChineseRow));
                    table.addCell(cell4);
                    table.addCell(cell5);
                    sum = Arith.add(sum, Double.parseDouble(numer.getCurrent().replaceAll("[a-zA-Z]", "")));
                    flag++;
                }
                Cell cell6 = new Cell();
                Cell cell7 = new Cell();
                cell6.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell7.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell6.addElement(new Paragraph("", fontChineseRow));
                cell7.addElement(new Paragraph(Arith.round(sum, 2) + "G", fontChineseRow));
                table.addCell(cell6);
                table.addCell(cell7);
            }
        }
        for (int i = 0; i < dbTitle.length; i++) {
            Cell cell = new Cell();
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.addElement(new Paragraph(dbTitle[i], fontChineseTitle));
            if (i == 0) {
                cell.setRowspan(dbList.size() + 1);
            }
            if (i == 3) {
                cell.setColspan(4);
            } else if (i != 0) {
                cell.setColspan(2);
            }
            cell.setBackgroundColor(Color.LIGHT_GRAY);
            table.addCell(cell);
        }
        if (dbIt != null) {
            while (dbIt.hasNext()) {
                Cell cell2 = new Cell();
                Cell cell3 = new Cell();
                Cell cell4 = new Cell();
                cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell3.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell4.setVerticalAlignment(Element.ALIGN_MIDDLE);
                MonitorDBDTO monitorNodeDTO = (MonitorDBDTO) dbIt.next();
                cell2.addElement(new Paragraph(monitorNodeDTO.getAlias(), fontChineseRow));
                cell3.addElement(new Paragraph(monitorNodeDTO.getDbtype(), fontChineseRow));
                cell4.addElement(new Paragraph(monitorNodeDTO.getIpAddress(), fontChineseRow));
                cell2.setColspan(2);
                cell3.setColspan(2);
                cell4.setColspan(4);
                table.addCell(cell2);
                table.addCell(cell3);
                table.addCell(cell4);
            }
        }
        for (int i = 0; i < midwareTitle.length; i++) {
            Cell cell = new Cell();
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.addElement(new Paragraph(midwareTitle[i], fontChineseTitle));
            if (i == 0) {
                cell.setRowspan(midwareList.size() + 1);
            }
            if (i == 3) {
                cell.setColspan(4);
            } else if (i != 0) {
                cell.setColspan(2);
            }
            cell.setBackgroundColor(Color.LIGHT_GRAY);
            table.addCell(cell);
        }
        if (midwareIt != null) {
            while (midwareIt.hasNext()) {
                Cell cell2 = new Cell();
                Cell cell3 = new Cell();
                Cell cell4 = new Cell();
                cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell3.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell4.setVerticalAlignment(Element.ALIGN_MIDDLE);
                MonitorMiddlewareDTO monitorNodeDTO = (MonitorMiddlewareDTO) midwareIt.next();
                cell2.addElement(new Paragraph(monitorNodeDTO.getAlias(), fontChineseRow));
                cell3.addElement(new Paragraph(monitorNodeDTO.getCategory(), fontChineseRow));
                cell4.addElement(new Paragraph(monitorNodeDTO.getIpAddress(), fontChineseRow));
                cell2.setColspan(2);
                cell3.setColspan(2);
                cell4.setColspan(4);
                table.addCell(cell2);
                table.addCell(cell3);
                table.addCell(cell4);
            }
        }
        document.add(table);
        document.close();
    } catch (Exception e) {
        SysLogger.error("", e);
    }
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

public void createReport_hostNewDoc(String file) throws DocumentException, IOException {
    Hashtable Memory = (Hashtable) reportHash.get("Memory");
    // EventListDao eventListDao = new EventListDao();

    Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash");
    Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash");
    Hashtable CPU = (Hashtable) reportHash.get("CPU");
    String[] memoryItemch = { "", "", "", "" };
    String[] memoryItem = { "Capability", "Utilization" };
    if (CPU == null)
        CPU = new Hashtable();
    String cpu = "";
    if (CPU.get("cpu") != null)
        cpu = (String) CPU.get("cpu");
    String cpumax = "0.0%";
    if (CPU.get("cpumax") != null)
        cpumax = (String) CPU.get("cpumax");
    String avgcpu = "";
    if (CPU.get("avgcpu") != null)
        avgcpu = (String) CPU.get("avgcpu");
    String starttime = (String) reportHash.get("starttime");
    String totime = (String) reportHash.get("totime");
    String hostname = (String) reportHash.get("equipname");
    String hostnameDoc = (String) reportHash.get("equipnameDoc");
    String ip = (String) reportHash.get("ip");
    String typename = (String) reportHash.get("typename");
    String startdate = (String) reportHash.get("startdate");
    int cpuvalue = ((Integer) reportHash.get("cpuvalue")).intValue();

    int memvalue = ((Integer) reportHash.get("memvalue")).intValue();
    int diskvalue = ((Integer) reportHash.get("diskvalue")).intValue();
    int pingvalue = ((Integer) reportHash.get("pingvalue")).intValue();

    /* String type = (String)request.getAttribute("type"); */
    Document document = new Document(PageSize.A4);
    // (Writer)document(Writer)
    RtfWriter2.getInstance(document, new FileOutputStream(file));
    document.open();/*from   w w  w .j a  v a  2  s .c  o m*/
    // 
    BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED);
    // 
    Font titleFont = new Font(bfChinese, 12, Font.BOLD);
    // 
    Font contextFont = new Font(bfChinese, 12, Font.NORMAL);

    Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black);
    Table aTable = new Table(8);
    float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f };
    aTable.setWidths(widths);
    aTable.setWidth(100); //  90%
    aTable.setAlignment(Element.ALIGN_CENTER);// 
    aTable.setAutoFillEmptyCells(true); // 
    aTable.setBorderWidth(1); // 
    aTable.setBorderColor(new Color(0, 125, 255)); // 
    aTable.setPadding(2);// 
    aTable.setSpacing(0);// 
    aTable.setBorder(2);// 

    aTable.endHeaders();
    Cell cell = null;
    cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(8);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_CENTER);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    aTable.addCell(cell);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    cell = new Cell(new Phrase("\n" + starttime + "  " + totime + "\n", contextFont));
    cell.setColspan(7);

    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(hostnameDoc, contextFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("IP", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(ip, contextFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(typename, contextFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    String grade = (String) reportHash.get("grade");
    cell = new Cell(new Phrase("\n" + grade + "\n", contextFont));
    cell.setColspan(7);

    aTable.addCell(cell);
    cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setRowspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "CPU" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(avgcpu, contextFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("CPU", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase(cpumax, contextFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    String avgvalue = "0.0%";
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    if (memAvgHash.get("PhysicalMemory") != null) {

        avgvalue = (String) memAvgHash.get("PhysicalMemory");
        cell = new Cell(new Phrase(avgvalue, contextFont));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
    } else {
        cell = new Cell(new Phrase(avgvalue, contextFont));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
    }
    cell = new Cell(new Phrase("", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    String value = "0.0%";
    if (memMaxHash.get("PhysicalMemory") != null) {

        value = (String) memMaxHash.get("PhysicalMemory");
        cell = new Cell(new Phrase(value, contextFont));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
    } else {
        cell = new Cell(new Phrase(value, contextFont));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
    }

    // end 

    // end  }
    cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setRowspan(4);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("\n" + "CPU" + cpuvalue + "" + "\n", contextFont));
    cell.setColspan(7);
    aTable.addCell(cell);

    cell = new Cell(new Phrase("\n" + "" + memvalue + "" + "\n", contextFont));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + pingvalue + "" + "\n", contextFont));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + diskvalue + "" + "\n", contextFont));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(8);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    String strcpu = "";
    String strmem = "";
    String strping = "";
    String strdisk = "";
    if (cpuvalue > 0) {
        strcpu = "    2   " + cpuvalue + "CPU" + "\n"
                + "\n";
    } else {
        strcpu = "    2   CPU" + " \n" + "\n";
    }
    if (memvalue > 0) {
        strmem = "    3   " + memvalue + "" + "\n" + "\n";
    } else {
        strmem = "    3   " + "\n" + "\n";
    }
    if (pingvalue > 0) {
        strping = "    4   " + pingvalue + "" + "\n"
                + "\n";
    } else {
        strping = "    4   " + "\n" + "\n";
    }
    if (diskvalue > 0) {

        strdisk = "    5   " + diskvalue + "";
    } else {
        strdisk = "    5   ";
    }

    cell = new Cell(new Phrase("    1   " + " \n" + "\n"
            + strcpu + strmem + strping + strdisk + "\n" + "\n" + "\n", contextFont)

    );
    cell.setColspan(8);
    aTable.addCell(cell);
    document.add(aTable);
    document.close();

}

From source file:com.afunms.report.abstraction.ExcelReport1.java

public void createReport_hostNewPDF(String file) throws DocumentException, IOException {
    Hashtable Memory = (Hashtable) reportHash.get("Memory");
    // EventListDao eventListDao = new EventListDao();

    Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash");
    Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash");
    Hashtable CPU = (Hashtable) reportHash.get("CPU");
    String[] memoryItemch = { "", "", "", "" };
    String[] memoryItem = { "Capability", "Utilization" };
    if (CPU == null)
        CPU = new Hashtable();
    String cpu = "";
    if (CPU.get("cpu") != null)
        cpu = (String) CPU.get("cpu");
    String cpumax = "0.0%";
    if (CPU.get("cpumax") != null)
        cpumax = (String) CPU.get("cpumax");
    String avgcpu = "";
    if (CPU.get("avgcpu") != null)
        avgcpu = (String) CPU.get("avgcpu");
    String starttime = (String) reportHash.get("starttime");
    String totime = (String) reportHash.get("totime");
    String hostname = (String) reportHash.get("equipname");
    String hostnameDoc = (String) reportHash.get("equipnameDoc");
    String ip = (String) reportHash.get("ip");
    String typename = (String) reportHash.get("typename");
    String startdate = (String) reportHash.get("startdate");
    int cpuvalue = ((Integer) reportHash.get("cpuvalue")).intValue();
    int memvalue = ((Integer) reportHash.get("memvalue")).intValue();
    int diskvalue = ((Integer) reportHash.get("diskvalue")).intValue();
    int pingvalue = ((Integer) reportHash.get("pingvalue")).intValue();

    /* String type = (String)request.getAttribute("type"); */
    Document document = new Document(PageSize.A4);
    // (Writer)document(Writer)
    PdfWriter.getInstance(document, new FileOutputStream(file));
    document.open();//from   w w w.  j  av a2s  . c  om
    // 
    BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);

    // 
    Font titleFont = new Font(bfChinese, 12, Font.BOLD);
    // 
    Font contextFont = new Font(bfChinese, 12, Font.NORMAL);
    Font contextFont1 = new Font(bfChinese, 10, Font.NORMAL);
    Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black);
    Table aTable = new Table(8);
    float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f };
    aTable.setWidths(widths);
    aTable.setWidth(100); //  90%
    aTable.setAlignment(Element.ALIGN_CENTER);// 
    aTable.setAutoFillEmptyCells(true); // 
    aTable.setBorderWidth(1); // 
    aTable.setBorderColor(new Color(0, 125, 255)); // 
    aTable.setPadding(2);// 
    aTable.setSpacing(0);// 
    aTable.setBorder(2);// 

    aTable.endHeaders();
    Cell cell = null;
    cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(8);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_CENTER);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    aTable.addCell(cell);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    cell = new Cell(new Phrase("\n" + starttime + "  " + totime + "\n", contextFont1));
    cell.setColspan(7);

    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(hostnameDoc, contextFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("IP", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(ip));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(typename, contextFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    String grade = (String) reportHash.get("grade");
    cell = new Cell(new Phrase("\n" + grade + "\n", contextFont));
    cell.setColspan(7);

    aTable.addCell(cell);
    cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setRowspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "CPU" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(avgcpu));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("CPU", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase(cpumax));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    String avgvalue = "0.0%";
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    if (memAvgHash.get("PhysicalMemory") != null) {

        avgvalue = (String) memAvgHash.get("PhysicalMemory");
        cell = new Cell(new Phrase(avgvalue));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
    } else {
        cell = new Cell(new Phrase(avgvalue));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
    }
    cell = new Cell(new Phrase("", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    String value = "0.0%";
    if (memMaxHash.get("PhysicalMemory") != null) {

        value = (String) memMaxHash.get("PhysicalMemory");
        cell = new Cell(new Phrase(value));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
    } else {
        cell = new Cell(new Phrase(value));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
    }

    // end 

    // end  }
    cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setRowspan(4);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("\n" + "CPU" + cpuvalue + "" + "\n", contextFont));
    cell.setColspan(7);
    aTable.addCell(cell);

    cell = new Cell(new Phrase("\n" + "" + memvalue + "" + "\n", contextFont));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + pingvalue + "" + "\n", contextFont));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + diskvalue + "" + "\n", contextFont));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(8);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    String strcpu = "";
    String strmem = "";
    String strping = "";
    String strdisk = "";
    if (cpuvalue > 0) {
        strcpu = "    2   " + cpuvalue + "CPU" + "\n"
                + "\n";
    } else {
        strcpu = "    2   CPU" + " \n" + "\n";
    }
    if (memvalue > 0) {
        strmem = "    3   " + memvalue + "" + "\n" + "\n";
    } else {
        strmem = "    3   " + "\n" + "\n";
    }
    if (pingvalue > 0) {
        strping = "    4   " + pingvalue + "" + "\n"
                + "\n";
    } else {
        strping = "    4   " + "\n" + "\n";
    }
    if (diskvalue > 0) {

        strdisk = "    5   " + diskvalue + "";
    } else {
        strdisk = "    5   ";
    }

    cell = new Cell(new Phrase("    1   " + " \n" + "\n"
            + strcpu + strmem + strping + strdisk + "\n" + "\n" + "\n", contextFont)

    );
    /*
     * cell = new Cell(new Phrase(" 1 " + " \n" +
     * "\n" + " 2 " + cpuvalue + "CPU" + "\n" +
     * "\n" + " 3 "+memvalue+"" + "\n" +
     * "\n" + " 4 "+pingvalue+"" + "\n" +
     * "\n"+" 5 "+diskvalue+"" + "\n" + "\n"+
     * "\n",contextFont) );
     */
    cell.setColspan(8);
    aTable.addCell(cell);
    document.add(aTable);
    document.close();

}

From source file:com.afunms.report.abstraction.ExcelReport1.java

/**
 * @author wxy word//from  w w w. j ava 2 s .  c  o  m
 * @param filename
 * @date 2010-3-28
 */
public void createReport_ServiceEventDoc(String filename) throws IOException {
    if (impReport.getTable() == null) {
        fileName = null;
        return;
    }
    try {
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        RtfWriter2.getInstance(document, new FileOutputStream(filename));
        document.open();
        // 
        BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED);
        // 
        Font titleFont = new Font(bfChinese, 12, Font.BOLD);
        // 
        Font contextFont = new Font(bfChinese, 12, Font.NORMAL);
        List list = new ArrayList();
        list = (List) reportHash.get("eventlist");
        String ip = "";
        String servicename = "";
        String sum = "";
        String levelone = "";
        String leveltwo = "";
        String levelthree = "";
        if (list != null && list.size() > 0) {

            List _eventlist = (List) list.get(0);
            if (_eventlist != null && _eventlist.size() > 0) {
                ip = (String) _eventlist.get(0);
                servicename = (String) _eventlist.get(1);
                sum = (String) _eventlist.get(2);
                levelone = (String) _eventlist.get(3);
                leveltwo = (String) _eventlist.get(4);
                levelthree = (String) _eventlist.get(5);
            }
        }

        Paragraph title = new Paragraph(servicename + "", titleFont);
        // 
        title.setAlignment(Element.ALIGN_CENTER);
        // title.setFont(titleFont);
        document.add(title);
        String starttime = (String) reportHash.get("starttime");
        String totime = (String) reportHash.get("totime");

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String contextString = ":" + impReport.getTimeStamp() + " \n"// 
                + ":" + starttime + "  " + totime;

        Paragraph context = new Paragraph(contextString, contextFont);
        // 
        context.setAlignment(Element.ALIGN_LEFT);
        // context.setFont(contextFont);
        // 
        context.setSpacingBefore(5);
        // 
        context.setFirstLineIndent(5);
        document.add(context);

        // 
        Table dbTable = new Table(6);
        float[] cellWidths = { 220f, 220f, 220f, 220f, 220f, 220f };
        dbTable.setWidths(cellWidths);
        dbTable.setWidth(100); //  90%
        dbTable.setAlignment(Element.ALIGN_CENTER);// 
        dbTable.setAutoFillEmptyCells(true); // 
        dbTable.setBorderWidth(1); // 
        dbTable.setBorderColor(new Color(0, 125, 255)); // 
        dbTable.setPadding(2);// 
        dbTable.setSpacing(0);// 
        dbTable.setBorder(2);// 
        dbTable.endHeaders();

        Cell cell = null;
        cell = new Cell(new Phrase("", titleFont));
        cell.setColspan(6);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new Cell(new Phrase("IP", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new Cell(new Phrase("()", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new Cell(new Phrase("()", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new Cell(new Phrase("() ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new Cell(new Phrase("() ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new Cell(new Phrase(ip, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new Cell(new Phrase(servicename, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new Cell(new Phrase(sum, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new Cell(new Phrase(levelone, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new Cell(new Phrase(leveltwo, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new Cell(new Phrase(levelthree, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        document.add(dbTable);

        addEventListToDoc(document, titleFont, contextFont);

        document.close();
    } catch (Exception e) {
        // SysLogger.error("Error in ExcelReport.createReport()",e);
        SysLogger.error("", e);
    }
}