Example usage for com.lowagie.text Table Table

List of usage examples for com.lowagie.text Table Table

Introduction

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

Prototype

public Table(int columns, int rows) throws BadElementException 

Source Link

Document

Constructs a Table with a certain number of columns and a certain number of Rows.

Usage

From source file:QMSMultiQuoteController.java

License:Open Source License

private int doPDFGeneration(MultiQuoteFinalDOB finalDOB, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    int mailFlag = 0;
    int faxFlag = 0;
    int printFlag = 0;
    int returnFlag = 3;
    //@@Modified by kiran.v on 01/08/2011 for Wpbn Issue 271485
    ArrayList Sd = null;/* w w w. j  a v a 2  s .  co m*/
    ArrayList Cd = null;
    ArrayList Cdn = null;
    boolean frequencyFlag = false;
    boolean carrierFlag = false;
    boolean serviceFlag = false;
    Map<String, String> surChargesMap = null;
    //Kiran ends
    String transitTime = null;
    String[] contents = null;
    String[] levels = null;
    String[] aligns = null;
    String[] headFoot = null;
    String charge_desc = null;//@@Added by govind for the issue 258189
    //@@Added by Kameswari for the WPBN issue-61289
    ArrayList dobList = new ArrayList();
    MultiQuoteAttachmentDOB attachmentDOB = null;
    //@@Added by Kameswari for the WPBN issue-146448
    ArrayList charges = null;
    int chargesSize = 0;
    int noOfLanes = 0;
    MultiQuoteCharges chargesDOB = null;
    MultiQuoteChargeInfo multiQuoteChargeInfo = null;
    ArrayList freightCharges = null;
    MultiQuoteFreightLegSellRates legCharges = null;
    MultiQuoteFreightLegSellRates legOrginCharges = null;
    MultiQuoteFreightLegSellRates legDestCharges = 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;

    int gTemp = 0; // Added By Gowtham For PDF View Issue
    String placeDesc = null; // Added By Gowtham For PDF View Issue
    String tmpOrgPort = ""; // Added by Gowtham
    int gTemp1 = 0;
    String tmpfrq = "";
    String tmpServl = "";
    String tmpCarrier = "";
    String tmpDestPort = "";
    int LegSize = 0;
    HashSet PortAbbSet = null;
    //@@WPBN issue-146448
    ArrayList filesList = new ArrayList();
    File file = null;
    byte[] buffer = null;
    ArrayList bufferList = new ArrayList();
    ArrayList pdfFilesList = new ArrayList();
    HttpSession session = request.getSession();
    // Added by kiran.v on 16/09/2011
    String operation = finalDOB.getOperation() != null ? finalDOB.getOperation()
            : finalDOB.getMasterDOB().getOperation();

    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    
    QMSMultiQuoteSessionHome home = null;
    QMSMultiQuoteSession remote = null;
    int incoSize = 0; // Added by Gowtham on 24Feb2011 for IncoTerms display in PDF
    //   @@ Ended by subrahmanyam for the WPBN ISSUE: 146460 on 29/01/2009   

    //@@ WPBN issue-61289
    PdfPTable pTable;
    PdfPCell pCell;

    try {
        Sd = new ArrayList();
        Cd = new ArrayList();
        Cdn = new ArrayList();
        String carrierChecked = request.getParameter("selectCarrier");
        String serviceLevelChecked = request.getParameter("selectService");
        String frequencyChecked = request.getParameter("selectFrequecy");
        String transitTimeChecked = request.getParameter("selectTransitTime");
        String validityChecked = request.getParameter("selectFrieghtValidity");
        boolean carrierflag = false;
        boolean serviceflag = false;
        boolean frequencyflag = false;
        //@@Added by kiran.v on 23/09/2011 for Wpbn Issue 272712
        boolean transittimeflag = false;
        boolean freightValidity = false;
        DecimalFormat df = new DecimalFormat("###,###,###,##0.00");
        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 & 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"))) {
            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());
                //@@Modified by kiran.v on 28/07/2011 for Wpbn Issue -256087
                effDate = eSupplyDateUtility.getDisplayStringArray(masterDOB.getEffDate());
            }

        } 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
        if (!"Charges".equalsIgnoreCase(masterDOB.getQuoteWith()))
            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);
        // int b = writer.getPageNumber();
        baos.close();

        document.open();

        //jyothi
        PdfContentByte cb = writer.getDirectContent();
        cb.rectangle(document.left(), document.bottom(), document.right() - document.left(),
                document.top() - document.bottom());

        cb.stroke();
        //jyothi
        // Graphic horizontalLine = new Graphic();
        //horizontalLine.setHorizontalLine(1f, 100f);
        // horizontalLine.setColorStroke(Color.BLACK);
        //horizontalLine.setLineWidth(100);

        // 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(2);
        mainT.setWidth(80);
        //mainT.setWidths(widths);
        mainT.setBorderColor(Color.white);
        mainT.setPadding(1);
        mainT.setSpacing(0);*/

        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);
        // 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);
        // img0.scaleToFit(6.0f, 1.9f);
        //System.out.println("Lower Left:   "" Upper   Left:   "+img0.getRight()+"   "+);

        // imageCell.setWidth("6");

        // imageCell.setColspan(2);
        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);
        // System.out.println("After Image && Before Content--------------------------->");

        Table partCountry = new Table(4, 5);

        Table partCountry1 = new Table(4);
        int[] widths1 = { 30, 20, 30, 20 };
        //partCountry1.setBorderWidth(0);
        partCountry1.setBorderWidth(1f);//modified by silpa.p on 3-06-11
        partCountry1.setWidths(widths1);
        partCountry1.setWidth(100);
        partCountry1.setBorderColor(Color.black);
        partCountry1.setPadding(1);
        partCountry1.setSpacing(0);
        partCountry1.setBorder(1);//added by silpa.p on 3-06-11
        partCountry1.setAutoFillEmptyCells(true);
        //partCountry.setTableFitsPage(true);
        partCountry.setAlignment(partCountry.ALIGN_CENTER);
        partCountry.setBorderWidth(0);
        ;

        int[] widths2 = { 20, 30, 20, 30 };
        partCountry.setBorderWidth(0);
        partCountry.setBorderWidth(1f);//modified by silpa.p on 3-06-11
        partCountry.setWidths(widths2);
        partCountry.setWidth(100);
        partCountry.setBorderColor(Color.black);
        partCountry.setPadding(1);
        partCountry.setBorder(1);//added by silpa.p on 3-06-11
        partCountry.setSpacing(0);
        partCountry.setAutoFillEmptyCells(true);
        //partCountry.setTableFitsPage(true);
        partCountry.setAlignment(partCountry.ALIGN_CENTER);
        //Jyothi
        partCountry.setBorderWidthBottom(1);
        partCountry.setBorderWidthTop(0);
        partCountry.setBorderWidthLeft(1);
        partCountry.setBorderWidthRight(1);
        //Jyothi
        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", 8, Font.BOLD, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setWidth("100");
        //cellCountry.setColspan(1);
        cellCountry.setBorderWidth(0);
        cellCountry.setBackgroundColor(Color.LIGHT_GRAY);//modified by silpa.p on 3-06-11
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(10.0f);
        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
        partCountry1.addCell(cellCountry);

        chk = new Chunk("");
        cellCountry = new Cell(chk);
        cellCountry.setBackgroundColor(Color.LIGHT_GRAY);//modified by silpa.p on 3-06-11
        cellCountry.setWidth("100");
        //cellCountry.setColspan(1);
        cellCountry.setBorderWidth(0);
        partCountry1.addCell(cellCountry);

        chk = new Chunk("SERVICE INFORMATION", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setWidth("100");
        //cellCountry.setColspan(2);
        cellCountry.setBorderWidth(0);
        cellCountry.setBackgroundColor(Color.LIGHT_GRAY);//modified by silpa.p on 3-06-11
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(10.0f);
        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
        partCountry1.addCell(cellCountry);

        chk = new Chunk("");
        cellCountry = new Cell(chk);
        cellCountry.setBackgroundColor(Color.LIGHT_GRAY);//modified by silpa.p on 3-06-11
        cellCountry.setWidth("100");
        //cellCountry.setColspan(1);
        cellCountry.setBorderWidth(0);
        partCountry1.addCell(cellCountry);

        document.add(partCountry1);

        chk = new Chunk("Customer Name: ", FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setHeader(true);
        cellCountry.setWidth("30");
        cellCountry.setBorderWidth(0);
        cellCountry.setBackgroundColor(Color.LIGHT_GRAY);//modified by silpa.p on 3-06-11
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(10.0f);
        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_LEFT);
        partCountry.addCell(cellCountry);

        chk = new Chunk(headerDOB.getCustomerName() != null ? toTitleCase(headerDOB.getCustomerName()) : "",
                FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setHeader(true);
        cellCountry.setWidth("100");
        cellCountry.setBorderWidth(0);
        cellCountry.setBackgroundColor(Color.LIGHT_GRAY);//modified by silpa.p on 3-06-11
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(10.0f);
        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_LEFT);
        partCountry.addCell(cellCountry);

        chk = new Chunk("Agent: ", FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setHeader(true);
        cellCountry.setWidth("30");
        cellCountry.setBorderWidth(0);
        cellCountry.setBackgroundColor(Color.LIGHT_GRAY);//modified by silpa.p on 3-06-11
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(10.0f);
        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_LEFT);
        partCountry.addCell(cellCountry);

        chk = new Chunk(headerDOB.getAgent() != null ? headerDOB.getAgent() : "",
                FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setHeader(true);
        cellCountry.setWidth("100");
        cellCountry.setBorderWidth(0);
        cellCountry.setBackgroundColor(Color.LIGHT_GRAY);//modified by silpa.p on 3-06-11
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(10.0f);
        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_LEFT);
        partCountry.addCell(cellCountry);

        chk = new Chunk("Attention To: ", FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setHeader(true);
        cellCountry.setWidth("100");
        cellCountry.setBorderWidth(0);
        cellCountry.setNoWrap(true);
        cellCountry.setBackgroundColor(Color.LIGHT_GRAY);//modified by silpa.p on 3-06-11
        cellCountry.setLeading(10.0f);
        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_LEFT);
        partCountry.addCell(cellCountry);

        chk = new Chunk(toTitleCase(attentionTo.toString()),
                FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setHeader(true);
        cellCountry.setWidth("100");
        cellCountry.setBorderWidth(0);
        cellCountry.setNoWrap(true);
        cellCountry.setBackgroundColor(Color.LIGHT_GRAY);//modified by silpa.p on 3-06-11
        cellCountry.setLeading(10.0f);
        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_LEFT);
        partCountry.addCell(cellCountry);

        chk = new Chunk("Commodity Or Product: ", FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setHeader(true);
        cellCountry.setWidth("100");
        cellCountry.setBorderWidth(0);
        cellCountry.setNoWrap(true);
        cellCountry.setBackgroundColor(Color.LIGHT_GRAY);//modified by silpa.p on 3-06-11
        cellCountry.setLeading(10.0f);
        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_LEFT);
        partCountry.addCell(cellCountry);

        //chk = new Chunk(headerDOB.getCommodity()!=null?toTitleCase(headerDOB.getCommodity()):"",FontFactory.getFont("ARIAL", 7, Font.NORMAL,Color.BLACK));//commented by silpa.p on 21-06-11
        chk = new Chunk(headerDOB.getCommodity() != null ? (headerDOB.getCommodity()) : "",
                FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));//added by silpa.p on 21-06-11
        cellCountry = new Cell(chk);
        cellCountry.setHeader(true);
        cellCountry.setWidth("100");
        cellCountry.setBorderWidth(0);
        cellCountry.setNoWrap(true);
        cellCountry.setBackgroundColor(Color.LIGHT_GRAY);//modified by silpa.p on 3-06-11
        cellCountry.setLeading(10.0f);
        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_LEFT);
        partCountry.addCell(cellCountry);

        chk = new Chunk("Quote Reference: ", FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setHeader(true);
        cellCountry.setWidth("100");
        cellCountry.setBorderWidth(0);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(10.0f);
        cellCountry.setBackgroundColor(Color.LIGHT_GRAY);
        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_LEFT);
        partCountry.addCell(cellCountry);

        chk = new Chunk(masterDOB.getQuoteId() != null ? masterDOB.getQuoteId() : "",
                FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setHeader(true);
        cellCountry.setWidth("100");
        cellCountry.setBorderWidth(0);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(10.0f);
        cellCountry.setBackgroundColor(Color.LIGHT_GRAY);//modified by silpa.p on 3-06-11
        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_LEFT);
        partCountry.addCell(cellCountry);

        chk = new Chunk("Notes: ", FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));//modified by silpa.p on 13-06-11
        cellCountry = new Cell(chk);
        cellCountry.setHeader(true);
        cellCountry.setWidth("100");
        cellCountry.setBorderWidth(0);
        cellCountry.setNoWrap(true);
        cellCountry.setBackgroundColor(Color.LIGHT_GRAY);//modified by silpa.p on 3-06-11
        cellCountry.setLeading(10.0f);
        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_LEFT);
        partCountry.addCell(cellCountry);

        chk = new Chunk(headerDOB.getNotes() != null ? toTitleCase(headerDOB.getNotes()) : "",
                FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setHeader(true);
        cellCountry.setWidth("100");
        cellCountry.setBorderWidth(0);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(10.0f);
        cellCountry.setBackgroundColor(Color.LIGHT_GRAY);//modified by silpa.p on 3-06-11
        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_LEFT);
        partCountry.addCell(cellCountry);

        chk = new Chunk("Date Of Quotation: ", FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setHeader(true);
        cellCountry.setWidth("100");
        cellCountry.setBorderWidth(0);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(10.0f);
        cellCountry.setBackgroundColor(Color.LIGHT_GRAY);//modified by silpa.p on 3-06-11
        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_LEFT);
        partCountry.addCell(cellCountry);

        chk = new Chunk(strDate[0], FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setHeader(true);
        cellCountry.setWidth("100");
        cellCountry.setBorderWidth(0);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(10.0f);
        cellCountry.setBackgroundColor(Color.LIGHT_GRAY);//modified by silpa.p on 3-06-11
        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_LEFT);
        partCountry.addCell(cellCountry);

        chk = new Chunk("Date Effective: ", FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setHeader(true);
        cellCountry.setWidth("100");
        cellCountry.setBorderWidth(0);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(10.0f);
        cellCountry.setBackgroundColor(Color.LIGHT_GRAY);//modified by silpa.p on 3-06-11
        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_LEFT);
        partCountry.addCell(cellCountry);

        chk = new Chunk((effDate[0] != null ? effDate[0] : ""),
                FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setHeader(true);
        cellCountry.setWidth("100");
        cellCountry.setBorderWidth(0);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(10.0f);
        cellCountry.setBackgroundColor(Color.LIGHT_GRAY);//modified by silpa.p on 3-06-11
        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_LEFT);
        partCountry.addCell(cellCountry);

        chk = new Chunk("Sales Person : ", FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setHeader(true);
        cellCountry.setWidth("100");
        cellCountry.setBorderWidth(0);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(10.0f);
        cellCountry.setBackgroundColor(Color.LIGHT_GRAY);//modified by silpa.p on 3-06-11
        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_LEFT);
        partCountry.addCell(cellCountry);

        chk = new Chunk((headerDOB.getPreparedBy() != null ? toTitleCase(headerDOB.getPreparedBy()) : ""),
                FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setHeader(true);
        cellCountry.setWidth("100");
        cellCountry.setBorderWidth(0);
        cellCountry.setNoWrap(true);
        cellCountry.setBackgroundColor(Color.LIGHT_GRAY);//modified by silpa.p on 3-06-11
        cellCountry.setLeading(10.0f);
        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_LEFT);
        partCountry.addCell(cellCountry);

        chk = new Chunk("Validity Of Quote: ", FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setHeader(true);
        cellCountry.setWidth("100");
        cellCountry.setBorderWidth(0);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(10.0f);
        cellCountry.setBackgroundColor(Color.LIGHT_GRAY);//modified by silpa.p on 3-06-11
        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_LEFT);
        partCountry.addCell(cellCountry);

        chk = new Chunk((validUptoStr != null ? validUptoStr : "VALID UNTIL FURTHER NOTICE"),
                FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
        cellCountry = new Cell(chk);
        cellCountry.setHeader(true);
        cellCountry.setWidth("100");
        cellCountry.setBorderWidth(0);
        cellCountry.setNoWrap(true);
        cellCountry.setLeading(10.0f);
        cellCountry.setBackgroundColor(Color.LIGHT_GRAY);//modified by silpa.p on 3-06-11
        cellCountry.setHorizontalAlignment(cellCountry.ALIGN_LEFT);
        partCountry.addCell(cellCountry);

        document.add(partCountry);

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

        document.add(pTable);

        /* if(chargesSize==1)
         {
         if("MY".equalsIgnoreCase(masterDOB.getCountryId()))
         {
         chk = new Chunk((headerDOB.getOriginCountry()!=null?headerDOB.getOriginCountry()[0].toUpperCase():"")+" TO "+(headerDOB.getDestinationCountry()!=null?headerDOB.getDestinationCountry()[0].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()[0].toUpperCase():"")+" TO "+(headerDOB.getDestinationCountry()!=null?headerDOB.getDestinationCountry()[0].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);
         }
         }else{
          if("MY".equalsIgnoreCase(masterDOB.getCountryId()))
          {
          //chk = new Chunk("Multi-Lane/Multi-Carrier",FontFactory.getFont("ARIAL", 16, Font.BOLD,Color.BLUE)); // Commented by Gowtham on 24Feb2011
          chk = new Chunk("Multiple Origins And/Or Destinations",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("Multi-Lane/Multi-Carrier",FontFactory.getFont("ARIAL", 16, Font.BOLD,Color.RED));
            chk = new Chunk("Multiple Origins And/Or Destinations",FontFactory.getFont("ARIAL", 16, Font.BOLD,Color.RED)); // Commented by Gowtham on 24Feb2011
            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); */

        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);
            /*content = null;
            cellContent =  null;*/
        }
        /*content = new Table(1);
        Cell cellContent1 = new Cell(new Chunk(""));
        content.addCell(cellContent1); */

        if (!"Charges".equalsIgnoreCase(masterDOB.getQuoteWith())) {
            //@@Added by Kameswari for the WPBN issue-146448 on 03/12/08
            for (int i = 0; i < chargesSize; i++) {
                legCharges = (MultiQuoteFreightLegSellRates) charges.get(0);
                freightCharges = legCharges.getFreightChargesList();
                int tempCount = freightCharges.size();
                for (int j = 0; j < tempCount; j++) {
                    multiQuoteChargeInfo = (MultiQuoteChargeInfo) freightCharges.get(i);//govind

                    if (multiQuoteChargeInfo.getSelectedLaneNum() == i) {
                        if (multiQuoteChargeInfo != null && multiQuoteChargeInfo.getValidUpto() != null) {
                            str1 = eSupplyDateUtility
                                    .getDisplayStringArray(multiQuoteChargeInfo.getValidUpto());
                        }
                        ///////////////////////////////////////////Second Table////////////////////////////
                        if (chargesSize > 1) {
                            if ("Y".equalsIgnoreCase(multiQuoteChargeInfo.getFrequencyChecked())
                                    || "on".equalsIgnoreCase(multiQuoteChargeInfo.getFrequencyChecked())) {
                                //Added by kiran.v on 16/09/2011
                                frequencyFlag = true;
                                frequency.add(multiQuoteChargeInfo.getFrequency());
                                frequency_o.add(legCharges.getOrigin());
                                frequency_d.add(legCharges.getDestination());
                            }
                            if ("Y".equalsIgnoreCase(multiQuoteChargeInfo.getTransitTimeChecked())
                                    || "on".equalsIgnoreCase(multiQuoteChargeInfo.getTransitTimeChecked())) {
                                transittime.add(multiQuoteChargeInfo.getTransitTime());
                                transit_o.add(legCharges.getOrigin());
                                transit_d.add(legCharges.getDestination());
                            }
                            if ("Y".equalsIgnoreCase(multiQuoteChargeInfo.getCarrierChecked())
                                    || "on".equalsIgnoreCase(multiQuoteChargeInfo.getCarrierChecked())) {
                                carrierFlag = true;
                                carrier.add(multiQuoteChargeInfo.getCarrier());
                                carrier_o.add(legCharges.getOrigin());
                                carrier_d.add(legCharges.getDestination());
                            }
                            if ("Y".equalsIgnoreCase(multiQuoteChargeInfo.getRateValidityChecked())
                                    || "on".equalsIgnoreCase(multiQuoteChargeInfo.getRateValidityChecked())) {
                                if (multiQuoteChargeInfo.getValidUpto() != null) {
                                    str1 = eSupplyDateUtility
                                            .getDisplayStringArray(multiQuoteChargeInfo.getValidUpto());
                                    ratevalidity.add(str1[0]);
                                }

                                validity_o.add(legCharges.getOrigin());
                                validity_d.add(legCharges.getDestination());
                            }
                        } else {

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

                            }
                        }
                    }
                }
            }
        } // partCountry  =  new Table(2,13);
        size = frequency.size() + transittime.size() + carrier.size() + ratevalidity.size();
        /* Table prepareTable = new Table(1) ;
         prepareTable.setWidth(100);
         prepareTable.setBackgroundColor(Color.white);
         prepareTable.setBorderColor(Color.white);
         prepareTable.setPadding(1);
         chk = new Chunk("Prepared By: "+(headerDOB.getPreparedBy()!=null?headerDOB.getPreparedBy().toUpperCase():""),FontFactory.getFont("ARIAL", 10, Font.BOLD,Color.BLACK));
         cellCountry = new Cell(chk);
        // cellCountry.setBackgroundColor(Color.lightGray);
         cellCountry.setBorder(0);
         cellCountry.setNoWrap(true);
         cellCountry.setHorizontalAlignment(cellCountry.ALIGN_LEFT);
         cellCountry.setBorder(0);
         cellCountry.setLeading(8.0f);
         prepareTable.addCell(cellCountry);
                
         document.add(prepareTable); */

        /*  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.WHITE);
          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.setBorder(0);
          cellCountry.setNoWrap(true);
          cellCountry.setHorizontalAlignment(cellCountry.ALIGN_RIGHT);
          cellCountry.setBorder(0);
          cellCountry.setLeading(8.0f);
          partCountry.addCell(cellCountry);*/

        /* chk = new Chunk("SERVICE INFORMATION ",FontFactory.getFont("Courier-Bold", 12, Font.UNDERLINE,Color.blue));
         cellCountry = new Cell(chk);
         cellCountry.setColspan(2);
         cellCountry.setHorizontalAlignment(cellCountry.ALIGN_CENTER);
         //cellCountry.setBackgroundColor(Color.ORANGE);
         cellCountry.setBorder(0);
         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.setBorder(0);
         cellCountry.setNoWrap(true); 
         cellCountry.setHorizontalAlignment(cellCountry.ALIGN_RIGHT);
         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.setBorder(0);
         cellCountry.setLeading(8.0f);
         partCountry.addCell(cellCountry);
                
         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.setBorder(0);
         cellCountry.setHorizontalAlignment(cellCountry.ALIGN_RIGHT);
         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.setBorder(0);
         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.setBorder(0);
         cellCountry.setHorizontalAlignment(cellCountry.ALIGN_RIGHT);
         cellCountry.setLeading(8.0f);
         partCountry.addCell(cellCountry);
                 
         chk = new Chunk("   "+(headerDOB.getTypeOfService()!=null?headerDOB.getTypeOfService().toUpperCase():""),FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
         cellCountry = new Cell(chk);
         cellCountry.setNoWrap(true); 
         cellCountry.setBorder(0);
         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.setBorder(0);
         cellCountry.setHorizontalAlignment(cellCountry.ALIGN_RIGHT);
         cellCountry.setLeading(8.0f);
         partCountry.addCell(cellCountry);
                 
         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);
         cellCountry.setBorder(0);
         partCountry.addCell(cellCountry);
                 
         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.setBorder(0);
         cellCountry.setHorizontalAlignment(cellCountry.ALIGN_RIGHT);
         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.setBorder(0);
         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.setBorder(0);
         cellCountry.setHorizontalAlignment(cellCountry.ALIGN_RIGHT);
         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.setBorder(0);
         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.setBorder(0);
         cellCountry.setHorizontalAlignment(cellCountry.ALIGN_RIGHT);
         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.setBorder(0);
         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();

        //@@Added by Kameswari for the WPBN issue-146448
        charges = finalDOB.getLegDetails();
        noOfLanes = charges.size();
        //Added by kiran.v on 16/09/2011
        // session.setAttribute("legSize",noOfLanes);           
        PdfPTable chargeCountry2 = null;
        Table chargeCountry = null;
        PdfPCell cell2 = null;
        Cell cell = null;
        Table frtHeader = null;
        Table chargeTitle = null;
        Table chargeCountry1 = null;
        Cell cell1 = null;
        CustomCell border = new CustomCell();
        // float cellWidths[]   = {40,20,10,15,25};//@@Added by Kameswari for the WPBN issue - on 12/11/08
        float cellWidths[] = { 40, 15, 15, 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;
        MultiQuoteChargeInfo chargeInfo = null;
        ArrayList originLaneCharges = finalDOB.getLegDetails();//.get(0)).getOriginChargesList();
        for (int c = 0; c < noOfLanes; c++) //charges........
        {
            legOrginCharges = (MultiQuoteFreightLegSellRates) originLaneCharges.get(c);
            ArrayList originCharges = legOrginCharges.getOriginChargesList();
            int[] originIndices = legOrginCharges.getSelectedOriginChargesListIndices();
            int originChargesSize = 0;
            if (originIndices != null)
                originChargesSize = originIndices.length;
            else
                originChargesSize = 0;

            /*PdfPCell hLine = new PdfPCell(new Phrase(""));
            hLine.setBorder(PdfPCell.NO_BORDER);*/

            if (originChargesSize <= 0) {
                continue;
            }
            /*  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);
            home = (QMSMultiQuoteSessionHome) LookUpBean.getEJBHome("QMSMultiQuoteSessionBean");
            remote = home.create();
            //document.add(horizontalLine);

            chargeTitle = new Table(1);
            chargeTitle.setWidth(100);
            chargeTitle.setPadding(1);
            chargeTitle.setSpacing(1);
            chargeTitle.setBorderColor(Color.BLACK);
            chargeTitle.setDefaultHorizontalAlignment(Element.ALIGN_LEFT);
            chargeTitle.setBackgroundColor(Color.ORANGE);//modified by silpa.p on 3-06-11
            chargeTitle.setBorderWidth(1f);
            //chargeTitle.setBorder(1);

            if (legOrginCharges.getShipmentMode() == 2)
                chk = new Chunk(remote.getPortName(legOrginCharges.getOrigin()) + "-Origin Charges",
                        FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.black));
            else
                chk = new Chunk(remote.getLocationName(legOrginCharges.getOrigin()) + "-Origin Charges",
                        FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.black));
            cell1 = new Cell(chk);
            cell1.setLeading(10.0f);
            cell1.setBorder(0);
            cell1.setHeader(true);
            chargeTitle.addCell(cell1);
            document.add(chargeTitle);

            //chargeCountry  = new PdfPTable(6);
            chargeCountry = new Table(6);
            //chargeCountry.setWidth(100);
            chargeCountry.setWidths(cellWidths);
            chargeCountry.setBorder(1);
            chargeCountry.setWidth(100);
            chargeCountry.setDefaultVerticalAlignment(cell.ALIGN_MIDDLE);
            chargeCountry.setDefaultHorizontalAlignment(cell.ALIGN_CENTER);
            chargeCountry.setPadding(3);
            chargeCountry.setSpacing(0);
            //chargeCountry.setOffset(5);
            //chargeCountry.setBackgroundColor(Color.WHITE);
            // chargeCountry.setBorderColor(Color.WHITE);
            // chargeCountry.setDefaultHorizontalAlignment(Element.ALIGN_CENTER);
            chargeCountry.setBorderWidth(1f);
            //chargeCountry.setWidthPercentage(100);

            chargeCountry.setWidths(cellWidths);
            //document.add(horizontalLine);
            chk = new Chunk("Charge Description", FontFactory.getFont("ARIAL", 7, Font.BOLD, Color.BLACK)); // Added by Gowtham on 01-Feb-2011.
            // cell = new PdfPCell(new Phrase(chk));
            cell = new Cell(new Phrase(chk));
            //cell.setColspan(5);/@@Added by Kameswari for the WPBN issue - on 12/11/08
            // cell.setColspan(6);
            //cell.setLeading(10.0f);
            cell.setHorizontalAlignment(cell.ALIGN_LEFT);
            // cell.setBackgroundColor(Color.ORANGE);  
            ////cell.setBorder(0);
            //cell.setHeader(true);
            //cell.setBorder(Rectangle.BOTTOM);
            cell.setBorderWidth(1);
            //cell.setCellEvent(border); 
            chargeCountry.addCell(cell);

            chk = new Chunk("Weight Break Slab", FontFactory.getFont("ARIAL", 7, Font.BOLD, Color.BLACK));
            cell = new Cell(new Phrase(chk));
            //cell.setBorder(Rectangle.BOTTOM);
            //cell.setCellEvent(border); 
            cell.setHorizontalAlignment(cell.ALIGN_CENTER);
            cell.setBorderWidth(1);
            chargeCountry.addCell(cell);

            chk = new Chunk("Currency", FontFactory.getFont("ARIAL", 7, Font.BOLD, Color.BLACK));
            cell = new Cell(new Phrase(chk));
            //cell.setBorder(Rectangle.BOTTOM);
            //cell.setCellEvent(border);
            cell.setBorderWidth(1);
            cell.setHorizontalAlignment(cell.ALIGN_CENTER);
            chargeCountry.addCell(cell);

            chk = new Chunk("Charge Rate", FontFactory.getFont("ARIAL", 7, Font.BOLD, Color.BLACK));
            cell = new Cell(new Phrase(chk));
            //cell.setBorder(Rectangle.BOTTOM);
            //cell.setCellEvent(border);
            cell.setBorderWidth(1);
            cell.setHorizontalAlignment(cell.ALIGN_CENTER);
            chargeCountry.addCell(cell);

            chk = new Chunk("Basis", FontFactory.getFont("ARIAL", 7, Font.BOLD, Color.BLACK));
            cell = new Cell(new Phrase(chk));
            //cell.setBorder(Rectangle.BOTTOM);
            //cell.setCellEvent(border);
            cell.setBorderWidth(1);
            cell.setHorizontalAlignment(cell.ALIGN_LEFT);
            chargeCountry.addCell(cell);

            chk = new Chunk("Density Ratio", FontFactory.getFont("ARIAL", 7, Font.BOLD, Color.BLACK));
            cell = new Cell(new Phrase(chk));
            //cell.setBorder(Rectangle.BOTTOM);
            //cell.setCellEvent(border);
            cell.setBorderWidth(1);
            cell.setHorizontalAlignment(cell.ALIGN_CENTER);
            chargeCountry.addCell(cell);

            //@@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();
            // charge_desc  = "";
            for (int lc = 0; lc < originChargesSize; lc++) {
                if ((operation != null && "view".equalsIgnoreCase(operation) || ("Y".equalsIgnoreCase(
                        legOrginCharges.getOriginChargesSelectedFlag()[originIndices[lc]])))) {

                    //chargeCountry.endHeaders();
                    chargesDOB = (MultiQuoteCharges) originCharges.get(originIndices[lc]);

                    // for(int i=0;i<originChargesSize;i++)
                    //{
                    if (originIndices[lc] != -1) {

                        logger.info("Origin Charges doPDFGeneration::" + lc + ":" + 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 = (MultiQuoteChargeInfo) originChargeInfo.get(k);
                            if (k == 0) {
                                if ("B".equalsIgnoreCase(chargesDOB.getSellBuyFlag())
                                        || "S".equalsIgnoreCase(chargesDOB.getSellBuyFlag()))//||"BC".equalsIgnoreCase(chargesDOB.getSellBuyFlag())||"SC".equalsIgnoreCase(chargesDOB.getSellBuyFlag())) // Added by Gowtham
                                    chk = new Chunk(
                                            chargesDOB.getExternalName() != null ? chargesDOB.getExternalName()
                                                    : "",
                                            FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
                                else
                                    chk = new Chunk(
                                            chargesDOB.getChargeDescriptionId() != null
                                                    ? chargesDOB.getChargeDescriptionId()
                                                    : "",
                                            FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));

                                cell = new Cell(new Phrase(chk));
                                cell.setLeading(7.0f);
                                cell.setBorder(1);
                                cell.setRowspan(originChargesInfoSize);
                                cell.setHorizontalAlignment(cell.ALIGN_LEFT);
                                cell.setVerticalAlignment(cell.ALIGN_LEFT);
                                cell.setBorderWidthTop(0);
                                cell.setBorderWidthBottom(0.1f);
                                if (lc == originChargesSize - 1 && k == originChargesInfoSize - 1) {
                                    cell.setBorderWidthBottom(0.1f);
                                    cell.setHorizontalAlignment(cell.ALIGN_LEFT);
                                    //cell.setVerticalAlignment(cell.ALIGN_MIDDLE);

                                } else if (k == originChargesInfoSize - 1) {
                                    cell.setBorderWidthBottom(0.1f);
                                    cell.setHorizontalAlignment(cell.ALIGN_LEFT);
                                    //cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
                                    //cell.setBorderWidthBottom(0.1f);                            
                                } else {
                                    cell.setHorizontalAlignment(cell.ALIGN_LEFT);
                                    //cell.setVerticalAlignment(cell.ALIGN_CENTER);

                                }
                                chargeCountry.addCell(cell);

                            }
                            /* else if (k==originChargesInfoSize-1) 
                             {
                               cell = new Cell(new Phrase(new Chunk("")));
                             //  cell.setLeading(15.0f);
                               //cell.setBorder(Rectangle.BOTTOM);
                            // cell.setCellEvent(border);                        
                               if(lc!=originChargesSize-1){
                               cell.setBorder(0);
                               cell.setBorderWidth(0f);
                               }    
                               else{
                                  cell.setBorderWidthBottom(0.1f);  
                                      
                               }
                             cell.setHorizontalAlignment(cell.ALIGN_BOTTOM);
                                      
                            cell.setVerticalAlignment(cell.ALIGN_CENTER);
                             chargeCountry.addCell(cell);
                                    
                             }*/

                            /*else{
                               cell = new Cell(new Phrase(new Chunk("")));
                              //cell.setBorder(0);
                               //cell.setCellEvent(border); 
                              cell.setBorder(0);
                                 cell.setBorderWidth(0f);
                                // cell.setLeading(15.0f);
                               cell.setHorizontalAlignment(cell.ALIGN_BOTTOM);
                                     
                              cell.setVerticalAlignment(cell.ALIGN_CENTER);
                                     
                              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", 7, Font.NORMAL,Color.BLACK)); Commented by silpa for not displaying the abslute brak in pdf
                            chk = new Chunk(breakPoint != null ? breakPoint : "",
                                    FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));//added by silpa.p on 16-06-11
                            cell = new Cell(new Phrase(chk));
                            cell.setLeading(7.0f);
                            if (k == originChargesInfoSize - 1) {
                                //cell.setBorder(Rectangle.ALIGN_CENTER);
                                // cell.setCellEvent(border); 
                                //  cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
                                cell.setHorizontalAlignment(cell.ALIGN_CENTER);
                            } else {
                                ;
                                //cell.setBorder(0);
                                //cell.setCellEvent(border); 
                                // cell.setBorder(Rectangle.ALIGN_CENTER);                          
                                //cell.setVerticalAlignment(cell.ALIGN_MIDDLE);
                                cell.setHorizontalAlignment(cell.ALIGN_CENTER);
                            }

                            chargeCountry.addCell(cell);
                            //   @@ Ended by subrahmanyam for 146455 on 19/02/09                

                            chk = new Chunk(chargeInfo.getCurrency(),
                                    FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
                            cell = new Cell(new Phrase(chk));
                            cell.setLeading(7.0f);
                            if (k == originChargesInfoSize - 1) {
                                //cell.setBorder(Rectangle.BOTTOM);
                                // cell.setCellEvent(border); 
                                cell.setHorizontalAlignment(cell.ALIGN_CENTER);
                            } else {
                                //cell.setBorder(0);
                                //cell.setCellEvent(border); 
                                cell.setHorizontalAlignment(cell.ALIGN_CENTER);
                            }
                            chargeCountry.addCell(cell);

                            chk = new Chunk(
                                    df.format(chargeInfo.getSellRate())
                                            + (chargeInfo.isPercentValue() ? " %" : ""),
                                    FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
                            cell = new Cell(new Phrase(chk));
                            cell.setLeading(7.0f);
                            if (k == originChargesInfoSize - 1) {
                                //cell.setBorder(Rectangle.BOTTOM);
                                //cell.setCellEvent(border); 
                                cell.setHorizontalAlignment(cell.ALIGN_CENTER);
                            } else {
                                //cell.setBorder(0);
                                //cell.setCellEvent(border); 
                                cell.setHorizontalAlignment(cell.ALIGN_CENTER);
                            }
                            chargeCountry.addCell(cell);

                            chk = new Chunk(chargeInfo.getBasis() != null ? chargeInfo.getBasis() : "",
                                    FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
                            cell = new Cell(new Phrase(chk));
                            cell.setLeading(7.0f);
                            if (k == originChargesInfoSize - 1) {
                                //cell.setBorder(Rectangle.BOTTOM);
                                //cell.setCellEvent(border); 
                                cell.setHorizontalAlignment(cell.ALIGN_LEFT);
                            } else {
                                //cell.setBorder(0);
                                //cell.setCellEvent(border); 
                                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", 7, Font.NORMAL, Color.BLACK));
                            cell = new Cell(new Phrase(chk));
                            cell.setLeading(7.0f);
                            if (k == originChargesInfoSize - 1) {
                                //cell.setBorder(Rectangle.BOTTOM);
                                //cell.setCellEvent(border); 
                                cell.setHorizontalAlignment(cell.ALIGN_CENTER);
                            } else {
                                //cell.setBorder(0);
                                //cell.setCellEvent(border); 
                                cell.setHorizontalAlignment(cell.ALIGN_CENTER);
                            }
                            chargeCountry.addCell(cell);

                        }
                    }
                    //}
                }
            }

            if (chargeCountry != null)
                document.add(chargeCountry);

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

            //} // Added by Gowtham on 01-Feb-2011.
            //@@Added by kiran.v on 31/01/2012 for Wpbn Issue-287659

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

        document.add(pTable);

        // document.newPage();

        // boolean b1 = document.newPage();

        //Freight Charges
        //document.setMargins(10,10,10,10);
        //System.out.println("After         Origin Charges --------------------------------->");

        if (!"Charges".equalsIgnoreCase(masterDOB.getQuoteWith())) {
            // Added by Gowtham. to skip in case of quote with charges.
            //Table   chargeCountry1 = null;
            //Cell   cell1         =null;
            int freightChargesSize = 0;
            int freightChargesInfoSize = 0;
            int[] frtIndices = null;
            int tableColwidth = 0; //Added by Gowtham for Landscape Issue.
            String tmpBasis = "";
            int tmpBrkptsize = 0;
            String tmpmultiBrkpt = "";
            int tmpTableWidth = 0;
            String rates = null;
            Double rates1 = 0.00;
            int tmpCount = 0;
            String basis = "";
            String orgDesc = "";
            String destDesc = "";
            String breakpt = "";
            String tmpFreq = "";
            String tmpFreq1 = "";
            int tmpFrCnt = 0; //Added by Gowtham for Landscape Issue
            MultiQuoteChargeInfo viewDOB = null;
            ArrayList chargesInfolist = new ArrayList();
            int[] tmpBrksize = null;

            //QuoteFreightLegSellRates       legCharges       = null;
            // ArrayList                      freightCharges = null;
            ArrayList freightChargeInfo = null;
            int m = 0;
            String breakPoint = null;
            String space = "";
            Table country = null;
            String serviceLevelDesc = "";//Added by silpa on 16-05-2011
            String carrierDesc = "";//Added by silpa on 16-05-2011

            // b2= writer.getPageNumber();
            // int[] frtCellWidths = {15,16,15,15,18,12,25,12,12,20,15}; // Modified by Gowtham on 24Feb2011

            if ("View".equalsIgnoreCase(request.getParameter("Operation"))) {
                home = (QMSMultiQuoteSessionHome) LookUpBean.getEJBHome("QMSMultiQuoteSessionBean");
                remote = home.create();

                chargesInfolist = remote.getChargeInfoDetailsforView(masterDOB.getQuoteId());
                viewDOB = (MultiQuoteChargeInfo) chargesInfolist.get(0);
                tmpBrkptsize = viewDOB.getMultiBreakPoints().length;
                surChargesMap = viewDOB.getSurChragesMap();

            } else {

                surChargesMap = new HashMap<String, String>();
                for (int lane = 0; lane < noOfLanes; lane++) {
                    legCharges = (MultiQuoteFreightLegSellRates) charges.get(lane);
                    freightCharges = legCharges.getFreightChargesList();
                    MultiQuoteChargeInfo tempChargeInfo = freightCharges != null
                            ? (MultiQuoteChargeInfo) freightCharges.get(lane)
                            : null;
                    // tmpBrkptsize =   tempChargeInfo!=null?finalDOB.getMultiQuoteSelectedBreaks().split(",").length:0;

                    String[] breakpoints = tempChargeInfo != null ? tempChargeInfo.getMultiBreakPoints() : null;
                    String[] rateDescs = tempChargeInfo != null ? tempChargeInfo.getMultiRateDescriptions()
                            : null;
                    String chargeDesc = null;

                    for (int i = 0; i < (breakpoints != null ? breakpoints.length : 0); i++) {
                        chargeDesc = rateDescs[i];
                        /*if(chargeDesc!=null && !"-".equals(chargeDesc) && !"A FREIGHT RATE".equals(chargeDesc)){
                           surChargesMap.put(breakpoints[i].length()>=7?breakpoints[i].substring(0, 3):breakpoints[i],chargeDesc.substring(0, chargeDesc.length()-3) );
                        }*/
                        if (!"List".equalsIgnoreCase(finalDOB.getMasterDOB().getMultiquoteweightBrake())) {
                            if (chargeDesc != null && !"-".equals(chargeDesc)
                                    && !"A FREIGHT RATE".equals(chargeDesc)) {
                                if (breakpoints[i].length() >= 7)
                                    surChargesMap.put(breakpoints[i].substring(0, 3),
                                            chargeDesc.substring(0, chargeDesc.length() - 3));
                            }
                        }

                        if ("List".equalsIgnoreCase(finalDOB.getMasterDOB().getMultiquoteweightBrake())) {
                            if (chargeDesc != null && !"-".equals(chargeDesc)
                                    && !"A FREIGHT RATE".equals(chargeDesc)) {
                                if (breakpoints[i].length() > 4 && breakpoints[i].length() < 10)
                                    surChargesMap.put(breakpoints[i].substring(4, 7),
                                            chargeDesc.substring(0, chargeDesc.length() - 3));
                            }
                        }
                    }
                }

                legCharges = (MultiQuoteFreightLegSellRates) charges.get(0);
                freightCharges = legCharges.getFreightChargesList();
                MultiQuoteChargeInfo tempChargeInfo = freightCharges != null
                        ? (MultiQuoteChargeInfo) freightCharges.get(0)
                        : null;
                tmpBrkptsize = tempChargeInfo != null ? finalDOB.getMultiQuoteSelectedBreaks().split(",").length
                        : 0;

                tmpBrksize = new int[tmpBrkptsize];
                int tmpBrk = 0;
                for (int frtCnt1 = 0; frtCnt1 < tmpBrkptsize; frtCnt1++) {
                    tmpBrk = Integer.parseInt(finalDOB.getMultiQuoteSelectedBreaks().split(",")[frtCnt1]);
                    //if("Y".equalsIgnoreCase(tempChargeInfo.getChecked_Flag().split(",")[frtCnt1]))
                    //{ 
                    tmpBasis = tmpBasis != "" ? (tmpBasis + tempChargeInfo.getBasis().split(",")[tmpBrk] + ",")
                            : (tempChargeInfo.getBasis().split(",")[tmpBrk] + ",");
                    tmpmultiBrkpt = tmpmultiBrkpt != ""
                            ? (tmpmultiBrkpt + tempChargeInfo.getMultiBreakPoints()[tmpBrk] + ",")
                            : (tempChargeInfo.getMultiBreakPoints()[tmpBrk] + ",");
                    tmpBrksize[frtCnt1] = tmpBrk;
                    // tmpTableWidth++;
                    // }
                }
            }

            /* if("Add".equalsIgnoreCase(request.getParameter("Operation"))||"Modify".equalsIgnoreCase(request.getParameter("Operation"))||"Copy".equalsIgnoreCase(request.getParameter("Operation")))
             {      
                     
             tableColwidth = tmpBrkptsize;
                     
             }
             else
             tableColwidth =  tmpBrkptsize;*/

            // tableColwidth = tmpBrkptsize + 4;   //added by silpa.p on 16-05-11//commented by silpa.p on 23-06-11
            tableColwidth = tmpBrkptsize + 5; //added by silpa.p on 23-06-11 for currency add
            //@@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(request.getParameter("selectCarrier"))) {
                    tableColwidth = tableColwidth + 1;
                }
                if ("checked".equalsIgnoreCase(request.getParameter("selectService"))) {
                    tableColwidth = tableColwidth + 1;
                }
                if ("checked".equalsIgnoreCase(request.getParameter("selectFrequecy"))) {
                    tableColwidth = tableColwidth + 1;
                }
                //@@Added by kiran.v on 23/09/2011 for Wpbn Issue 272712
                if ("checked".equalsIgnoreCase(request.getParameter("selectTransitTime"))) {
                    tableColwidth = tableColwidth + 1;
                }
                if ("checked".equalsIgnoreCase(request.getParameter("selectFrieghtValidity"))) {
                    tableColwidth = tableColwidth + 1;
                }
            } else {
                if ("checked".equalsIgnoreCase(request.getParameter("selectCarrier"))
                        || "Y".equalsIgnoreCase(
                                multiQuoteChargeInfo != null ? multiQuoteChargeInfo.getCarrierChecked() : "N")
                        || "on".equalsIgnoreCase(
                                multiQuoteChargeInfo != null ? multiQuoteChargeInfo.getCarrierChecked() : "")) {
                    tableColwidth = tableColwidth + 1;
                }
                if ("checked".equalsIgnoreCase(request.getParameter("selectService"))
                        || "Y".equalsIgnoreCase(
                                multiQuoteChargeInfo != null ? multiQuoteChargeInfo.getServiceChecked() : "N")
                        || "on".equalsIgnoreCase(
                                multiQuoteChargeInfo != null ? multiQuoteChargeInfo.getServiceChecked() : "")) {
                    tableColwidth = tableColwidth + 1;
                }
                if ("checked".equalsIgnoreCase(request.getParameter("selectFrequecy"))
                        || "Y".equalsIgnoreCase(
                                multiQuoteChargeInfo != null ? multiQuoteChargeInfo.getFrequencyChecked() : "N")
                        || "on".equalsIgnoreCase(
                                multiQuoteChargeInfo != null ? multiQuoteChargeInfo.getFrequencyChecked()
                                        : "")) {
                    tableColwidth = tableColwidth + 1;
                }
                //@@Added by kiran.v on 23/09/2011 for Wpbn Issue 272712
                if ("checked".equalsIgnoreCase(request.getParameter("selectTransitTime"))
                        || "Y".equalsIgnoreCase(
                                multiQuoteChargeInfo != null ? multiQuoteChargeInfo.getTransitTimeChecked()
                                        : "N")
                        || "on".equalsIgnoreCase(
                                multiQuoteChargeInfo != null ? multiQuoteChargeInfo.getTransitTimeChecked()
                                        : "")) {
                    tableColwidth = tableColwidth + 1;
                }
                if ("checked".equalsIgnoreCase(request.getParameter("selectFrieghtValidity"))
                        || "Y".equalsIgnoreCase(
                                multiQuoteChargeInfo != null ? multiQuoteChargeInfo.getRateValidityChecked()
                                        : "N")
                        || "on".equalsIgnoreCase(
                                multiQuoteChargeInfo != null ? multiQuoteChargeInfo.getRateValidityChecked()
                                        : "")) {
                    tableColwidth = tableColwidth + 1;
                }
            }
            //@@Ended by kiran.v
            int[] frtCellWidths = new int[tableColwidth];//modified by silpa.p 0n 16-05-11
            for (int frtcnt = 0; frtcnt < tableColwidth; frtcnt++)//modified by silpa.p 0n 16-05-11
            {
                frtCellWidths[frtcnt] = 10;
            }
            if (noOfLanes > 0) {

                //if( originChargesSize >0)
                //document.newPage(); 
                //document.add(horizontalLine);
                frtHeader = new Table(1);
                frtHeader.setWidth(100);
                frtHeader.setBackgroundColor(Color.white);
                frtHeader.setBorderColor(Color.BLACK);
                //frtHeader.setBorder(Rectangle.TOP);
                frtHeader.setBorderWidth(1f);
                frtHeader.setDefaultHorizontalAlignment(Element.ALIGN_LEFT);
                frtHeader.setPadding(1);
                frtHeader.setSpacing(1);
                frtHeader.setTableFitsPage(true);

                chk = new Chunk("FREIGHT CHARGES", FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));
                cell1 = new Cell(chk);
                cell1.setLeading(10.0f);
                cell1.setBorder(0);
                cell1.setBackgroundColor(Color.ORANGE);//modified by silpa.p on 3-06-11
                frtHeader.addCell(cell1);
                document.add(frtHeader);
                //document.add(horizontalLine);
                chargeCountry2 = new PdfPTable(tableColwidth);//modified by silpa.p on 16-05-11
                chargeCountry2.setWidthPercentage(100);
                chargeCountry2.setWidths(frtCellWidths);

                /*chargeCountry.setPadding(1);
                chargeCountry.setSpacing(0);
                chargeCountry.setOffset(5);*/

                /*
                cell = new PdfPCell(new Phrase(new Chunk("")));
                 cell.setBorder(Rectangle.BOTTOM);
                cell.setCellEvent(border); 
                cell.setHorizontalAlignment(cell.ALIGN_LEFT);
                chargeCountry.addCell(cell);*/

                /* chargeCountry.setBackgroundColor(Color.WHITE);
                 chargeCountry.setBorderColor(Color.white);
                 chargeCountry.setDefaultHorizontalAlignment(Element.ALIGN_CENTER);
                 //chargeCountry.setBorderWidth(1f);
                 chargeCountry.setTableFitsPage(true);//@@Added by kameswari 
                */
                if (!"Charges".equalsIgnoreCase(masterDOB.getQuoteWith())) {//Added by Anil.k
                    //for(int i=0;i<noOfLanes;i++)//testttttttttttinggggggggg

                    legCharges = (MultiQuoteFreightLegSellRates) charges.get(0);
                    freightCharges = legCharges.getFreightChargesList();

                    freightChargesSize = freightCharges.size();//No of rates per lane
                    //Added By Kishore Podili (this change was over rided)
                    if ("View".equalsIgnoreCase(request.getParameter("Operation")))
                        freightChargesSize = chargesInfolist.size();

                    //added by silpa.p on 16-05-11
                    //ended                      
                    if (freightChargesSize > 0) {

                        chk = new Chunk("Origin",
                                FontFactory.getFont("Courier-Bold ", 7, Font.BOLD, Color.BLACK));
                        cell2 = new PdfPCell(new Phrase(chk));
                        cell2.setBorder(Rectangle.BOTTOM);
                        cell2.setCellEvent(border);
                        cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                        chargeCountry2.addCell(cell2);

                        chk = new Chunk("Destination",
                                FontFactory.getFont("Courier-Bold ", 7, Font.BOLD, Color.BLACK));
                        cell2 = new PdfPCell(new Phrase(chk));
                        cell2.setBorder(Rectangle.BOTTOM);
                        cell2.setCellEvent(border);
                        cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                        chargeCountry2.addCell(cell2);
                        System.out.println("operation" + operation);
                        //@@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)) {//added by silpa.p on 14-05-11
                                chk = new Chunk("Carrier",
                                        FontFactory.getFont("Courier-Bold ", 7, Font.BOLD, Color.BLACK));
                                cell2 = new PdfPCell(new Phrase(chk));
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);
                            } //ended

                            if ("checked".equalsIgnoreCase(serviceLevelChecked)) {//added by silpa.p on 14-05-11
                                chk = new Chunk("Service level",
                                        FontFactory.getFont("Courier-Bold ", 7, Font.BOLD, Color.BLACK));
                                cell2 = new PdfPCell(new Phrase(chk));
                                // serviceflag=true;
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);

                            } //ended
                            if ("checked".equalsIgnoreCase(frequencyChecked)) {//added by silpa.p on 16-05-11
                                chk = new Chunk("Frequency",
                                        FontFactory.getFont("Courier-Bold ", 7, Font.BOLD, Color.BLACK));
                                cell2 = new PdfPCell(new Phrase(chk));
                                // frequencyflag=true;
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);
                            }
                            //@@Added by kiran.v on 23/09/2011 for Wpbn Issue 272712
                            if ("checked".equalsIgnoreCase(transitTimeChecked)) {
                                chk = new Chunk("TransitTime",
                                        FontFactory.getFont("Courier-Bold ", 7, Font.BOLD, Color.BLACK));
                                cell2 = new PdfPCell(new Phrase(chk));
                                // frequencyflag=true;
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);
                            }
                            if ("checked".equalsIgnoreCase(validityChecked)) {
                                chk = new Chunk("FreightValidity",
                                        FontFactory.getFont("Courier-Bold ", 7, Font.BOLD, Color.BLACK));
                                cell2 = new PdfPCell(new Phrase(chk));
                                // frequencyflag=true;
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);
                            }
                        } else {
                            if ("checked".equalsIgnoreCase(carrierChecked)
                                    || "Y".equalsIgnoreCase(multiQuoteChargeInfo.getCarrierChecked())
                                    || "on".equalsIgnoreCase(multiQuoteChargeInfo.getCarrierChecked())) {//added by silpa.p on 14-05-11
                                chk = new Chunk("Carrier",
                                        FontFactory.getFont("Courier-Bold ", 7, Font.BOLD, Color.BLACK));
                                carrierFlag = true;
                                cell2 = new PdfPCell(new Phrase(chk));
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);
                            } //ended
                            if ("checked".equalsIgnoreCase(serviceLevelChecked)
                                    || "Y".equalsIgnoreCase(multiQuoteChargeInfo.getServiceChecked())
                                    || "on".equalsIgnoreCase(multiQuoteChargeInfo.getServiceChecked())) {//added by silpa.p on 14-05-11
                                chk = new Chunk("Service level",
                                        FontFactory.getFont("Courier-Bold ", 7, Font.BOLD, Color.BLACK));
                                cell2 = new PdfPCell(new Phrase(chk));
                                serviceflag = true;
                                serviceFlag = true;
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);

                            } //ended
                            if ("checked".equalsIgnoreCase(frequencyChecked)
                                    || "Y".equalsIgnoreCase(multiQuoteChargeInfo.getFrequencyChecked())
                                    || "on".equalsIgnoreCase(multiQuoteChargeInfo.getFrequencyChecked())) {//added by silpa.p on 16-05-11
                                chk = new Chunk("Frequency",
                                        FontFactory.getFont("Courier-Bold ", 7, Font.BOLD, Color.BLACK));
                                cell2 = new PdfPCell(new Phrase(chk));
                                frequencyflag = true;
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);
                            }
                            //@@Added by kiran.v on 23/09/2011 for Wpbn Issue 272712
                            if ("checked".equalsIgnoreCase(transitTimeChecked)
                                    || "Y".equalsIgnoreCase(multiQuoteChargeInfo.getTransitTimeChecked())
                                    || "on".equalsIgnoreCase(multiQuoteChargeInfo.getTransitTimeChecked())) {
                                chk = new Chunk("TransitTime",
                                        FontFactory.getFont("Courier-Bold ", 7, Font.BOLD, Color.BLACK));
                                cell2 = new PdfPCell(new Phrase(chk));
                                transittimeflag = true;
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);
                            }
                            if ("checked".equalsIgnoreCase(validityChecked)
                                    || "Y".equalsIgnoreCase(multiQuoteChargeInfo.getRateValidityChecked())
                                    || "on".equalsIgnoreCase(multiQuoteChargeInfo.getRateValidityChecked())) {
                                chk = new Chunk("FreightValidity",
                                        FontFactory.getFont("Courier-Bold ", 7, Font.BOLD, Color.BLACK));
                                cell2 = new PdfPCell(new Phrase(chk));
                                freightValidity = true;
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);
                            }
                        }
                        //@@ Ended by kiran.v
                        chk = new Chunk("Incoterms",
                                FontFactory.getFont("Courier-Bold ", 7, Font.BOLD, Color.BLACK));
                        cell2 = new PdfPCell(new Phrase(chk));
                        cell2.setBorder(Rectangle.BOTTOM);
                        cell2.setCellEvent(border);
                        cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                        chargeCountry2.addCell(cell2);
                        //added by silpa.p on 23-06-11 for currency add
                        chk = new Chunk("Currency",
                                FontFactory.getFont("Courier-Bold ", 7, Font.BOLD, Color.BLACK));
                        cell2 = new PdfPCell(new Phrase(chk));
                        cell2.setBorder(Rectangle.BOTTOM);
                        cell2.setCellEvent(border);
                        cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                        chargeCountry2.addCell(cell2);//ended

                        if ("Add".equalsIgnoreCase(request.getParameter("Operation"))
                                || "Modify".equalsIgnoreCase(request.getParameter("Operation"))
                                || "Copy".equalsIgnoreCase(request.getParameter("Operation"))) {
                            for (int brk1 = 0; brk1 < tmpBrkptsize; brk1++) {

                                if (tmpmultiBrkpt.split(",")[brk1] != null
                                        && tmpmultiBrkpt.split(",")[brk1].toUpperCase().endsWith("MIN")) {
                                    if (tmpmultiBrkpt.split(",")[brk1].length() > 7)
                                        breakpt = "MIN" + "\n" + tmpmultiBrkpt.split(",")[brk1].substring(0, 3);
                                    //breakpt = "MIN";
                                    else
                                        breakpt = "MIN";
                                } else if (tmpmultiBrkpt.split(",")[brk1] != null
                                        && tmpmultiBrkpt.split(",")[brk1].toUpperCase().endsWith("BASIC")) {

                                    if (tmpmultiBrkpt.split(",")[brk1].length() > 7)
                                        breakpt = "BASIC" + "\n"
                                                + tmpmultiBrkpt.split(",")[brk1].substring(0, 3);
                                    //breakpt = "BASIC";
                                    else
                                        breakpt = "BASIC";
                                } else if (tmpmultiBrkpt.split(",")[brk1] != null
                                        && tmpmultiBrkpt.split(",")[brk1].toUpperCase().endsWith("FLAT")) {

                                    if (tmpmultiBrkpt.split(",")[brk1].length() > 7)
                                        breakpt = "FLAT" + "\n"
                                                + tmpmultiBrkpt.split(",")[brk1].substring(0, 3);
                                    //breakpt ="FLAT";
                                    else
                                        breakpt = "FLAT";
                                } else if (tmpmultiBrkpt.split(",")[brk1] != null
                                        && tmpmultiBrkpt.split(",")[brk1].toUpperCase().endsWith("ABSOLUTE")) {

                                    if (tmpmultiBrkpt.split(",")[brk1].length() > 10)
                                        breakpt = "ABSOLUTE" + "\n"
                                                + tmpmultiBrkpt.split(",")[brk1].substring(0, 3);
                                    //breakpt = "ABSOLUTE";
                                    else
                                        breakpt = "ABSOLUTE";
                                } else if (tmpmultiBrkpt.split(",")[brk1] != null
                                        && tmpmultiBrkpt.split(",")[brk1].toUpperCase().endsWith("PERCENT")) {

                                    if (tmpmultiBrkpt.split(",")[brk1].length() > 10)
                                        breakpt = "PERCENT" + "\n"
                                                + tmpmultiBrkpt.split(",")[brk1].substring(0, 3);
                                    //breakpt = "PERCENT";
                                    else
                                        breakpt = "PERCENT";
                                } else if (isInteger(tmpmultiBrkpt.split(",")[brk1])
                                        || isDouble(tmpmultiBrkpt.split(",")[brk1])) {
                                    breakpt = tmpmultiBrkpt.split(",")[brk1];
                                } else
                                    breakpt = tmpmultiBrkpt
                                            .split(",")[brk1] != null
                                                    ? (tmpmultiBrkpt.split(",")[brk1].length() > 5
                                                            ? tmpmultiBrkpt.split(",")[brk1].substring(0, 4)
                                                                    + "\n"
                                                                    + tmpmultiBrkpt.split(",")[brk1].substring(
                                                                            4,
                                                                            tmpmultiBrkpt.split(",")[brk1]
                                                                                    .length() - 2)
                                                            : tmpmultiBrkpt.split(",")[brk1])
                                                    : "";
                                basis = tmpBasis.split(",")[brk1] != null ? tmpBasis.split(",")[brk1] : "";

                                //chk = new Chunk(breakpt+"\n"+basis,FontFactory.getFont("Courier-Bold ", 8, Font.BOLD,Color.BLACK));
                                chk = new Chunk(breakpt,
                                        FontFactory.getFont("Courier-Bold ", 7, Font.BOLD, Color.BLACK));
                                cell2 = new PdfPCell(new Phrase(chk));
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);
                            }
                        } else {
                            for (int t = 0; t < tmpBrkptsize; t++) {
                                if (viewDOB.getMultiBreakPoints()[t].toUpperCase().endsWith("MIN")) {
                                    if (viewDOB.getMultiBreakPoints()[t].length() > 7)
                                        breakpt = "MIN" + "\n"
                                                + viewDOB.getMultiBreakPoints()[t].substring(0, 3);
                                    //breakpt= "MIN";
                                    else
                                        breakpt = "MIN";
                                } else if (viewDOB.getMultiBreakPoints()[t].toUpperCase().endsWith("BASIC")) {
                                    if (viewDOB.getMultiBreakPoints()[t].length() > 7)
                                        breakpt = "BASIC" + "\n"
                                                + viewDOB.getMultiBreakPoints()[t].substring(0, 3);
                                    //breakpt= "BASIC";
                                    else
                                        breakpt = "BASIC";
                                } else if (viewDOB.getMultiBreakPoints()[t].toUpperCase().endsWith("FLAT")) {
                                    if (viewDOB.getMultiBreakPoints()[t].length() > 7)
                                        breakpt = "FLAT" + "\n"
                                                + viewDOB.getMultiBreakPoints()[t].substring(0, 3);
                                    //breakpt= "FLAT";

                                    else
                                        breakpt = "FLAT";
                                } else if (viewDOB.getMultiBreakPoints()[t].toUpperCase()
                                        .endsWith("ABSOLUTE")) {
                                    if (viewDOB.getMultiBreakPoints()[t].length() > 10)
                                        breakpt = "ABSOLUTE" + "\n"
                                                + viewDOB.getMultiBreakPoints()[t].substring(0, 3);
                                    //breakpt= "ABSOLUTE";
                                    else
                                        breakpt = "ABSOLUTE";
                                } else if (viewDOB.getMultiBreakPoints()[t].toUpperCase().endsWith("PERCENT")) {
                                    if (viewDOB.getMultiBreakPoints()[t].length() > 7)
                                        breakpt = "PERCENT" + "\n"
                                                + viewDOB.getMultiBreakPoints()[t].substring(0, 3);
                                    //breakpt= "PERCENT";
                                    else
                                        breakpt = "PERCENT";
                                } else
                                    breakpt = viewDOB.getMultiBreakPoints()[t] != null
                                            ? (viewDOB.getMultiBreakPoints()[t].length() > 5
                                                    ? viewDOB.getMultiBreakPoints()[t].substring(0, 4) + "\n"
                                                            + viewDOB.getMultiBreakPoints()[t].substring(4,
                                                                    viewDOB.getMultiBreakPoints()[t].length()
                                                                            - 2)
                                                    : viewDOB.getMultiBreakPoints()[t])
                                            : "";

                                //chk = new Chunk(breakpt+"\n"+viewDOB.getBasis().split(",")[t],FontFactory.getFont("Courier-Bold ", 8, Font.BOLD,Color.BLACK));
                                chk = new Chunk(breakpt,
                                        FontFactory.getFont("Courier-Bold ", 7, Font.BOLD, Color.BLACK));
                                cell2 = new PdfPCell(new Phrase(chk));
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);

                            }
                        }

                        chk = new Chunk("Density Ratio",
                                FontFactory.getFont("Courier-Bold ", 7, Font.BOLD, Color.BLACK));
                        cell2 = new PdfPCell(new Phrase(chk));
                        cell2.setBorder(Rectangle.BOTTOM);
                        cell2.setCellEvent(border);
                        cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                        chargeCountry2.addCell(cell2);

                    }

                    //added by silpa.p on 16-05-11 for adding new line for pdf
                    if (freightChargesSize > 0) {

                        chk = new Chunk("", FontFactory.getFont("Courier-Bold ", 8, Font.BOLD, Color.BLACK));
                        cell2 = new PdfPCell(new Phrase(chk));
                        cell2.setBorder(Rectangle.BOTTOM);
                        cell2.setCellEvent(border);
                        cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                        chargeCountry2.addCell(cell2);

                        cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                        chargeCountry2.addCell(cell2);
                        chk = new Chunk("", FontFactory.getFont("Courier-Bold ", 8, Font.BOLD, Color.BLACK));
                        cell2 = new PdfPCell(new Phrase(chk));
                        cell2.setBorder(Rectangle.BOTTOM);
                        cell2.setCellEvent(border);
                        //@@ Modified by kiran.v on 28/08/2011 for Wpbn Issue -258778
                        // 09/11/2011
                        if ("add".equalsIgnoreCase(operation) || "modify".equalsIgnoreCase(operation)
                                || "Copy".equalsIgnoreCase(operation)) {
                            if ("checked".equalsIgnoreCase(carrierChecked)) {//added by silpa.p on 14-05-11
                                chk = new Chunk("",
                                        FontFactory.getFont("Courier-Bold ", 8, Font.BOLD, Color.BLACK));
                                cell2 = new PdfPCell(new Phrase(chk));
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);
                            }

                            if ("checked".equalsIgnoreCase(serviceLevelChecked)) {//added by silpa.p on 14-05-11
                                chk = new Chunk("",
                                        FontFactory.getFont("Courier-Bold ", 8, Font.BOLD, Color.BLACK));
                                cell2 = new PdfPCell(new Phrase(chk));
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);

                            }
                            if ("checked".equalsIgnoreCase(frequencyChecked)) {//added by silpa.p on 16-05-11
                                chk = new Chunk("",
                                        FontFactory.getFont("Courier-Bold ", 8, Font.BOLD, Color.BLACK));
                                cell2 = new PdfPCell(new Phrase(chk));
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);
                            }
                            //@@Added by kiran.v on 23/09/2011 for Wpbn Issue 272712
                            if ("checked".equalsIgnoreCase(transitTimeChecked)) {
                                chk = new Chunk("",
                                        FontFactory.getFont("Courier-Bold ", 8, Font.BOLD, Color.BLACK));
                                cell2 = new PdfPCell(new Phrase(chk));
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);
                            }
                            if ("checked".equalsIgnoreCase(validityChecked)) {
                                chk = new Chunk("",
                                        FontFactory.getFont("Courier-Bold ", 8, Font.BOLD, Color.BLACK));
                                cell2 = new PdfPCell(new Phrase(chk));
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);
                            }
                        } else {
                            if ("Y".equalsIgnoreCase(
                                    multiQuoteChargeInfo != null ? multiQuoteChargeInfo.getCarrierChecked()
                                            : "N")
                                    || "on".equalsIgnoreCase(multiQuoteChargeInfo != null
                                            ? multiQuoteChargeInfo.getCarrierChecked()
                                            : "")) {//added by silpa.p on 14-05-11
                                chk = new Chunk(" ",
                                        FontFactory.getFont("Courier-Bold ", 8, Font.BOLD, Color.BLACK));
                                cell2 = new PdfPCell(new Phrase(chk));
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);
                            }

                            if ("Y".equalsIgnoreCase(
                                    multiQuoteChargeInfo != null ? multiQuoteChargeInfo.getServiceChecked()
                                            : "N")
                                    || "on".equalsIgnoreCase(multiQuoteChargeInfo != null
                                            ? multiQuoteChargeInfo.getServiceChecked()
                                            : "")) {//added by silpa.p on 14-05-11
                                chk = new Chunk(" ",
                                        FontFactory.getFont("Courier-Bold ", 8, Font.BOLD, Color.BLACK));
                                cell2 = new PdfPCell(new Phrase(chk));
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);

                            }
                            if ("Y".equalsIgnoreCase(
                                    multiQuoteChargeInfo != null ? multiQuoteChargeInfo.getFrequencyChecked()
                                            : "N")
                                    || "on".equalsIgnoreCase(multiQuoteChargeInfo != null
                                            ? multiQuoteChargeInfo.getFrequencyChecked()
                                            : "")) {//added by silpa.p on 16-05-11
                                chk = new Chunk(" ",
                                        FontFactory.getFont("Courier-Bold ", 8, Font.BOLD, Color.BLACK));
                                cell2 = new PdfPCell(new Phrase(chk));
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);
                            }
                            //@@Added by kiran.v on 23/09/2011 for Wpbn Issue 272712
                            if ("Y".equalsIgnoreCase(
                                    multiQuoteChargeInfo != null ? multiQuoteChargeInfo.getTransitTimeChecked()
                                            : "N")
                                    || "on".equalsIgnoreCase(multiQuoteChargeInfo != null
                                            ? multiQuoteChargeInfo.getTransitTimeChecked()
                                            : "")) {
                                chk = new Chunk(" ",
                                        FontFactory.getFont("Courier-Bold ", 8, Font.BOLD, Color.BLACK));
                                cell2 = new PdfPCell(new Phrase(chk));
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);
                            }
                            if ("Y".equalsIgnoreCase(
                                    multiQuoteChargeInfo != null ? multiQuoteChargeInfo.getRateValidityChecked()
                                            : "N")
                                    || "on".equalsIgnoreCase(multiQuoteChargeInfo != null
                                            ? multiQuoteChargeInfo.getRateValidityChecked()
                                            : "")) {
                                chk = new Chunk(" ",
                                        FontFactory.getFont("Courier-Bold ", 8, Font.BOLD, Color.BLACK));
                                cell2 = new PdfPCell(new Phrase(chk));
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);
                            }
                        }
                        chk = new Chunk("", FontFactory.getFont("Courier-Bold ", 8, Font.BOLD, Color.BLACK));
                        cell2 = new PdfPCell(new Phrase(chk));
                        cell2.setBorder(Rectangle.BOTTOM);
                        cell2.setCellEvent(border);
                        cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                        chargeCountry2.addCell(cell2);
                        //added by silpa.p on 23-06-11 for currency add
                        chk = new Chunk("", FontFactory.getFont("Courier-Bold ", 8, Font.BOLD, Color.BLACK));
                        cell2 = new PdfPCell(new Phrase(chk));
                        cell2.setBorder(Rectangle.BOTTOM);
                        cell2.setCellEvent(border);
                        cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                        chargeCountry2.addCell(cell2);//ended

                        if ("Add".equalsIgnoreCase(request.getParameter("Operation"))
                                || "Modify".equalsIgnoreCase(request.getParameter("Operation"))
                                || "Copy".equalsIgnoreCase(request.getParameter("Operation"))) {
                            for (int brk1 = 0; brk1 < tmpBrkptsize; brk1++) {

                                if (tmpmultiBrkpt.split(",")[brk1] != null
                                        && tmpmultiBrkpt.split(",")[brk1].toUpperCase().endsWith("MIN")) {
                                    if (tmpmultiBrkpt.split(",")[brk1].length() > 7)
                                        breakpt = "MIN" + "\n" + tmpmultiBrkpt.split(",")[brk1].substring(0, 3);
                                    //breakpt = "MIN";
                                    else
                                        breakpt = "MIN";
                                } else if (tmpmultiBrkpt.split(",")[brk1] != null
                                        && tmpmultiBrkpt.split(",")[brk1].toUpperCase().endsWith("BASIC")) {

                                    if (tmpmultiBrkpt.split(",")[brk1].length() > 7)
                                        breakpt = "BASIC" + "\n"
                                                + tmpmultiBrkpt.split(",")[brk1].substring(0, 3);
                                    //breakpt = "BASIC";
                                    else
                                        breakpt = "BASIC";
                                } else if (tmpmultiBrkpt.split(",")[brk1] != null
                                        && tmpmultiBrkpt.split(",")[brk1].toUpperCase().endsWith("FLAT")) {

                                    if (tmpmultiBrkpt.split(",")[brk1].length() > 7)
                                        breakpt = "FLAT" + "\n"
                                                + tmpmultiBrkpt.split(",")[brk1].substring(0, 3);
                                    //breakpt ="FLAT";
                                    else
                                        breakpt = "FLAT";
                                } else if (tmpmultiBrkpt.split(",")[brk1] != null
                                        && tmpmultiBrkpt.split(",")[brk1].toUpperCase().endsWith("ABSOLUTE")) {

                                    if (tmpmultiBrkpt.split(",")[brk1].length() > 10)
                                        breakpt = "ABSOLUTE" + "\n"
                                                + tmpmultiBrkpt.split(",")[brk1].substring(0, 3);
                                    //breakpt = "ABSOLUTE";
                                    else
                                        breakpt = "ABSOLUTE";
                                } else if (tmpmultiBrkpt.split(",")[brk1] != null
                                        && tmpmultiBrkpt.split(",")[brk1].toUpperCase().endsWith("PERCENT")) {

                                    if (tmpmultiBrkpt.split(",")[brk1].length() > 10)
                                        breakpt = "PERCENT" + "\n"
                                                + tmpmultiBrkpt.split(",")[brk1].substring(0, 3);
                                    //breakpt = "PERCENT";
                                    else
                                        breakpt = "PERCENT";
                                } else if (isInteger(tmpmultiBrkpt.split(",")[brk1])
                                        || isDouble(tmpmultiBrkpt.split(",")[brk1])) {
                                    breakpt = tmpmultiBrkpt.split(",")[brk1];
                                } else
                                    breakpt = tmpmultiBrkpt
                                            .split(",")[brk1] != null
                                                    ? (tmpmultiBrkpt.split(",")[brk1].length() > 5
                                                            ? tmpmultiBrkpt.split(",")[brk1].substring(0, 4)
                                                                    + "\n"
                                                                    + tmpmultiBrkpt.split(",")[brk1].substring(
                                                                            4,
                                                                            tmpmultiBrkpt.split(",")[brk1]
                                                                                    .length() - 2)
                                                            : tmpmultiBrkpt.split(",")[brk1])
                                                    : "";
                                basis = tmpBasis.split(",")[brk1] != null ? tmpBasis.split(",")[brk1] : "";

                                //chk = new Chunk(breakpt+"\n"+basis,FontFactory.getFont("Courier-Bold ", 8, Font.BOLD,Color.BLACK));
                                chk = new Chunk(basis,
                                        FontFactory.getFont("Courier-Bold ", 7, Font.NORMAL, Color.BLACK));
                                cell2 = new PdfPCell(new Phrase(chk));
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);
                            }

                        } else {
                            for (int t = 0; t < tmpBrkptsize; t++) {
                                if (viewDOB.getMultiBreakPoints()[t].toUpperCase().endsWith("MIN")) {
                                    if (viewDOB.getMultiBreakPoints()[t].length() > 7)
                                        breakpt = "MIN" + "\n"
                                                + viewDOB.getMultiBreakPoints()[t].substring(0, 3);
                                    //breakpt= "MIN";
                                    else
                                        breakpt = "MIN";
                                } else if (viewDOB.getMultiBreakPoints()[t].toUpperCase().endsWith("BASIC")) {
                                    if (viewDOB.getMultiBreakPoints()[t].length() > 7)
                                        breakpt = "BASIC" + "\n"
                                                + viewDOB.getMultiBreakPoints()[t].substring(0, 3);
                                    //breakpt= "BASIC";
                                    else
                                        breakpt = "BASIC";
                                } else if (viewDOB.getMultiBreakPoints()[t].toUpperCase().endsWith("FLAT")) {
                                    if (viewDOB.getMultiBreakPoints()[t].length() > 7)
                                        breakpt = "FLAT" + "\n"
                                                + viewDOB.getMultiBreakPoints()[t].substring(0, 3);
                                    //breakpt= "FLAT";

                                    else
                                        breakpt = "FLAT";
                                } else if (viewDOB.getMultiBreakPoints()[t].toUpperCase()
                                        .endsWith("ABSOLUTE")) {
                                    if (viewDOB.getMultiBreakPoints()[t].length() > 10)
                                        breakpt = "ABSOLUTE" + "\n"
                                                + viewDOB.getMultiBreakPoints()[t].substring(0, 3);
                                    //breakpt= "ABSOLUTE";
                                    else
                                        breakpt = "ABSOLUTE";
                                } else if (viewDOB.getMultiBreakPoints()[t].toUpperCase().endsWith("PERCENT")) {
                                    if (viewDOB.getMultiBreakPoints()[t].length() > 7)
                                        breakpt = "PERCENT" + "\n"
                                                + viewDOB.getMultiBreakPoints()[t].substring(0, 3);
                                    //breakpt= "PERCENT";
                                    else
                                        breakpt = "PERCENT";
                                } else
                                    breakpt = viewDOB.getMultiBreakPoints()[t] != null
                                            ? (viewDOB.getMultiBreakPoints()[t].length() > 5
                                                    ? viewDOB.getMultiBreakPoints()[t].substring(0, 4) + "\n"
                                                            + viewDOB.getMultiBreakPoints()[t].substring(4,
                                                                    viewDOB.getMultiBreakPoints()[t].length()
                                                                            - 2)
                                                    : viewDOB.getMultiBreakPoints()[t])
                                            : "";

                                //chk = new Chunk(breakpt+"\n"+viewDOB.getBasis().split(",")[t],FontFactory.getFont("Courier-Bold ", 8, Font.BOLD,Color.BLACK));
                                chk = new Chunk(viewDOB.getBasis().split(",")[t],
                                        FontFactory.getFont("Courier-Bold ", 7, Font.NORMAL, Color.BLACK));
                                cell2 = new PdfPCell(new Phrase(chk));
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);

                            }
                        }
                        chk = new Chunk("", FontFactory.getFont("Courier-Bold ", 7, Font.BOLD, Color.BLACK));
                        cell2 = new PdfPCell(new Phrase(chk));
                        cell2.setBorder(Rectangle.BOTTOM);
                        cell2.setCellEvent(border);
                        cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                        chargeCountry2.addCell(cell2);

                    } //ended
                    if ("View".equalsIgnoreCase(request.getParameter("Operation")))
                        freightChargesSize = chargesInfolist.size();
                    for (int j = 0; j < freightChargesSize; j++) {
                        if ("View".equalsIgnoreCase(request.getParameter("Operation"))) {
                            multiQuoteChargeInfo = (MultiQuoteChargeInfo) chargesInfolist.get(j);
                            // multiQuoteChargeInfo         = (MultiQuoteChargeInfo)freightCharges.get(j);
                        } else
                            multiQuoteChargeInfo = (MultiQuoteChargeInfo) freightCharges.get(j);
                        logger.info("Freight Charges doPDFGeneration::" + j + ":" + chargesDOB); // newly added

                        home = (QMSMultiQuoteSessionHome) LookUpBean.getEJBHome("QMSMultiQuoteSessionBean");
                        remote = home.create();
                        //orgDesc = remote.getLocationName(multiQuoteChargeInfo.getOrginLoc());//Commented by silpa.p on 5-07-11
                        orgDesc = multiQuoteChargeInfo.getOrginLoc();//modified by silpa.p on 5-07-11
                        chk = new Chunk(orgDesc != null ? orgDesc : "",
                                FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
                        cell2 = new PdfPCell(new Phrase(chk));
                        cell2.setBorder(Rectangle.BOTTOM);
                        cell2.setCellEvent(border);
                        cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                        chargeCountry2.addCell(cell2);

                        //destDesc = remote.getLocationName(multiQuoteChargeInfo.getDestLoc());//commented by silpa.p on 5-07-11
                        destDesc = multiQuoteChargeInfo.getDestLoc();//modified by silpa.p on 5-07-11

                        chk = new Chunk(destDesc != null ? destDesc : "",
                                FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
                        cell2 = new PdfPCell(new Phrase(chk));
                        cell2.setBorder(Rectangle.BOTTOM);
                        cell2.setCellEvent(border);
                        cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                        chargeCountry2.addCell(cell2);

                        // tmpCarrier1 = multiQuoteChargeInfo.getCarrier(); Commented by Gowtham
                        /* if("View".equalsIgnoreCase(request.getParameter("Operation"))&& ("C".equalsIgnoreCase(CarrierChecked)))
                        {     
                        chk = new Chunk(multiQuoteChargeInfo.getCarrier()!=null?multiQuoteChargeInfo.getCarrier():"",FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                        cell = new PdfPCell(new Phrase(chk));
                          cell.setBorder(Rectangle.BOTTOM);
                        cell.setCellEvent(border); 
                        cell.setHorizontalAlignment(cell.ALIGN_CENTER);
                        chargeCountry.addCell(cell);
                                
                        }
                        else
                        {
                           if("C".equalsIgnoreCase(CarrierChecked)){
                           chk = new Chunk(multiQuoteChargeInfo.getCarrierName()!=null?multiQuoteChargeInfo.getCarrierName():"",FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                           cell = new PdfPCell(new Phrase(chk));
                             cell.setBorder(Rectangle.BOTTOM);
                           cell.setCellEvent(border); 
                           cell.setHorizontalAlignment(cell.ALIGN_CENTER);
                           chargeCountry.addCell(cell);
                           }
                        }*/ //carrierDesc = remote.getServiceLevelName(multiQuoteChargeInfo.getServiceLevel());
                        //@@Added by kiran.v on 01/08/2011 for Wpbn Issue 258778
                        carrierDesc = multiQuoteChargeInfo.getCarrier();
                        Cd.add(carrierDesc);
                        String carrierName = remote.getCarrierName(multiQuoteChargeInfo.getCarrier());
                        Cdn.add(carrierName);
                        //@@Added by kiran.v on 23/09/2011 for Wpbn Issue 272712
                        String time = multiQuoteChargeInfo.getTransitTime();
                        //Cdn.add(multiQuoteChargeInfo.getCarrierName());
                        // carrierDesc = remote.getCarrierName(multiQuoteChargeInfo.getCarrier());//added by silpa.p on 16-05-11
                        if ("View".equalsIgnoreCase(request.getParameter("Operation")))
                            //chk = new Chunk(multiQuoteChargeInfo.getCarrierName()!=null?multiQuoteChargeInfo.getCarrierName():"",FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                            chk = new Chunk(carrierDesc != null ? carrierDesc : "",
                                    FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));//modified by silpa.p on 16-05-11
                        //@@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)) {//added by silpa.p on 14-05-11                            
                                // chk = new Chunk(multiQuoteChargeInfo.getCarrier()!=null?multiQuoteChargeInfo.getCarrier():"",FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                                chk = new Chunk(carrierDesc != null ? carrierDesc : "",
                                        FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
                                cell2 = new PdfPCell(new Phrase(chk));
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);
                            } //ended
                            //@@Added by kiran.v on 01/08/2011 for Wpbn Issue 258778
                            serviceLevelDesc = multiQuoteChargeInfo.getServiceLevel();

                            Sd.add(serviceLevelDesc);
                            // serviceLevelDesc = remote.getServiceLevelName(multiQuoteChargeInfo.getServiceLevel());//added by silpa.p on 16-05-11
                            //tmpServl1=multiQuoteChargeInfo.getServiceLevel(); Commented by Gowtham
                            if ("checked".equalsIgnoreCase(serviceLevelChecked)) {//added by silpa.p on 14-05-11
                                //chk = new Chunk(multiQuoteChargeInfo.getServiceLevel()!=null?multiQuoteChargeInfo.getServiceLevel():"",FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                                chk = new Chunk(serviceLevelDesc != null ? serviceLevelDesc : "",
                                        FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));//modified by silpa.p on 16-05-11
                                cell2 = new PdfPCell(new Phrase(chk));
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);
                            }
                            if ("checked".equalsIgnoreCase(frequencyChecked)) {//added by silpa.p on 16-05-11
                                tmpFrCnt = multiQuoteChargeInfo.getFrequency() != null
                                        ? multiQuoteChargeInfo.getFrequency().split(",").length
                                        : 0;
                                if (tmpFrCnt > 1) {
                                    for (int tmpFc = 0; tmpFc < tmpFrCnt; tmpFc++) {
                                        if ("1".equals(multiQuoteChargeInfo.getFrequency().split(",")[tmpFc]))
                                            tmpFreq = "Mon";
                                        else if ("2"
                                                .equals(multiQuoteChargeInfo.getFrequency().split(",")[tmpFc]))
                                            tmpFreq = "Tue";
                                        else if ("3"
                                                .equals(multiQuoteChargeInfo.getFrequency().split(",")[tmpFc]))
                                            tmpFreq = "Wed";
                                        else if ("4"
                                                .equals(multiQuoteChargeInfo.getFrequency().split(",")[tmpFc]))
                                            tmpFreq = "Thr";
                                        else if ("5"
                                                .equals(multiQuoteChargeInfo.getFrequency().split(",")[tmpFc]))
                                            tmpFreq = "Fri";
                                        else if ("6"
                                                .equals(multiQuoteChargeInfo.getFrequency().split(",")[tmpFc]))
                                            tmpFreq = "Sat";
                                        else if ("7"
                                                .equals(multiQuoteChargeInfo.getFrequency().split(",")[tmpFc]))
                                            tmpFreq = "Sun";
                                        if (tmpFc == tmpFrCnt - 1)
                                            tmpFreq1 = tmpFreq1 + tmpFreq;
                                        else
                                            tmpFreq1 = tmpFreq1 + tmpFreq + ",";
                                    }
                                } else if (multiQuoteChargeInfo.getFrequency() != null
                                        && isInteger(multiQuoteChargeInfo.getFrequency())) {
                                    if ("1".equals(multiQuoteChargeInfo.getFrequency()))
                                        tmpFreq1 = "Mon";
                                    else if ("2".equals(multiQuoteChargeInfo.getFrequency()))
                                        tmpFreq1 = "Tue";
                                    else if ("3".equals(multiQuoteChargeInfo.getFrequency()))
                                        tmpFreq1 = "Wed";
                                    else if ("4".equals(multiQuoteChargeInfo.getFrequency()))
                                        tmpFreq1 = "Thr";
                                    else if ("5".equals(multiQuoteChargeInfo.getFrequency()))
                                        tmpFreq1 = "Fri";
                                    else if ("6".equals(multiQuoteChargeInfo.getFrequency()))
                                        tmpFreq1 = "Sat";
                                    else if ("7".equals(multiQuoteChargeInfo.getFrequency()))
                                        tmpFreq1 = "Sun";
                                } else
                                    tmpFreq1 = multiQuoteChargeInfo.getFrequency() != null
                                            ? multiQuoteChargeInfo.getFrequency()
                                            : "";

                                chk = new Chunk(tmpFreq1 != null ? tmpFreq1 : "",
                                        FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
                                cell2 = new PdfPCell(new Phrase(chk));
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);
                            }
                            //@@Added by kiran.v on 23/09/2011 for Wpbn Issue 272712
                            String time1 = multiQuoteChargeInfo.getTransitTime();
                            String validity = multiQuoteChargeInfo.getRateValidity();
                            if ("checked".equalsIgnoreCase(transitTimeChecked)) {
                                //chk = new Chunk(multiQuoteChargeInfo.getServiceLevel()!=null?multiQuoteChargeInfo.getServiceLevel():"",FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                                chk = new Chunk(time1 != null ? time1 : "",
                                        FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
                                cell2 = new PdfPCell(new Phrase(chk));
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);
                            }
                            if ("checked".equalsIgnoreCase(validityChecked)) {
                                //chk = new Chunk(multiQuoteChargeInfo.getServiceLevel()!=null?multiQuoteChargeInfo.getServiceLevel():"",FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                                chk = new Chunk(validity != null ? validity : "",
                                        FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
                                cell2 = new PdfPCell(new Phrase(chk));
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);
                            }
                        } else {
                            if ("checked".equalsIgnoreCase(carrierChecked)
                                    || "Y".equalsIgnoreCase(multiQuoteChargeInfo.getCarrierChecked())
                                    || "on".equalsIgnoreCase(multiQuoteChargeInfo.getCarrierChecked())
                                    || carrierFlag) {//added by silpa.p on 14-05-11                            
                                // chk = new Chunk(multiQuoteChargeInfo.getCarrier()!=null?multiQuoteChargeInfo.getCarrier():"",FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                                chk = new Chunk(carrierDesc != null ? carrierDesc : "",
                                        FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
                                cell2 = new PdfPCell(new Phrase(chk));
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);
                            } //ended
                              //@@Added by kiran.v on 01/08/2011 for Wpbn Issue 258778
                            serviceLevelDesc = multiQuoteChargeInfo.getServiceLevel();

                            Sd.add(serviceLevelDesc);
                            // serviceLevelDesc = remote.getServiceLevelName(multiQuoteChargeInfo.getServiceLevel());//added by silpa.p on 16-05-11
                            //tmpServl1=multiQuoteChargeInfo.getServiceLevel(); Commented by Gowtham                     
                            if ("checked".equalsIgnoreCase(serviceLevelChecked)
                                    || "Y".equalsIgnoreCase(multiQuoteChargeInfo.getServiceChecked())
                                    || "on".equalsIgnoreCase(multiQuoteChargeInfo.getServiceChecked())
                                    || serviceflag) {//added by silpa.p on 14-05-11
                                //chk = new Chunk(multiQuoteChargeInfo.getServiceLevel()!=null?multiQuoteChargeInfo.getServiceLevel():"",FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                                chk = new Chunk(serviceLevelDesc != null ? serviceLevelDesc : "",
                                        FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));//modified by silpa.p on 16-05-11
                                cell2 = new PdfPCell(new Phrase(chk));
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);
                            }
                            if ("checked".equalsIgnoreCase(frequencyChecked)
                                    || "Y".equalsIgnoreCase(multiQuoteChargeInfo.getFrequencyChecked())
                                    || "on".equalsIgnoreCase(multiQuoteChargeInfo.getFrequencyChecked())
                                    || frequencyflag) {//added by silpa.p on 16-05-11
                                tmpFrCnt = multiQuoteChargeInfo.getFrequency() != null
                                        ? multiQuoteChargeInfo.getFrequency().split(",").length
                                        : 0;
                                if (tmpFrCnt > 1) {
                                    for (int tmpFc = 0; tmpFc < tmpFrCnt; tmpFc++) {
                                        if ("1".equals(multiQuoteChargeInfo.getFrequency().split(",")[tmpFc]))
                                            tmpFreq = "Mon";
                                        else if ("2"
                                                .equals(multiQuoteChargeInfo.getFrequency().split(",")[tmpFc]))
                                            tmpFreq = "Tue";
                                        else if ("3"
                                                .equals(multiQuoteChargeInfo.getFrequency().split(",")[tmpFc]))
                                            tmpFreq = "Wed";
                                        else if ("4"
                                                .equals(multiQuoteChargeInfo.getFrequency().split(",")[tmpFc]))
                                            tmpFreq = "Thr";
                                        else if ("5"
                                                .equals(multiQuoteChargeInfo.getFrequency().split(",")[tmpFc]))
                                            tmpFreq = "Fri";
                                        else if ("6"
                                                .equals(multiQuoteChargeInfo.getFrequency().split(",")[tmpFc]))
                                            tmpFreq = "Sat";
                                        else if ("7"
                                                .equals(multiQuoteChargeInfo.getFrequency().split(",")[tmpFc]))
                                            tmpFreq = "Sun";
                                        if (tmpFc == tmpFrCnt - 1)
                                            tmpFreq1 = tmpFreq1 + tmpFreq;
                                        else
                                            tmpFreq1 = tmpFreq1 + tmpFreq + ",";
                                    }
                                } else if (multiQuoteChargeInfo.getFrequency() != null
                                        && isInteger(multiQuoteChargeInfo.getFrequency())) {
                                    if ("1".equals(multiQuoteChargeInfo.getFrequency()))
                                        tmpFreq1 = "Mon";
                                    else if ("2".equals(multiQuoteChargeInfo.getFrequency()))
                                        tmpFreq1 = "Tue";
                                    else if ("3".equals(multiQuoteChargeInfo.getFrequency()))
                                        tmpFreq1 = "Wed";
                                    else if ("4".equals(multiQuoteChargeInfo.getFrequency()))
                                        tmpFreq1 = "Thr";
                                    else if ("5".equals(multiQuoteChargeInfo.getFrequency()))
                                        tmpFreq1 = "Fri";
                                    else if ("6".equals(multiQuoteChargeInfo.getFrequency()))
                                        tmpFreq1 = "Sat";
                                    else if ("7".equals(multiQuoteChargeInfo.getFrequency()))
                                        tmpFreq1 = "Sun";
                                } else
                                    tmpFreq1 = multiQuoteChargeInfo.getFrequency() != null
                                            ? multiQuoteChargeInfo.getFrequency()
                                            : "";

                                chk = new Chunk(tmpFreq1 != null ? tmpFreq1 : "",
                                        FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
                                cell2 = new PdfPCell(new Phrase(chk));
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);
                            }
                            //@@Added by kiran.v on 23/09/2011 for Wpbn Issue 272712
                            String time1 = multiQuoteChargeInfo.getTransitTime();
                            if ("checked".equalsIgnoreCase(transitTimeChecked)
                                    || "Y".equalsIgnoreCase(multiQuoteChargeInfo.getTransitTimeChecked())
                                    || "on".equalsIgnoreCase(multiQuoteChargeInfo.getTransitTimeChecked())
                                    || transittimeflag) {
                                //chk = new Chunk(multiQuoteChargeInfo.getServiceLevel()!=null?multiQuoteChargeInfo.getServiceLevel():"",FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                                chk = new Chunk(time1 != null ? time1 : "",
                                        FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
                                cell2 = new PdfPCell(new Phrase(chk));
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);
                            }
                            String validity = multiQuoteChargeInfo.getRateValidity();

                            if ("checked".equalsIgnoreCase(validityChecked)
                                    || "Y".equalsIgnoreCase(multiQuoteChargeInfo.getRateValidityChecked())
                                    || "on".equalsIgnoreCase(multiQuoteChargeInfo.getRateValidityChecked())
                                    || freightValidity) {
                                //chk = new Chunk(multiQuoteChargeInfo.getServiceLevel()!=null?multiQuoteChargeInfo.getServiceLevel():"",FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));
                                chk = new Chunk(validity != null ? validity : "",
                                        FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
                                cell2 = new PdfPCell(new Phrase(chk));
                                cell2.setBorder(Rectangle.BOTTOM);
                                cell2.setCellEvent(border);
                                cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry2.addCell(cell2);
                            }
                        }
                        //@@Ended by kiran.v
                        chk = new Chunk((multiQuoteChargeInfo.getIncoTerms() != null
                                ? multiQuoteChargeInfo.getIncoTerms()
                                : ""), FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
                        cell2 = new PdfPCell(new Phrase(chk));
                        cell2.setBorder(Rectangle.BOTTOM);
                        cell2.setCellEvent(border);
                        cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                        chargeCountry2.addCell(cell2);
                        //added by silpa.p on 23-06-11 for currency add
                        if ("View".equalsIgnoreCase(request.getParameter("Operation"))) {
                            chk = new Chunk((multiQuoteChargeInfo.getCurrency() != null
                                    ? multiQuoteChargeInfo.getCurrency()
                                    : ""), FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
                        } else {
                            chk = new Chunk((multiQuoteChargeInfo.getCurrency() != null
                                    ? multiQuoteChargeInfo.getCurrency()
                                    : ""), FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
                        }
                        cell2 = new PdfPCell(new Phrase(chk));
                        cell2.setBorder(Rectangle.BOTTOM);
                        cell2.setCellEvent(border);
                        cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                        chargeCountry2.addCell(cell2);//ended

                        for (int trc = 0; trc < tmpBrkptsize; trc++) {
                            if ("View".equalsIgnoreCase(request.getParameter("Operation"))) {
                                rates1 = Double.parseDouble(multiQuoteChargeInfo.getMultiBuyRates()[trc]);
                                rates = ("0.00".equals(rates1.toString()) || "0".equals(rates1.toString()))
                                        ? "-"
                                        : rates1.toString();
                            } else
                                rates = multiQuoteChargeInfo.getMultiCalSellRates()[tmpBrksize[trc]] != null
                                        ? ("0.00".equals(
                                                multiQuoteChargeInfo.getMultiCalSellRates()[tmpBrksize[trc]])
                                                || ("0".equals(multiQuoteChargeInfo
                                                        .getMultiCalSellRates()[tmpBrksize[trc]]))
                                                                ? "-"
                                                                : multiQuoteChargeInfo
                                                                        .getMultiCalSellRates()[tmpBrksize[trc]])
                                        : "0.00";//modified by silpa.p on 3-06-11

                            chk = new Chunk(rates, FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
                            cell2 = new PdfPCell(new Phrase(chk));
                            cell2.setBorder(Rectangle.BOTTOM);
                            cell2.setCellEvent(border);
                            cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                            chargeCountry2.addCell(cell2);
                        }

                        chk = new Chunk(
                                multiQuoteChargeInfo.getRatio() != null ? "1:" + multiQuoteChargeInfo.getRatio()
                                        : "",
                                FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
                        cell2 = new PdfPCell(new Phrase(chk));
                        cell2.setBorder(Rectangle.BOTTOM);
                        cell2.setCellEvent(border);
                        cell2.setHorizontalAlignment(cell.ALIGN_CENTER);
                        chargeCountry2.addCell(cell2);

                        tmpFreq1 = "";
                    }
                    //02Mar11
                }

                document.add(chargeCountry2);

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

        } // Added by Gowtham. to skip in case of quote with charges.

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

        document.add(pTable);

        ArrayList destChargeInfo = null;
        //Destination
        MultiQuoteChargeInfo chargeInfo1 = null;
        ArrayList destLaneCharges = finalDOB.getLegDetails();//.get(0)).getOriginChargesList();

        for (int dc = 0; dc < noOfLanes; dc++) {
            legDestCharges = (MultiQuoteFreightLegSellRates) destLaneCharges.get(dc);
            ArrayList destCharges = legDestCharges.getDestChargesList();
            int[] destIndices = legDestCharges.getSelctedDestChargesListIndices();
            int destChargesSize = 0;
            String breakPoint = "";
            if (destIndices != null)
                destChargesSize = destIndices.length;
            else
                destChargesSize = 0;

            int destChargesInfoSize = 0;
            if (destChargesSize > 0) { //document.newPage();  
                //document.add(horizontalLine);
                chargeTitle = new Table(1);
                chargeTitle.setWidth(100);
                chargeTitle.setPadding(1);
                chargeTitle.setSpacing(1);
                chargeTitle.setBorderColor(Color.BLACK);
                chargeTitle.setDefaultHorizontalAlignment(Element.ALIGN_LEFT);
                chargeTitle.setBackgroundColor(Color.ORANGE);//modified by silpa.p on 3-06-11
                chargeTitle.setBorderWidth(1f);

                home = (QMSMultiQuoteSessionHome) LookUpBean.getEJBHome("QMSMultiQuoteSessionBean");
                remote = home.create();
                if (legOrginCharges.getShipmentMode() == 2
                        && !"Charges".equalsIgnoreCase(masterDOB.getQuoteWith()))//added by silpa.p on 16-06-11
                {
                    chk = new Chunk(
                            (legDestCharges.getDestination() != null
                                    ? remote.getPortName(legDestCharges.getDestination())
                                    : "") + "-Destination Charges",
                            FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK)); // Added by Gowtham on 01-Feb-2011.   
                } else
                    chk = new Chunk(
                            (legDestCharges.getDestination() != null
                                    ? remote.getLocationName(legDestCharges.getDestination())
                                    : "") + "-Destination Charges",
                            FontFactory.getFont("ARIAL", 8, Font.BOLD, Color.BLACK));// Added by Gowtham on 01-Feb-2011.
                cell1 = new Cell(chk);

                cell1.setLeading(10.0f);
                cell1.setBackgroundColor(Color.WHITE);
                cell1.setHeader(true);
                cell1.setBorder(0);
                cell1.setBackgroundColor(Color.ORANGE);//modified by silpa.p on 3-06-11
                chargeTitle.addCell(cell1);
                //document.newPage();
                document.add(chargeTitle);

                //document.add(horizontalLine);

                /* chargeCountry1  = new Table(6);
                 chargeCountry1.setWidth(100);
                 chargeCountry1.setWidths(cellWidths);
                 chargeCountry1.setPadding(1);
                 chargeCountry1.setSpacing(0);
                 chargeCountry1.setOffset(5);
                 chargeCountry1.setBackgroundColor(Color.WHITE);
                 chargeCountry1.setBorderColor(Color.WHITE);
                 chargeCountry1.setDefaultHorizontalAlignment(Element.ALIGN_CENTER);
                 chargeCountry1.setBorderWidth(1f);
                 chargeCountry1.setTableFitsPage(true);*/

                chargeTitle.setWidth(100);
                chargeTitle.setBorderWidth(1f);

                chargeCountry = new Table(6);
                chargeCountry.setWidths(cellWidths);
                //chargeCountry.setWidthPercentage(100);
                chargeCountry.setPadding(3);
                chargeCountry.setSpacing(0);
                chargeCountry.setWidths(cellWidths);
                chargeCountry.setBorder(1);
                chargeCountry.setWidth(100);
                chargeCountry.setBorderWidth(1f);
                /* home        = (QMSMultiQuoteSessionHome)LookUpBean.getEJBHome("QMSMultiQuoteSessionBean");//146460
                remote      = home.create();
                 if(legOrginCharges.getShipmentMode()==2)
                 {       
                 chk = new Chunk((legDestCharges.getDestination()!=null?remote.getPortName(legDestCharges.getDestination()):"")+"-Destination Charges",FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK)); // Added by Gowtham on 01-Feb-2011.   
                 }
                 else
                chk = new Chunk((legDestCharges.getDestination()!=null ? remote.getLocationName(legDestCharges.getDestination()):"")+"-Destination Charges",FontFactory.getFont("ARIAL", 8, Font.NORMAL,Color.BLACK));// Added by Gowtham on 01-Feb-2011.
                cell = new Cell(chk);
                        
                cell.setLeading(10.0f);
                cell.setBackgroundColor(Color.ORANGE);                
                cell.setHeader(true);
                chargeCountry.addCell(cell);*/
                chk = new Chunk("Charge Description", FontFactory.getFont("ARIAL", 7, Font.BOLD, Color.BLACK));
                cell = new Cell(new Phrase(chk));
                cell.setHorizontalAlignment(cell.ALIGN_LEFT);
                ////cell.setBorder(Rectangle.BOTTOM);
                cell.setBorderWidth(1);
                chargeCountry.addCell(cell);

                chk = new Chunk("Weight Break Slab", FontFactory.getFont("ARIAL", 7, Font.BOLD, Color.BLACK));
                cell = new Cell(new Phrase(chk));
                ////cell.setBorder(Rectangle.BOTTOM);
                cell.setBorderWidth(1);
                cell.setHorizontalAlignment(cell.ALIGN_CENTER);
                chargeCountry.addCell(cell);

                chk = new Chunk("Currency", FontFactory.getFont("ARIAL", 7, Font.BOLD, Color.BLACK));
                cell = new Cell(new Phrase(chk));
                ////cell.setBorder(Rectangle.BOTTOM);
                cell.setBorderWidth(1);
                cell.setHorizontalAlignment(cell.ALIGN_CENTER);
                chargeCountry.addCell(cell);

                chk = new Chunk("Charge Rate", FontFactory.getFont("ARIAL", 7, Font.BOLD, Color.BLACK));
                cell = new Cell(new Phrase(chk));
                ////cell.setBorder(Rectangle.BOTTOM);
                cell.setBorderWidth(1);
                cell.setHorizontalAlignment(cell.ALIGN_CENTER);
                chargeCountry.addCell(cell);

                chk = new Chunk("Basis", FontFactory.getFont("ARIAL", 7, Font.BOLD, Color.BLACK));
                cell = new Cell(new Phrase(chk));
                ////cell.setBorder(Rectangle.BOTTOM);
                cell.setBorderWidth(1);
                cell.setHorizontalAlignment(cell.ALIGN_LEFT);
                chargeCountry.addCell(cell);

                chk = new Chunk("Density Ratio", FontFactory.getFont("ARIAL", 7, Font.BOLD, Color.BLACK));
                cell = new Cell(new Phrase(chk));
                ////cell.setBorder(Rectangle.BOTTOM);
                cell.setBorderWidth(1);
                cell.setHorizontalAlignment(cell.ALIGN_CENTER);
                chargeCountry.addCell(cell);

                for (int dcc = 0; dcc < destChargesSize; dcc++) {
                    if ((operation != null && operation.equals("View")) || ("Y"
                            .equalsIgnoreCase(legDestCharges.getDestChargesSelectedFlag()[destIndices[dcc]])))//modified by silpa.p on 21-06-11
                    {

                        chargesDOB = (MultiQuoteCharges) destCharges.get(destIndices[dcc]);

                        //  for(int j=0;j<destChargesSize;j++)
                        //{
                        if (destIndices[dcc] != -1) {
                            // chargesDOB            = (MultiQuoteCharges)destCharges.get(destIndices[j]);
                            logger.info("Destination Charges doPDFGeneration::" + dcc + ":" + chargesDOB); // newly added                      
                            destChargeInfo = chargesDOB.getChargeInfoList();
                            destChargesInfoSize = destChargeInfo.size();
                            for (int k = 0; k < destChargesInfoSize; k++) {
                                chargeInfo = (MultiQuoteChargeInfo) destChargeInfo.get(k);
                                // if(k==destChargesInfoSize/2 )
                                if (k == 0) {
                                    if ("B".equalsIgnoreCase(chargesDOB.getSellBuyFlag())
                                            || "S".equalsIgnoreCase(chargesDOB.getSellBuyFlag()))
                                        chk = new Chunk(
                                                chargesDOB.getExternalName() != null
                                                        ? chargesDOB.getExternalName()
                                                        : "",
                                                FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
                                    else
                                        chk = new Chunk(
                                                chargesDOB.getChargeDescriptionId() != null
                                                        ? chargesDOB.getChargeDescriptionId()
                                                        : "",
                                                FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));

                                    /*cell1 = new Cell(chk);
                                    cell1.setLeading(9.0f);
                                    //cell.setRowspan(destChargesInfoSize);
                                    //cell.setBorderWidth(0);
                                    //cell.setBackgroundColor(Color.lightGray);
                                    cell1.setBorder(0);
                                    cell1.setHeader(true);       
                                    cell1.setHorizontalAlignment(cell1.ALIGN_LEFT);
                                    chargeCountry1.addCell(cell1)*/;

                                    cell = new Cell(new Phrase(chk));
                                    cell.setLeading(7.0f);
                                    cell.setBorder(1);
                                    cell.setRowspan(destChargesInfoSize);
                                    cell.setBorderWidthTop(0);
                                    cell.setBorderWidthBottom(0.1f);
                                    cell.setHorizontalAlignment(cell.ALIGN_LEFT);
                                    cell.setVerticalAlignment(cell.ALIGN_LEFT);

                                    if (dcc == destChargesSize - 1 && k == destChargesInfoSize - 1) {
                                        cell.setBorderWidthBottom(0.1f);
                                        cell.setHorizontalAlignment(cell.ALIGN_LEFT);
                                    } else if (k == destChargesInfoSize - 1) {
                                        cell.setBorderWidthBottom(0.1f);
                                        cell.setHorizontalAlignment(cell.ALIGN_LEFT);

                                    } else {
                                        cell.setHorizontalAlignment(cell.ALIGN_LEFT);
                                    }
                                    // cell.setBorderWidthTop(0);
                                    // cell.setHorizontalAlignment(cell.ALIGN_CENTER);
                                    chargeCountry.addCell(cell);

                                }
                                /*else if (k==destChargesInfoSize-1) 
                                {
                                   cell = new Cell(new Phrase(new Chunk("")));
                                   ////cell.setBorder(Rectangle.BOTTOM);
                                 ////cell.setCellEvent(border); 
                                   if(dcc!=destChargesSize-1){
                                 cell.setBorder(0);
                                 cell.setBorderWidth(0f);
                                 cell.setLeading(7.0f);
                                   }
                                   else
                                {
                                    cell.setBorder(1);  
                                    cell.setBorderWidthTop(0);
                                    cell.setBorderWidthBottom(0.1f);
                                    cell.setLeading(7.0f);
                                            
                                   }
                                  cell.setHorizontalAlignment(cell.ALIGN_CENTER);
                                  chargeCountry.addCell(cell);
                                        
                                }
                                else
                                {
                                     cell = new Cell(new Phrase(new Chunk("")));
                                  ////cell.setBorder(0);
                                  ////cell.setCellEvent(border); 
                                  cell.setBorder(0);
                                     cell.setLeading(7.0f);
                                    cell.setBorderWidth(0f);                                
                                  cell.setHorizontalAlignment(cell.ALIGN_CENTER);
                                  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", 7, Font.NORMAL,Color.BLACK));

                                chk = new Chunk(breakPoint != null ? breakPoint : "",
                                        FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));//added by silpa.p on 16-06-11
                                /*cell1 = new Cell(chk);cell1.setLeading(8.0f);
                                // cell.setBackgroundColor(Color.lightGray);
                                cell1.setHeader(true);
                                cell1.setBorder(0);
                                  chargeCountry1.addCell(cell1);*/

                                cell = new Cell(new Phrase(chk));
                                cell.setLeading(7.0f);
                                if (k == destChargesInfoSize - 1) {
                                    ////cell.setBorder(Rectangle.BOTTOM);
                                    ////cell.setCellEvent(border); 

                                } else {
                                    // //cell.setBorder(0);
                                }
                                cell.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry.addCell(cell);

                                //@@Ended by subrahmanyam for 146455 on 18/02/09   

                                chk = new Chunk(chargeInfo.getCurrency(),
                                        FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
                                cell = new Cell(new Phrase(chk));
                                cell.setLeading(7.0f);
                                if (k == destChargesInfoSize - 1) {
                                    ////cell.setBorder(Rectangle.BOTTOM);
                                    ////cell.setCellEvent(border); 

                                } else {
                                    ////cell.setBorder(0);
                                }
                                cell.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry.addCell(cell);

                                chk = new Chunk(
                                        df.format(chargeInfo.getSellRate())
                                                + (chargeInfo.isPercentValue() ? " %" : ""),
                                        FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
                                cell = new Cell(new Phrase(chk));
                                cell.setLeading(7.0f);
                                if (k == destChargesInfoSize - 1) {
                                    ////cell.setBorder(Rectangle.BOTTOM);
                                    // //cell.setCellEvent(border); 

                                } else {
                                    ////cell.setBorder(0);
                                }
                                cell.setHorizontalAlignment(cell.ALIGN_CENTER);
                                chargeCountry.addCell(cell);

                                chk = new Chunk(chargeInfo.getBasis() != null ? chargeInfo.getBasis() : "",
                                        FontFactory.getFont("ARIAL", 7, Font.NORMAL, Color.BLACK));
                                cell = new Cell(new Phrase(chk));
                                cell.setLeading(7.0f);
                                if (k == destChargesInfoSize - 1) {
                                    ////cell.setBorder(Rectangle.BOTTOM);
                                    ////cell.setCellEvent(border); 

                                } else {
                                    //cell.setBorder(0);
                                }
                                cell.setHorizontalAlignment(cell1.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", 7, Font.NORMAL, Color.BLACK));
                                cell = new Cell(new Phrase(chk));
                                cell.setLeading(7.0f);
                                if (k == destChargesInfoSize - 1) {
                                    ////cell.setBorder(Rectangle.BOTTOM);
                                    //  //cell.setCellEvent(border); 

                                } else {
                                    //cell.setBorder(0);
                                }
                                cell.setHorizontalAlignment(cell1.ALIGN_CENTER);
                                chargeCountry.addCell(cell);
                            }
                        }
                        //}
                    }
                }
                document.add(chargeCountry);
                pTable = new PdfPTable(1);
                pTable.setSpacingAfter(10f);
                pCell = new PdfPCell(new Phrase(new Chunk("")));
                pCell.setBorder(0);
                pTable.addCell(pCell);

                document.add(pTable);
            }

        }
        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(1);
            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", 8, Font.BOLD, Color.BLACK));
            notesCell = new Cell(chk);
            notesCell.setHeader(true);
            notesCell.setLeading(8.0f);
            notesCell.setBackgroundColor(Color.ORANGE);//MODIFIED BY SILPA.P ON 3-06-11
            notes.addCell(notesCell);
            for (int i = 0; i < finalDOB.getExternalNotes().length; i++) {
                if (finalDOB.getExternalNotes()[i] != null
                        && !"".equals(finalDOB.getExternalNotes()[i].trim())) {
                    chk = new Chunk(
                            finalDOB.getExternalNotes()[i] != null ? finalDOB.getExternalNotes()[i] : "",
                            FontFactory.getFont("ARIAL", 7, 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));//modified by silpa.p on 2-06-11
                    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);
        }
        //@@Modified by kiran.v on 19/09/2011 for Wpbn Issue 271485
        if (!"Charges".equalsIgnoreCase(masterDOB.getQuoteWith())) {
            String filename = "Abbrivation.pdf";
            doPdfAbbrivations(filename, finalDOB, request, response, Sd, Cd, Cdn, frequencyFlag, carrierFlag,
                    serviceFlag, surChargesMap);
        }
        //@@Ended by kiran.v
        PdfContentByte cb1 = writer.getDirectContent();
        cb1.rectangle(document.left(), document.bottom(), document.right() - document.left(),
                document.top() - document.bottom());
        cb1.stroke();

        //Jyothi
        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);
            //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, 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" + file_tsmp + ".pdf");
        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() != null && finalDOB.getAttachmentDOBList().size() == 0
                && "View".equalsIgnoreCase(request.getParameter("Operation"))) {

            home = (QMSMultiQuoteSessionHome) LookUpBean.getEJBHome("QMSMultiQuoteSessionBean");//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        = (QMSMultiQuoteSessionHome)LookUpBean.getEJBHome("QMSMultiQuoteSessionBean");   
                 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 = (MultiQuoteAttachmentDOB)filesList.get(i);
              FileOutputStream  fileStream= new FileOutputStream(attachmentDOB.getFileName());
              fileStream.write(attachmentDOB.getPdfFile());
              pdfFilesList.add((String)attachmentDOB.getFileName());
        }
        }
             buffer = concatPDF(pdfFilesList);
        //@@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",buffer);
        }
        */
        //@@ Ended by subrahmanyam for the enhancement 146460
        //f.delete();
        //baos.close();

        String[] contactPersons = masterDOB.getCustContactNames();
        String contactName = "";
        int contactPersonsLength = 0;//added by silpa.p for sent mail modifications on 24-05-11
        boolean mailSent = false;//added by silpa.p for sent mail modifications  on 24-05-11

        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()[0].toUpperCase() : ""))
                .append(" to ")
                .append((headerDOB.getDestinationCountry()[0] != null
                        ? headerDOB.getDestinationCountry()[0].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"));

        doGenerateCartagePDF(filename, finalDOB, request, response);

        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 = (QMSMultiQuoteSessionHome) LookUpBean.getEJBHome("QMSMultiQuoteSessionBean");
                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 = (MultiQuoteAttachmentDOB) filesList.get(i);
                FileOutputStream fileStream = new FileOutputStream(attachmentDOB.getFileName());
                fileStream.write(attachmentDOB.getPdfFile());
                pdfFilesList.add((String) attachmentDOB.getFileName());
                fileStream.close();
            }
        }

        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); 

        //@@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);
        }

        for (int dc = 0; dc < noOfLanes; dc++) {
            legDestCharges = (MultiQuoteFreightLegSellRates) destLaneCharges.get(dc);

            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 ((legDestCharges.getPickZoneZipMap() != null
                                            && legDestCharges.getPickZoneZipMap().size() > 0)
                                            || (legDestCharges.getDeliveryZoneZipMap() != null
                                                    && legDestCharges.getDeliveryZoneZipMap().size() > 0)) {
                                        if (!mailSent || contactPersonsLength < contPersonLen) {//added by silpa.p for sent mail modifications  on 24-05-11
                                            sendMail(finalDOB.getMasterDOB().getUserEmailId(),
                                                    masterDOB.getCustomerContactsEmailIds()[i],
                                                    subject.toString(), body,
                                                    "Quote" + file_tsmp + ".pdf,Annexure" + file_tsmp + ".pdf",
                                                    finalDOB.getAttachmentDOBList());
                                            mailSent = true;
                                            contactPersonsLength++;
                                        } //ended
                                    }

                                    else if (!mailSent || contactPersonsLength < contPersonLen) {//added by silpa.p for sent mail modifications  on 24-05-11

                                        sendMail(finalDOB.getMasterDOB().getUserEmailId(),
                                                masterDOB.getCustomerContactsEmailIds()[i], subject.toString(),
                                                body, "Quote" + file_tsmp + ".pdf",
                                                finalDOB.getAttachmentDOBList());
                                        mailSent = true;
                                        contactPersonsLength++;
                                    } //ended

                                } else if (!mailSent || contactPersonsLength < contPersonLen) {//added by silpa.p for sent mail modifications  on 24-05-11
                                    sendMail(finalDOB.getMasterDOB().getUserEmailId(),
                                            masterDOB.getCustomerContactsEmailIds()[i], subject.toString(),
                                            body, "Quote" + file_tsmp + ".pdf",
                                            finalDOB.getAttachmentDOBList());
                                    mailSent = true;
                                    contactPersonsLength++;
                                } //ended
                                //  }
                                //@@Added by Kameswari for the WPBN issue-61289
                            }
                        }
                        if ("Y".equalsIgnoreCase(masterDOB.getSalesPersonFlag())) {
                            if (masterDOB.getShipperZipCode() == null
                                    || masterDOB.getConsigneeZipCode() == null) {
                                if ((legDestCharges.getPickZoneZipMap() != null
                                        && legDestCharges.getPickZoneZipMap().size() > 0)
                                        || (legDestCharges.getDeliveryZoneZipMap() != null
                                                && legDestCharges.getDeliveryZoneZipMap().size() > 0))
                                    if (!mailSent || contactPersonsLength < contPersonLen) {//added by silpa.p for sent mail modifications  on 24-05-11

                                        sendMail(finalDOB.getMasterDOB().getUserEmailId(),
                                                masterDOB.getSalesPersonEmail(), subject.toString(), body,
                                                "Quote" + file_tsmp + ".pdf,Annexure" + file_tsmp + ".pdf",
                                                finalDOB.getAttachmentDOBList());
                                        mailSent = true;
                                        contactPersonsLength++;
                                    } //ended
                                    else if (!mailSent || contactPersonsLength < contPersonLen) {//added by silpa.p for sent mail modifications on 24-05-11
                                        sendMail(finalDOB.getMasterDOB().getUserEmailId(),
                                                masterDOB.getSalesPersonEmail(), subject.toString(), body,
                                                "Quote" + file_tsmp + ".pdf", finalDOB.getAttachmentDOBList());
                                        mailSent = true;
                                        contactPersonsLength++;
                                    } //ended
                            } else if (!mailSent || contactPersonsLength < contPersonLen) {//added by silpa.p for sent mail modifications  on 24-05-11
                                sendMail(finalDOB.getMasterDOB().getUserEmailId(),
                                        masterDOB.getSalesPersonEmail(), subject.toString(), body,
                                        "Quote" + file_tsmp + ".pdf", finalDOB.getAttachmentDOBList());
                                mailSent = true;
                                contactPersonsLength++;
                            } //ended
                        }
                        //@@ 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 ((legDestCharges.getPickZoneZipMap() != null
                                    && legDestCharges.getPickZoneZipMap().size() > 0)
                                    || (legDestCharges.getDeliveryZoneZipMap() != null
                                            && legDestCharges.getDeliveryZoneZipMap().size() > 0))
                                if (!mailSent) {//added by silpa.p for sent mail modifications  on 24-05-11
                                    sendMail(finalDOB.getMasterDOB().getUserEmailId(), to_emailIds,
                                            subject.toString(), body,
                                            "Quote" + file_tsmp + ".pdf,Annexure" + file_tsmp + ".pdf",
                                            finalDOB.getAttachmentDOBList());
                                    mailSent = true;

                                } //ended
                                else if (!mailSent) {//added by silpa.p for sent mail modifications mail on 24-05-11
                                    sendMail(finalDOB.getMasterDOB().getUserEmailId(), to_emailIds,
                                            subject.toString(), body, "Quote" + file_tsmp + ".pdf",
                                            finalDOB.getAttachmentDOBList());
                                    mailSent = true;
                                } //ended
                        } else if (!mailSent) {//added by silpa.p for sent mail modifications mail on 24-05-11
                            sendMail(finalDOB.getMasterDOB().getUserEmailId(), to_emailIds, subject.toString(),
                                    body, "Quote" + file_tsmp + ".pdf", finalDOB.getAttachmentDOBList());
                            mailSent = true;
                        } //ended
                    }

                    //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 ((legDestCharges.getPickZoneZipMap() != null
                                            && legDestCharges.getPickZoneZipMap().size() > 0)
                                            || (legDestCharges.getDeliveryZoneZipMap() != null
                                                    && legDestCharges.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 ((legDestCharges.getPickZoneZipMap() != null
                                        && legDestCharges.getPickZoneZipMap().size() > 0)
                                        || (legDestCharges.getDeliveryZoneZipMap() != null
                                                && legDestCharges.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: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 2s.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:FirstPdf.java

private static void createTable(Section subCatPart) throws BadElementException {
    Table t = new Table(3, 2);
    t.setBorderColor(Color.GRAY);
    t.setPadding(4);/* w w  w.  j  a v a2s  .co m*/
    t.setSpacing(4);
    t.setBorderWidth(1);
    Cell c1 = new Cell("Table Header 1");
    c1.setHeader(true);
    t.addCell(c1);
    c1 = new Cell("Table Header 2");
    t.addCell(c1);
    c1 = new Cell("Table Header 3");
    t.addCell(c1);
    t.endHeaders();
    t.addCell("1.0");
    t.addCell("1.1");
    t.addCell("1.2");
    t.addCell("2.1");
    t.addCell("2.2");
    t.addCell("2.3");
    subCatPart.add(t);
}

From source file:com.sinkluge.reports.contracts.GenContractChecklist.java

public void create(Info in, Image toplogo) throws Exception {

    //adds the unchecked box
    Image checkbox = Image.getInstance(in.path + "/WEB-INF/images/unchecked.jpg");
    Chunk ch2 = new Chunk(checkbox, -10, -10);
    Phrase checkboxPhrase = new Phrase();
    checkboxPhrase.add(ch2);/*from   ww w .ja  v  a 2s . com*/
    int[] two = { 10, 90 };//sets the widths of the columns(2) with checkboxes

    //blank spacer for keeping tables apart
    Table spacer = new Table(1, 1);
    spacer.setBorderWidth(0);
    //spacer.setDefaultCellBorderWidth(0);
    spacer.setWidth(100);
    spacer.setPadding(0);
    spacer.setSpacing(0);
    Cell blank = new Cell();
    blank.add(new Chunk("", new Font(Font.TIMES_ROMAN, 1, Font.BOLD, new Color(255, 255, 255))));
    blank.setBorderWidth(0);
    blank.setLeading(0);
    spacer.addCell(blank);

    init();
    //document.setMargins(left, right, top, bottom);
    //add image
    Phrase p1 = new Phrase();
    int[] widths = { 60, 40 };
    Table table1 = new Table(2, 1);
    table1.setWidths(widths);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(2);
    table1.setSpacing(2);
    toplogo.scalePercent(20);
    //Chunk ch1=new Chunk(toplogo, -10, -80);
    Cell cell = new Cell(toplogo);
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    cell.setBorder(0);
    table1.addCell(cell);
    //just added image

    //add title on right side
    cell = new Cell();
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase("\n" + title + " Checklist", new Font(Font.TIMES_ROMAN, 18, Font.BOLD)));
    cell.add(new Phrase("\n" + currentDate, new Font(Font.TIMES_ROMAN, 16, Font.BOLD)));
    cell.setBorder(0);
    table1.addCell(cell);
    document.add(table1);

    document.add(spacer);
    document.add(spacer);
    document.add(spacer);
    document.add(spacer);
    document.add(spacer);

    //add "To:" and "Re:"
    table1 = new Table(1, 1);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(3);
    cell = new Cell();
    p1 = new Phrase("To:", new Font(Font.TIMES_ROMAN, 14, Font.BOLD));
    cell.setVerticalAlignment("middle");
    cell.add(p1);
    cell.add(new Phrase("\t\t" + companyName, new Font(Font.TIMES_ROMAN, 14, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);
    cell = new Cell();
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase("Re:", new Font(Font.TIMES_ROMAN, 14, Font.BOLD)));
    cell.add(new Phrase("\t\t" + jobName, new Font(Font.TIMES_ROMAN, 14, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);
    cell = new Cell();
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase("Enclosed:", new Font(Font.TIMES_ROMAN, 14, Font.BOLD)));
    cell.add(new Phrase("\t\t" + title + " Agreement", new Font(Font.TIMES_ROMAN, 14, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);
    document.add(table1);

    document.add(spacer);

    //add Instructions
    table1 = new Table(1, 1);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(3);
    cell = new Cell();
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase(
            "In order to finalize your agreement with " + shortName
                    + ", please complete all items as outlined below. "
                    + " It is essential to be finalized no later than ",
            new Font(Font.TIMES_ROMAN, 12, Font.NORMAL)));
    cell.add(new Phrase(agreementDate + ".  ", new Font(Font.TIMES_ROMAN, 12, Font.BOLDITALIC)));
    cell.setBorder(0);
    table1.addCell(cell);
    //p1 = new Phrase("Subcontractor Change Order Overview Report", new Font(Font.TIMES_ROMAN, 8, Font.BOLD));
    cell = new Cell();
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase(
            "A subcontract is considered finalized and ready to activate when all of the attached items outlined below "
                    + "are completed, signed, and returned to " + shortName
                    + ". Do not make any changes directly to the contract documents."
                    + " Any alterations or amendments must be negotiated and mutually agreed upon in advance. If necessary, a new, "
                    + "updated contract will be sent. Contract negotiations are best in person and can be accomplished following the pre-"
                    + "construction conference.",
            new Font(Font.TIMES_ROMAN, 12, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);
    document.add(table1);

    document.add(spacer);

    //add "Checklist:"
    table1 = new Table(1, 1);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(3);
    cell = new Cell();
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase("Checklist: ", new Font(Font.TIMES_ROMAN, 12, Font.BOLD)));
    cell.setBorder(0);
    table1.addCell(cell);
    document.add(table1);

    //add "Business Information"
    table1 = new Table(2, 1);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(3);
    table1.setWidths(two);

    cell = new Cell(checkboxPhrase);
    cell.setBorderWidth(0);
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("top");
    cell.setBorder(0);
    table1.addCell(cell);

    cell = new Cell();
    cell.setVerticalAlignment("bottom");
    cell.add(new Phrase("Business Information", new Font(Font.TIMES_ROMAN, 12, Font.NORMAL)));
    cell.add(new Phrase(" (* indicates required information)", new Font(Font.TIMES_ROMAN, 12, Font.ITALIC)));

    cell.add(new Phrase("\n     * Business Telephone Number", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.add(new Phrase("\n        Primary Contact Name", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.add(new Phrase("\n        Business Fax Number", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.add(new Phrase("\n        Mobile Telephone Number", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.add(new Phrase("\n        Email Address", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.add(new Phrase("\n     * Federal ID # or Social Security Number",
            new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    if (insure) {
        cell.add(new Phrase("\n     * Contractor's License Number",
                new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
        cell.add(new Phrase("\n     * Attach copy of current contractor's license",
                new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    }
    cell.setBorder(0);
    table1.addCell(cell);
    document.add(table1);

    //add "Sign and Date the Agreement"
    table1 = new Table(2, 1);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(3);
    table1.setWidths(two);

    cell = new Cell(checkboxPhrase);
    cell.setBorderWidth(0);
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    cell.setBorder(0);
    table1.addCell(cell);

    cell = new Cell();
    cell.setVerticalAlignment("bottom");
    cell.add(new Phrase("Sign and date the agreement", new Font(Font.TIMES_ROMAN, 12, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);

    document.add(table1);

    //add "initial all pages"
    table1 = new Table(2, 1);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(3);
    table1.setWidths(two);

    cell = new Cell(checkboxPhrase);
    cell.setBorderWidth(0);
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    cell.setBorder(0);
    table1.addCell(cell);

    cell = new Cell();
    cell.setVerticalAlignment("bottom");
    cell.add(new Phrase("Initial front page where indicated", new Font(Font.TIMES_ROMAN, 12, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);

    document.add(table1);

    //add "provide signatures"
    table1 = new Table(2, 1);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(3);
    table1.setWidths(two);

    cell = new Cell(checkboxPhrase);
    cell.setBorderWidth(0);
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    cell.setBorder(0);
    table1.addCell(cell);

    cell = new Cell();
    cell.setVerticalAlignment("bottom");
    cell.add(new Phrase("Provide appropriate signatures at Exhibit \"C\", Item #2",
            new Font(Font.TIMES_ROMAN, 12, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);

    document.add(table1);

    //add "complete and sign exhibit d"
    if (insure) {
        table1 = new Table(2, 1);
        table1.setBorderWidth(0);
        table1.setWidth(100);
        //table1.setDefaultCellBorder(0);
        table1.setPadding(3);
        table1.setWidths(two);

        cell = new Cell(checkboxPhrase);
        cell.setBorderWidth(0);
        cell.setHorizontalAlignment("center");
        cell.setVerticalAlignment("middle");
        cell.setBorder(0);
        table1.addCell(cell);

        cell = new Cell();
        cell.setVerticalAlignment("bottom");
        cell.add(new Phrase("Complete and sign Exhibit \"D\"", new Font(Font.TIMES_ROMAN, 12, Font.NORMAL)));
        cell.setBorder(0);
        table1.addCell(cell);

        document.add(table1);

        //add "Forward"
        table1 = new Table(2, 1);
        table1.setBorderWidth(0);
        table1.setWidth(100);
        //table1.setDefaultCellBorder(0);
        table1.setPadding(3);
        table1.setWidths(two);

        cell = new Cell(checkboxPhrase);
        cell.setBorderWidth(0);
        cell.setHorizontalAlignment("center");
        cell.setVerticalAlignment("middle");
        cell.setBorder(0);
        table1.addCell(cell);

        cell = new Cell();
        cell.setVerticalAlignment("bottom");
        cell.add(new Phrase(
                "Forward the required insurance certificates (per article 7 and Exhibit \"C\") to " + shortName,
                new Font(Font.TIMES_ROMAN, 12, Font.NORMAL)));
        cell.setBorder(0);
        table1.addCell(cell);

        document.add(table1);
    }

    //add "return all pages"
    table1 = new Table(2, 1);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(3);
    table1.setWidths(two);

    cell = new Cell(checkboxPhrase);
    cell.setBorderWidth(0);
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    cell.setBorder(0);
    table1.addCell(cell);

    cell = new Cell();
    cell.setVerticalAlignment("bottom");
    cell.add(new Phrase("Return all pages of both completed copies of your " + title
            + " agreement.  Do not remove any pages.", new Font(Font.TIMES_ROMAN, 12, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);

    document.add(table1);

}

From source file:com.sinkluge.reports.contracts.GenSubcontract.java

public void create(Info in, Image toplogo) throws Exception {

    //for the unchecked box
    Image checkbox = Image.getInstance(in.path + "/WEB-INF/images/unchecked.jpg");
    Chunk ch2 = new Chunk(checkbox, -7, -7);
    Phrase checkboxPhrase = new Phrase();
    checkboxPhrase.add(ch2);// www .  ja  va  2 s  .c  om

    Font tnr8 = new Font(Font.TIMES_ROMAN, 8, Font.NORMAL);

    Image iBox = Image.getInstance(in.path + "/WEB-INF/images/initialsBox.jpg");//(in.path + "/jsp/dev/images/epcologo3.jpg");
    Chunk ch3 = new Chunk(iBox, -3, -3);
    Phrase initialsBoxPhrase = new Phrase();
    initialsBoxPhrase.add(ch3);

    Phrase footerPhrase = new Phrase(
            attr.get("full_name") + ", " + attr.get("address") + ", " + attr.get("city") + ", "
                    + attr.get("state") + " " + attr.get("zip") + "\nPhone: " + attr.get("phone") + "   Fax: "
                    + attr.get("fax") + "   " + attr.get("url") + "   Page: ",
            new Font(Font.TIMES_ROMAN, 7, Font.BOLD | Font.ITALIC));

    HeaderFooter footer = new HeaderFooter(footerPhrase, true);
    footer.setBorder(0);
    footer.setAlignment(Element.ALIGN_CENTER);
    init(40, 40, 40, 40, footer);

    Phrase underLinePhrase = new Phrase(
            "  ___________________________________________________________________________________________  ",
            new Font(Font.TIMES_ROMAN, 10, Font.BOLD));
    int[] twoC = { 30, 70 };
    int[] twoD = { 5, 95 };
    int[] twoF = { 10, 90 };
    int[] twoE = { 25, 75 };
    int[] twoG = { 40, 60 };
    int[] threeD = { 4, 11, 85 };
    int[] threeB = { 70, 15, 15 };
    //int[] threeC = { 47, 5, 48 };
    int[] five = { 18, 25, 14, 18, 25 };

    //blank spacer for keeping tables apart
    Table spacer = new Table(1, 1);
    spacer.setBorderWidth(0);
    //spacer.setDefaultCellBorderWidth(0);
    spacer.setWidth(100);
    spacer.setPadding(0);
    spacer.setSpacing(0);
    Cell blank = new Cell();
    blank.add(new Chunk("", new Font(Font.TIMES_ROMAN, 8, Font.BOLD, new Color(255, 255, 255))));
    blank.setBorderWidth(0);
    //blank.setLeading(0);
    spacer.addCell(blank);

    //start of document
    //document.setFooter(footer);

    //document.setFooter(footer);

    //add image
    Phrase p1 = new Phrase();
    Table table1 = new Table(1, 1);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(2);
    table1.setSpacing(2);
    toplogo.scalePercent(20);
    //Chunk ch1=new Chunk(toplogo, -36, -55);
    //p1.add(ch1);
    Cell cell = new Cell(toplogo);
    cell.setBorderWidth(0);
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    table1.addCell(cell);

    document.add(table1);
    document.add(spacer);
    document.add(spacer);
    document.add(spacer);
    document.add(spacer);
    document.add(spacer);
    document.add(spacer);
    document.add(spacer);
    document.add(spacer);
    document.add(spacer);
    document.add(spacer);

    table1 = new Table(1, 1);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(0);
    cell = new Cell();
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    cell.setLeading(19);
    cell.add(
            new Phrase(title.toUpperCase() + " AGREEMENT BETWEEN CONTRACTOR AND " + cTitle.toUpperCase() + "\n",
                    new Font(Font.TIMES_ROMAN, 20, Font.BOLD)));
    cell.setUseDescender(true);
    cell.setBackgroundColor(Color.lightGray);
    cell.setBorder(0);
    table1.addCell(cell);
    document.add(table1);

    table1 = new Table(1, 1);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(0);
    table1.setSpacing(0);
    cell = new Cell();
    cell.add(underLinePhrase);
    cell.setBorder(0);
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase("\nDOCUMENTS CONTAINED HEREIN:\n", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);
    document.add(table1);

    table1 = new Table(3, 1);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setWidths(threeD);
    table1.setPadding(0);
    table1.setSpacing(0);
    table1.addCell(blank);

    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase("Page 1", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);

    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase("Agreement Declaration", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL)));
    cell.add(new Phrase("    Initial boxes below to indicate complete review of this agreement.",
            new Font(Font.TIMES_ROMAN, 8, Font.ITALIC)));
    cell.setBorder(0);
    table1.addCell(cell);

    table1.addCell(blank);

    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase("Page 2", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);

    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase("Articles of " + title + " Agreement and Standard Provisions", tnr8));
    cell.add(new Phrase("    Sign the concluding page.", new Font(Font.TIMES_ROMAN, 8, Font.ITALIC)));
    cell.setBorder(0);
    table1.addCell(cell);

    table1.addCell(blank);

    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase("Exhibit \"A\"", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);

    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase("List of Contract Documents, Plans, Specifications, Etc.", tnr8));
    cell.setBorder(0);
    //cell.add(new Phrase("    Read and initial each page.", new Font(Font.TIMES_ROMAN, 8, Font.ITALIC)));
    table1.addCell(cell);

    table1.addCell(blank);

    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase("Exhibit \"B\"", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);

    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase(cTitle + "'s Scope of Work", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);

    table1.addCell(blank);

    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");

    cell.add(new Phrase("Exhibit \"C\"", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);

    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");

    cell.add(new Phrase(cTitle + "'s Special Provisions and Procedure Requirements", tnr8));
    cell.add(new Phrase("    Read and complete \"Release Authorization\" information.",
            new Font(Font.TIMES_ROMAN, 8, Font.ITALIC)));
    cell.setBorder(0);
    table1.addCell(cell);
    table1.addCell(blank);
    if (insure) {
        cell = new Cell();
        cell.setHorizontalAlignment("left");
        cell.setVerticalAlignment("middle");
        cell.add(new Phrase("Exhibit \"D\"", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL)));
        cell.setBorder(0);
        table1.addCell(cell);

        cell = new Cell();
        cell.setHorizontalAlignment("left");
        cell.setVerticalAlignment("middle");
        cell.add(new Phrase(cTitle + " Cost Breakdown", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL)));
        cell.add(new Phrase("    Complete and return with signed contract",
                new Font(Font.TIMES_ROMAN, 8, Font.ITALIC)));
        cell.setBorder(0);
        table1.addCell(cell);

        table1.addCell(blank);
    }
    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    cell.setColspan(2);
    cell.add(new Phrase("NOTE OTHERS HERE:", new Font(Font.TIMES_ROMAN, 8, Font.ITALIC)));
    cell.setBorder(0);
    table1.addCell(cell);

    document.add(table1);

    table1 = new Table(3);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(0);
    table1.setWidths(threeB);
    table1.addCell(blank);
    cell = new Cell();
    cell.setColspan(2);
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase("(Initial) Entire agreement thoroughly reviewed:\n",
            new Font(Font.TIMES_ROMAN, 6, Font.ITALIC)));
    cell.setBorder(0);
    table1.addCell(cell);

    table1.addCell(blank);

    cell = new Cell();

    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase("Contractor: ________", new Font(Font.TIMES_ROMAN, 6, Font.ITALIC)));
    cell.setBorder(0);
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase(cTitle + ": ________", new Font(Font.TIMES_ROMAN, 6, Font.ITALIC)));
    cell.setBorder(0);
    table1.addCell(cell);
    cell = new Cell();
    cell.setColspan(3);
    cell.add(underLinePhrase);
    cell.setBorder(0);
    table1.addCell(cell);
    document.add(table1);

    table1 = new Table(1);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(0);
    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase("AGREEMENT", new Font(Font.TIMES_ROMAN, 10, Font.BOLD)));
    cell.add(new Phrase(" made as of " + agreementDate, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);

    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    //cell.setLeading(10);
    cell.add(new Phrase("BETWEEN", new Font(Font.TIMES_ROMAN, 10, Font.BOLD)));
    cell.add(new Phrase(" the Contractor: \n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.add(new Phrase("     " + attr.get("full_name") + " \n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.add(new Phrase("     " + attr.get("address") + " \n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.add(new Phrase("     " + attr.get("city") + ", " + attr.get("state") + " " + attr.get("zip"),
            new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.add(new Phrase("                (hereinafter known as \"Contractor\")\n",
            new Font(Font.TIMES_ROMAN, 6, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);

    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    //cell.setLeading(10);
    cell.add(new Phrase("AND", new Font(Font.TIMES_ROMAN, 10, Font.BOLD)));
    cell.add(new Phrase(" the " + cTitle + ": \n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.add(new Phrase("     " + subName + " \n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.add(new Phrase("     " + subAddress + "\n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.add(new Phrase("     " + subCityStateZip, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.add(new Phrase("                (hereinafter known as \"" + cTitle + "\")\n",
            new Font(Font.TIMES_ROMAN, 6, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);

    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    //cell.setLeading(10);
    cell.add(new Phrase("FOR", new Font(Font.TIMES_ROMAN, 10, Font.BOLD)));
    cell.add(new Phrase(" the the fixed sum of  " + DocHelper.numberAndText(amount) + " \n",
            new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    //cell.add(new Phrase("     " + amountString + " \n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);

    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    //cell.setLeading(10);
    cell.add(new Phrase("FOR", new Font(Font.TIMES_ROMAN, 10, Font.BOLD)));
    cell.add(new Phrase(" the Project known as:\n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.add(new Phrase("     " + projectName + " \n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.add(new Phrase("     " + projectAddress + "\n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.add(new Phrase("     " + projectCityStateZip, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.add(new Phrase("                (hereinafter known as \"Project\")\n",
            new Font(Font.TIMES_ROMAN, 6, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);

    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    //cell.setLeading(10);
    cell.add(new Phrase("BY", new Font(Font.TIMES_ROMAN, 10, Font.BOLD)));
    cell.add(new Phrase(" the Architect:\n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.add(new Phrase("     " + architectName + " \n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.add(new Phrase("     " + architectAddress + "\n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.add(new Phrase("     " + architectCityStateZip, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.add(new Phrase("                (hereinafter known as \"Architect\")\n",
            new Font(Font.TIMES_ROMAN, 6, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);

    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    //cell.setLeading(10);
    cell.add(new Phrase("FOR", new Font(Font.TIMES_ROMAN, 10, Font.BOLD)));
    cell.add(new Phrase(" the Project owner:\n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.add(new Phrase("     " + ownerName + " \n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.add(new Phrase("     " + ownerAddress + "\n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.add(new Phrase("     " + ownerCityStateZip, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.add(new Phrase("                (hereinafter known as \"Owner\")\n",
            new Font(Font.TIMES_ROMAN, 6, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);

    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase("WHEREFORE", new Font(Font.TIMES_ROMAN, 10, Font.BOLD)));
    cell.add(new Phrase(" the Contractor and " + cTitle + " agree as follows:\n\n\n",
            new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);

    document.add(table1);
    /*
          table1 = new Table(1);
          table1.setBorderWidth(0); table1.setWidth(100);
          //table1.setDefaultCellBorder(0);
          table1.setPadding(0);
               
          cell = new Cell();
          cell.setHorizontalAlignment("center");
          cell.setVerticalAlignment("middle");
          //cell.add(new Phrase("\n", new Font(Font.TIMES_ROMAN, 6, Font.NORMAL)));
          cell.setBorder(Rectangle.BOTTOM | Rectangle.TOP);
          cell.setBorderWidth(1.1f);
          cell.add(footerPhrase);
          cell.add(new Phrase(" 1\n ",
    new Font(Font.TIMES_ROMAN, 6, Font.NORMAL)));
          //cell.add(footerPhrase2);
                  
          cell.setBorder(0); table1.addCell(cell);
            
          document.add(table1);
    */
    document.newPage();

    table1 = new Table(1, 1);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(3);
    cell = new Cell();
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase(title.toUpperCase() + " AGREEMENT\n", new Font(Font.TIMES_ROMAN, 20, Font.BOLD)));
    cell.setBackgroundColor(Color.lightGray);
    cell.setLeading(19);
    cell.setUseDescender(true);
    cell.setBorder(0);
    table1.addCell(cell);
    document.add(table1);

    Paragraph para = new Paragraph(8, "\n\n" + text.toString(), tnr8);

    document.add(para);

    Phrase p;

    document.add(spacer);
    table1 = new Table(2, 1);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setWidths(twoC);
    table1.setPadding(0);
    p = new Phrase("Date:\n\n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL));
    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    cell.add(p);
    cell.setBorder(0);
    table1.addCell(cell);
    p = new Phrase("Signed:\n\n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL));
    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    cell.add(p);
    cell.setBorder(0);
    table1.addCell(cell);

    p = new Phrase("_______________________", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL));
    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    cell.add(p);
    cell.setBorder(0);
    table1.addCell(cell);
    p = new Phrase("_________________________________________________________________",
            new Font(Font.TIMES_ROMAN, 10, Font.NORMAL));
    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    cell.add(p);
    cell.setBorder(0);
    table1.addCell(cell);

    table1.addCell(blank);
    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase("            General Contractor                                               Title\n",
            tnr8));
    cell.setBorder(0);
    table1.addCell(cell);

    cell = new Cell();
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    cell.setColspan(2);
    cell.add(new Phrase("\nThis " + title
            + " Agreement supercedes all other proposals, documents, and negotiations whether written or verbal\n\n",
            new Font(Font.TIMES_ROMAN, 8, Font.BOLDITALIC)));
    cell.setBorder(0);
    table1.addCell(cell);

    p = new Phrase("Date:\n\n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL));
    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    cell.add(p);
    cell.setBorder(0);
    table1.addCell(cell);
    p = new Phrase("Signed:\n\n", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL));
    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    cell.add(p);
    cell.setBorder(0);
    table1.addCell(cell);

    p = new Phrase("_______________________", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL));
    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    cell.add(p);
    cell.setBorder(0);
    table1.addCell(cell);
    p = new Phrase("_________________________________________________________________",
            new Font(Font.TIMES_ROMAN, 10, Font.NORMAL));
    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    cell.add(p);
    cell.setBorder(0);
    table1.addCell(cell);

    table1.addCell(blank);
    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase(
            "            " + cTitle + "                                                       Title\n", tnr8));
    cell.setBorder(0);
    table1.addCell(cell);
    table1.setCellsFitPage(true);
    table1.setTableFitsPage(true);
    document.add(table1);

    document.newPage();

    table1 = new Table(1, 1);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(3);
    cell = new Cell();
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase(cTitle.toUpperCase() + " INFORMATION\n", new Font(Font.TIMES_ROMAN, 20, Font.BOLD)));
    cell.setBackgroundColor(Color.lightGray);
    cell.setLeading(19);
    cell.setUseDescender(true);
    cell.setBorder(0);
    table1.addCell(cell);
    document.add(table1);

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

    table1 = new Table(5, 1);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(1);
    table1.setWidths(five);
    cell = new Cell();
    cell.setHorizontalAlignment("right");
    cell.setVerticalAlignment("middle");

    cell.add(new Phrase("Federal I.D. : ", new Font(Font.TIMES_ROMAN, 10, Font.BOLD)));
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    cell.setBorder(15);
    cell.add(new Phrase(federal_id, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.setUseDescender(true);
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");

    cell.add(new Phrase("(Both Required)", new Font(Font.TIMES_ROMAN, 8, Font.BOLD)));

    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("right");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase("License Number : ", new Font(Font.TIMES_ROMAN, 10, Font.BOLD)));
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    cell.setBorder(15);
    cell.add(new Phrase(license_number, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.setUseDescender(true);
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("right");
    cell.setVerticalAlignment("middle");

    cell.add(new Phrase("Contact : ", new Font(Font.TIMES_ROMAN, 10, Font.BOLD)));
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    cell.setBorder(15);
    cell.setUseDescender(true);
    cell.add(new Phrase(contactName, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase("", new Font(Font.TIMES_ROMAN, 8, Font.BOLD)));
    cell.setUseDescender(true);
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("right");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase("Company : ", new Font(Font.TIMES_ROMAN, 10, Font.BOLD)));
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    cell.setBorder(15);
    cell.add(new Phrase(subName, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.setUseDescender(true);
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("right");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase("Telephone : ", new Font(Font.TIMES_ROMAN, 10, Font.BOLD)));
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    cell.setBorder(15);
    cell.setUseDescender(true);
    cell.add(new Phrase(telephone, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase("", new Font(Font.TIMES_ROMAN, 8, Font.BOLD)));
    cell.setUseDescender(true);
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("right");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase("Fax : ", new Font(Font.TIMES_ROMAN, 10, Font.BOLD)));
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    cell.setBorder(15);
    cell.add(new Phrase(fax, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.setUseDescender(true);
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("right");
    cell.setVerticalAlignment("middle");

    cell.add(new Phrase("Mobile phone : ", new Font(Font.TIMES_ROMAN, 10, Font.BOLD)));
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    cell.setBorder(15);
    cell.add(new Phrase(mobile, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.setUseDescender(true);
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase("", new Font(Font.TIMES_ROMAN, 8, Font.BOLD)));
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("right");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase("E-mail : ", new Font(Font.TIMES_ROMAN, 10, Font.BOLD)));
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    cell.setBorder(15);
    cell.add(new Phrase(email, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.setUseDescender(true);
    table1.addCell(cell);
    document.add(table1);

    //document.add(spacer);

    table1 = new Table(1, 1);
    //table1.setBorderWidth(4);
    //table1.setBorderColor(Color.lightGray);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(3);
    table1.setBorder(0);
    cell = new Cell();
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    if (insure)
        cell.add(new Phrase("Please attach a COPY of your current state license to this page:",
                new Font(Font.TIMES_ROMAN, 12, Font.NORMAL)));
    else
        cell.add(new Phrase("", new Font(Font.TIMES_ROMAN, 12, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);
    document.add(table1);
    document.add(spacer);

    table1 = new Table(1, 1);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(3);
    cell = new Cell();
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    if (insure)
        cell.add(new Phrase("\n\nAttach\nCopy of\nContractor's\nLicense\nHere\n(If Applicable)",
                new Font(Font.TIMES_ROMAN, 24, Font.NORMAL, Color.lightGray)));
    else
        cell.add(new Phrase("", new Font(Font.TIMES_ROMAN, 24, Font.NORMAL, Color.lightGray)));
    cell.setBorder(0);
    table1.addCell(cell);
    document.add(table1);

    //document.setMargins(72, 72, 36, 36);
    document.newPage();

    table1 = new Table(1, 1);
    table1.setOffset(0);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(3);
    table1.setWidth(100);
    cell = new Cell();
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase(title.toUpperCase() + " EXHIBIT \"A\"\n", new Font(Font.TIMES_ROMAN, 20, Font.BOLD)));
    cell.setLeading(6);
    cell.setBorder(0);
    table1.addCell(cell);
    cell = new Cell(new Phrase("\n", new Font(Font.TIMES_ROMAN, 8)));
    cell.setBorder(0);
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase("CONTRACT DOCUMENTS, PLANS,\nSPECIFICATIONS, ADDENDUMS, ETC.\n",
            new Font(Font.TIMES_ROMAN, 16, Font.BOLD)));
    cell.setUseDescender(true);
    cell.setLeading(17);
    cell.setBackgroundColor(Color.lightGray);
    cell.setBorder(0);
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase("\n" + subName
            + " is responsible to verify versions, dates, and completeness of documents that were used in the preparation of the "
            + cTitle + "'s bid proposal before signing this " + title + " Agreement\n", tnr8));
    cell.setBorder(0);
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase("This " + title + " Agreement includes, but is not limited to the following items:",
            new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.setUseDescender(true);
    cell.setBorder(Rectangle.BOTTOM);
    cell.setBorderWidth(0.5f);
    table1.addCell(cell);
    document.add(table1);

    Paragraph prgh = new Paragraph("\n" + bidDocuments + "\n", tnr8);
    prgh.setLeading(10);
    document.add(prgh);

    document.add(spacer);
    /*
     p = new Phrase("\n"+bidDocuments, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL));
     p.setLeading(10);
     cell= new Cell(p);
     cell.setBorder(Rectangle.TOP | Rectangle.BOTTOM);
     cell.setBorderWidth(0.5f);
     //cell.setBorderColor(Color.lightGray);
     cell.setHorizontalAlignment("left");
     cell.setVerticalAlignment("middle");
     //cell.setLeading(10);
     cell.setUseDescender(true);
     table1.addCell(cell);
     */

    table1 = new Table(1, 1);
    table1.setOffset(0);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(3);
    table1.setWidth(100);
    table1.setTableFitsPage(true);
    p = new Phrase("\nPlease note below all verbal conditions or instructions, if any, that the " + cTitle
            + " has received during the bid process which might affect the scope of work as required by the contract documents",
            new Font(Font.TIMES_ROMAN, 10, Font.NORMAL));
    p.setLeading(10);
    cell = new Cell(p);
    cell.setBorder(Rectangle.TOP);
    cell.setBorderWidth(0.5f);
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    table1.addCell(cell);

    document.add(table1);

    document.newPage();

    table1 = new Table(1, 1);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(3);
    table1.setOffset(0);
    table1.setWidth(100);
    cell = new Cell();
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase(title.toUpperCase() + " EXHIBIT \"B\"\n", new Font(Font.TIMES_ROMAN, 20, Font.BOLD)));
    cell.setLeading(6);
    cell.setBorder(0);
    table1.addCell(cell);
    cell = new Cell(new Phrase("\n", new Font(Font.TIMES_ROMAN, 8)));
    cell.setBorder(0);
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase("SCOPE OF WORK\n", new Font(Font.TIMES_ROMAN, 16, Font.BOLD)));
    cell.setBackgroundColor(Color.lightGray);
    cell.setUseDescender(true);
    cell.setLeading(17);
    cell.setBorder(0);
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase(
            "\nThis " + title + " Agreement includes, but is not limited to the following items:\n\n",
            new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
    cell.setBorder(Rectangle.BOTTOM);
    cell.setBorderWidth(0.5f);
    table1.addCell(cell);

    document.add(table1);

    prgh = new Paragraph("\n" + contractDescription + "\n", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL));
    prgh.setLeading(10);
    document.add(prgh);
    //cell= new Cell(prgh);
    //cell.setBorder(Rectangle.TOP | Rectangle.BOTTOM);
    //cell.setBorderWidth(0.5f);
    //cell.setBorderColor(Color.lightGray);
    //cell.setHorizontalAlignment("left");
    //cell.setVerticalAlignment("middle");
    //cell.setLeading(10);
    //cell.setUseDescender(true);
    //table1.addCell(cell);

    document.add(spacer);

    table1 = new Table(1, 1);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(3);
    table1.setOffset(0);
    table1.setWidth(100);
    table1.setTableFitsPage(true);

    p = new Phrase("\nAll " + cTitle
            + " bid proposal conditions that are outside of, in addition to or are limiting of conditions contained in the Contract Documents are of no effect and are invalid to the "
            + title + " Agreement unless expressly included in the description above.", tnr8);
    p.setLeading(10);
    cell = new Cell(p);
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    cell.setBorder(Rectangle.TOP);
    cell.setBorderWidth(0.5f);
    table1.addCell(cell);

    document.add(table1);

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

    document.newPage();

    table1 = new Table(1, 1);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(3);
    table1.setOffset(0);
    cell = new Cell();
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase(title.toUpperCase() + " EXHIBIT \"C\"\n", new Font(Font.TIMES_ROMAN, 20, Font.BOLD)));
    cell.setLeading(6);
    cell.setBorder(0);
    cell.setBorder(0);
    table1.addCell(cell);
    cell = new Cell(new Phrase("\n", new Font(Font.TIMES_ROMAN, 8)));
    cell.setBorder(0);
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("center");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase(cTitle.toUpperCase() + " SPECIAL PROVISIONS AND REQUIREMENTS\n",
            new Font(Font.TIMES_ROMAN, 16, Font.BOLD)));
    cell.setBackgroundColor(Color.lightGray);
    cell.setUseDescender(true);
    cell.setLeading(17);
    cell.setBorder(0);
    table1.addCell(cell);

    document.add(table1);

    int count = 1;

    if (insure) {

        table1 = new Table(1, 1);
        table1.setBorderWidth(0);
        table1.setWidth(100);
        //table1.setDefaultCellBorder(0);
        table1.setPadding(0);
        table1.setOffset(4);
        cell = new Cell();
        cell.add(new Phrase("1.     Insurance Provisions (If Applicable)",
                new Font(Font.TIMES_ROMAN, 10, Font.BOLD)));
        //cell.setLeading(6);
        cell.setBorder(0);
        table1.addCell(cell);
        document.add(table1);
        count++;
        table1 = new Table(2, 1);
        table1.setBorderWidth(0);
        table1.setWidth(100);
        //table1.setDefaultCellBorder(0);
        table1.setPadding(0);
        table1.setWidths(twoD);
        table1.setOffset(0);
        cell = new Cell();
        cell.setHorizontalAlignment("left");
        cell.setVerticalAlignment("middle");
        cell.setLeading(6);
        cell.add(new Phrase(
                "a.  The " + cTitle + " is required to name the following as additional Primary-Insured:",
                tnr8));
        table1.addCell(blank);
        cell.setBorder(0);
        table1.addCell(cell);
        document.add(table1);

        table1 = new Table(2, 1);
        table1.setBorderWidth(0);
        table1.setWidth(100);
        //table1.setDefaultCellBorder(0);
        table1.setPadding(0);
        table1.setWidths(twoE);
        table1.setOffset(0);
        cell = new Cell();
        cell.setHorizontalAlignment("right");
        cell.setVerticalAlignment("middle");
        cell.add(new Phrase("Contractor:  ", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL)));
        cell.setBorder(0);
        table1.addCell(cell);
        cell = new Cell();
        cell.setHorizontalAlignment("left");
        cell.setVerticalAlignment("middle");
        cell.add(new Phrase(attr.get("full_name"), new Font(Font.TIMES_ROMAN, 8, Font.NORMAL)));
        cell.setBorder(0);
        table1.addCell(cell);
        cell = new Cell();
        cell.setHorizontalAlignment("right");
        cell.setVerticalAlignment("middle");
        cell.add(new Phrase("Owner:  ", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL)));
        cell.setBorder(0);
        table1.addCell(cell);
        cell = new Cell();
        cell.setHorizontalAlignment("left");
        cell.setVerticalAlignment("middle");
        cell.add(new Phrase(ownerName, new Font(Font.TIMES_ROMAN, 8, Font.NORMAL)));
        cell.setBorder(0);
        table1.addCell(cell);
        cell = new Cell();
        cell.setHorizontalAlignment("right");
        cell.setVerticalAlignment("middle");
        cell.add(new Phrase("Other:  ", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL)));
        cell.setBorder(0);
        table1.addCell(cell);
        cell = new Cell();
        cell.setHorizontalAlignment("left");
        cell.setVerticalAlignment("middle");
        cell.add(new Phrase("_______________________________________", tnr8));
        cell.setBorder(0);
        table1.addCell(cell);
        document.add(table1);

        table1 = new Table(2, 1);
        table1.setBorderWidth(0);
        table1.setWidth(100);
        //table1.setDefaultCellBorder(0);
        table1.setPadding(0);
        table1.setWidths(twoD);
        table1.setOffset(4);
        p = new Phrase("b.  The " + cTitle
                + " must provide verification of current Worker's Compensation coverage with reference to "
                + jobName + " on the policy.", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL));
        p.setLeading(8);
        cell = new Cell(p);
        cell.setHorizontalAlignment("left");
        cell.setVerticalAlignment("middle");
        cell.setLeading(8);
        table1.addCell(blank);
        cell.setBorder(0);
        table1.addCell(cell);
        document.add(table1);
    }

    table1 = new Table(1, 1);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(0);
    table1.setOffset(4);
    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase(count + ".     Release Authorizations", new Font(Font.TIMES_ROMAN, 10, Font.BOLD)));
    count++;
    cell.setBorder(0);
    table1.addCell(cell);
    document.add(table1);
    table1 = new Table(2, 1);
    table1.setOffset(4);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(0);
    table1.setWidths(twoD);
    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    p = new Phrase(
            "List any Owners, Partners, and/or Corporate Officers who are legally authorized to sign for "
                    + subName
                    + " and who will be signing the MONTHLY REQUEST FOR PAYMENT, FINAL REQUEST FOR PAYMENT, and LIEN WAIVER documents:\n\n",
            tnr8);
    p.setLeading(8);
    p1 = new Phrase(
            "       ______________________________________________________________________          ______________________________________________________________________\n",
            new Font(Font.TIMES_ROMAN, 6, Font.ITALIC));
    //p1.setLeading(0);
    Phrase p2 = new Phrase(
            "       Printed name and title                                                                                                                   Signature\n\n",
            new Font(Font.TIMES_ROMAN, 6, Font.ITALIC));
    //cell.setLeading(8);
    cell.add(p);
    cell.add(p1);
    cell.add(p2);
    cell.add(p1);
    cell.add(p2);
    cell.add(p1);
    cell.add(p2);
    table1.addCell(blank);
    cell.setBorder(0);
    table1.addCell(cell);
    document.add(table1);

    table1 = new Table(1, 1);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(3);
    table1.setOffset(0);
    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase(count + ".     Shop Drawings - Samples - Submittals",
            new Font(Font.TIMES_ROMAN, 10, Font.BOLD)));
    cell.setBorder(0);
    table1.addCell(cell);
    document.add(table1);
    count++;

    table1 = new Table(2, 1);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(0);
    table1.setWidths(twoD);
    table1.setOffset(2);
    p = new Phrase(
            "All shop drawings, materials samples, and submittals shall be submitted to the Contractor within 30 days of the issuance of this "
                    + title
                    + " Agreement unless specifically noted below.  All submitted items shall be in number and type as per the contract documents including, but not limited to, the following:",
            tnr8);
    p.setLeading(8);
    cell = new Cell(p);
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    table1.addCell(blank);
    cell.setBorder(0);
    table1.addCell(cell);
    document.add(table1);

    table1 = new Table(2, 1);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(0);
    table1.setWidths(twoF);
    table1.setOffset(4);

    p = new Phrase("--The number of copies of each submittal for " + jobName + " is " + submittal_copies
            + ".\n--All submittals, of any type, are due on or before " + dueDate
            + " unless specifically noted otherwise.\n", tnr8);
    p.setLeading(8);
    cell = new Cell(p);
    table1.addCell(blank);
    cell.setBorder(0);
    table1.addCell(cell);
    String submittals = "";
    if (!submittalVector.isEmpty()) {
        p = new Phrase("            Due Date:\n", new Font(Font.TIMES_ROMAN, 8, Font.BOLD));
        p.setLeading(8);
        cell = new Cell(p);
        cell.setColspan(2);
        cell.setBorder(0);
        table1.addCell(cell);
        for (int i = 0; i < submittalVector.size(); i++) {
            submittals += (String) submittalVector.elementAt(i) + "\n";
        }
        p = new Phrase(submittals, new Font(Font.TIMES_ROMAN, 8, Font.NORMAL));
        p.setLeading(8);
        cell = new Cell(p);
        table1.addCell(blank);
        cell.setBorder(0);
        table1.addCell(cell);
    } else {
        p = new Phrase("\nSubmittals required per contract documents and specifications.\n",
                new Font(Font.TIMES_ROMAN, 8, Font.BOLD));
        p.setLeading(8);
        cell = new Cell(p);
        table1.addCell(blank);
        cell.setBorder(0);
        table1.addCell(cell);
    }
    p = new Phrase("\n(" + subName
            + " is responsible for all submittals required in the Contract Documents as pertaining to labor and materials included in the scope of this "
            + title + " Agreement regardless of items listed, not listed, or incorrectly listed above.)",
            new Font(Font.TIMES_ROMAN, 6, Font.ITALIC));
    p.setLeading(8);
    cell = new Cell(p);

    table1.addCell(blank);
    cell.setBorder(0);
    table1.addCell(cell);
    document.add(table1);

    table1 = new Table(2, 1);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(1);
    table1.setWidths(twoD);
    table1.setOffset(2);
    p = new Phrase(cTitle.toUpperCase()
            + " acknowledges that review and approval of any type of submittal which deviates from the Project Plans and Specifications does NOT relieve the "
            + cTitle
            + " from costs, penalties and all other remedies required to meet the published specifications where the "
            + cTitle
            + " failed to notify the Owner/Architect/Contractor in writing of the variations from the specifications and failed to obtain written approval for EACH variation from the published specifications.",
            tnr8);
    p.setLeading(8);
    cell = new Cell(p);
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    //cell.setLeading(8);
    table1.addCell(blank);
    cell.setBorder(0);
    table1.addCell(cell);
    document.add(table1);

    table1 = new Table(1, 1);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(0);
    table1.setOffset(2);
    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    cell.add(new Phrase(count + ".     Project Close-out", new Font(Font.TIMES_ROMAN, 10, Font.BOLD)));
    cell.setBorder(0);
    table1.addCell(cell);
    document.add(table1);
    count++;
    table1 = new Table(2, 1);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(0);
    table1.setOffset(4);
    table1.setWidths(twoD);
    p = new Phrase(
            "All project close-out documents, materials, and Owner-training required by the Contract Documents shall be submitted to the Contractor PRIOR to payment of the "
                    + cTitle
                    + "'s 90% completion payment request.  The requirements shall include, but not be limited to, the following:",
            tnr8);
    p.setLeading(8);
    cell = new Cell(p);
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("middle");
    //cell.setLeading(8);
    table1.addCell(blank);
    cell.setBorder(0);
    table1.addCell(cell);
    document.add(table1);

    table1 = new Table(2, 1);
    table1.setBorderWidth(0);
    table1.setWidth(100);
    //table1.setDefaultCellBorder(0);
    table1.setPadding(0);
    table1.setOffset(0);
    table1.setWidths(twoG);
    cell = new Cell();
    cell.setHorizontalAlignment("right");
    cell.setVerticalAlignment("top");
    cell.add(new Phrase("\"O & M\" Submittals: ", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("top");
    cell.add(new Phrase(omSubmittals, new Font(Font.TIMES_ROMAN, 8, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("right");
    cell.setVerticalAlignment("top");
    cell.add(new Phrase("Full Warranty: ", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("top");
    cell.add(new Phrase(fullWarranty, new Font(Font.TIMES_ROMAN, 8, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("right");
    cell.setVerticalAlignment("top");
    cell.add(new Phrase("Up-to-date Lien Release(s): ", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("top");
    cell.add(new Phrase(lienReleases, new Font(Font.TIMES_ROMAN, 8, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("right");
    cell.setVerticalAlignment("top");
    cell.add(new Phrase("Signed Training Form: ", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("top");
    cell.add(new Phrase(signedTraining, new Font(Font.TIMES_ROMAN, 8, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("right");
    cell.setVerticalAlignment("top");
    cell.add(new Phrase("Materials-Equip-Specialty Items: ", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("top");
    cell.add(new Phrase(specialtyItems, new Font(Font.TIMES_ROMAN, 8, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("right");
    cell.setVerticalAlignment("top");
    cell.add(new Phrase("Other Items: ", new Font(Font.TIMES_ROMAN, 8, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);
    cell = new Cell();
    cell.setHorizontalAlignment("left");
    cell.setVerticalAlignment("top");
    cell.add(new Phrase(otherItems, new Font(Font.TIMES_ROMAN, 8, Font.NORMAL)));
    cell.setBorder(0);
    table1.addCell(cell);
    document.add(table1);

    if (insure) {
        table1 = new Table(1, 1);
        table1.setBorderWidth(0);
        table1.setWidth(100);
        //table1.setDefaultCellBorder(0);
        table1.setPadding(3);
        table1.setOffset(2);
        cell = new Cell();
        cell.setHorizontalAlignment("left");
        cell.setVerticalAlignment("middle");
        cell.add(new Phrase(count + ".     " + cTitle + " Safety Program (If Applicable)",
                new Font(Font.TIMES_ROMAN, 10, Font.BOLD)));
        cell.setBorder(0);
        table1.addCell(cell);
        document.add(table1);
        table1 = new Table(2, 1);
        table1.setBorderWidth(0);
        table1.setWidth(100);
        //table1.setDefaultCellBorder(0);
        table1.setPadding(0);
        table1.setOffset(2);
        table1.setWidths(twoD);
        p = new Phrase(
                cTitle + " will submit one copy of the " + cTitle + "'s job-specific safety program to "
                        + attr.get("full_name")
                        + " before any equipment, manpower, or materials are brought onto the Project site.  ",
                tnr8);
        p.setLeading(8);
        cell = new Cell(p);
        p = new Phrase(cTitle + " will require it's " + cTitle.toLowerCase()
                + "s to have in place a job-specific safety program before they enter the Project site.", tnr8);
        p.setLeading(8);
        cell.add(p);
        cell.setHorizontalAlignment("left");
        cell.setVerticalAlignment("middle");
        //cell.setLeading(8);

        table1.addCell(blank);
        cell.setBorder(0);
        table1.addCell(cell);
        document.add(table1);
    }

    if (insure) {
        document.newPage();

        table1 = new Table(1, 1);
        table1.setBorderWidth(0);
        table1.setWidth(100);
        //table1.setDefaultCellBorder(0);
        table1.setPadding(3);
        table1.setOffset(0);
        cell = new Cell();
        cell.setHorizontalAlignment("center");
        cell.setVerticalAlignment("middle");
        cell.add(new Phrase(title.toUpperCase() + " EXHIBIT \"D\"", new Font(Font.TIMES_ROMAN, 20, Font.BOLD)));
        cell.setLeading(6);
        cell.setBorder(0);
        table1.addCell(cell);
        cell = new Cell(new Phrase("\n", new Font(Font.TIMES_ROMAN, 8)));
        cell.setBorder(0);
        table1.addCell(cell);
        cell = new Cell();
        cell.setHorizontalAlignment("center");
        cell.setVerticalAlignment("middle");
        cell.add(new Phrase(cTitle.toUpperCase() + "'S COST BREAKDOWN\n",
                new Font(Font.TIMES_ROMAN, 16, Font.BOLD)));
        cell.setBackgroundColor(Color.lightGray);
        cell.setUseDescender(true);
        cell.setLeading(17);
        cell.setBorder(0);
        table1.addCell(cell);
        document.add(table1);
        table1 = new Table(1, 1);
        table1.setBorderWidth(0);
        table1.setWidth(100);
        //table1.setDefaultCellBorder(0);
        table1.setPadding(0);
        table1.setOffset(2);
        p = new Phrase("The following information is to be supplied by " + subName + " for " + jobName
                + ". List all SUPPLIERS and SUBCONTRACTORS for approval and payment confirmation (attach additional pages if needed):",
                new Font(Font.TIMES_ROMAN, 10, Font.NORMAL));
        p.setLeading(12);
        cell = new Cell(p);
        cell.setHorizontalAlignment("left");
        cell.setVerticalAlignment("middle");
        cell.setBorder(0);
        table1.addCell(cell);
        cell = new Cell();
        cell.setHorizontalAlignment("left");
        cell.setVerticalAlignment("middle");
        cell.add(new Phrase(
                "     Name                                        City                                  Phone                                                                            Estimated Dollar Amount",
                tnr8));
        cell.setBorder(0);
        table1.addCell(cell);
        cell = new Cell();
        p = new Phrase(
                "________________________________________________________________________  $___________________\n",
                new Font(Font.TIMES_ROMAN, 10, Font.NORMAL));
        cell.setHorizontalAlignment("left");
        cell.setVerticalAlignment("middle");
        for (int i = 0; i < 10; i++) {
            cell.add(p);
        }
        cell.setBorder(0);
        table1.addCell(cell);

        p = new Phrase(
                "Supplier accepts full responsibility for acts and omissions of his subcontractors and suppliers.  No suppliers or subcontractors are to be added or deleted without prior notification to "
                        + attr.get("full_name") + ".",
                new Font(Font.TIMES_ROMAN, 8, Font.ITALIC));
        p.setLeading(10);
        cell = new Cell(p);
        cell.setHorizontalAlignment("left");
        cell.setVerticalAlignment("middle");
        cell.setLeading(15);
        cell.setBorder(0);
        table1.addCell(cell);
        p = new Phrase(
                "List the primary phases of your contracted scope of work and the associated costs.  This information may be released to the Owner if disputes arise over future billings and progress payments.",
                new Font(Font.TIMES_ROMAN, 10, Font.NORMAL));
        p.setLeading(12);
        cell = new Cell(p);
        cell.setHorizontalAlignment("left");
        cell.setVerticalAlignment("middle");
        cell.setLeading(15);
        cell.setBorder(0);
        table1.addCell(cell);
        cell = new Cell();
        cell.setHorizontalAlignment("left");
        cell.setVerticalAlignment("middle");
        cell.add(new Phrase(
                "Description/Phase of Work                     Labor                      Material                    Equipment/Tools       Sub-subcontractor     Total",
                tnr8));
        cell.setBorder(0);
        table1.addCell(cell);
        cell = new Cell();
        p = new Phrase(
                "________________________  $____________ $____________ $____________ $____________ $____________ \n",
                new Font(Font.TIMES_ROMAN, 10, Font.NORMAL));
        cell.setHorizontalAlignment("left");
        cell.setVerticalAlignment("middle");
        for (int i = 0; i < 13; i++) {
            cell.add(p);
        }
        cell.setBorder(0);
        table1.addCell(cell);
        document.add(table1);

        document.add(spacer);

        table1 = new Table(1, 1);
        table1.setBorderWidth(0);
        table1.setWidth(100);
        //table1.setDefaultCellBorder(0);
        table1.setOffset(2);
        table1.setPadding(1);
        cell = new Cell();
        cell.setHorizontalAlignment("center");
        cell.setVerticalAlignment("middle");
        //cell.setLeading(10);
        cell.add(new Phrase(subName, new Font(Font.TIMES_ROMAN, 10, Font.UNDERLINE)));
        cell.add(new Phrase("\n" + cTitle, new Font(Font.TIMES_ROMAN, 6, Font.ITALIC)));
        cell.setBorder(0);
        table1.addCell(cell);
        document.add(table1);
        document.add(spacer);
        document.add(spacer);

        table1 = new Table(1, 1);
        table1.setBorderWidth(0);
        table1.setWidth(100);
        //table1.setDefaultCellBorder(0);
        table1.setOffset(0);
        cell = new Cell();
        cell.setHorizontalAlignment("center");
        cell.setVerticalAlignment("middle");
        //cell.setLeading(10);
        cell.add(new Phrase("By:____________________________", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
        cell.add(new Phrase("\nPrint Name of Authorized Company Officer",
                new Font(Font.TIMES_ROMAN, 6, Font.ITALIC)));
        cell.setBorder(0);
        table1.addCell(cell);
        document.add(table1);
        document.add(spacer);
        document.add(spacer);
        table1 = new Table(1, 1);
        table1.setOffset(0);
        table1.setBorderWidth(0);
        table1.setWidth(100);
        //table1.setDefaultCellBorder(0);
        cell = new Cell();
        cell.setHorizontalAlignment("center");
        cell.setVerticalAlignment("middle");
        //cell.setLeading(10);
        cell.add(new Phrase("By:____________________________", new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)));
        cell.add(new Phrase("\nAuthorized Signature", new Font(Font.TIMES_ROMAN, 6, Font.ITALIC)));
        cell.setBorder(0);
        table1.addCell(cell);
        document.add(table1);

    }

}

From source file:com.util.load.RecordDocCreate.java

/**
 * /* ww w.  j  ava  2 s .  c o  m*/
 * @param unitInfo ???
 * @param systemManager ?
 * @param rank 
 * @param countTol ?
 * @param countSec ?
 * @param countThr ?
 * @param countThir?
 * @param countMay ?
 * @param fileName ??
 * @return ?   1?
 */
public static int createRecordDoc(UnitInfo unitInfo, SystemManager systemManager, Rank rank, int countTol,
        int countSec, int countThr, int countThir, int countMay, File fileName) {

    Document document = new Document(PageSize.A4, 90.0F, 90.0F, 50.0F, 40.0F);
    try {
        RtfWriter2.getInstance(document, new FileOutputStream(fileName));
        document.open();

        String songPath = "";
        String blackFontPath = "";
        String fangsongPath = "";
        String wingdings2FontPath = "";
        if (System.getProperties().getProperty("os.name").toUpperCase().indexOf("WINDOWS") == 0) {
            songPath = "c:\\windows\\fonts\\msyh.ttf";
            blackFontPath = "c:\\windows\\fonts\\simhei.ttf";
            fangsongPath = "C:\\Windows\\Fonts\\simfang.ttf";
            wingdings2FontPath = "c:\\windows\\fonts\\WINGDNG2.TTF";
        } else {
            /*songPath="/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf";
            blackFontPath="/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono-Bold.ttf";
            fangsongPath="/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif.ttf";
            wingdings2FontPath="/usr/share/fonts/truetype/unifont/unifont.ttf";*/
            songPath = "/usr/share/fonts/dejavu/DejaVuSansMono.ttf";
            blackFontPath = "/usr/share/fonts/dejavu/DejaVuSansMono-Bold.ttf";
            fangsongPath = "/usr/share/fonts/dejavu/DejaVuSerif.ttf";
            wingdings2FontPath = "/usr/share/fonts/dejavu/unifont.ttf";
        }

        BaseFont blackBaseFont = BaseFont.createFont(songPath, "Identity-H", false);
        BaseFont songFont = BaseFont.createFont(blackFontPath, "Identity-H", false);
        BaseFont fangsongFont = BaseFont.createFont(fangsongPath, "Identity-H", false);
        BaseFont wingdings2Font = BaseFont.createFont(wingdings2FontPath, "Identity-H", false);

        Font songfont_11 = new Font(songFont, 11.0F, 0);
        Font songfontUnderLine_11 = new Font(songFont, 11.0F, 4);

        Chunk rightSign = new Chunk("R", new Font(wingdings2Font, 16.0F, 0));
        Chunk blankSign = new Chunk("*", new Font(wingdings2Font, 20.0F, 0));

        Paragraph p = new Paragraph();
        //p.setFont(new Font(songFont, 14.0F, 0));
        p.add("  2");
        document.add(p);

        Paragraph p1 = new Paragraph();
        p1.add(new Chunk("?"));
        Table numTable = new Table(12, 1);
        numTable.setLeft(0);
        numTable.setWidth(50.0F);
        numTable.addCell("");
        p1.add(numTable);
        document.add(p1);
        /*String docName="";
        if("1".equals(rank.getRankOrganType())){
        docName="??";
        }
        if("2".equals(rank.getRankOrganType())){
        docName="??";
        }
        if("3".equals(rank.getRankOrganType())){
        docName="??";
        }
        if("4".equals(rank.getRankOrganType())){
        docName="???";
        }
        if("5".equals(rank.getRankOrganType())){
        docName="?";
        }
        if("6".equals(rank.getRankOrganType())){
        docName="?";
        }*/
        p = new Paragraph(rank.getSysInfoName() + "?");
        p.setFont(new Font(songFont, 36.0F, 1));
        p.setAlignment(1);
        document.add(p);

        document.add(Chunk.NEWLINE);
        document.add(Chunk.NEWLINE);
        document.add(Chunk.NEWLINE);
        document.add(Chunk.NEWLINE);
        document.add(Chunk.NEWLINE);
        p = new Paragraph();
        p.setAlignment(1);
        p.add(new Chunk("  ? ?", new Font(fangsongFont, 16.0F, 0)));
        p.add(new Chunk("__________", new Font(fangsongFont, 16.0F, 0)));
        p.add(new Chunk("()", new Font(fangsongFont, 16.0F, 4)));
        p.add(new Chunk("__________", new Font(fangsongFont, 16.0F, 0)));
        document.add(p);

        document.add(Chunk.NEWLINE);

        p = new Paragraph();
        p.setAlignment(1);
        p.add(new Chunk("   ", new Font(fangsongFont, 16.0F, 0)));
        p.add(new Chunk("__________________________", new Font(fangsongFont, 16.0F, 0)));
        document.add(p);

        document.add(Chunk.NEWLINE);
        document.add(Chunk.NEWLINE);
        p = new Paragraph();
        p.setAlignment(1);
        p.add(new Chunk("   ", new Font(fangsongFont, 16.0F, 0)));
        p.add(new Chunk("__________", new Font(fangsongFont, 16.0F, 0)));
        p.add(new Chunk("()", new Font(fangsongFont, 16.0F, 4)));
        p.add(new Chunk("__________", new Font(fangsongFont, 16.0F, 0)));
        document.add(p);

        document.add(Chunk.NEWLINE);

        p = new Paragraph();
        p.setAlignment(1);
        p.add(new Chunk("   ", new Font(fangsongFont, 16.0F, 0)));
        p.add(new Chunk("__________________________", new Font(fangsongFont, 16.0F, 0)));
        document.add(p);

        document.add(Chunk.NEWLINE);
        document.add(Chunk.NEWLINE);
        p = new Paragraph();
        p.setAlignment(1);
        p.add(new Chunk("????", new Font(fangsongFont, 16.0F, 0)));
        p.add(new Chunk("__________", new Font(fangsongFont, 16.0F, 0)));
        p.add(new Chunk("()", new Font(fangsongFont, 16.0F, 4)));
        p.add(new Chunk("__________", new Font(fangsongFont, 16.0F, 0)));
        document.add(p);

        document.add(Chunk.NEWLINE);

        p = new Paragraph();
        p.setAlignment(1);
        p.add(new Chunk("? ?  ", new Font(fangsongFont, 16.0F, 0)));
        p.add(new Chunk("__________________________", new Font(fangsongFont, 16.0F, 0)));
        document.add(p);
        document.add(Chunk.NEWLINE);
        document.add(Chunk.NEWLINE);
        document.add(Chunk.NEWLINE);
        document.add(Chunk.NEWLINE);
        document.add(Chunk.NEWLINE);
        document.add(Chunk.NEWLINE);
        document.add(Chunk.NEWLINE);
        document.add(Chunk.NEWLINE);
        document.add(Chunk.NEWLINE);
        document.add(Chunk.NEWLINE);
        p = new Paragraph();
        p.setAlignment(1);
        p.add(new Chunk("?", new Font(songFont, 20.0F, 1)));
        document.add(p);

        p = new Paragraph();
        p.setAlignment(1);
        p.add(new Chunk("", new Font(songFont, 16.0F, 1)));
        document.add(p);

        Chapter chapter = new Chapter(1);
        com.lowagie.text.List list = new com.lowagie.text.List(true, false, 20.0F);

        //1
        ListItem listItem = new ListItem();
        Chunk itemChunk = new Chunk("??", new Font(blackBaseFont, 11.0F, 0));
        listItem.add(itemChunk);
        itemChunk = new Chunk(
                "????[2007]43?");
        listItem.add(itemChunk);
        list.add(listItem);

        //2
        listItem = new ListItem();
        itemChunk = new Chunk("", new Font(blackBaseFont, 11.0F, 0));
        listItem.add(itemChunk);
        itemChunk = new Chunk(
                "???????????????????????????????????????????????");
        listItem.add(itemChunk);
        list.add(listItem);

        //3
        listItem = new ListItem();
        itemChunk = new Chunk("??", new Font(blackBaseFont, 11.0F, 0));
        listItem.add(itemChunk);
        itemChunk = new Chunk(
                "??????");
        listItem.add(itemChunk);
        list.add(listItem);

        //4
        listItem = new ListItem("",
                new Font(songFont, 11.0F, 0));
        listItem.add(blankSign);
        listItem.add(new Chunk("?", songfont_11));
        listItem.add(rightSign);
        listItem.add(new Chunk("???",
                songfont_11));
        list.add(listItem);

        //5
        listItem = new ListItem();
        itemChunk = new Chunk("???", new Font(songFont, 11.0F, 0));
        listItem.add(itemChunk);
        itemChunk = new Chunk(
                "??11?6????????GA380-20025???????");
        listItem.add(itemChunk);
        list.add(listItem);

        //6
        listItem = new ListItem();
        itemChunk = new Chunk("????", new Font(songFont, 11.0F, 0));
        listItem.add(itemChunk);
        itemChunk = new Chunk("?????");
        listItem.add(itemChunk);
        list.add(listItem);

        //7
        listItem = new ListItem();
        itemChunk = new Chunk("??", new Font(songFont, 11.0F, 0));
        listItem.add(itemChunk);
        itemChunk = new Chunk("??");
        listItem.add(itemChunk);
        list.add(listItem);
        //8
        listItem = new ListItem();
        itemChunk = new Chunk("??????", new Font(songFont, 11.0F, 0));
        listItem.add(itemChunk);
        itemChunk = new Chunk(
                "???????");
        listItem.add(itemChunk);
        list.add(listItem);

        //9
        listItem = new ListItem();
        itemChunk = new Chunk("04?", new Font(songFont, 11.0F, 0));
        listItem.add(itemChunk);
        itemChunk = new Chunk("??(???)?");
        listItem.add(itemChunk);
        list.add(listItem);

        //10
        listItem = new ListItem();
        itemChunk = new Chunk("05??", new Font(songFont, 11.0F, 0));
        listItem.add(itemChunk);
        itemChunk = new Chunk("???");
        listItem.add(itemChunk);
        list.add(listItem);

        //11
        listItem = new ListItem();
        itemChunk = new Chunk("06", new Font(songFont, 11.0F, 0));
        listItem.add(itemChunk);
        itemChunk = new Chunk("???");
        listItem.add(itemChunk);
        list.add(listItem);

        //12
        listItem = new ListItem();
        itemChunk = new Chunk("08", new Font(songFont, 11.0F, 0));
        listItem.add(itemChunk);
        itemChunk = new Chunk(
                "????????GB/T124041997");
        listItem.add(itemChunk);
        list.add(listItem);

        //13
        listItem = new ListItem();
        itemChunk = new Chunk("02?", new Font(songFont, 11.0F, 0));
        listItem.add(itemChunk);
        itemChunk = new Chunk("????????");
        listItem.add(itemChunk);
        list.add(listItem);

        //14
        listItem = new ListItem();
        itemChunk = new Chunk("05?", new Font(songFont, 11.0F, 0));
        listItem.add(itemChunk);
        itemChunk = new Chunk("");
        listItem.add(itemChunk);
        list.add(listItem);

        //15
        listItem = new ListItem();
        itemChunk = new Chunk("07?", new Font(songFont, 11.0F, 0));
        listItem.add(itemChunk);
        itemChunk = new Chunk(
                "??????????");
        listItem.add(itemChunk);
        list.add(listItem);

        //16
        listItem = new ListItem();
        itemChunk = new Chunk("08?", new Font(songFont, 11.0F, 0));
        listItem.add(itemChunk);
        itemChunk = new Chunk(
                "?????????");
        listItem.add(itemChunk);
        list.add(listItem);

        //17
        listItem = new ListItem();
        itemChunk = new Chunk("", new Font(songFont, 11.0F, 0));
        listItem.add(itemChunk);
        itemChunk = new Chunk(
                "??????");
        listItem.add(itemChunk);
        list.add(listItem);
        document.add(list);

        document.add(Chunk.NEXTPAGE);

        p = new Paragraph();
        p.setAlignment(1);
        p.add(new Chunk("  ??", new Font(songFont, 16.0F, 0)));
        document.add(p);

        Table table1 = new Table(16);
        table1.setWidth(110.0F);
        table1.setWidths(new int[] { 20, 5, 5, 5, 5, 5, 5, 10, 25, 5, 5, 5, 5, 5, 5, 10 });
        Cell cell = new Cell(new Phrase(new Chunk("01????", songfont_11)));
        setLocal(cell);
        table1.addCell(cell);
        cell = new Cell(unitInfo.getUnitName() == null ? " " : unitInfo.getUnitName());
        setLocal(cell);
        cell.setColspan(15);
        table1.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("02???", songfont_11)));
        setLocal(cell);
        table1.addCell(cell);
        cell = new Cell();
        Font underLineFont = new Font(songFont, 11.0F, 4);
        cell.add(new Chunk(unitInfo.getProvince() == null ? "" : unitInfo.getProvince(), underLineFont));
        cell.add(new Chunk("?(?) ", songfont_11));
        cell.add(new Chunk(unitInfo.getCity() == null ? "" : unitInfo.getCity(), underLineFont));
        cell.add(new Chunk(" (???) ", songfont_11));
        cell.add(new Chunk(unitInfo.getCounty() == null ? "" : unitInfo.getCounty(), underLineFont));
        cell.add(new Chunk("(??)", songfont_11));
        cell.setColspan(15);
        table1.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("03?", songfont_11)));
        setLocal(cell);
        table1.addCell(cell);

        table1.addCell(
                new Phrase(new Chunk(unitInfo.getPostcode() == null || "".equals(unitInfo.getPostcode()) ? ""
                        : unitInfo.getPostcode().charAt(0) + "", songfont_11)));
        table1.addCell(
                new Phrase(new Chunk(unitInfo.getPostcode() == null || "".equals(unitInfo.getPostcode()) ? ""
                        : unitInfo.getPostcode().charAt(1) + "", songfont_11)));
        table1.addCell(
                new Phrase(new Chunk(unitInfo.getPostcode() == null || "".equals(unitInfo.getPostcode()) ? ""
                        : unitInfo.getPostcode().charAt(2) + "", songfont_11)));
        table1.addCell(
                new Phrase(new Chunk(unitInfo.getPostcode() == null || "".equals(unitInfo.getPostcode()) ? ""
                        : unitInfo.getPostcode().charAt(3) + "", songfont_11)));
        table1.addCell(
                new Phrase(new Chunk(unitInfo.getPostcode() == null || "".equals(unitInfo.getPostcode()) ? ""
                        : unitInfo.getPostcode().charAt(4) + "", songfont_11)));
        table1.addCell(
                new Phrase(new Chunk(unitInfo.getPostcode() == null || "".equals(unitInfo.getPostcode()) ? ""
                        : unitInfo.getPostcode().charAt(5) + "", songfont_11)));
        table1.addCell("");
        table1.addCell(new Phrase(new Chunk("04?", songfont_11)));
        table1.addCell(new Phrase(
                new Chunk(unitInfo.getDivisionCode() == null || "".equals(unitInfo.getDivisionCode()) ? ""
                        : unitInfo.getDivisionCode().charAt(0) + "", songfont_11)));
        table1.addCell(new Phrase(
                new Chunk(unitInfo.getDivisionCode() == null || "".equals(unitInfo.getDivisionCode()) ? ""
                        : unitInfo.getDivisionCode().charAt(1) + "", songfont_11)));
        table1.addCell(new Phrase(
                new Chunk(unitInfo.getDivisionCode() == null || "".equals(unitInfo.getDivisionCode()) ? ""
                        : unitInfo.getDivisionCode().charAt(2) + "", songfont_11)));
        table1.addCell(new Phrase(
                new Chunk(unitInfo.getDivisionCode() == null || "".equals(unitInfo.getDivisionCode()) ? ""
                        : unitInfo.getDivisionCode().charAt(3) + "", songfont_11)));
        table1.addCell(new Phrase(
                new Chunk(unitInfo.getDivisionCode() == null || "".equals(unitInfo.getDivisionCode()) ? ""
                        : unitInfo.getDivisionCode().charAt(4) + "", songfont_11)));
        table1.addCell(new Phrase(
                new Chunk(unitInfo.getDivisionCode() == null || "".equals(unitInfo.getDivisionCode()) ? ""
                        : unitInfo.getDivisionCode().charAt(5) + "", songfont_11)));
        table1.addCell("");

        cell = new Cell(new Chunk("05??", new Font(songFont, 11.0F, 0)));
        setLocal(cell);
        cell.setRowspan(2);
        table1.addCell(cell);

        cell = new Cell(new Chunk("   ??", new Font(songFont, 11.0F, 0)));
        cell.setColspan(3);
        table1.addCell(cell);
        cell = new Cell(new Chunk(unitInfo.getUnitLeader() == null ? "" : unitInfo.getUnitLeader(),
                new Font(songFont, 11.0F, 0)));
        cell.setColspan(4);
        table1.addCell(cell);

        table1.addCell(new Phrase(new Chunk("?/?", new Font(songFont, 11.0F, 0))));
        cell = new Cell(new Phrase(
                new Chunk(unitInfo.getDuty() == null ? "" : unitInfo.getDuty(), new Font(songFont, 11.0F, 0))));
        cell.setColspan(7);
        table1.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("?", new Font(songFont, 11.0F, 0))));
        cell.setColspan(3);
        table1.addCell(cell);
        cell = new Cell(new Chunk(unitInfo.getUnitTel() == null ? "" : unitInfo.getUnitTel(),
                new Font(songFont, 11.0F, 0)));
        cell.setColspan(4);
        table1.addCell(cell);

        table1.addCell(new Phrase(new Chunk("?", new Font(songFont, 11.0F, 0))));
        cell = new Cell(new Phrase(new Chunk(unitInfo.getUnitEmail() == null ? "" : unitInfo.getUnitEmail(),
                new Font(songFont, 11.0F, 0))));
        cell.setColspan(7);
        table1.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("06", new Font(songFont, 11.0F, 0))));
        setLocal(cell);
        table1.addCell(cell);
        cell = new Cell(new Chunk(unitInfo.getUnitDep() == null ? "" : unitInfo.getUnitDep(),
                new Font(songFont, 11.0F, 0)));
        cell.setColspan(15);
        table1.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("07?", new Font(songFont, 11.0F, 0))));
        setLocal(cell);
        cell.setRowspan(3);
        table1.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("   ??", new Font(songFont, 11.0F, 0))));
        cell.setColspan(3);
        table1.addCell(cell);
        cell = new Cell(new Chunk(unitInfo.getDepContact() == null ? "" : unitInfo.getDepContact(),
                new Font(songFont, 11.0F, 0)));
        cell.setColspan(4);
        table1.addCell(cell);

        table1.addCell(new Phrase(new Chunk("?/?", new Font(songFont, 11.0F, 0))));
        cell = new Cell(new Chunk(unitInfo.getDepDuty() == null ? "" : unitInfo.getDepDuty(),
                new Font(songFont, 11.0F, 0)));
        cell.setColspan(7);
        table1.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("?", new Font(songFont, 11.0F, 0))));
        cell.setColspan(3);
        table1.addCell(cell);
        cell = new Cell(new Chunk(unitInfo.getDepTel() == null ? "" : unitInfo.getDepTel(),
                new Font(songFont, 11.0F, 0)));
        cell.setColspan(4);
        table1.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("?", new Font(songFont, 11.0F, 0))));
        cell.setRowspan(2);
        table1.addCell(cell);
        cell = new Cell(new Chunk(unitInfo.getDepEmail() == null ? "" : unitInfo.getDepEmail(),
                new Font(songFont, 11.0F, 0)));
        cell.setColspan(7);
        cell.setRowspan(2);
        table1.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("?", new Font(songFont, 11.0F, 0))));
        cell.setColspan(3);
        table1.addCell(cell);
        cell = new Cell(new Chunk(unitInfo.getDepMobile() == null ? "" : unitInfo.getDepMobile(),
                new Font(songFont, 11.0F, 0)));
        cell.setColspan(4);
        table1.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("08", new Font(songFont, 11.0F, 0))));
        setLocal(cell);
        table1.addCell(cell);
        cell = new Cell("".equals(unitInfo.getSubordinate()) ? rightSign : blankSign);
        cell.add(new Chunk("1\t", new Font(songFont, 11.0F, 0)));
        cell.add("?".equals(unitInfo.getSubordinate()) ? rightSign : blankSign);
        cell.add(new Chunk("2?(?)\t", new Font(songFont, 11.0F, 0)));
        cell.add("".equals(unitInfo.getSubordinate()) ? rightSign : blankSign);
        cell.add(new Chunk("3(???)\t", new Font(songFont, 11.0F, 0)));
        cell.add(Chunk.NEWLINE);
        cell.add("".equals(unitInfo.getSubordinate()) ? rightSign : blankSign);
        cell.add(new Chunk("4(??)\t", new Font(songFont, 11.0F, 0)));
        cell.add("".equals(unitInfo.getSubordinate()) ? rightSign : blankSign);
        cell.add(new Chunk("9", new Font(songFont, 11.0F, 0)));
        cell.add(new Chunk(unitInfo.getOtherSub() != null ? unitInfo.getOtherSub() : "________",
                new Font(songFont, 11.0F, 4)));
        cell.setColspan(15);
        table1.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("09??", new Font(songFont, 11.0F, 0))));
        setLocal(cell);
        table1.addCell(cell);
        cell = new Cell("".equals(unitInfo.getUnitType()) ? rightSign : blankSign);
        cell.add(new Chunk("1\t\t", songfont_11));
        cell.add("".equals(unitInfo.getUnitType()) ? rightSign : blankSign);
        cell.add(new Chunk("2\t\t", songfont_11));
        cell.add("??".equals(unitInfo.getUnitType()) ? rightSign : blankSign);
        cell.add(new Chunk("3??\t\t", songfont_11));
        cell.add("?".equals(unitInfo.getUnitType()) ? rightSign : blankSign);
        cell.add(new Chunk("4?", songfont_11));
        cell.add(Chunk.NEWLINE);
        cell.add("".equals(unitInfo.getUnitType()) ? rightSign : blankSign);
        cell.add(new Chunk("9", songfont_11));
        cell.add(new Chunk(unitInfo.getOtherUnitType() != null ? unitInfo.getOtherUnitType() : "________",
                new Font(songFont, 11.0F, 4)));
        cell.setColspan(15);
        table1.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("10", songfont_11)));
        setLocal(cell);
        table1.addCell(cell);
        cell = new Cell("".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("11\t\t", songfont_11));

        cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("12\t", songfont_11));

        cell.add("???".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("13???", songfont_11));
        cell.add(Chunk.NEWLINE);

        cell.add("?".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("21?\t\t", songfont_11));

        cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("22\t", songfont_11));

        cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("23\t\t\t", songfont_11));

        cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("24", songfont_11));
        cell.add(Chunk.NEWLINE);

        cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("25\t\t", songfont_11));

        cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("26\t", songfont_11));

        cell.add("?".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("27?\t\t\t", songfont_11));

        cell.add("?".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("28?", songfont_11));
        cell.add(Chunk.NEWLINE);

        cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("31\t", songfont_11));

        cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("32\t", songfont_11));

        cell.add("?".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("33?\t", songfont_11));

        cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("34", songfont_11));
        cell.add(Chunk.NEWLINE);

        cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("35\t\t", songfont_11));

        cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("36\t", songfont_11));

        cell.add("?".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("37?\t\t\t", songfont_11));

        cell.add("?".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("38?", songfont_11));
        cell.add(Chunk.NEWLINE);

        cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("39\t\t", songfont_11));

        cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("40\t", songfont_11));

        cell.add("?".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("41?\t\t", songfont_11));

        cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("42", songfont_11));
        cell.add(Chunk.NEWLINE);

        cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("43\t\t", songfont_11));

        cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("44\t", songfont_11));

        cell.add("?".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("45?\t\t\t", songfont_11));

        cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("46", songfont_11));
        cell.add(Chunk.NEWLINE);

        cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("47\t\t", songfont_11));

        cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("48\t", songfont_11));

        cell.add("??".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("49??\t\t\t", songfont_11));

        cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("50", songfont_11));
        cell.add(Chunk.NEWLINE);

        cell.add("".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("51\t\t", songfont_11));

        cell.add("??".equals(unitInfo.getEmployment()) ? rightSign : blankSign);
        cell.add(new Chunk("52??\t", songfont_11));
        cell.add(Chunk.NEWLINE);

        cell.add("".equals(unitInfo.getOtherEmp()) ? rightSign : blankSign);
        cell.add(new Chunk("99", songfont_11));
        cell.add(new Chunk("".equals(unitInfo.getOtherEmp()) ? unitInfo.getOtherEmp() : "________"));
        cell.setColspan(15);
        table1.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("11?", songfont_11)));
        setLocal(cell);
        cell.setRowspan(2);
        table1.addCell(cell);
        cell = new Cell(new Phrase(new Chunk(countTol + "", songfont_11)));
        setLocal(cell);
        cell.setColspan(2);
        cell.setRowspan(2);
        table1.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("12?", songfont_11)));
        cell.setColspan(5);
        table1.addCell(cell);
        cell = new Cell(new Phrase(new Chunk(countSec + "", songfont_11)));
        setLocal(cell);
        cell.setColspan(1);
        table1.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("13?", songfont_11)));
        cell.setColspan(6);
        table1.addCell(cell);
        cell = new Cell(new Phrase(new Chunk(countThr + "", songfont_11)));
        cell.setColspan(1);
        setLocal(cell);
        table1.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("14?", songfont_11)));
        cell.setColspan(5);
        table1.addCell(cell);
        cell = new Cell(new Phrase(new Chunk(countThir + "", songfont_11)));
        cell.setColspan(1);
        setLocal(cell);
        table1.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("15?", songfont_11)));
        cell.setColspan(6);
        table1.addCell(cell);
        cell = new Cell(new Phrase(new Chunk("0", songfont_11)));
        cell.setColspan(1);
        setLocal(cell);
        table1.addCell(cell);

        document.add(table1);

        document.add(Chunk.NEXTPAGE);

        p = new Paragraph();
        p.setAlignment(1);
        p.add(new Chunk(" (" + rank.getSysInfoName() + ")?",
                new Font(songFont, 16.0F, 0)));
        document.add(p);

        Table table2 = new Table(14);
        table2.setWidth(120.0F);
        table2.setWidths(new int[] { 8, 13, 5, 12, 3, 8, 5, 5, 5, 13, 5, 5, 5, 5 });

        cell = new Cell(new Phrase(new Chunk("01??", songfont_11)));
        setLocal(cell);
        cell.setColspan(2);
        table2.addCell(cell);
        cell = new Cell(new Chunk(rank.getSysInfoName() == null ? "" : rank.getSysInfoName(), songfont_11));
        cell.setColspan(7);
        table2.addCell(cell);

        table2.addCell(new Phrase(new Chunk("02?", songfont_11)));
        cell = new Cell(new Chunk(rank.getSysInfoId() == null ? "" : rank.getSysInfoId(), songfont_11));
        cell.setColspan(4);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("03", songfont_11)));
        setLocal(cell);
        cell.setRowspan(2);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("", songfont_11)));
        setLocal(cell);
        table2.addCell(cell);
        cell = new Cell("1".equals(systemManager.getBusType()) ? rightSign : blankSign);
        cell.add(new Chunk("1\t", songfont_11));
        cell.add("2".equals(systemManager.getBusType()) ? rightSign : blankSign);
        cell.add(new Chunk("2\t", songfont_11));
        cell.add("3".equals(systemManager.getBusType()) ? rightSign : blankSign);
        cell.add(new Chunk("3?\t", songfont_11));
        cell.add("4".equals(systemManager.getBusType()) ? rightSign : blankSign);
        cell.add(new Chunk("4\t\n", songfont_11));
        cell.add("5".equals(systemManager.getBusType()) ? rightSign : blankSign);
        cell.add(new Chunk("5?\t", songfont_11));
        cell.add("9".equals(systemManager.getBusType()) ? rightSign : blankSign);
        cell.add(new Chunk("9", songfont_11));
        cell.add(new Chunk(
                systemManager.getOtherBusType() != null ? systemManager.getOtherBusType() : "________",
                songfontUnderLine_11));
        cell.setColspan(12);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("??", songfont_11)));
        setLocal(cell);
        table2.addCell(cell);
        cell = new Cell(new Chunk(systemManager.getBusDescription(), songfont_11));
        cell.setColspan(12);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("04?", songfont_11)));
        setLocal(cell);
        cell.setRowspan(2);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("?", songfont_11)));
        setLocal(cell);
        table2.addCell(cell);
        cell = new Cell("10".equals(systemManager.getSerArea()) ? rightSign : blankSign);
        cell.add(new Chunk("10\t", songfont_11));

        cell.add(new Chunk("11".equals(systemManager.getSerArea()) ? rightSign : blankSign));
        cell.add(new Chunk("11??", songfont_11));
        cell.add(new Chunk(systemManager.getProTotal() != null ? systemManager.getProTotal() + "" : "________",
                songfontUnderLine_11));
        cell.add(new Chunk("\t", songfont_11));

        cell.add("20".equals(systemManager.getSerArea()) ? rightSign : blankSign);
        cell.add(new Chunk("20??\t\n", songfont_11));

        cell.add("21".equals(systemManager.getSerArea()) ? rightSign : blankSign);
        cell.add(new Chunk("21? ", songfont_11));
        cell.add(
                new Chunk(systemManager.getCityTotal() != null ? systemManager.getCityTotal() + "" : "________",
                        songfontUnderLine_11));
        cell.add(new Chunk("\t", songfont_11));

        cell.add("30".equals(systemManager.getSerArea()) ? rightSign : blankSign);
        cell.add(new Chunk("30?\t", songfont_11));

        cell.add(new Chunk("99".equals(systemManager.getSerArea()) ? rightSign : blankSign));
        cell.add(new Chunk("99", songfont_11));
        cell.add(new Chunk(systemManager.getOtherArea() != null ? systemManager.getOtherArea() : "________",
                songfontUnderLine_11));
        cell.setColspan(12);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("?", songfont_11)));
        setLocal(cell);
        table2.addCell(cell);
        cell = new Cell("1".equals(systemManager.getSerObj()) ? rightSign : blankSign);
        cell.add(new Chunk("1??   ", songfont_11));
        cell.add("2".equals(systemManager.getSerObj()) ? rightSign : blankSign);
        cell.add(new Chunk("2   ", songfont_11));
        cell.add("3".equals(systemManager.getSerObj()) ? rightSign : blankSign);
        cell.add(new Chunk("3?   ", songfont_11));
        cell.add("9".equals(systemManager.getSerObj()) ? rightSign : blankSign);
        cell.add(new Chunk("9", songfont_11));
        cell.add(new Chunk(systemManager.getOtherObj() != null ? systemManager.getOtherObj() : "________",
                songfontUnderLine_11));
        cell.setColspan(12);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("05?", songfont_11)));
        setLocal(cell);
        cell.setRowspan(2);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("", songfont_11)));
        setLocal(cell);
        table2.addCell(cell);
        cell = new Cell("1".equals(rank.getRankCoveArea()) ? rightSign : blankSign);
        cell.add(new Chunk("1\t", songfont_11));
        cell.add("2".equals(rank.getRankCoveArea()) ? rightSign : blankSign);
        cell.add(new Chunk("2\t", songfont_11));
        cell.add("3".equals(rank.getRankCoveArea()) ? rightSign : blankSign);
        cell.add(new Chunk("3\t", songfont_11));
        cell.add("4".equals(rank.getRankCoveArea()) ? rightSign : blankSign);
        cell.add(new Chunk("9", songfont_11));
        cell.add(new Chunk(rank.getRankOthArea() != null ? rank.getRankOthArea() : "________",
                songfontUnderLine_11));
        cell.setColspan(12);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("", songfont_11)));
        setLocal(cell);
        table2.addCell(cell);
        cell = new Cell("1".equals(rank.getRankNetworkProp()) ? rightSign : blankSign);
        cell.add(new Chunk("1\t", songfont_11));
        cell.add("2".equals(rank.getRankNetworkProp()) ? rightSign : blankSign);
        cell.add(new Chunk("2?\t", songfont_11));
        cell.add("3".equals(rank.getRankNetworkProp()) ? rightSign : blankSign);
        cell.add(new Chunk("9", songfont_11));
        cell.add(new Chunk(rank.getRankOthNetworkProp() != null ? rank.getRankOthNetworkProp() : "________",
                songfontUnderLine_11));
        cell.setColspan(12);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("06?", songfont_11)));
        setLocal(cell);
        cell.setColspan(2);
        table2.addCell(cell);

        cell = new Cell("1".equals(rank.getRankSysConn()) ? rightSign : blankSign);
        cell.add(new Chunk("1\t", songfont_11));
        cell.add("2".equals(rank.getRankSysConn()) ? rightSign : blankSign);
        cell.add(new Chunk("2??\t\n", songfont_11));
        cell.add("3".equals(rank.getRankSysConn()) ? rightSign : blankSign);
        cell.add(new Chunk("3??\t", songfont_11));
        cell.add("4".equals(rank.getRankSysConn()) ? rightSign : blankSign);
        cell.add(new Chunk("9", songfont_11));
        cell.add(new Chunk(rank.getRankOtherSysConn() != null ? rank.getRankOtherSysConn() : "________",
                songfontUnderLine_11));
        cell.setColspan(12);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("07?", songfont_11)));
        cell.setColspan(2);
        cell.setRowspan(8);
        setLocal(cell);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("??", songfont_11)));
        setLocal(cell);
        cell.setRowspan(2);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("?", songfont_11)));
        setLocal(cell);
        cell.setRowspan(2);
        cell.setColspan(2);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("?", songfont_11)));
        setLocal(cell);
        cell.setRowspan(2);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("?", songfont_11)));
        setLocal(cell);
        cell.setColspan(8);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk(" ", songfont_11)));
        setLocal(cell);
        cell.setColspan(2);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk(" ", songfont_11)));
        setLocal(cell);
        cell.setColspan(2);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("?  ", songfont_11)));
        setLocal(cell);
        cell.setColspan(4);
        table2.addCell(cell);

        for (int i = 1; i <= 6; i++) {

            table2.addCell(new Phrase(new Chunk(i + "", songfont_11)));
            switch (i) {

            case 1:
                cell = new Cell(new Chunk("?", songfont_11));
                cell.setColspan(2);
                table2.addCell(cell);
                table2.addCell(new Phrase(new Chunk(rank.getRankSecCount(), songfont_11)));
                cell = new Cell(("100".equals(rank.getRankSecUse())) ? rightSign : blankSign);
                setLocal(cell);
                cell.setColspan(2);
                table2.addCell(cell);
                cell = new Cell(("0".equals(rank.getRankSecUse())) ? rightSign : blankSign);
                setLocal(cell);
                cell.setColspan(2);
                table2.addCell(cell);
                cell = new Cell(("3".equals(rank.getRankSecUse())) ? rightSign : blankSign);
                setLocal(cell);
                cell.add(new Chunk(
                        (rank.getPartRankSecUse() != null ? rank.getPartRankSecUse() : "________") + "%",
                        songfontUnderLine_11));
                cell.setColspan(4);
                table2.addCell(cell);
                break;

            case 2:
                cell = new Cell(new Chunk("?", songfont_11));
                cell.setColspan(2);
                table2.addCell(cell);
                table2.addCell(new Phrase(new Chunk(rank.getRankNetCount(), songfont_11)));
                cell = new Cell(("100".equals(rank.getRankNetUse())) ? rightSign : blankSign);
                setLocal(cell);
                cell.setColspan(2);
                table2.addCell(cell);
                cell = new Cell(("0".equals(rank.getRankNetUse())) ? rightSign : blankSign);
                setLocal(cell);
                cell.setColspan(2);
                table2.addCell(cell);
                cell = new Cell(("3".equals(rank.getRankNetUse())) ? rightSign : blankSign);
                setLocal(cell);
                cell.add(new Chunk(
                        (rank.getPartRankNetUse() != null ? rank.getPartRankNetUse() : "________") + "%",
                        songfontUnderLine_11));
                cell.setColspan(4);
                table2.addCell(cell);
                break;
            case 3:
                cell = new Cell(new Chunk("?", songfont_11));
                cell.setColspan(2);
                table2.addCell(cell);
                table2.addCell(new Phrase(new Chunk(rank.getRankSysCount(), songfont_11)));
                cell = new Cell(("100".equals(rank.getRankSysUse())) ? rightSign : blankSign);
                setLocal(cell);
                cell.setColspan(2);
                table2.addCell(cell);
                cell = new Cell(("0".equals(rank.getRankSysUse())) ? rightSign : blankSign);
                setLocal(cell);
                cell.setColspan(2);
                table2.addCell(cell);
                cell = new Cell(("3".equals(rank.getRankSysUse())) ? rightSign : blankSign);
                setLocal(cell);
                cell.add(new Chunk(
                        (rank.getPartRankSysUse() != null ? rank.getPartRankSysUse() : "________") + "%",
                        songfontUnderLine_11));
                cell.setColspan(4);
                table2.addCell(cell);
                break;
            case 4:
                cell = new Cell(new Chunk("?", songfont_11));
                cell.setColspan(2);
                table2.addCell(cell);
                table2.addCell(new Phrase(new Chunk(rank.getRankSqlCount(), songfont_11)));
                cell = new Cell(("100".equals(rank.getRankSqlUse())) ? rightSign : blankSign);
                setLocal(cell);
                cell.setColspan(2);
                table2.addCell(cell);
                cell = new Cell(("0".equals(rank.getRankSqlUse())) ? rightSign : blankSign);
                setLocal(cell);
                cell.setColspan(2);
                table2.addCell(cell);
                cell = new Cell(("3".equals(rank.getRankSqlUse())) ? rightSign : blankSign);
                setLocal(cell);
                cell.add(new Chunk(
                        (rank.getPartRankSqlUse() != null ? rank.getPartRankSqlUse() : "________") + "%",
                        songfontUnderLine_11));
                cell.setColspan(4);
                table2.addCell(cell);
                break;
            case 5:
                cell = new Cell(new Chunk("?", songfont_11));
                cell.setColspan(2);
                table2.addCell(cell);
                table2.addCell(new Phrase(new Chunk(rank.getRankSerCount(), songfont_11)));
                cell = new Cell(("100".equals(rank.getRankSerUse())) ? rightSign : blankSign);
                setLocal(cell);
                cell.setColspan(2);
                table2.addCell(cell);
                cell = new Cell(("0".equals(rank.getRankSerUse())) ? rightSign : blankSign);
                setLocal(cell);
                cell.setColspan(2);
                table2.addCell(cell);
                cell = new Cell(("3".equals(rank.getRankSerUse())) ? rightSign : blankSign);
                setLocal(cell);
                cell.add(new Chunk(
                        (rank.getPartRankSerUse() != null ? rank.getPartRankSerUse() : "________") + "%",
                        songfontUnderLine_11));
                cell.setColspan(4);
                table2.addCell(cell);
                break;
            case 6:
                cell = new Cell(new Chunk("", songfont_11));
                cell.add(new Chunk((rank.getRankOthProd() != null ? rank.getRankOthProd() : "________"),
                        songfontUnderLine_11));
                cell.setColspan(2);
                table2.addCell(cell);
                table2.addCell(new Phrase(new Chunk(rank.getRankOthProdCount(), songfont_11)));
                cell = new Cell(("100".equals(rank.getRankOthProdUse())) ? rightSign : blankSign);
                setLocal(cell);
                cell.setColspan(2);
                table2.addCell(cell);
                cell = new Cell(("0".equals(rank.getRankOthProdUse())) ? rightSign : blankSign);
                setLocal(cell);
                cell.setColspan(2);
                table2.addCell(cell);
                cell = new Cell(("3".equals(rank.getRankOthProdUse())) ? rightSign : blankSign);
                setLocal(cell);
                cell.add(new Chunk(
                        (rank.getPartRankOthProdUse() != null ? rank.getPartRankOthProdUse() : "________")
                                + "%",
                        songfontUnderLine_11));
                cell.setColspan(4);
                table2.addCell(cell);
                break;

            }

        }

        cell = new Cell(new Phrase(new Chunk("08?", songfont_11)));
        cell.setColspan(2);
        cell.setRowspan(10);
        setLocal(cell);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("??", songfont_11)));
        setLocal(cell);
        cell.setRowspan(2);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("?", songfont_11)));
        setLocal(cell);
        cell.setRowspan(2);
        cell.setColspan(3);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("?", songfont_11)));
        setLocal(cell);
        cell.setColspan(8);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("??", songfont_11)));
        setLocal(cell);
        cell.setColspan(3);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("? ", songfont_11)));
        setLocal(cell);
        cell.setColspan(2);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("?", songfont_11)));
        setLocal(cell);
        cell.setColspan(3);
        table2.addCell(cell);

        table2.addCell(new Phrase(new Chunk("1", songfont_11)));
        table2.addCell(new Phrase(new Chunk("", songfont_11)));
        cell = new Cell("1".equals(rank.getRankIfGradeEval()) ? rightSign : blankSign);
        setLocal(cell);
        cell.add(new Chunk("", new Font(songFont, 9.0F, 0)));
        cell.add(("0".equals(rank.getRankIfGradeEval())) ? rightSign : blankSign);
        setLocal(cell);
        cell.add(new Chunk("", new Font(songFont, 9.0F, 0)));
        cell.setColspan(2);
        table2.addCell(cell);
        cell = new Cell("1".equals(rank.getRankSerGradeType()) ? rightSign : blankSign);
        setLocal(cell);
        cell.setColspan(3);
        table2.addCell(cell);
        cell = new Cell("2".equals(rank.getRankSerGradeType()) ? rightSign : blankSign);
        setLocal(cell);
        cell.setColspan(2);
        table2.addCell(cell);
        cell = new Cell("3".equals(rank.getRankSerGradeType()) ? rightSign : blankSign);
        setLocal(cell);
        cell.setColspan(3);
        table2.addCell(cell);

        table2.addCell(new Phrase(new Chunk("2", songfont_11)));
        table2.addCell(new Phrase(new Chunk("", songfont_11)));
        cell = new Cell("1".equals(rank.getRankIfRiskEval()) ? rightSign : blankSign);
        setLocal(cell);
        cell.add(new Chunk("", new Font(songFont, 9.0F, 0)));
        cell.add(("0".equals(rank.getRankIfRiskEval())) ? rightSign : blankSign);
        setLocal(cell);
        cell.add(new Chunk("", new Font(songFont, 9.0F, 0)));
        cell.setColspan(2);
        table2.addCell(cell);
        cell = new Cell("1".equals(rank.getRankSerRiskType()) ? rightSign : blankSign);
        setLocal(cell);
        cell.setColspan(3);
        table2.addCell(cell);
        cell = new Cell("2".equals(rank.getRankSerRiskType()) ? rightSign : blankSign);
        setLocal(cell);
        cell.setColspan(2);
        table2.addCell(cell);
        cell = new Cell("3".equals(rank.getRankSerRiskType()) ? rightSign : blankSign);
        setLocal(cell);
        cell.setColspan(3);
        table2.addCell(cell);

        table2.addCell(new Phrase(new Chunk("3", songfont_11)));
        table2.addCell(new Phrase(new Chunk("???", songfont_11)));
        cell = new Cell("1".equals(rank.getRankIfSuffReco()) ? rightSign : blankSign);
        setLocal(cell);
        cell.add(new Chunk("", new Font(songFont, 9.0F, 0)));
        cell.add(("0".equals(rank.getRankIfSuffReco())) ? rightSign : blankSign);
        setLocal(cell);
        cell.add(new Chunk("", new Font(songFont, 9.0F, 0)));
        cell.setColspan(2);
        table2.addCell(cell);
        cell = new Cell("1".equals(rank.getRankIfSuffRecoType()) ? rightSign : blankSign);
        setLocal(cell);
        cell.setColspan(3);
        table2.addCell(cell);
        cell = new Cell("2".equals(rank.getRankIfSuffRecoType()) ? rightSign : blankSign);
        setLocal(cell);
        cell.setColspan(2);
        table2.addCell(cell);
        cell = new Cell("3".equals(rank.getRankIfSuffRecoType()) ? rightSign : blankSign);
        setLocal(cell);
        cell.setColspan(3);
        table2.addCell(cell);

        table2.addCell(new Phrase(new Chunk("4", songfont_11)));
        table2.addCell(new Phrase(new Chunk("?", songfont_11)));
        cell = new Cell("1".equals(rank.getRankIfResponse()) ? rightSign : blankSign);
        setLocal(cell);
        cell.add(new Chunk("", new Font(songFont, 9.0F, 0)));
        cell.add(("0".equals(rank.getRankIfResponse())) ? rightSign : blankSign);
        setLocal(cell);
        cell.add(new Chunk("", new Font(songFont, 9.0F, 0)));
        cell.setColspan(2);
        table2.addCell(cell);
        cell = new Cell("1".equals(rank.getRankResponseType()) ? rightSign : blankSign);
        setLocal(cell);
        cell.setColspan(3);
        table2.addCell(cell);
        cell = new Cell("2".equals(rank.getRankResponseType()) ? rightSign : blankSign);
        setLocal(cell);
        cell.setColspan(2);
        table2.addCell(cell);
        cell = new Cell("3".equals(rank.getRankResponseType()) ? rightSign : blankSign);
        setLocal(cell);
        cell.setColspan(3);
        table2.addCell(cell);

        table2.addCell(new Phrase(new Chunk("5", songfont_11)));
        table2.addCell(new Phrase(new Chunk("?", songfont_11)));
        cell = new Cell("1".equals(rank.getRankIfSysInte()) ? rightSign : blankSign);
        setLocal(cell);
        cell.add(new Chunk("", new Font(songFont, 9.0F, 0)));
        cell.add(("0".equals(rank.getRankIfSysInte())) ? rightSign : blankSign);
        setLocal(cell);
        cell.add(new Chunk("", new Font(songFont, 9.0F, 0)));
        cell.setColspan(2);
        table2.addCell(cell);
        cell = new Cell("1".equals(rank.getRankSysInteType()) ? rightSign : blankSign);
        setLocal(cell);
        cell.setColspan(3);
        table2.addCell(cell);
        cell = new Cell("2".equals(rank.getRankSysInteType()) ? rightSign : blankSign);
        setLocal(cell);
        cell.setColspan(2);
        table2.addCell(cell);
        cell = new Cell("3".equals(rank.getRankSysInteType()) ? rightSign : blankSign);
        setLocal(cell);
        cell.setColspan(3);
        table2.addCell(cell);

        table2.addCell(new Phrase(new Chunk("6", songfont_11)));
        table2.addCell(new Phrase(new Chunk("", songfont_11)));
        cell = new Cell("1".equals(rank.getRankIfSecCon()) ? rightSign : blankSign);
        setLocal(cell);
        cell.add(new Chunk("", new Font(songFont, 9.0F, 0)));
        cell.add(("0".equals(rank.getRankIfSecCon())) ? rightSign : blankSign);
        setLocal(cell);
        cell.add(new Chunk("", new Font(songFont, 9.0F, 0)));
        cell.setColspan(2);
        table2.addCell(cell);
        cell = new Cell("1".equals(rank.getRankSecConypeType()) ? rightSign : blankSign);
        setLocal(cell);
        cell.setColspan(3);
        table2.addCell(cell);
        cell = new Cell("2".equals(rank.getRankSecConypeType()) ? rightSign : blankSign);
        setLocal(cell);
        cell.setColspan(2);
        table2.addCell(cell);
        cell = new Cell("3".equals(rank.getRankSecConypeType()) ? rightSign : blankSign);
        setLocal(cell);
        cell.setColspan(3);
        table2.addCell(cell);

        table2.addCell(new Phrase(new Chunk("7", songfont_11)));
        table2.addCell(new Phrase(new Chunk("", songfont_11)));
        cell = new Cell("1".equals(rank.getRankIfSecTrain()) ? rightSign : blankSign);
        setLocal(cell);
        cell.add(new Chunk("", new Font(songFont, 9.0F, 0)));
        cell.add(("0".equals(rank.getRankIfSecTrain())) ? rightSign : blankSign);
        setLocal(cell);
        cell.add(new Chunk("", new Font(songFont, 9.0F, 0)));
        cell.setColspan(2);
        table2.addCell(cell);
        cell = new Cell("1".equals(rank.getRankSecTrainType()) ? rightSign : blankSign);
        setLocal(cell);
        cell.setColspan(3);
        table2.addCell(cell);
        cell = new Cell("2".equals(rank.getRankSecTrainType()) ? rightSign : blankSign);
        setLocal(cell);
        cell.setColspan(2);
        table2.addCell(cell);
        cell = new Cell("3".equals(rank.getRankSecTrainType()) ? rightSign : blankSign);
        setLocal(cell);
        cell.setColspan(3);
        table2.addCell(cell);

        table2.addCell(new Phrase(new Chunk("8", songfont_11)));
        cell = new Cell(new Chunk("", songfont_11));
        cell.add(new Chunk((rank.getRankOthSerName() != null ? rank.getRankOthSerName() : "________"),
                songfontUnderLine_11));
        table2.addCell(cell);
        cell = new Cell("1".equals(rank.getRankIfOthSer()) ? rightSign : blankSign);
        setLocal(cell);
        cell.add(new Chunk("", new Font(songFont, 9.0F, 0)));
        cell.add(("0".equals(rank.getRankIfOthSer())) ? rightSign : blankSign);
        setLocal(cell);
        cell.add(new Chunk("", new Font(songFont, 9.0F, 0)));
        cell.setColspan(2);
        table2.addCell(cell);
        cell = new Cell("1".equals(rank.getRankOthUseType()) ? rightSign : blankSign);
        setLocal(cell);
        cell.setColspan(3);
        table2.addCell(cell);
        cell = new Cell("2".equals(rank.getRankOthUseType()) ? rightSign : blankSign);
        setLocal(cell);
        cell.setColspan(2);
        table2.addCell(cell);
        cell = new Cell("3".equals(rank.getRankOthUseType()) ? rightSign : blankSign);
        setLocal(cell);
        cell.setColspan(3);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("09????", songfont_11)));
        cell.setColspan(2);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk(rank.getRankEvalUnitName(), songfont_11)));
        cell.setColspan(12);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("10?", songfont_11)));
        cell.setColspan(2);
        table2.addCell(cell);

        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
        cell = new Cell(new Phrase(new Chunk(format.format(rank.getRankUseDate()), songfont_11)));
        cell.setColspan(12);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("11?", songfont_11)));
        cell.setColspan(2);
        table2.addCell(cell);

        cell = new Cell("1".equals(rank.getRankFlag()) ? rightSign : blankSign);
        cell.add(new Chunk("", songfont_11));
        cell.add("0".equals(rank.getRankFlag()) ? rightSign : blankSign);
        cell.add(new Chunk("?", songfont_11));
        cell.setColspan(12);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("12??", songfont_11)));
        cell.setColspan(2);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk(rank.getRankParentSysName(), songfont_11)));
        cell.setColspan(12);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("13????", songfont_11)));
        cell.setColspan(2);
        table2.addCell(cell);

        cell = new Cell(new Phrase(new Chunk(rank.getRankParentUnitName(), songfont_11)));
        cell.setColspan(12);
        table2.addCell(cell);

        document.add(table2);
        document.add(Chunk.NEXTPAGE);

        p = new Paragraph();
        p.setAlignment(1);
        p.add(new Chunk("(" + systemManager.getSysName() + ")?",
                new Font(songFont, 16.0F, 0)));
        document.add(p);

        Table table3 = new Table(2);
        table3.setWidth(110.0F);
        table3.setWidths(new int[] { 40, 70 });

        cell = new Cell(new Phrase(new Chunk("01??", songfont_11)));
        table3.addCell(cell);

        cell = new Cell("".equals(rank.getRankGrade()) ? rightSign : blankSign);
        cell.add(new Chunk("", songfont_11));
        cell.add("".equals(rank.getRankGrade()) ? rightSign : blankSign);
        cell.add(new Chunk("", songfont_11));
        cell.add("".equals(rank.getRankGrade()) ? rightSign : blankSign);
        cell.add(new Chunk("", songfont_11));
        cell.add("".equals(rank.getRankGrade()) ? rightSign : blankSign);
        cell.add(new Chunk("", songfont_11));
        cell.add("".equals(rank.getRankGrade()) ? rightSign : blankSign);
        cell.add(new Chunk("", songfont_11));
        table3.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("02", songfont_11)));
        table3.addCell(cell);
        cell = new Cell(new Chunk(format.format(rank.getRankTime()), songfont_11));
        table3.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("03", songfont_11)));
        table3.addCell(cell);
        cell = new Cell(new Phrase(
                new Chunk("1".equals(rank.getRankJudge()) ? "" : "", songfont_11)));
        table3.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("04?", songfont_11)));
        table3.addCell(cell);
        cell = new Cell("1".equals(rank.getRankIsDep()) ? rightSign : blankSign);
        cell.add(new Chunk("", songfont_11));
        cell.add("0".equals(rank.getRankIsDep()) ? rightSign : blankSign);
        cell.add(new Chunk("", songfont_11));
        table3.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("05??", songfont_11)));
        table3.addCell(cell);
        cell = new Cell(
                new Phrase(new Chunk(rank.getRankDepName() == null ? "" : rank.getRankDepName(), songfont_11)));
        table3.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("06", songfont_11)));
        table3.addCell(cell);
        cell = new Cell("1".equals(rank.getRankDepJudge()) ? rightSign : blankSign);
        cell.add(new Chunk("", songfont_11));
        cell.add("0".equals(rank.getRankDepJudge()) ? rightSign : blankSign);
        cell.add(new Chunk("", songfont_11));
        table3.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("07", songfont_11)));
        table3.addCell(cell);
        cell = new Cell(new Phrase(new Chunk("1".equals(rank.getRankDoc()) ? rightSign : blankSign)));
        cell.add(new Chunk("", songfont_11));
        cell.add("0".equals(rank.getRankDoc()) ? rightSign : blankSign);
        cell.add(new Chunk("\t", songfont_11));
        cell.add(new Chunk("??" + (rank.getRankAccess() == null ? "" : rank.getRankAccess()),
                songfont_11));
        table3.addCell(cell);

        cell = new Cell(new Phrase(new Chunk("", songfont_11)));
        cell.add(new Chunk(rank.getRankInformant()));
        table3.addCell(cell);
        cell = new Cell(new Phrase(new Chunk("", songfont_11)));
        cell.add(new Chunk(format.format(rank.getRankDate())));
        table3.addCell(cell);

        document.add(table3);
        p = new Paragraph();
        p.setAlignment(1);
        p.add(new Chunk(
                "                                           ",
                songfont_11));
        document.add(p);
        document.add(Chunk.NEXTPAGE);

        p = new Paragraph();
        p.setAlignment(1);
        p.add(new Chunk(" " + systemManager.getSysName()
                + " ??????", songfont_11));
        document.add(p);
        if (null == null) {
            Table table4 = new Table(2);
            table4.setWidth(110.0F);
            table4.setWidths(new int[] { 40, 70 });

            table4.addCell(new Phrase(new Chunk("01?", songfont_11)));
            cell = new Cell("1".equals(rank.getRankTopStruct()) ? rightSign : blankSign);
            cell.add(new Chunk("", songfont_11));
            cell.add("0".equals(rank.getRankTopStruct()) ? rightSign : blankSign);
            cell.add(new Chunk("\t??", songfont_11));
            cell.add(new Chunk(rank.getRankTopRelAcc() != null ? rank.getRankTopRelAcc() : "________",
                    songfont_11));
            table4.addCell(cell);

            table4.addCell(new Phrase(new Chunk("02??", songfont_11)));

            cell = new Cell("1".equals(rank.getRankSysManage()) ? rightSign : blankSign);
            cell.add(new Chunk("", songfont_11));
            cell.add("0".equals(rank.getRankSysManage()) ? rightSign : blankSign);
            cell.add(new Chunk("\t??", songfont_11));
            cell.add(new Chunk(rank.getRankSysManRel() != null ? rank.getRankSysManRel() : "________",
                    songfont_11));
            table4.addCell(cell);

            table4.addCell(new Phrase(new Chunk(
                    "03?", songfont_11)));
            cell = new Cell("1".equals(rank.getRankSysPlan()) ? rightSign : blankSign);
            cell.add(new Chunk("", songfont_11));
            cell.add("0".equals(rank.getRankSysPlan()) ? rightSign : blankSign);
            cell.add(new Chunk("\t??", songfont_11));
            cell.add(new Chunk(rank.getRankSysPlanRel() != null ? rank.getRankSysPlanRel() : "________",
                    songfont_11));

            table4.addCell(cell);

            table4.addCell(new Phrase(new Chunk(
                    "04???????", songfont_11)));
            cell = new Cell("1".equals(rank.getRankSysLicense()) ? rightSign : blankSign);
            cell.add(new Chunk("", songfont_11));
            cell.add("0".equals(rank.getRankSysLicense()) ? rightSign : blankSign);
            cell.add(new Chunk("\t??", songfont_11));
            cell.add(new Chunk(rank.getRankSysLiceRel() != null ? rank.getRankSysLiceRel() : "________",
                    songfont_11));
            table4.addCell(cell);

            table4.addCell(new Phrase(new Chunk("05", songfont_11)));
            cell = new Cell("1".equals(rank.getRankSysReport()) ? rightSign : blankSign);
            cell.add(new Chunk("", songfont_11));
            cell.add("0".equals(rank.getRankSysReport()) ? rightSign : blankSign);
            cell.add(new Chunk("\t??", songfont_11));
            cell.add(new Chunk(rank.getRankSysReportRel() != null ? rank.getRankSysReportRel() : "________",
                    songfont_11));
            table4.addCell(cell);

            table4.addCell(new Phrase(new Chunk("06", songfont_11)));
            cell = new Cell("1".equals(rank.getRankPeerRev()) ? rightSign : blankSign);
            cell.add(new Chunk("", songfont_11));
            cell.add("0".equals(rank.getRankPeerRev()) ? rightSign : blankSign);
            cell.add(new Chunk("\t??", songfont_11));
            cell.add(new Chunk(rank.getRankPeerRevRel() != null ? rank.getRankPeerRevRel() : "________",
                    songfont_11));
            table4.addCell(cell);

            table4.addCell(new Phrase(new Chunk("07??", songfont_11)));
            cell = new Cell("1".equals(rank.getRankSuperOpin()) ? rightSign : blankSign);
            cell.add(new Chunk("", songfont_11));
            cell.add("0".equals(rank.getRankSuperOpin()) ? rightSign : blankSign);
            cell.add(new Chunk("\t??", songfont_11));
            cell.add(new Chunk(rank.getRankSuperOpinRel() != null ? rank.getRankSuperOpinRel() : "________",
                    songfont_11));
            table4.addCell(cell);

            document.add(table4);
            document.close();
        }
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (DocumentException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return 1;

}

From source file:de.maklerpoint.office.Schnittstellen.PDF.ExportListePDF.java

License:Open Source License

public void write() throws DocumentException, FileNotFoundException {

    SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy HH:mm");

    Document doc = null;/*from  ww  w .  j ava  2 s  .com*/

    if (titles.length > 7)
        doc = new Document(PageSize.A4.rotate(), 20, 20, 20, 20);
    else
        doc = new Document(PageSize.A4, 20, 20, 20, 20);

    PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream(filename));
    doc.addAuthor("MaklerPoint - www.maklerpoint.de");
    doc.addCreator("MaklerPoint - www.maklerpoint.de");
    doc.addCreationDate();
    doc.addTitle(title);

    doc.open();

    doc.add(new Paragraph(title, FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, Color.BLACK)));

    Table t = new Table(titles.length, data.length + 1);
    t.setPadding(3);
    t.setSpacing(0);
    t.setBorderWidth(1);

    for (int i = 0; i < titles.length; i++) {
        Cell c1 = new Cell(titles[i]);
        c1.setHeader(true);
        t.addCell(c1);
    }
    t.endHeaders();

    for (int i = 0; i < data.length; i++) {
        for (int j = 0; j < data[i].length; j++) {
            Cell c1 = null;
            if (data[i][j] != null)
                c1 = new Cell(data[i][j].toString());
            else
                c1 = new Cell("");
            t.addCell(c1);
        }
    }

    doc.add(t);

    if (footer == null) {
        doc.add(new Paragraph(
                ("Export " + title + " - Genereriert am " + df.format(new Date(System.currentTimeMillis())))
                        + " von MaklerPoint",
                FontFactory.getFont(FontFactory.TIMES, 10, Font.NORMAL, Color.black)));
    } else {
        doc.add(new Paragraph(footer, FontFactory.getFont(FontFactory.TIMES, 10, Font.NORMAL, Color.black)));
    }

    doc.close();
}

From source file:include.nseer_cookie.MakePdf.java

License:Open Source License

public void make(String database, String tablename, String sql1, String sql2, String filename, int everypage,
        HttpSession session) {/*from  ww w  .  java  2  s  .c  o m*/
    try {

        nseer_db aaa = new nseer_db(database);
        nseer_db demo_db = new nseer_db(database);

        ServletContext context = session.getServletContext();
        String path = context.getRealPath("/");

        Masking reader = new Masking(configFile);
        Vector columnNames = new Vector();
        Vector tables = reader.getTableNicks();
        Iterator loop = tables.iterator();
        while (loop.hasNext()) {
            String tablenick = (String) loop.next();
            columnNames = reader.getColumnNames(tablenick);
        }

        int cpage = 1; //? 

        int spage = 1;
        int ipage = everypage;
        String pagesql = sql1;

        //? 
        ResultSet pagers = demo_db.executeQuery(pagesql);
        pagers.next();
        int allCol = pagers.getInt("A");

        allpage = (int) Math.ceil((allCol + ipage - 1) / ipage);
        //
        for (int m = 1; m <= allpage; m++) {
            spage = (m - 1) * ipage;
            String sql = sql2 + " limit " + spage + "," + ipage;

            ResultSet bbb = aaa.executeQuery(sql);
            //ResultSetMetaData tt=bbb.getMetaData();       //
            int b = columnNames.size(); //
            int a = 0;
            while (bbb.next()) {
                a++;
            } //
            bbb.first(); //    ??
            Rectangle rectPageSize = new Rectangle(PageSize.A4);// 
            rectPageSize = rectPageSize.rotate();
            Document document = new Document(rectPageSize, 20, 20, 20, 20); //? Document
            PdfWriter writer = PdfWriter.getInstance(document,
                    new FileOutputStream(path + filename + m + ".pdf")); //?PDF??
            document.open(); //
            BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); //?
            com.lowagie.text.Font FontChinese = new com.lowagie.text.Font(bfChinese, 8,
                    com.lowagie.text.Font.NORMAL); //

            Paragraph title1 = new Paragraph("nseer ERP",
                    FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLDITALIC));
            Chapter chapter1 = new Chapter(title1, 1); // ? 
            chapter1.setNumberDepth(0);

            Paragraph title11 = new Paragraph(tablename,
                    FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD));
            Section section1 = chapter1.addSection(title11); //?                                                                                            

            Table t = new Table(b, a); // ? 
            t.setPadding(1); //  
            t.setSpacing(0); //  ?
            t.setBorderWidth(1); //

            do { //
                 //
                for (int k = 0; k < b; k++) { //
                    Cell cell = new Cell(
                            new Paragraph(bbb.getString((String) columnNames.elementAt(k)), FontChinese)); //?                                    //
                    t.addCell(cell); //   ?
                    //
                } //
            } while (bbb.next()); //

            section1.add(t); //
            document.add(chapter1); // 
            document.close();

        } // ?
    } catch (Exception pp) {
        pp.printStackTrace();
    }
}

From source file:opisiame.controller.gestion_resultat.Choix_exportController.java

@FXML
public void pdf_export() {
    File pdf_file = choix_chemin_enregistrement("PDF files (*.pdf)", "*.pdf");

    if (onglet_actif.equals("questions")) {

        if (pdf_file != null) {
            Document document = new Document(PageSize.A4);
            try {
                PdfWriter.getInstance(document, new FileOutputStream(pdf_file));
                document.open();/*w w w.j av  a 2  s  .  c o m*/
                document.add(new Paragraph("Rsultat Quiz"));

                Table tableau = new Table(6, reponse_questions.size());
                tableau.setAutoFillEmptyCells(true);
                tableau.setPadding(2);

                Cell cell = new Cell("Question");
                cell.setHeader(true);
                tableau.addCell(cell);

                cell = new Cell("Pourcentage reponse A");
                cell.setHeader(true);
                tableau.addCell(cell);

                cell = new Cell("Pourcentage reponse B");
                cell.setHeader(true);
                tableau.addCell(cell);

                cell = new Cell("Pourcentage reponse C");
                cell.setHeader(true);
                tableau.addCell(cell);

                cell = new Cell("Pourcentage reponse D");
                cell.setHeader(true);
                tableau.addCell(cell);

                cell = new Cell("Pourcentage bonne rponse");
                cell.setHeader(true);
                tableau.addCell(cell);

                tableau.endHeaders();
                tableau.setWidth(100);
                fill_data_pdf(tableau);
                document.add(tableau);
            } catch (DocumentException | IOException de) {
                de.printStackTrace();
            }
            document.close();
        }

    } else if (onglet_actif.equals("eleves")) {

        if (pdf_file != null) {
            Document document = new Document(PageSize.A4);
            try {
                PdfWriter.getInstance(document, new FileOutputStream(pdf_file));
                document.open();
                document.add(new Paragraph("Rsultats des tudiants"));

                Table tableau = new Table(5, resultats_eleves.size());
                tableau.setAutoFillEmptyCells(true);
                tableau.setPadding(2);

                Cell cell = new Cell("Nom");
                cell.setHeader(true);
                tableau.addCell(cell);

                cell = new Cell("Prnom");
                cell.setHeader(true);
                tableau.addCell(cell);

                cell = new Cell("N tudiant");
                cell.setHeader(true);
                tableau.addCell(cell);

                cell = new Cell("Note");
                cell.setHeader(true);
                tableau.addCell(cell);

                cell = new Cell("Pourcentage");
                cell.setHeader(true);
                tableau.addCell(cell);

                tableau.endHeaders();
                tableau.setWidth(100);
                fill_data_pdf(tableau);
                document.add(tableau);
            } catch (DocumentException | IOException de) {
                de.printStackTrace();
            }
            document.close();
        }
    } else if (onglet_actif.equals("eleves_pas_num")) {

        if (pdf_file != null) {
            Document document = new Document(PageSize.A4);
            try {
                PdfWriter.getInstance(document, new FileOutputStream(pdf_file));
                document.open();
                document.add(new Paragraph("Rsultats des tudiants"));

                Table tableau = new Table(4, resultats_eleves.size());
                tableau.setAutoFillEmptyCells(true);
                tableau.setPadding(2);

                Cell cell = new Cell("Nom");
                cell.setHeader(true);
                tableau.addCell(cell);

                cell = new Cell("Prnom");
                cell.setHeader(true);
                tableau.addCell(cell);

                cell = new Cell("Note");
                cell.setHeader(true);
                tableau.addCell(cell);

                cell = new Cell("Pourcentage");
                cell.setHeader(true);
                tableau.addCell(cell);

                tableau.endHeaders();
                tableau.setWidth(100);
                fill_data_pdf(tableau);
                document.add(tableau);
            } catch (DocumentException | IOException de) {
                de.printStackTrace();
            }
            document.close();
        }
    }

    close_window();
}

From source file:org.activityinfo.server.report.renderer.itext.ItextPivotTableRenderer.java

License:Open Source License

@Override
public void render(DocWriter writer, Document document, PivotTableReportElement element)
        throws DocumentException {

    document.add(ThemeHelper.elementTitle(element.getTitle()));
    ItextRendererHelper.addFilterDescription(document, element.getContent().getFilterDescriptions());
    ItextRendererHelper.addDateFilterDescription(document, element.getFilter().getDateRange());
    PivotTableData data = element.getContent().getData();

    if (data.isEmpty()) {
        document.add(new Paragraph("Aucune Donnes")); // TODO: i18n

    } else {/*  ww w.j a v a2s . c  om*/
        int colDepth = data.getRootColumn().getDepth();
        List<PivotTableData.Axis> colLeaves = data.getRootColumn().getLeaves();
        int colBreadth = colLeaves.size();

        Table table = new Table(colBreadth + 1, 1);
        table.setUseVariableBorders(true);
        table.setWidth(100.0f);
        table.setWidths(calcColumnWidths(document, data, colLeaves));
        table.setBorderWidth(0);

        // first write the column headers

        for (int depth = 1; depth <= colDepth; ++depth) {

            if (depth == 1) {
                Cell cell = ThemeHelper.cornerCell();
                cell.setRowspan(colDepth);
                table.addCell(cell);
            }

            List<PivotTableData.Axis> columns = data.getRootColumn().getDescendantsAtDepth(depth);
            for (PivotTableData.Axis column : columns) {
                Cell cell = ThemeHelper.columnHeaderCell(column.getLabel(), column.isLeaf());
                cell.setColspan(Math.max(1, column.getLeaves().size()));
                table.addCell(cell);
            }

        }
        table.endHeaders();

        for (PivotTableData.Axis row : data.getRootRow().getChildren()) {
            writeRow(table, row, colLeaves, 0);
        }
        document.add(table);
    }
}