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

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

Introduction

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

Prototype

public void setBorderWidthLeft(float borderWidthLeft) 

Source Link

Document

Sets the width of the left border.

Usage

From source file:airportpainter.util.AirportPainter.java

License:Open Source License

private void createSheetsRunways(Airport airport, Document document) {
    notifyAction("createSheetsRunways");

    PdfPTable table = new PdfPTable(6);

    // titles//from w ww . j  av  a2s  .  c om
    com.lowagie.text.Font fontTitle = new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, 8,
            com.lowagie.text.Font.NORMAL);
    {
        PdfPCell cell = new PdfPCell();
        cell.setVerticalAlignment(Element.ALIGN_CENTER);
        cell.setBorderWidthTop(borderWidth);
        cell.setBorderWidthBottom(borderWidthThin);
        cell.setBorderWidthRight(borderWidthThin);
        cell.setBorderWidthLeft(borderWidth);
        Paragraph p = new Paragraph("RWY N" + degrees, fontTitle);
        p.setLeading((p.leading() / 2) + 2);
        p.setAlignment(Element.ALIGN_CENTER);
        cell.addElement(p);
        table.addCell(cell);
    }
    {
        PdfPCell cell = new PdfPCell();
        cell.setVerticalAlignment(Element.ALIGN_CENTER);
        cell.setBorderWidthTop(borderWidth);
        cell.setBorderWidthBottom(borderWidthThin);
        cell.setBorderWidthRight(borderWidthThin);
        cell.setBorderWidthLeft(borderWidthThin);
        Paragraph p = new Paragraph("Dimension (ft) - Surface", fontTitle);
        p.setLeading((p.leading() / 2) + 2);
        p.setAlignment(Element.ALIGN_CENTER);
        cell.addElement(p);
        table.addCell(cell);
    }
    {
        PdfPCell cell = new PdfPCell();
        cell.setVerticalAlignment(Element.ALIGN_CENTER);
        cell.setBorderWidthTop(borderWidth);
        cell.setBorderWidthBottom(borderWidthThin);
        cell.setBorderWidthRight(borderWidthThin);
        cell.setBorderWidthLeft(borderWidthThin);
        Paragraph p = new Paragraph("TORA (ft)", fontTitle);
        p.setLeading((p.leading() / 2) + 2);
        p.setAlignment(Element.ALIGN_CENTER);
        cell.addElement(p);
        table.addCell(cell);
    }
    {
        PdfPCell cell = new PdfPCell();
        cell.setVerticalAlignment(Element.ALIGN_CENTER);
        cell.setBorderWidthTop(borderWidth);
        cell.setBorderWidthBottom(borderWidthThin);
        cell.setBorderWidthRight(borderWidthThin);
        cell.setBorderWidthLeft(borderWidthThin);
        Paragraph p = new Paragraph("LDA (ft)", fontTitle);
        p.setLeading((p.leading() / 2) + 2);
        p.setAlignment(Element.ALIGN_CENTER);
        cell.addElement(p);
        table.addCell(cell);
    }
    {
        PdfPCell cell = new PdfPCell();
        cell.setVerticalAlignment(Element.ALIGN_CENTER);
        cell.setBorderWidthTop(borderWidth);
        cell.setBorderWidthBottom(borderWidthThin);
        cell.setBorderWidthRight(borderWidthThin);
        cell.setBorderWidthLeft(borderWidthThin);
        Paragraph p = new Paragraph("Strength", fontTitle);
        p.setLeading((p.leading() / 2) + 2);
        p.setAlignment(Element.ALIGN_CENTER);
        cell.addElement(p);
        table.addCell(cell);

    }
    {
        PdfPCell cell = new PdfPCell();
        cell.setVerticalAlignment(Element.ALIGN_CENTER);
        cell.setBorderWidthTop(borderWidth);
        cell.setBorderWidthBottom(borderWidthThin);
        cell.setBorderWidthRight(borderWidth);
        cell.setBorderWidthLeft(borderWidthThin);
        Paragraph p = new Paragraph("Lights", fontTitle);
        p.setLeading((p.leading() / 2) + 2);
        p.setAlignment(Element.ALIGN_CENTER);
        cell.addElement(p);
        table.addCell(cell);
    }

    // data
    com.lowagie.text.Font fontData = new com.lowagie.text.Font(com.lowagie.text.Font.TIMES_ROMAN, 10,
            com.lowagie.text.Font.NORMAL);
    int rc = 0;
    for (final Runway runway : airport.getRunways()) {
        {
            PdfPCell cell = new PdfPCell();
            cell.setVerticalAlignment(Element.ALIGN_CENTER);
            cell.setBorderWidthLeft(borderWidth);
            if (rc < airport.getRunways().size() - 1) {
                // thin bottom if not last runway
                cell.setBorderWidthBottom(borderWidthThin);
            } else {
                cell.setBorderWidthBottom(borderWidth);
            }
            cell.setBorderWidthRight(borderWidthThin);
            Paragraph p = new Paragraph(runway.getNumber() + "\r\n" + runway.getOppositeNumber(), fontData);
            p.setLeading((p.leading() / 2) + 2);
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            table.addCell(cell);
        }
        {
            PdfPCell cell = new PdfPCell();
            cell.setVerticalAlignment(Element.ALIGN_CENTER);
            cell.setBorderWidthLeft(borderWidthThin);
            if (rc < airport.getRunways().size() - 1) {
                // thin bottom if not last runway
                cell.setBorderWidthBottom(borderWidthThin);
            } else {
                cell.setBorderWidthBottom(borderWidth);
            }
            cell.setBorderWidthRight(borderWidthThin);
            String runwayLength = new Integer(runway.getLength()).toString() + " x "
                    + new Integer(runway.getWidth()).toString() + " " + runway.getSurfaceName();
            Paragraph p = new Paragraph(runwayLength, fontData);
            p.setLeading((p.leading() / 2) + 2);
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            table.addCell(cell);

        }
        {
            PdfPCell cell = new PdfPCell();
            cell.setVerticalAlignment(Element.ALIGN_CENTER);
            cell.setBorderWidthLeft(borderWidthThin);
            if (rc < airport.getRunways().size() - 1) {
                // thin bottom if not last runway
                cell.setBorderWidthBottom(borderWidthThin);
            } else {
                cell.setBorderWidthBottom(borderWidth);
            }
            cell.setBorderWidthRight(borderWidthThin);
            Paragraph p = new Paragraph(runway.getLength() + "\r\n" + runway.getLength(), fontData);
            p.setLeading((p.leading() / 2) + 2);
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            table.addCell(cell);
        }
        {
            PdfPCell cell = new PdfPCell();
            cell.setVerticalAlignment(Element.ALIGN_CENTER);
            cell.setBorderWidthLeft(borderWidthThin);
            if (rc < airport.getRunways().size() - 1) {
                // thin bottom if not last runway
                cell.setBorderWidthBottom(borderWidthThin);
            } else {
                cell.setBorderWidthBottom(borderWidth);
            }
            cell.setBorderWidthRight(borderWidthThin);
            Paragraph p = new Paragraph((runway.getLength() - runway.getDisplacement()) + "\r\n"
                    + (runway.getLength() - runway.getDisplacementOpposite()), fontData);
            p.setLeading((p.leading() / 2) + 2);
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            table.addCell(cell);
        }
        {
            PdfPCell cell = new PdfPCell();
            cell.setVerticalAlignment(Element.ALIGN_CENTER);
            cell.setBorderWidthLeft(borderWidthThin);
            if (rc < airport.getRunways().size() - 1) {
                // thin bottom if not last runway
                cell.setBorderWidthBottom(borderWidthThin);
            } else {
                cell.setBorderWidthBottom(borderWidth);
            }
            cell.setBorderWidthRight(borderWidthThin);
            Paragraph p = new Paragraph("to do...", fontData);
            p.setLeading((p.leading() / 2) + 2);
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            table.addCell(cell);
        }
        {
            PdfPCell cell = new PdfPCell();
            cell.setVerticalAlignment(Element.ALIGN_CENTER);
            cell.setBorderWidthLeft(borderWidthThin);
            cell.setBorderWidthRight(borderWidth);
            if (rc < airport.getRunways().size() - 1) {
                // thin bottom if not last runway
                cell.setBorderWidthBottom(borderWidthThin);
            } else {
                cell.setBorderWidthBottom(borderWidth);
            }
            Paragraph p = new Paragraph();
            p.setLeading((p.leading() / 2) + 2);
            p.setAlignment(Element.ALIGN_CENTER);
            try {
                if (runway.hasALSF_I(true) || runway.hasALSF_I(false) || runway.hasALSF_II(true)
                        || runway.hasALSF_II(false) || runway.hasPapi(true) || runway.hasPapi(false)
                        || runway.hasSALSF(true) || runway.hasSALSF(false) || runway.hasSSLP(true)
                        || runway.hasSSLP(false) || runway.hasVasi(true) || runway.hasVasi(false)) {
                    p.add(new Chunk(Image.getInstance(getClass().getResource(Main.imgFolder + "light.png")), 0,
                            0));
                } else {
                    p.add(new Chunk("--", fontData));
                }
            } catch (BadElementException ex) {
                Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex);
            }
            cell.addElement(p);
            table.addCell(cell);
        }

        rc++;

    }

    float[] widths2 = { 1f, 2f, 1f, 1f, 2f, 1f };
    try {
        table.setWidths(widths2);
    } catch (DocumentException ex) {
        Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex);
    }

    table.setWidthPercentage(100);
    try {
        document.add(table);
    } catch (DocumentException ex) {
        Logger.getLogger(AirportPainter.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:com.actelion.research.spiritapp.ui.util.PDFUtils.java

License:Open Source License

public static void convertHSSF2Pdf(Workbook wb, String header, File reportFile) throws Exception {
    assert wb != null;
    assert reportFile != null;

    //Precompute formula
    FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
    for (int i = 0; i < wb.getNumberOfSheets(); i++) {
        Sheet sheet = wb.getSheetAt(i);/*from  w  ww.j  av a  2  s.c  o  m*/

        for (Row r : sheet) {
            for (Cell c : r) {
                if (c.getCellType() == HSSFCell.CELL_TYPE_FORMULA) {
                    try {
                        evaluator.evaluateFormulaCell(c);
                    } catch (Exception e) {
                        System.err.println(e);
                    }
                }
            }
        }
    }

    File tmp = File.createTempFile("tmp_", ".xlsx");
    try (OutputStream out = new BufferedOutputStream(new FileOutputStream(tmp))) {
        wb.write(out);
    }

    //Find page orientation
    int maxColumnsGlobal = 0;
    for (int sheetNo = 0; sheetNo < wb.getNumberOfSheets(); sheetNo++) {
        Sheet sheet = wb.getSheetAt(sheetNo);
        for (Iterator<Row> rowIterator = sheet.iterator(); rowIterator.hasNext();) {
            Row row = rowIterator.next();
            maxColumnsGlobal = Math.max(maxColumnsGlobal, row.getLastCellNum());
        }
    }

    Rectangle pageSize = maxColumnsGlobal < 10 ? PageSize.A4 : PageSize.A4.rotate();
    Document pdfDocument = new Document(pageSize, 10f, 10f, 20f, 20f);

    PdfWriter writer = PdfWriter.getInstance(pdfDocument, new FileOutputStream(reportFile));
    addHeader(writer, header);
    pdfDocument.open();
    //we have two columns in the Excel sheet, so we create a PDF table with two columns
    //Note: There are ways to make this dynamic in nature, if you want to.
    //Loop through sheets
    for (int sheetNo = 0; sheetNo < wb.getNumberOfSheets(); sheetNo++) {
        Sheet sheet = wb.getSheetAt(sheetNo);

        //Loop through rows, to find number of columns
        int minColumns = 1000;
        int maxColumns = 0;
        for (Iterator<Row> rowIterator = sheet.iterator(); rowIterator.hasNext();) {
            Row row = rowIterator.next();
            if (row.getFirstCellNum() >= 0)
                minColumns = Math.min(minColumns, row.getFirstCellNum());
            if (row.getLastCellNum() >= 0)
                maxColumns = Math.max(maxColumns, row.getLastCellNum());
        }
        if (maxColumns == 0)
            continue;

        //Loop through first rows, to find relative width
        float[] widths = new float[maxColumns];
        int totalWidth = 0;
        for (int c = 0; c < maxColumns; c++) {
            int w = sheet.getColumnWidth(c);
            widths[c] = w;
            totalWidth += w;
        }

        for (int c = 0; c < maxColumns; c++) {
            widths[c] /= totalWidth;
        }

        //Create new page and a new chapter with the sheet's name
        if (sheetNo > 0)
            pdfDocument.newPage();
        Chapter pdfSheet = new Chapter(sheet.getSheetName(), sheetNo + 1);

        PdfPTable pdfTable = null;
        PdfPCell pdfCell = null;
        boolean inTable = false;

        //Loop through cells, to create the content
        //         boolean leftBorder = true;
        //         boolean[] topBorder = new boolean[maxColumns+1];
        for (int r = 0; r <= sheet.getLastRowNum(); r++) {
            Row row = sheet.getRow(r);

            //Check if we exited a table (empty line)
            if (row == null) {
                if (pdfTable != null) {
                    addTable(pdfDocument, pdfSheet, totalWidth, widths, pdfTable);
                    pdfTable = null;
                }
                inTable = false;
                continue;
            }

            //Check if we start a table (>MIN_COL_IN_TABLE columns)
            if (row.getLastCellNum() >= MIN_COL_IN_TABLE) {
                inTable = true;
            }

            if (!inTable) {
                //Process the data outside table, just add the text
                boolean hasData = false;
                Iterator<Cell> cellIterator = row.cellIterator();
                while (cellIterator.hasNext()) {
                    Cell cell = cellIterator.next();
                    if (cell.getCellType() == Cell.CELL_TYPE_BLANK)
                        continue;
                    Chunk chunk = getChunk(wb, cell);
                    pdfSheet.add(chunk);
                    pdfSheet.add(new Chunk(" "));
                    hasData = true;
                }
                if (hasData)
                    pdfSheet.add(Chunk.NEWLINE);

            } else {
                //Process the data in table
                if (pdfTable == null) {
                    //Create table
                    pdfTable = new PdfPTable(maxColumns);
                    pdfTable.setWidths(widths);
                    //                  topBorder = new boolean[maxColumns+1];
                }

                int cellNumber = minColumns;
                //               leftBorder = false;
                Iterator<Cell> cellIterator = row.cellIterator();
                while (cellIterator.hasNext()) {

                    Cell cell = cellIterator.next();

                    for (; cellNumber < cell.getColumnIndex(); cellNumber++) {
                        pdfCell = new PdfPCell();
                        pdfCell.setBorder(0);
                        pdfTable.addCell(pdfCell);
                    }

                    Chunk phrase = getChunk(wb, cell);
                    pdfCell = new PdfPCell(new Phrase(phrase));
                    pdfCell.setFixedHeight(row.getHeightInPoints() - 3);
                    pdfCell.setNoWrap(!cell.getCellStyle().getWrapText());
                    pdfCell.setPaddingLeft(1);
                    pdfCell.setHorizontalAlignment(
                            cell.getCellStyle().getAlignment() == CellStyle.ALIGN_CENTER ? PdfPCell.ALIGN_CENTER
                                    : cell.getCellStyle().getAlignment() == CellStyle.ALIGN_RIGHT
                                            ? PdfPCell.ALIGN_RIGHT
                                            : PdfPCell.ALIGN_LEFT);
                    pdfCell.setUseBorderPadding(false);
                    pdfCell.setUseVariableBorders(false);
                    pdfCell.setBorderWidthRight(cell.getCellStyle().getBorderRight() == 0 ? 0 : .5f);
                    pdfCell.setBorderWidthBottom(cell.getCellStyle().getBorderBottom() == 0 ? 0
                            : cell.getCellStyle().getBorderBottom() > 1 ? 1 : .5f);
                    pdfCell.setBorderWidthLeft(cell.getCellStyle().getBorderLeft() == 0 ? 0
                            : cell.getCellStyle().getBorderLeft() > 1 ? 1 : .5f);
                    pdfCell.setBorderWidthTop(cell.getCellStyle().getBorderTop() == 0 ? 0
                            : cell.getCellStyle().getBorderTop() > 1 ? 1 : .5f);
                    String color = cell.getCellStyle().getFillForegroundColorColor() == null ? null
                            : ((XSSFColor) cell.getCellStyle().getFillForegroundColorColor()).getARGBHex();
                    if (color != null)
                        pdfCell.setBackgroundColor(new Color(Integer.decode("0x" + color.substring(2))));
                    pdfTable.addCell(pdfCell);
                    cellNumber++;
                }
                for (; cellNumber < maxColumns; cellNumber++) {
                    pdfCell = new PdfPCell();
                    pdfCell.setBorder(0);
                    pdfTable.addCell(pdfCell);
                }
            }

            //Custom code to add all images on the first sheet (works for reporting)
            if (sheetNo == 0 && row.getRowNum() == 0) {
                for (PictureData pd : wb.getAllPictures()) {
                    try {
                        Image pdfImg = Image.getInstance(pd.getData());
                        pdfImg.scaleToFit(
                                pageSize.getWidth() * .8f - pageSize.getBorderWidthLeft()
                                        - pageSize.getBorderWidthRight(),
                                pageSize.getHeight() * .8f - pageSize.getBorderWidthTop()
                                        - pageSize.getBorderWidthBottom());
                        pdfSheet.add(pdfImg);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        }
        if (pdfTable != null) {
            addTable(pdfDocument, pdfSheet, totalWidth, widths, pdfTable);
        }

        pdfDocument.add(pdfSheet);
    }
    pdfDocument.close();

}

From source file:com.actelion.research.spiritapp.ui.util.PDFUtils.java

License:Open Source License

private static void collapseBorder(PdfPTable pdfTable) {
    for (int r = 0; r < pdfTable.getRows().size(); r++) {
        for (int c = 0; c < pdfTable.getNumberOfColumns(); c++) {
            PdfPCell cell = pdfTable.getRow(r).getCells()[c];
            if (cell.getBorderWidthTop() > 0 && r > 0) {
                PdfPCell cell2 = pdfTable.getRow(r - 1).getCells()[c];
                if (cell2.getBorderWidthBottom() > 0)
                    cell.setBorderWidthTop(0);
            }/*w  ww .j  a  va  2  s  . c o  m*/
            if (cell.getBorderWidthLeft() > 0 && c > 0) {
                PdfPCell cell2 = pdfTable.getRow(r).getCells()[c - 1];
                if (cell2.getBorderWidthRight() > 0)
                    cell.setBorderWidthLeft(0);
            }
        }
    }
}

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

public void onStartArRedInvoicePage(PdfWriter writer, Document document) {
    try {/*  w ww. j a  va 2s .  c o  m*/
        SystemRulesDAO systemRulesDAO = new SystemRulesDAO();
        String companyAddress = systemRulesDAO.getSystemRulesByCode("CompanyAddress");
        String companyPhone = systemRulesDAO.getSystemRulesByCode("CompanyPhone");
        String companyFax = systemRulesDAO.getSystemRulesByCode("CompanyFax");
        PdfPCell cell = new PdfPCell();
        PdfPTable headingMainTable = new PdfPTable(1);
        headingMainTable.setWidthPercentage(100);
        PdfPTable headingTable = new PdfPTable(1);
        headingTable.setWidths(new float[] { 100 });
        PdfPTable imgTable = new PdfPTable(1);
        imgTable.setWidthPercentage(100);
        Image img = null;
        String logoImage = "";
        String brand = this.setBrand(fileNumberId);
        if (CommonUtils.isNotEmpty(brand)) {
            if ("ECI".equalsIgnoreCase(brand)) {
                logoImage = LoadLogisoftProperties.getProperty("application.image.econo.logo");
                img = Image.getInstance(realPath + logoImage);
                img.scalePercent(75);
            } else if ("OTI".equalsIgnoreCase(brand)) {
                logoImage = LoadLogisoftProperties.getProperty("application.image.econo.logo");
                img = Image.getInstance(realPath + logoImage);
                img.scalePercent(45);
            } else {
                logoImage = LoadLogisoftProperties.getProperty("application.image.logo");
                img = Image.getInstance(realPath + logoImage);
                img.scalePercent(45);
            }
        }
        img.scalePercent(75);
        PdfPCell logoCell = new PdfPCell(img);
        logoCell.setBorder(Rectangle.NO_BORDER);
        logoCell.setHorizontalAlignment(Element.ALIGN_LEFT);
        logoCell.setVerticalAlignment(Element.ALIGN_LEFT);
        logoCell.setPaddingLeft(+27);
        imgTable.addCell(logoCell);
        PdfPTable addrTable = new PdfPTable(1);
        addrTable.setWidthPercentage(100);
        PdfPTable invoiceFacturaTable = new PdfPTable(3);
        invoiceFacturaTable.setWidthPercentage(100);
        invoiceFacturaTable.setWidths(new float[] { 40, 20, 40 });
        StringBuilder stringBuilder = new StringBuilder();
        addrTable.addCell(makeCellCenterNoBorderFclBL("MAILING ADDRESS: "
                + (CommonUtils.isNotEmpty(companyAddress) ? companyAddress.toUpperCase() : "")));
        stringBuilder.append("TEL: ");
        stringBuilder.append(CommonUtils.isNotEmpty(companyPhone) ? companyPhone : "").append(" / ");
        stringBuilder.append("FAX: ");
        stringBuilder.append(CommonUtils.isNotEmpty(companyFax) ? companyFax : "");
        addrTable.addCell(makeCellCenterNoBorderFclBL(stringBuilder.toString()));
        addrTable.addCell(makeCellLeftNoBorderFclBL(""));
        addrTable.addCell(makeCellLeftNoBorderFclBL(""));
        invoiceFacturaTable.addCell(makeCellLeftNoBorderFclBL(""));
        cell = makeCell("INVOICE", Element.ALIGN_CENTER, new Font(Font.HELVETICA, 12, Font.BOLD, Color.RED),
                0.06f);
        invoiceFacturaTable.addCell(cell);
        invoiceFacturaTable.addCell(makeCellLeftNoBorderFclBL(""));
        cell = new PdfPCell();
        cell.addElement(invoiceFacturaTable);
        cell.setBorder(0);
        addrTable.addCell(cell);
        addrTable.addCell(makeCellLeftNoBorderFclBL(""));
        addrTable.addCell(makeCellLeftNoBorderFclBL(""));

        cell = new PdfPCell();
        cell.addElement(imgTable);
        cell.setBorder(0);
        cell.setPaddingLeft(+150);
        headingMainTable.addCell(cell);
        //            headingTable.addCell(cell);
        cell = new PdfPCell();
        cell.addElement(addrTable);
        cell.setBorder(0);
        headingTable.addCell(cell);
        cell = makeCellLeftNoBorderFclBL("");
        cell.setBorderWidthRight(0.06f);
        cell.setBorderWidthLeft(0.06f);
        cell.setBorderWidthTop(0.06f);
        cell.setBorderWidthBottom(0.0f);
        cell.addElement(headingTable);
        headingMainTable.addCell(cell);
        document.add(headingMainTable);
    } catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}

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

public void createImportFreightPdf(String realPath, String unitSsId, String fileId, String fileNumber,
        String outputFileName, String documentName, String voyNotiemailId, User loginUser) throws Exception {
    ImportPortConfigurationDAO importPortConfigurationDAO = new ImportPortConfigurationDAO();
    LclUnitSsDispoDAO lclUnitSsDispoDAO = new LclUnitSsDispoDAO();
    LclUnitSsDAO lclUnitSsDAO = new LclUnitSsDAO();
    LclRemarksDAO lclRemarksDAO = new LclRemarksDAO();
    LclBookingPieceDAO lclBookingPieceDAO = new LclBookingPieceDAO();
    String trmname = "";
    String trmAddress = "";
    String trmZip = "";
    String customerPo = "";
    String unitNo = "";
    String masterBl = "";
    StringBuilder originValues = new StringBuilder();
    StringBuilder destinationValues = new StringBuilder();
    String subHouseBl = "";
    String amsHouseBl = "";
    String shipName = "";
    String consName = "";
    String notyName = "";
    String forwName = "";
    String billToParty = "";
    String billToPartyAc = "";
    Date pickUpDate = null;/* w  w w . j  av a 2s.  c  o m*/
    Date vesselEtd = null;
    String billToPartyAcctName = "";
    StringBuilder consAddress = new StringBuilder();

    LclBooking lclBooking = new LCLBookingDAO().findById(Long.valueOf(fileId));
    shipName = null != lclBooking.getShipAcct() ? lclBooking.getShipContact().getCompanyName() : "";
    consName = null != lclBooking.getConsAcct() ? lclBooking.getConsContact().getCompanyName() : "";
    notyName = null != lclBooking.getNotyAcct() ? lclBooking.getNotyContact().getCompanyName() : "";
    forwName = null != lclBooking.getFwdAcct() ? lclBooking.getFwdAcct().getAccountName() : "";

    billToParty = null != lclBooking.getBillToParty() ? lclBooking.getBillToParty() : "";
    if (billToParty.equalsIgnoreCase("C")) {
        billToPartyAc = null != lclBooking.getConsAcct() ? lclBooking.getConsAcct().getAccountno() : "";
        billToPartyAcctName = null != lclBooking.getConsAcct() ? lclBooking.getConsContact().getCompanyName()
                : "";
    } else if (billToParty.equalsIgnoreCase("A")) {
        billToPartyAc = null != lclBooking.getSupAcct() ? lclBooking.getSupAcct().getAccountno() : "";
        billToPartyAcctName = null != lclBooking.getSupAcct() ? lclBooking.getSupAcct().getAccountName() : "";
    } else if (billToParty.equalsIgnoreCase("N")) {
        billToPartyAc = null != lclBooking.getNotyAcct() ? lclBooking.getNotyAcct().getAccountno() : "";
        billToPartyAcctName = null != lclBooking.getNotyAcct() ? lclBooking.getNotyContact().getCompanyName()
                : "";
    } else if (billToParty.equalsIgnoreCase("T")) {
        billToPartyAc = null != lclBooking.getThirdPartyAcct() ? lclBooking.getThirdPartyAcct().getAccountno()
                : "";
        billToPartyAcctName = null != lclBooking.getThirdPartyAcct()
                ? lclBooking.getThirdPartyAcct().getAccountName()
                : "";
    }

    originValues.append(lclUtils.getConcatenatedOriginByUnlocation(lclBooking.getPortOfLoading()));
    destinationValues.append(lclUtils.getConcatenatedOriginByUnlocation(lclBooking.getPortOfDestination()));
    if (lclBooking.getTerminal() != null) {
        RefTerminal terminal = new TerminalDAO()
                .findByTerminalNo(String.valueOf(lclBooking.getTerminal().getTrmnum()));
        trmname = null != terminal ? terminal.getTerminalLocation() : "";
        if (trmname.equalsIgnoreCase("IMPRTS LOS ANGELES")) {
            trmname = "Los Angeles";
        }
        trmAddress = null != terminal ? terminal.getAddres1() : "";
        trmZip = null != terminal ? terminal.getZipcde() : "";
    }
    customerPo = new Lcl3pRefNoDAO().getCustomerPo(fileId);
    CustAddress custAddress = new CustAddressDAO().findByAccountNo(billToPartyAc);
    if (custAddress != null) {
        consAddress.append(billToPartyAcctName).append("\n");
        consAddress.append(custAddress.getAddress1()).append("\n");
        consAddress.append(custAddress.getCity1()).append(" ").append(custAddress.getState()).append(" ")
                .append(custAddress.getZip());
    }
    List<LclBookingPiece> lclBookingPiece = lclBookingPieceDAO.findByProperty("lclFileNumber.id",
            Long.parseLong(fileId));
    LclFileNumber lclFileNumber = new LclFileNumberDAO().getByProperty("id", Long.parseLong(fileId));
    if (lclBookingPiece != null && !lclBookingPiece.isEmpty()
            && CommonUtils.isNotEmpty(lclBookingPiece.get(0).getLclBookingPieceUnitList())) {
        unitNo = lclBookingPiece.get(0).getLclBookingPieceUnitList().get(0).getLclUnitSs().getLclUnit()
                .getUnitNo();
        masterBl = lclBookingPiece.get(0).getLclBookingPieceUnitList().get(0).getLclUnitSs().getLclUnit()
                .getLclUnitSsManifestList().get(0).getMasterbl();
        vesselEtd = lclBookingPiece.get(0).getLclBookingPieceUnitList().get(0).getLclUnitSs().getLclSsHeader()
                .getLclSsDetailList().get(0).getSta();
    }
    Boolean isSegregationFlag = new LclBookingSegregationDao().isCheckedSegregationDr(Long.parseLong(fileId));
    if (isSegregationFlag) {
        amsHouseBl = new LclBookingImportAmsDAO().getAmsNo(fileId);
    } else {
        amsHouseBl = new LclBookingImportAmsDAO().getAmsNoGroup(fileId);
    }
    if (lclFileNumber.getLclBookingImport() != null) {
        subHouseBl = lclFileNumber.getLclBookingImport().getSubHouseBl();
        pickUpDate = lclFileNumber.getLclBookingImport().getPickupDateTime();
    }
    PdfPCell cell = new PdfPCell();
    PdfPTable mainTable = makeTable(2);
    mainTable.setWidthPercentage(100f);
    PdfPTable clientPTable = new PdfPTable(5);
    clientPTable.setWidthPercentage(100f);
    clientPTable.setWidths(new float[] { 25, 25, 17, 11, 22 });
    clientPTable.setKeepTogether(true);
    cell = makeCell("BILL TO ACCOUNT NO.", Element.ALIGN_LEFT, headingFontSize8, 0, Color.decode("#c5d9f1"));
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthRight(0.06f);
    clientPTable.addCell(cell);
    cell = makeCell("" + billToPartyAc, Element.ALIGN_LEFT, blackFontForFclAr, 0);
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthRight(0.06f);
    clientPTable.addCell(cell);

    cell = makeCell("INVOICE NO.", Element.ALIGN_CENTER, headingFontSize8, 0, Color.decode("#c5d9f1"));
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthBottom(0.06f);
    clientPTable.addCell(cell);
    cell = makeCell("DATE", Element.ALIGN_CENTER, headingFontSize8, 0, Color.decode("#c5d9f1"));
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthLeft(0.06f);
    cell.setBorderWidthBottom(0.06f);
    clientPTable.addCell(cell);
    cell = makeCell("BILLING TM", Element.ALIGN_CENTER, headingFontSize8, 0, Color.decode("#c5d9f1"));
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthLeft(0.06f);
    cell.setBorderWidthRight(0.06f);
    cell.setBorderWidthBottom(0.06f);
    clientPTable.addCell(cell);

    cell = makeCell("" + consAddress.toString(), Element.ALIGN_LEFT, blackFontForFclAr, 0);
    cell.setColspan(2);
    cell.setMinimumHeight(20f);
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthRight(0.06f);
    clientPTable.addCell(cell);

    //INVOICE NO
    cell = makeCell(fileNumber, Element.ALIGN_CENTER, blackFontForFclBl, 0);
    clientPTable.addCell(cell);

    //DATE
    String acctNumber = checkPayment(billToPartyAc);
    if (!acctNumber.equals("noCredit")) {
        if (CommonFunctions.isNotNull(acctNumber) && !acctNumber.equals("") && pickUpDate != null) {
            cell = makeCell(DateUtils.formatStringDateToAppFormatMMM(pickUpDate), Element.ALIGN_CENTER,
                    blackFontForFclBl, 0);
        } else if (pickUpDate == null && vesselEtd != null) {
            cell = makeCell(DateUtils.formatStringDateToAppFormatMMM(vesselEtd), Element.ALIGN_CENTER,
                    blackFontForFclBl, 0);
        } else {
            cell = makeCell("", Element.ALIGN_CENTER, blackFontForFclBl, 0);
        }
    } else if (acctNumber.equals("noCredit") && vesselEtd != null) {
        cell = makeCell(DateUtils.formatStringDateToAppFormatMMM(vesselEtd), Element.ALIGN_CENTER,
                blackFontForFclBl, 0);
    } else {
        cell = makeCell("", Element.ALIGN_CENTER, blackFontForFclBl, 0);
    }
    cell.setBorderWidthLeft(0.06f);
    clientPTable.addCell(cell);

    //BILLING TM
    cell = makeCell(trmname, Element.ALIGN_CENTER, blackFontForFclBl, 0);
    cell.setBorderWidthLeft(0.06f);
    clientPTable.addCell(cell);

    cell = makeCell("", Element.ALIGN_CENTER, blackBoldFontSize6, 0);
    cell.setColspan(2);
    clientPTable.addCell(cell);

    cell = makeCell("CUSTOMER REF NO.", Element.ALIGN_CENTER, headingFontSize8, 0, Color.decode("#c5d9f1"));
    cell.setColspan(3);
    cell.setBorderWidthLeft(0.06f);
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthBottom(0.06f);
    clientPTable.addCell(cell);

    cell = makeCell("", Element.ALIGN_CENTER, blackBoldFontSize6, 0);
    cell.setColspan(2);
    clientPTable.addCell(cell);
    //CUSTOMER REF NO.
    cell = makeCell(customerPo, Element.ALIGN_CENTER, blackFontForFclBl, 0);
    cell.setColspan(3);
    cell.setMinimumHeight(15f);
    cell.setBorderWidthLeft(0.06f);
    clientPTable.addCell(cell);

    cell = new PdfPCell();
    cell.addElement(clientPTable);
    cell.setColspan(5);
    cell.setBorder(0);
    cell.setPadding(0f);
    cell.setBorderWidthRight(0.06f);
    cell.setBorderWidthLeft(0.06f);
    mainTable.addCell(cell);

    PdfPTable othersTable = makeTable(4);
    othersTable.setWidthPercentage(100f);
    othersTable.setWidths(new float[] { 25, 25, 25, 25 });
    cell = makeCell("CONTAINER NO.", Element.ALIGN_CENTER, blackBoldFontSize6, 0, Color.decode("#c5d9f1"));
    cell.setBorderWidthBottom(0.06f);
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthRight(0.06f);
    othersTable.addCell(cell);
    cell = makeCell("ECI SHIPMENT FILE NO.", Element.ALIGN_CENTER, blackBoldFontSize6, 0,
            Color.decode("#c5d9f1"));
    cell.setBorderWidthBottom(0.06f);
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthRight(0.06f);
    othersTable.addCell(cell);
    cell = makeCell("ORIGIN", Element.ALIGN_CENTER, blackBoldFontSize6, 0, Color.decode("#c5d9f1"));
    cell.setBorderWidthBottom(0.06f);
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthRight(0.06f);
    othersTable.addCell(cell);
    cell = makeCell("DESTINATION", Element.ALIGN_CENTER, blackBoldFontSize6, 0, Color.decode("#c5d9f1"));
    cell.setBorderWidthBottom(0.06f);
    cell.setBorderWidthTop(0.06f);
    othersTable.addCell(cell);
    //CONTAINER NO
    cell = makeCell("" + unitNo, Element.ALIGN_CENTER, blackBoldFontSize6, 0);
    cell.setMinimumHeight(20f);
    cell.setBorderWidthRight(0.06f);
    othersTable.addCell(cell);
    //ECI SHIPMENT FILE NO
    cell = makeCell("IMP-" + fileNumber, Element.ALIGN_CENTER, blackBoldFontSize6, 0);
    cell.setMinimumHeight(20f);
    cell.setBorderWidthRight(0.06f);
    othersTable.addCell(cell);
    //ORIGIN
    cell = makeCell("" + originValues, Element.ALIGN_CENTER, blackBoldFontSize6, 0);
    cell.setMinimumHeight(20f);
    cell.setBorderWidthRight(0.06f);
    othersTable.addCell(cell);
    //DESTINATION
    cell = makeCell("" + destinationValues, Element.ALIGN_CENTER, blackBoldFontSize6, 0);
    cell.setMinimumHeight(20f);
    cell.setBorderWidthRight(0.06f);
    othersTable.addCell(cell);

    cell = makeCell("MBL / AWB NUMBER", Element.ALIGN_CENTER, blackBoldFontSize6, 0, Color.decode("#c5d9f1"));
    cell.setColspan(2);
    cell.setBorderWidthRight(0.06f);
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthBottom(0.06f);
    othersTable.addCell(cell);
    cell = makeCell("AMS HOUSE BL", Element.ALIGN_CENTER, blackBoldFontSize6, 0, Color.decode("#c5d9f1"));
    cell.setBorderWidthRight(0.06f);
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthBottom(0.06f);
    othersTable.addCell(cell);
    cell = makeCell("SUB HOUSE BL", Element.ALIGN_CENTER, blackBoldFontSize6, 0, Color.decode("#c5d9f1"));
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthBottom(0.06f);
    othersTable.addCell(cell);
    //MBL / AWB NUMBER
    cell = makeCell("" + masterBl, Element.ALIGN_CENTER, blackBoldFontSize6, 0);
    cell.setColspan(2);
    cell.setMinimumHeight(20f);
    cell.setBorderWidthRight(0.06f);
    othersTable.addCell(cell);
    //amsHouseBl
    cell = makeCell(amsHouseBl, Element.ALIGN_CENTER, blackBoldFontSize6, 0);
    cell.setMinimumHeight(20f);
    cell.setBorderWidthRight(0.06f);
    othersTable.addCell(cell);
    //subHouseBl
    cell = makeCell(subHouseBl, Element.ALIGN_CENTER, blackBoldFontSize6, 0);
    cell.setMinimumHeight(20f);
    cell.setBorderWidthRight(0.06f);
    othersTable.addCell(cell);

    cell = makeCell("SHIPPER", Element.ALIGN_CENTER, blackBoldFontSize6, 0, Color.decode("#c5d9f1"));
    cell.setColspan(2);
    cell.setBorderWidthRight(0.06f);
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthBottom(0.06f);
    othersTable.addCell(cell);
    cell = makeCell("FORWARDER", Element.ALIGN_CENTER, blackBoldFontSize6, 0, Color.decode("#c5d9f1"));
    cell.setColspan(2);
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthBottom(0.06f);
    othersTable.addCell(cell);
    //SHIPPER
    cell = makeCell(shipName, Element.ALIGN_CENTER, blackBoldFontSize6, 0);
    cell.setColspan(2);
    cell.setMinimumHeight(20f);
    cell.setBorderWidthRight(0.06f);
    othersTable.addCell(cell);
    //FORWARDER
    cell = makeCell(forwName, Element.ALIGN_CENTER, blackBoldFontSize6, 0);
    cell.setColspan(2);
    cell.setMinimumHeight(20f);
    cell.setBorderWidthRight(0.06f);
    othersTable.addCell(cell);

    cell = makeCell("CONSIGNEE", Element.ALIGN_CENTER, blackBoldFontSize6, 0, Color.decode("#c5d9f1"));
    cell.setColspan(2);
    cell.setBorderWidthRight(0.06f);
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthBottom(0.06f);
    othersTable.addCell(cell);

    cell = makeCell("NOTIFY PARTY", Element.ALIGN_CENTER, blackBoldFontSize6, 0, Color.decode("#c5d9f1"));
    cell.setColspan(2);
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthBottom(0.06f);
    othersTable.addCell(cell);
    //CONSIGNEE
    cell = makeCell(consName, Element.ALIGN_CENTER, blackBoldFontSize6, 0);
    cell.setColspan(2);
    cell.setMinimumHeight(20f);
    cell.setBorderWidthRight(0.06f);
    othersTable.addCell(cell);
    //NOTIFY PARTY
    cell = makeCell(notyName, Element.ALIGN_CENTER, blackBoldFontSize6, 0);
    cell.setColspan(2);
    cell.setMinimumHeight(20f);
    cell.setBorderWidthRight(0.06f);
    othersTable.addCell(cell);

    cell = new PdfPCell();
    cell.setColspan(2);
    cell.addElement(othersTable);
    cell.setBorder(0);
    cell.setPadding(0f);
    cell.setBorderWidthRight(0.06f);
    cell.setBorderWidthLeft(0.06f);
    mainTable.addCell(cell);

    Font boldHeadingFon = FontFactory.getFont("Arial", 7f, Font.BOLD);
    Paragraph p = null;

    PdfPTable othersTable1 = makeTable(5);
    othersTable1.setWidthPercentage(100f);
    othersTable1.setWidths(new float[] { 2f, 1f, 4f, 1.3f, 1.3f });
    //marks     
    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setBorderWidthBottom(0.6F);
    p = new Paragraph(7f, "MARKS AND NUMBERS", boldHeadingFon);
    p.setAlignment(Element.ALIGN_CENTER);
    cell.setBackgroundColor(Color.decode("#c5d9f1"));
    cell.addElement(p);
    othersTable1.addCell(cell);
    //no of pkgs
    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setBorderWidthBottom(0.6F);
    cell.setBorderWidthLeft(0.6f);
    p = new Paragraph(7f, "NO.OF.PKGS", boldHeadingFon);
    p.setAlignment(Element.ALIGN_CENTER);
    cell.setBackgroundColor(Color.decode("#c5d9f1"));
    cell.addElement(p);
    othersTable1.addCell(cell);
    //desc
    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setBorderWidthBottom(0.6F);
    cell.setBorderWidthLeft(0.6f);
    p = new Paragraph(7f, "DESCRIPTION OF PACKAGES AND GOODS", boldHeadingFon);
    p.setAlignment(Element.ALIGN_CENTER);
    cell.setBackgroundColor(Color.decode("#c5d9f1"));
    cell.addElement(p);
    othersTable1.addCell(cell);
    //grossweight
    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setBorderWidthBottom(0.6F);
    cell.setBorderWidthLeft(0.6f);
    p = new Paragraph(7f, "GROSS WEIGHT", boldHeadingFon);
    p.setAlignment(Element.ALIGN_CENTER);
    cell.setBackgroundColor(Color.decode("#c5d9f1"));
    cell.addElement(p);
    othersTable1.addCell(cell);
    //measure
    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setBorderWidthBottom(0.6F);
    cell.setBorderWidthLeft(0.6f);
    p = new Paragraph(7f, "MEASURE", boldHeadingFon);
    p.setAlignment(Element.ALIGN_CENTER);
    cell.setBackgroundColor(Color.decode("#c5d9f1"));
    cell.addElement(p);
    othersTable1.addCell(cell);

    //        List<LclBookingPiece> lclBookingPiecesList = null;
    //        lclBookingPiecesList = lclBookingPieceDAO.findByProperty("lclFileNumber.id", Long.parseLong(fileId));
    if (lclBookingPiece != null && lclBookingPiece.size() > 0) {
        for (LclBookingPiece lclBookingPieces : lclBookingPiece) {
            //MARKS AND NUMBERS
            cell = new PdfPCell();
            cell.setBorder(0);
            if (lclBookingPieces != null && lclBookingPieces.getMarkNoDesc() != null
                    && !lclBookingPieces.getMarkNoDesc().equals("")) {
                p = new Paragraph(7f, "" + lclBookingPieces.getMarkNoDesc().toUpperCase(),
                        blackNormalCourierFont8f);
            } else {
                p = new Paragraph(7f, "", blackNormalCourierFont8f);
            }
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            othersTable1.addCell(cell);
            //NO.OF.PKGS
            cell = new PdfPCell();
            cell.setBorder(0);
            cell.setBorderWidthLeft(0.6f);
            if (lclBookingPieces != null && lclBookingPieces.getBookedPieceCount() != null
                    && lclBookingPieces.getPackageType().getAbbr01() != null) {
                p = new Paragraph(7f, "" + lclBookingPieces.getBookedPieceCount() + " "
                        + lclBookingPieces.getPackageType().getAbbr01(), blackNormalCourierFont8f);
            } else {
                p = new Paragraph(7f, "", blackNormalCourierFont8f);
            }
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            othersTable1.addCell(cell);
            //DESCRIPTION OF PACKAGES AND GOODS
            cell = new PdfPCell();
            cell.setBorder(0);
            cell.setBorderWidthLeft(0.6f);
            if (lclBookingPieces != null && lclBookingPieces.getPieceDesc() != null
                    && !lclBookingPieces.getPieceDesc().equals("")) {
                p = new Paragraph(7f, "" + lclBookingPieces.getPieceDesc().toUpperCase(),
                        blackNormalCourierFont8f);
            } else {
                p = new Paragraph(7f, "", blackNormalCourierFont8f);
            }
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            othersTable1.addCell(cell);

            //grossweight
            cell = new PdfPCell();

            cell.setBorder(0);
            cell.setBorderWidthLeft(0.6f);
            if (lclBookingPieces != null && lclBookingPieces.getBookedWeightMetric() != null) {
                p = new Paragraph(7f, "" + lclBookingPieces.getBookedWeightMetric() + " KGS",
                        blackNormalCourierFont8f);
            } else {
                p = new Paragraph(7f, "", blackNormalCourierFont8f);
            }
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            othersTable1.addCell(cell);
            //measure
            cell = new PdfPCell();
            cell.setBorder(0);
            cell.setBorderWidthLeft(0.6f);
            if (lclBookingPieces != null && lclBookingPieces.getBookedVolumeMetric() != null) {
                p = new Paragraph(7f, "" + lclBookingPieces.getBookedVolumeMetric() + " CBM",
                        blackNormalCourierFont8f);
            } else {
                p = new Paragraph(7f, "", blackNormalCourierFont8f);
            }
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            othersTable1.addCell(cell);
            //2nd cell
            cell = new PdfPCell();
            cell.setBorder(0);
            p = new Paragraph(7f, "", blackNormalCourierFont8f);
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            othersTable1.addCell(cell);

            cell = new PdfPCell();
            cell.setBorder(0);
            cell.setBorderWidthLeft(0.6f);
            p = new Paragraph(7f, "", blackNormalCourierFont8f);
            p.setAlignment(Element.ALIGN_CENTER);

            cell.addElement(p);
            othersTable1.addCell(cell);

            cell = new PdfPCell();
            cell.setBorder(0);
            cell.setBorderWidthLeft(0.6f);
            p = new Paragraph(7f, "", blackNormalCourierFont8f);
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            othersTable1.addCell(cell);

            cell = new PdfPCell();
            cell.setBorder(0);
            cell.setBorderWidthLeft(0.6f);
            p = new Paragraph(7f, "", blackNormalCourierFont8f);
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            othersTable1.addCell(cell);

            cell = new PdfPCell();
            cell.setBorder(0);
            cell.setBorderWidthLeft(0.6f);
            p = new Paragraph(7f, "", blackNormalCourierFont8f);
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            othersTable1.addCell(cell);

            //3rd cell
            cell = new PdfPCell();
            cell.setBorder(0);
            p = new Paragraph(7f, "", blackNormalCourierFont8f);
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            othersTable1.addCell(cell);

            cell = new PdfPCell();
            cell.setBorder(0);
            cell.setBorderWidthLeft(0.6f);
            p = new Paragraph(7f, "", blackNormalCourierFont8f);
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            othersTable1.addCell(cell);

            cell = new PdfPCell();
            cell.setBorder(0);
            cell.setBorderWidthLeft(0.6f);
            p = new Paragraph(7f, "", blackNormalCourierFont8f);
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            othersTable1.addCell(cell);

            cell = new PdfPCell();
            cell.setBorder(0);
            cell.setBorderWidthLeft(0.6f);
            if (lclBookingPieces != null && lclBookingPieces.getBookedWeightImperial() != null) {
                p = new Paragraph(7f, "" + lclBookingPieces.getBookedWeightImperial() + " LBS",
                        blackNormalCourierFont8f);
            } else {
                p = new Paragraph(7f, "", blackNormalCourierFont8f);
            }
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            othersTable1.addCell(cell);

            cell = new PdfPCell();
            cell.setBorder(0);
            cell.setBorderWidthLeft(0.6f);
            if (lclBookingPieces != null && lclBookingPieces.getBookedVolumeImperial() != null) {
                p = new Paragraph(7f, "" + lclBookingPieces.getBookedVolumeImperial() + " CFT",
                        blackNormalCourierFont8f);
            } else {
                p = new Paragraph(7f, "", blackNormalCourierFont8f);
            }
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            othersTable1.addCell(cell);
        }

    }

    cell = new PdfPCell();
    cell.setColspan(5);
    cell.addElement(othersTable1);
    cell.setBorder(0);
    cell.setPadding(0f);
    cell.setBorderWidthRight(0.06f);
    cell.setBorderWidthLeft(0.06f);
    cell.setBorderWidthTop(0.06f);
    mainTable.addCell(cell);

    PdfPTable chargesTable = makeTable(4);
    chargesTable.setWidthPercentage(100.5f);
    chargesTable.setWidths(new float[] { 45, 35, 5, 15 });
    cell = makeCell("DESCRIPTION", Element.ALIGN_CENTER, headingFont, 0, Color.decode("#c5d9f1"));
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthRight(0.06f);
    cell.setBorderWidthBottom(0.06f);
    cell.setColspan(2);
    chargesTable.addCell(cell);
    cell = makeCell("CHARGES", Element.ALIGN_CENTER, headingFont, 0, Color.decode("#c5d9f1"));
    cell.setColspan(2);
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthBottom(0.06f);
    chargesTable.addCell(cell);

    NumberFormat number = new DecimalFormat("###,###,##0.00");
    String code = "";
    //        double totalCharges = 0.00;
    double lateFee = 0.00;
    double payAmount = 0.00;
    int chargeCount = 0;
    double total = 0.00;
    String[] billToPartyA;
    billToPartyA = new String[] { "C", "N", "T" };
    List<String> billtoPartyList = Arrays.asList(billToPartyA);
    List<BookingChargesBean> lclBookingAcList = null;
    lclBookingAcList = new LclCostChargeDAO().findBybookingAcId(fileId, billtoPartyList);
    for (int j = 0; j < lclBookingAcList.size(); j++) {
        chargeCount++;
        BookingChargesBean lclBookingAc = (BookingChargesBean) lclBookingAcList.get(j);

        String codeDesc = "";

        code = CommonUtils.isNotEmpty(lclBookingAc.getChargeCode()) ? lclBookingAc.getChargeCode() : "";
        codeDesc = new GenericCodeDAO().getGenericCodeDesc(code);

        if (CommonUtils.isNotEmpty(lclBookingAc.getChargeCode())) {
            //                    String desc = lclBookingAc.getChargeCode().toUpperCase();

            cell = makeCell("", Element.ALIGN_CENTER, blackFontForFclBl);
            cell.setBorderWidthRight(0.0f);
        }

        if (chargeCount == 1) {
            cell.setBorderWidthTop(0.0f);
            cell.setBorderWidthRight(0.0f);
            cell.setBorderWidthLeft(0.0f);
            cell.setBorderWidthBottom(0.0f);
        } else {
            cell.setBorderWidthRight(0.0f);
            cell.setBorderWidthLeft(0.0f);
            cell.setBorderWidthBottom(0.0f);
        }
        chargesTable.addCell(cell);

        if (CommonUtils.isNotEmpty(codeDesc)) {
            cell = makeCell("" + codeDesc, Element.ALIGN_LEFT, blackFontForFclBl, 0.06f);
            cell.setBorderWidthLeft(0.0f);
        } else {
            cell = makeCell("" + code, Element.ALIGN_LEFT, blackFontForFclBl, 0.06f);
            cell.setBorderWidthLeft(0.0f);
        }
        if (chargeCount == 1) {
            cell.setBorderWidthTop(0.0f);
            cell.setBorderWidthRight(0.0f);
            cell.setBorderWidthBottom(0.0f);
        } else {
            cell.setBorderWidthRight(0.0f);
            cell.setBorderWidthBottom(0.0f);
        }

        chargesTable.addCell(cell);

        cell = makeCell("$", Element.ALIGN_CENTER, blackFontForFclBl, 0.06f);//3
        if (chargeCount == 1) {
            cell.setBorderWidthTop(0.0f);
            cell.setBorderWidthRight(0.0f);
            cell.setBorderWidthBottom(0.0f);
        } else {
            cell.setBorderWidthRight(0.0f);
            cell.setBorderWidthBottom(0.0f);
        }
        chargesTable.addCell(cell);
        cell = makeCell(number.format(lclBookingAc.getTotalAmt().doubleValue()), Element.ALIGN_RIGHT,
                blackFontForFclBl, Rectangle.BOX);//4
        if (chargeCount == 1) {
            cell.setBorderWidth(0.0f);
        } else {
            cell.setBorderWidthLeft(0.0f);
            cell.setBorderWidthRight(0.0f);
            cell.setBorderWidthBottom(0.0f);
        }
        chargesTable.addCell(cell);
        total = total + lclBookingAc.getTotalAmt().doubleValue();

    }

    for (int i = 0; i < (14 - chargeCount); i++) {
        //            chargesTable.addCell(makeCellLeftNoBorderFclBL(""));
        //            chargesTable.addCell(makeCellRightNoBorderFclBL(""));
        cell = makeCell("", Element.ALIGN_LEFT, blackFontForFclBl, 0.06f);
        cell.setBorderWidthRight(0.0f);
        cell.setBorderWidthBottom(0.0f);
        cell.setBorderWidthLeft(0.0f);
        chargesTable.addCell(cell);

        cell = makeCell("", Element.ALIGN_CENTER, blackFontForFclBl, 0.06f);
        cell.setBorderWidthRight(0.0f);
        cell.setBorderWidthBottom(0.0f);
        cell.setBorderWidthLeft(0.0f);
        chargesTable.addCell(cell);
        cell = makeCell("", Element.ALIGN_CENTER, blackFontForFclBl, 0.06f);
        cell.setBorderWidthRight(0.0f);
        cell.setBorderWidthBottom(0.0f);
        chargesTable.addCell(cell);
        cell = makeCell("", Element.ALIGN_RIGHT, blackFontForFclBl, 0.06f);
        cell.setBorderWidthLeft(0.0f);
        cell.setBorderWidthRight(0.0f);
        cell.setBorderWidthBottom(0.0f);
        cell.setMinimumHeight(10f);
        chargesTable.addCell(cell);
    }
    cell = makeCell("", Element.ALIGN_LEFT, blackFontForFclBl, 0);
    cell.setBorderWidthTop(0.06f);
    chargesTable.addCell(cell);
    cell = makeCell("INVOICE TOTAL", Element.ALIGN_CENTER, blackFontForFclBl, 0);
    //        cell.setPaddingLeft(-15f);
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthBottom(0.06f);
    cell.setBorderWidthLeft(0.06f);
    cell.setBorderWidthRight(0.06f);
    chargesTable.addCell(cell);
    cell = makeCell("$", Element.ALIGN_CENTER, blackFontForFclBl, 0);
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthBottom(0.06f);
    chargesTable.addCell(cell);
    cell = makeCell(number.format(total), Element.ALIGN_RIGHT, blackFontForFclBl, 0);//4
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthBottom(0.06f);
    chargesTable.addCell(cell);
    cell = makeCell("", Element.ALIGN_CENTER, blackFontForFclBl, 0);
    cell.setColspan(4);
    chargesTable.addCell(cell);
    chargesTable.setKeepTogether(true);
    cell = new PdfPCell();
    cell.setColspan(2);
    cell.addElement(chargesTable);
    cell.setBorder(0);
    cell.setBorderWidthRight(0.06f);
    cell.setBorderWidthLeft(0.06f);
    mainTable.addCell(cell);
    //        
    payAmount = total;
    //        String acctNumber = checkPayment(billToPartyAc);
    boolean lateFeeFlag = false;
    TradingPartnerBC tradingPartnerBC = new TradingPartnerBC();
    TradingPartner tradingPartner = null;
    //        SimpleDateFormat simpDate = new SimpleDateFormat("dd-MMM-yyyy");
    PdfPTable paidTable = makeTable(6);
    paidTable.setWidthPercentage(100.5f);
    paidTable.setWidths(new float[] { 30, 15, 25, 10, 5, 15 });
    if (CommonFunctions.isNotNull(acctNumber) && !acctNumber.equals("") && !acctNumber.equals("noCredit")) {
        tradingPartner = tradingPartnerBC.findTradingPartnerById(acctNumber);
        if (CommonFunctions.isNotNullOrNotEmpty(tradingPartner.getAccounting())) {
            for (Iterator accountingList = tradingPartner.getAccounting().iterator(); accountingList
                    .hasNext();) {
                CustomerAccounting customerAccounting = (CustomerAccounting) accountingList.next();
                if (null != customerAccounting.getLclApplyLateFee()
                        && customerAccounting.getLclApplyLateFee().equals("on")) {
                    lateFeeFlag = true;
                }
                break;
            }
        }
    }

    cell = makeCell("ARRIVAL DATE", Element.ALIGN_CENTER, headingFontSize8, 0, Color.decode("#c5d9f1"));
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthRight(0.06f);
    cell.setBorderWidthBottom(0.06f);
    paidTable.addCell(cell);

    SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
    String outDate = "";
    String crtDate = "";

    if (vesselEtd != null) { //vessel arrivalDate         
        outDate = sdf.format(vesselEtd);
    }
    cell = makeCell("", Element.ALIGN_LEFT, blackFontForFclBl, 0);
    paidTable.addCell(cell);
    CustomerAccounting customerAccounting = new CustomerAccountingDAO().findByProperty("accountNo",
            billToPartyAc);

    if (customerAccounting != null && (customerAccounting.getCreditRate() != null
            && (CommonUtils.isNotEmpty(outDate)) && !acctNumber.equals("noCredit"))) {
        Calendar c = Calendar.getInstance();
        //            c.setTime(new Date(outDate)); //  Removed Deprecated Warning
        c.setTime(sdf.parse(outDate)); //   Now use previous date.
        if ((customerAccounting.getCreditRate().getCodedesc()).equalsIgnoreCase("Net 7 Days")) {
            c.add(Calendar.DATE, 7);
            crtDate = sdf.format(c.getTime());// Adding 7 days
        } else if ((customerAccounting.getCreditRate().getCodedesc()).equalsIgnoreCase("Net 15 Days")) {
            c.add(Calendar.DATE, 15);
            crtDate = sdf.format(c.getTime());// Adding 15 days
        } else if ((customerAccounting.getCreditRate().getCodedesc()).equalsIgnoreCase("NET 21 DAYS")) {
            c.add(Calendar.DATE, 21);
            crtDate = sdf.format(c.getTime());// Adding 21 days
        } else if ((customerAccounting.getCreditRate().getCodedesc()).equalsIgnoreCase("Net 30 Days")) {
            c.add(Calendar.DATE, 30);
            crtDate = sdf.format(c.getTime());// Adding 30 days
        } else if ((customerAccounting.getCreditRate().getCodedesc()).equalsIgnoreCase("Net 45 Days")) {
            c.add(Calendar.DATE, 45);
            crtDate = sdf.format(c.getTime());// Adding 45 days
        } else if ((customerAccounting.getCreditRate().getCodedesc()).equalsIgnoreCase("Net 60 Days")) {
            c.add(Calendar.DATE, 60);
            crtDate = sdf.format(c.getTime());// Adding 60 days
        }
    }

    if (lateFeeFlag) {
        lateFee = total * 0.015; // 1.5percent calculate
        payAmount = total + lateFee;
        cell = makeCell("LATE FEE IF NOT PAID BY - " + crtDate, Element.ALIGN_LEFT, blackFontForFclBl, 0);
        cell.setColspan(2);
        cell.setBorderWidthTop(0.06f);
        cell.setBorderWidthLeft(0.06f);
        paidTable.addCell(cell);

        cell = makeCell("$", Element.ALIGN_CENTER, blackFontForFclBl, 0);
        cell.setBorderWidthTop(0.06f);
        cell.setBorderWidthLeft(0.06f);
        paidTable.addCell(cell);
        cell = makeCell(number.format(lateFee), Element.ALIGN_RIGHT, blackFontForFclBl, 0);
        cell.setBorderWidthTop(0.06f);
        paidTable.addCell(cell);

        cell = makeCell(outDate, Element.ALIGN_CENTER, blackFontForFclBl, 0);
        cell.setMinimumHeight(10f);
        cell.setBorderWidthBottom(0.06f);
        cell.setBorderWidthRight(0.06f);
        paidTable.addCell(cell);

        cell = makeCell("", Element.ALIGN_CENTER, blackFontForFclBl, 0);
        paidTable.addCell(cell);

        cell = makeCell("PAY THIS AMOUNT IF NOT PAID BY DUE DATE", Element.ALIGN_LEFT, blackFontForFclBl, 0);
        cell.setBorderWidthBottom(0.06f);
        cell.setBorderWidthLeft(0.06f);
        cell.setBorderWidthTop(0.06f);
        cell.setColspan(2);
        paidTable.addCell(cell);
        cell = makeCell("$", Element.ALIGN_CENTER, blackFontForFclBl, 0);
        cell.setBorderWidthBottom(0.06f);
        cell.setBorderWidthLeft(0.06f);
        cell.setBorderWidthTop(0.06f);
        paidTable.addCell(cell);
        cell = makeCell(number.format(payAmount), Element.ALIGN_RIGHT, blackFontForFclBl, 0);
        cell.setBorderWidthBottom(0.06f);
        cell.setBorderWidthTop(0.06f);
        paidTable.addCell(cell);
    } else {
        //            String dueDate = "";
        //            if(arRedInvoice.getDueDate() != null){
        //            SimpleDateFormat sdfa = new SimpleDateFormat("dd-MMM-yyyy");
        //            dueDate = sdfa.format(arRedInvoice.getDueDate());
        //        }

        //            cell = makeCell(!"".equals(dueDate) ? "PAY THIS AMOUNT IF NOT PAID BY - " + dueDate : "PLEASE PAY THIS AMOUNT",Element.ALIGN_LEFT, blackFontForFclBl, 0);
        cell = makeCell("", Element.ALIGN_CENTER, blackFontForFclBl, 0);
        cell.setColspan(4);
        paidTable.addCell(cell);

        cell = makeCell(outDate, Element.ALIGN_CENTER, blackFontForFclBl, 0);
        cell.setMinimumHeight(10f);
        cell.setBorderWidthBottom(0.06f);
        cell.setBorderWidthRight(0.06f);
        paidTable.addCell(cell);

        cell = makeCell("", Element.ALIGN_CENTER, blackFontForFclBl, 0);
        paidTable.addCell(cell);

        cell = makeCell("PLEASE PAY THIS AMOUNT - " + crtDate, Element.ALIGN_LEFT, blackFontForFclBl, 0);
        cell.setBorderWidthBottom(0.06f);
        cell.setBorderWidthLeft(0.06f);
        cell.setBorderWidthTop(0.06f);
        cell.setColspan(2);
        paidTable.addCell(cell);
        cell = makeCell("$", Element.ALIGN_CENTER, blackFontForFclBl, 0);
        cell.setBorderWidthBottom(0.06f);
        cell.setBorderWidthLeft(0.06f);
        cell.setBorderWidthTop(0.06f);
        paidTable.addCell(cell);
        cell = makeCell(number.format(total), Element.ALIGN_RIGHT, blackFontForFclBl, 0);
        cell.setBorderWidthBottom(0.06f);
        cell.setBorderWidthTop(0.06f);
        paidTable.addCell(cell);
    }
    cell = makeCell("", Element.ALIGN_CENTER, blackFontForFclBl, 0);
    cell.setColspan(5);
    paidTable.addCell(cell);

    //paidTable.setKeepTogether(true);
    cell = new PdfPCell();
    cell.setColspan(2);
    cell.addElement(paidTable);
    cell.setBorder(0);
    cell.setBorderWidthRight(0.06f);
    cell.setBorderWidthLeft(0.06f);
    mainTable.addCell(cell);

    ///end of description & charges
    //        String paymentStatment = "";
    //        paymentStatment = checkPayment(arRedInvoice);
    PdfPTable commandTable = new PdfPTable(1);
    commandTable.setWidthPercentage(100);
    cell = makeCell("", Element.ALIGN_CENTER, headingFont, Rectangle.NO_BORDER);
    commandTable.addCell(cell);
    cell = makeCell("", Element.ALIGN_CENTER, headingFont, Rectangle.NO_BORDER);
    commandTable.addCell(cell);

    if (customerAccounting != null
            && (customerAccounting.getCreditRate() != null && (CommonUtils.isNotEmpty(outDate)))) {
        if ((customerAccounting.getCreditRate().getCodedesc()).equalsIgnoreCase("Due Upon Receipt")) {
            cell = makeCell("INVOICE IS PAYABLE UPON RECEIPT", Element.ALIGN_CENTER, blackFontForFclBl, 0,
                    Color.decode("#FFFF00"));
            commandTable.addCell(cell);
        } else {
            cell = makeCell("INVOICE PAYABLE ON OR BEFORE  " + (crtDate), Element.ALIGN_CENTER,
                    new Font(Font.HELVETICA, 10, Font.BOLDITALIC, Color.BLACK), Rectangle.NO_BORDER);
            commandTable.addCell(cell);
        }
    } else {
        cell = makeCell("INVOICE IS PAYABLE UPON RECEIPT", Element.ALIGN_CENTER, blackFontForFclBl, 0,
                Color.decode("#FFFF00"));
        commandTable.addCell(cell);
    }
    //        if (lateFeeFlag == false) {//if(paymentStatment.equals("noCredit") || lateFeeFlag == false){
    //            cell = makeCell("INVOICE IS PAYABLE UPON RECEIPT OR INVOICE PAYABLE WITHIN 30 DAYS FROM DEPARTURE/ARRIVAL DATE", Element.ALIGN_LEFT, blackFontForFclBl, 0, Color.decode("#FFFF00"));
    //            commandTable.addCell(cell);
    //        } else {
    //            cell = makeCell("", Element.ALIGN_CENTER, headingFont, Rectangle.NO_BORDER);
    //            commandTable.addCell(cell);
    //        }
    cell = makeCell("", Element.ALIGN_CENTER, headingFont, Rectangle.NO_BORDER);
    commandTable.addCell(cell);
    cell = makeCell("", Element.ALIGN_CENTER, headingFont, Rectangle.NO_BORDER);
    commandTable.addCell(cell);
    cell = makeCell("", Element.ALIGN_CENTER, headingFont, Rectangle.NO_BORDER);
    commandTable.addCell(cell);
    cell = makeCell("", Element.ALIGN_CENTER, headingFont, Rectangle.NO_BORDER);
    commandTable.addCell(cell);
    cell = new PdfPCell();
    cell.setColspan(2);
    cell.addElement(commandTable);
    cell.setBorder(0);
    cell.setBorderWidthRight(0.06f);
    cell.setBorderWidthLeft(0.06f);
    cell.setExtraParagraphSpace(10f);
    mainTable.addCell(cell);

    PdfPTable bankDetailsTable = makeTable(4);
    bankDetailsTable.setWidthPercentage(100f);
    bankDetailsTable.setWidths(new float[] { 3f, 1f, 4f, 2.6f });

    //
    //        SystemRulesDAO systemRulesDAO = new SystemRulesDAO();
    //        String eftBank = systemRulesDAO.getSystemRulesByCode("EFTBank");
    //        String eftBankAddress = systemRulesDAO.getSystemRulesByCode("EFTBankAddress");
    //        String eftABANo = systemRulesDAO.getSystemRulesByCode("EFTABANo");
    //        String eftAcctName = systemRulesDAO.getSystemRulesByCode("EFTAcctName");
    //        String eftAccountNo = systemRulesDAO.getSystemRulesByCode("EFTAccountNo");
    //        CompanyModel company = systemRulesDAO.getCompanyDetails();

    //PAYMENT METHODS
    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setBorderWidthBottom(0.6F);
    cell.setBorderWidthRight(0.6f);
    cell.setBorderWidthTop(0.6f);
    p = new Paragraph(7f, "PAYMENT METHODS", boldHeadingFon);
    p.setAlignment(Element.ALIGN_CENTER);
    cell.setBackgroundColor(Color.decode("#c5d9f1"));
    cell.addElement(p);
    bankDetailsTable.addCell(cell);
    // Empty

    cell = makeCell("", Element.ALIGN_CENTER, blackBoldFontSize6, 0);
    cell.setColspan(3);
    cell.setBorderWidthBottom(0.06f);
    bankDetailsTable.addCell(cell);

    //Via Check
    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setColspan(2);
    cell.setBorderWidthBottom(0.6F);
    cell.setBorderWidthLeft(0.6f);
    p = new Paragraph(7f, "Via Check", boldHeadingFon);
    p.setAlignment(Element.ALIGN_CENTER);
    cell.setBackgroundColor(Color.decode("#c5d9f1"));
    cell.addElement(p);
    bankDetailsTable.addCell(cell);
    //Via ACH or Wire Transfer
    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setBorderWidthBottom(0.6F);
    cell.setBorderWidthLeft(0.6f);
    p = new Paragraph(7f, "Via ACH or Wire Transfer", boldHeadingFon);
    p.setAlignment(Element.ALIGN_CENTER);
    cell.setBackgroundColor(Color.decode("#c5d9f1"));
    cell.addElement(p);
    bankDetailsTable.addCell(cell);
    //Credit Card Payments
    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setBorderWidthBottom(0.6F);
    cell.setBorderWidthLeft(0.6f);
    p = new Paragraph(7f, "Credit Card Payments", boldHeadingFon);
    p.setAlignment(Element.ALIGN_CENTER);
    cell.setBackgroundColor(Color.decode("#c5d9f1"));
    cell.addElement(p);
    bankDetailsTable.addCell(cell);

    // Via Check Details
    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setBorderWidthRight(0.06f);
    cell.setBorderWidthBottom(0.06f);
    cell.setColspan(2);
    p = new Paragraph(10f, "PLEASE REMIT PAYMENT TO", boldHeadingFon);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);

    p = new Paragraph(10f, companyName, boldHeadingFon);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    String creditStatusDomain = "";
    if (null != customerAccounting && null != customerAccounting.getCreditStatus()) {//no credit
        creditStatusDomain = customerAccounting.getCreditStatus().getCodedesc();
        if (!("No Credit").equalsIgnoreCase(creditStatusDomain)) {
            p = new Paragraph(10f, "2401 N.W. 69TH STREET", boldHeadingFon);
            p.setAlignment(Element.ALIGN_LEFT);
            cell.addElement(p);
            p = new Paragraph(10f, "Miami, FL  33147", boldHeadingFon);
            p.setAlignment(Element.ALIGN_LEFT);
            cell.addElement(p);
            bankDetailsTable.addCell(cell);
        } else {
            p = new Paragraph(10f, "" + trmAddress, boldHeadingFon);
            p.setAlignment(Element.ALIGN_LEFT);
            cell.addElement(p);
            p = new Paragraph(10f, "" + trmname + " " + trmZip, boldHeadingFon);
            p.setAlignment(Element.ALIGN_LEFT);
            cell.addElement(p);
            bankDetailsTable.addCell(cell);
        }
    }

    //Via ACH or Wire Transfer Details

    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setBorderWidthRight(0.06f);
    p = new Paragraph(10f, "Bank: " + company.getBankName(), boldHeadingFon);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    p = new Paragraph(10f, company.getBankAddress(), boldHeadingFon);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    p = new Paragraph(10f, "ABA: " + company.getBankAbaNumber(), boldHeadingFon);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    p = new Paragraph(10f, "ACCT: " + companyName, boldHeadingFon);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    p = new Paragraph(10f, "ACCOUNT NO: " + company.getBankAccountNumber(), boldHeadingFon);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    bankDetailsTable.addCell(cell);

    //Credit Card Payments Details
    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setBorderWidthRight(0.06f);
    p = new Paragraph(10f, "If paying via Credit card", boldHeadingFon);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    p = new Paragraph(10f, " Please go to:", boldHeadingFon);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    p = new Paragraph(10f, webSite, fileNoFont);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    bankDetailsTable.addCell(cell);

    cell = new PdfPCell();
    cell.setColspan(4);
    cell.addElement(bankDetailsTable);
    cell.setBorder(0);
    cell.setPadding(0f);
    cell.setBorderWidthRight(0.06f);
    cell.setBorderWidthLeft(0.06f);
    cell.setBorderWidthBottom(0.06f);
    mainTable.addCell(cell);

    document.add(mainTable);

}

From source file:com.gp.cong.logisoft.reports.BookingCoverSheetPdfCreater.java

public void createBody(SearchBookingReportDTO searchBookingReportDTO, String simpleRequest,
        MessageResources messageResources, String printFromBl, String documentName)
        throws DocumentException, MalformedURLException, IOException, Exception {
    NumberFormat numformat = new DecimalFormat("##,###,##0.00");
    PdfPCell cell = new PdfPCell();
    Paragraph paragraph;/*ww  w .jav  a 2s  .  com*/
    PdfPTable table;
    Phrase phrase;

    PdfPTable mainTable = makeTable(2);
    mainTable.setWidthPercentage(100);

    BookingFcl bookingFcl = searchBookingReportDTO.getBookingflFcl();
    FclBl fclBl = null;
    if (CommonUtils.isNotEmpty(printFromBl)) {
        fclBl = new FclBlDAO().getFileNoObject(bookingFcl.getFileNo());
    }
    String company = null;
    String contactName = "";
    String email = null;
    String phone = null;
    String fax = null;
    String address = null;
    QuotationDAO quotationDAO = new QuotationDAO();
    CustAddressBC custAddressBC = new CustAddressBC();
    Quotation quotation = quotationDAO.getFileNoObject(bookingFcl.getFileNo());
    if (null != quotation) {
        contactName = quotation.getContactname();
    }
    if (bookingFcl.getShippercheck() != null && bookingFcl.getShippercheck().equals("on")) {
        //from=bookingFcl.getShipper();
        company = bookingFcl.getShipper();
        email = bookingFcl.getShipperEmail();
        phone = bookingFcl.getShipperPhone();
        fax = bookingFcl.getShipperFax();
        address = bookingFcl.getAddressforShipper();
    } else if (bookingFcl.getForwardercheck() != null && bookingFcl.getForwardercheck().equals("on")) {
        company = bookingFcl.getForward();
        email = bookingFcl.getForwarderEmail();
        phone = bookingFcl.getForwarderPhone();
        fax = bookingFcl.getForwarderFax();
        address = bookingFcl.getAddressforForwarder();
    } else if (bookingFcl.getConsigneecheck() != null && bookingFcl.getConsigneecheck().equals("on")) {
        company = bookingFcl.getConsignee();
        email = bookingFcl.getConsingeeEmail();
        phone = bookingFcl.getConsingeePhone();
        fax = bookingFcl.getConsigneeFax();
        address = bookingFcl.getAddressforConsingee();
    } else {
        if (null != quotation) {
            company = quotation.getClientname();
            email = quotation.getEmail1();
            phone = quotation.getPhone();
            fax = quotation.getFax();
            CustAddress custAddress = custAddressBC.getClientAddress(quotation.getClientnumber());
            if (null != custAddress) {
                address = custAddress.getAddress1();
            }
        }
    }

    PdfPTable headerTable = makeTable(3);
    headerTable.setWidths(new float[] { 20, 50, 30 });
    headerTable.setWidthPercentage(100);

    PdfPTable headerTable1 = makeTable(1);
    headerTable1.setWidths(new float[] { 100 });
    headerTable1.setWidthPercentage(100);

    PdfPCell headingCell1 = makeCell(
            new Phrase(messageResources.getMessage("fileNumberPrefix") + String.valueOf(bookingFcl.getFileNo()),
                    headingFont1),
            Element.ALIGN_CENTER);
    headingCell1.setBackgroundColor(Color.LIGHT_GRAY);
    headingCell1.setVerticalAlignment(Element.ALIGN_MIDDLE);
    headerTable1.addCell(headingCell1);
    cell = makeCellleftNoBorder("");
    cell.addElement(headerTable1);
    headerTable.addCell(headerTable1);

    PdfPTable headerTable2 = makeTable(2);
    headerTable2.setWidths(new float[] { 38, 62 });
    headerTable2.setWidthPercentage(100);

    SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy HH:mm a");
    SimpleDateFormat sdfForddMMyyyy = new SimpleDateFormat("dd-MMM-yyyy");
    String colon = ": ";
    String docCut = "";
    String carrierDocCut = "";
    String etd = "";
    String eta = "";
    if (bookingFcl.getDocCutOff() != null) {
        docCut = sdf.format(bookingFcl.getDocCutOff());
    }
    if (bookingFcl.getCarrierDocCut() != null) {
        carrierDocCut = sdf.format(bookingFcl.getCarrierDocCut());
    }
    if (bookingFcl.getEtd() != null) {
        etd = sdfForddMMyyyy.format(bookingFcl.getEtd());
    }
    if (bookingFcl.getEta() != null) {
        eta = sdfForddMMyyyy.format(bookingFcl.getEta());
    }

    headerTable2.addCell(makeCell(new Phrase("Doc Cutoff", headingFont2), Element.ALIGN_LEFT));
    headerTable2.addCell(makeCell(new Phrase(colon + docCut, redBoldFont), Element.ALIGN_LEFT));
    headerTable2.addCell(makeCell(new Phrase("Carrier Doc Cut", headingFont2), Element.ALIGN_LEFT));
    headerTable2.addCell(makeCell(new Phrase(colon + carrierDocCut, redBoldFont), Element.ALIGN_LEFT));

    cell = makeCellleftNoBorder("");
    cell.addElement(headerTable2);
    headerTable.addCell(headerTable2);

    PdfPTable headerTable3 = makeTable(2);
    headerTable3.setWidths(new float[] { 20, 80 });
    headerTable3.setWidthPercentage(100);

    headerTable3.addCell(makeCell(new Phrase("ETD", headingFont2), Element.ALIGN_LEFT));
    headerTable3.addCell(makeCell(new Phrase(colon + etd, headingFont2), Element.ALIGN_LEFT));
    headerTable3.addCell(makeCell(new Phrase("ETA", headingFont2), Element.ALIGN_LEFT));
    headerTable3.addCell(makeCell(new Phrase(colon + eta, headingFont2), Element.ALIGN_LEFT));

    cell = makeCellleftNoBorder("");
    cell.addElement(headerTable3);
    headerTable.addCell(headerTable3);

    document.add(headerTable);

    PdfPTable pTable = new PdfPTable(2);
    pTable.setWidthPercentage(100);

    PdfPTable clientTable = makeTable(2);
    clientTable.setWidths(new float[] { 27, 73 });
    clientTable.setWidthPercentage(100);

    clientTable.addCell(makeCellleftNoBorderWithBoldFont("Client Name"));
    clientTable.addCell(makeCellLeftNoBorderValue(company));
    clientTable.addCell(makeCellleftNoBorderWithBoldFont("Client Address"));
    clientTable.addCell(makeCellLeftNoBorderValue(address));
    clientTable.addCell(makeCellleftNoBorderWithBoldFont("Contact Name"));
    clientTable.addCell(makeCellLeftNoBorderValue(contactName));
    cell = makeCellleftNoBorderWithBoldFont("Contact Number");
    cell.setNoWrap(true);
    clientTable.addCell(cell);
    clientTable.addCell(makeCellLeftNoBorderValue(phone));
    clientTable.addCell(makeCellleftNoBorderWithBoldFont("Contact Fax"));
    clientTable.addCell(makeCellLeftNoBorderValue(fax));
    clientTable.addCell(makeCellleftNoBorderWithBoldFont("Contact Email"));
    clientTable.addCell(makeCellLeftNoBorderValue(email));

    cell = makeCellleftNoBorder("");
    cell.setBorderWidthRight(0.6f);
    cell.setBorderWidthBottom(0.6f);
    cell.setBorderWidthLeft(0.6f);
    cell.setBorderWidthTop(0.6f);
    cell.addElement(clientTable);
    pTable.addCell(cell);

    PdfPTable carrierTable = makeTable(2);
    carrierTable.setWidths(new float[] { 26, 74 });
    carrierTable.setWidthPercentage(100);
    String sslName[] = bookingFcl.getSslname().split("//");

    carrierTable.addCell(makeCellleftNoBorderWithBoldFont("Carrier"));
    carrierTable.addCell(makeCellLeftNoBorderValue(sslName.length > 1 ? sslName[0] : ""));
    carrierTable.addCell(makeCellleftNoBorderWithBoldFont("Vessel"));
    carrierTable.addCell(makeCellLeftNoBorderValue(bookingFcl.getVessel()));
    carrierTable.addCell(makeCellleftNoBorderWithBoldFont("Voyage"));
    carrierTable.addCell(makeCellLeftNoBorderValue(bookingFcl.getVoyageCarrier()));
    carrierTable.addCell(makeCellleftNoBorderWithBoldFont("SSL Booking#"));
    carrierTable.addCell(makeCellLeftNoBorderValue(bookingFcl.getSSBookingNo()));
    carrierTable.addCell(makeCellleftNoBorderWithBoldFont("POO"));
    carrierTable.addCell(makeCellLeftNoBorderValue(getCityStateName(bookingFcl.getOriginTerminal())));
    carrierTable.addCell(makeCellleftNoBorderWithBoldFont("POL"));
    carrierTable.addCell(makeCellLeftNoBorderValue(getCityStateName(bookingFcl.getPortofOrgin())));
    carrierTable.addCell(makeCellleftNoBorderWithBoldFont("POD"));
    carrierTable.addCell(makeCellLeftNoBorderValue(getCityStateName(bookingFcl.getDestination())));
    carrierTable.addCell(makeCellleftNoBorderWithBoldFont("FD"));
    carrierTable.addCell(makeCellLeftNoBorderValue(getCityStateName(bookingFcl.getPortofDischarge())));
    carrierTable.addCell(makeCellleftNoBorderWithBoldFont("Containers"));
    carrierTable.addCell(makeCellLeftNoBorderValue(
            this.getContainers(simpleRequest, searchBookingReportDTO, messageResources).getContent()));
    //        PdfPCell cell1 = makeCell(this.getContainers(simpleRequest, searchBookingReportDTO, messageResources), 1);
    //        cell1.setColspan(2);
    //        cell1.setBorderWidthLeft(0.0F);
    //        carrierTable.addCell(cell1);

    cell = makeCellleftNoBorder("");
    cell.setBorderWidthRight(0.6f);
    cell.setBorderWidthBottom(0.6f);
    cell.setBorderWidthTop(0.6f);
    cell.addElement(carrierTable);

    pTable.addCell(cell);

    document.add(pTable);

    PdfPTable hazardsMainTable = makeTable(1);
    hazardsMainTable.setWidths(new float[] { 100 });
    hazardsMainTable.setWidthPercentage(100);

    PdfPTable hazardsTable = makeTable(3);
    hazardsTable.setWidths(new float[] { 70, 15, 15 });
    hazardsTable.setWidthPercentage(100);

    Image yes = Image.getInstance(searchBookingReportDTO.getContextPath() + "/images/icons/y.png");
    yes.scalePercent(60);
    yes.scaleAbsoluteWidth(18);
    PdfPCell yesCell = new PdfPCell();
    yesCell.setBorder(0);
    yesCell.addElement(new Chunk(yes, 32, -0));

    Image no = Image.getInstance(searchBookingReportDTO.getContextPath() + "/images/icons/n.png");
    no.scalePercent(60);
    no.scaleAbsoluteWidth(18);
    PdfPCell noCell = new PdfPCell();
    noCell.setBorder(0);
    noCell.addElement(new Chunk(no, 32, -0));

    hazardsTable.addCell(makeCellleftNoBorderWithBoldFont("HAZARDOUS"));
    if (bookingFcl.getHazmat() != null && "Y".equalsIgnoreCase(bookingFcl.getHazmat())) {
        hazardsTable.addCell(yesCell);
        hazardsTable.addCell(makeCell(new Phrase("N", fontforYandN), 1));
    } else {
        hazardsTable.addCell(makeCell(new Phrase("Y", fontforYandN), 1));
        hazardsTable.addCell(noCell);
    }
    hazardsTable.addCell(makeCellleftNoBorderWithBoldFont("AES"));
    hazardsTable.addCell(makeCell(new Phrase("Y", fontforYandN), Element.ALIGN_CENTER));
    hazardsTable.addCell(makeCell(new Phrase("N", fontforYandN), Element.ALIGN_CENTER));
    hazardsTable.addCell(makeCellleftNoBorderWithBoldFont("DIRECT CONSIGMENT"));
    if (bookingFcl.getDirectConsignmntCheck() != null
            && "on".equalsIgnoreCase(bookingFcl.getDirectConsignmntCheck())) {
        hazardsTable.addCell(yesCell);
        hazardsTable.addCell(makeCell(new Phrase("N", fontforYandN), 1));
    } else {
        hazardsTable.addCell(makeCell(new Phrase("Y", fontforYandN), 1));
        hazardsTable.addCell(noCell);
    }
    hazardsTable.addCell(makeCellleftNoBorderWithBoldFont("AFR"));
    hazardsTable.addCell(makeCell(new Phrase("Y", fontforYandN), Element.ALIGN_CENTER));
    hazardsTable.addCell(makeCell(new Phrase("N", fontforYandN), Element.ALIGN_CENTER));

    cell = makeCellleftNoBorder("");
    cell.setBorderWidthRight(0.6f);
    cell.setBorderWidthBottom(0.6f);
    cell.setBorderWidthLeft(0.6f);
    cell.addElement(hazardsTable);

    hazardsMainTable.addCell(cell);
    document.add(hazardsMainTable);

    PdfPTable docsMainTable = makeTable(2);
    docsMainTable.setWidths(new float[] { 30, 70 });
    docsMainTable.setWidthPercentage(100);

    PdfPTable docsTable = makeTable(2);
    docsTable.setWidths(new float[] { 50, 50 });
    docsTable.setWidthPercentage(100);

    Image img = Image.getInstance(searchBookingReportDTO.getContextPath() + "/images/icons/uncheckedBox.png");
    img.scalePercent(50);
    img.scaleAbsoluteWidth(18);
    PdfPCell pCell = new PdfPCell();
    pCell.setBorder(0);
    pCell.addElement(new Chunk(img, 25, -0));

    //        Image checkedimg = Image.getInstance(searchBookingReportDTO.getContextPath() + "/images/icons/check.png");
    //        checkedimg.scalePercent(60);
    //        checkedimg.scaleAbsoluteWidth(18);
    //        PdfPCell checkedCell = new PdfPCell();
    //        checkedCell.setBorder(0);
    //        checkedCell.addElement(new Chunk(checkedimg, 25, -0));
    docsTable.addCell(makeCellleftNoBorderWithBoldFont("Docs"));
    docsTable.addCell(pCell);

    docsTable.addCell(makeCellNoBorders("       "));
    docsTable.addCell(makeCellNoBorders("       "));

    docsTable.addCell(makeCellleftNoBorderWithBoldFont("COB"));
    docsTable.addCell(pCell);

    docsTable.addCell(makeCellNoBorders("       "));
    docsTable.addCell(makeCellNoBorders("       "));

    docsTable.addCell(makeCellleftNoBorderWithBoldFont("MBL"));
    docsTable.addCell(pCell);

    docsTable.addCell(makeCellNoBorders("       "));
    docsTable.addCell(makeCellNoBorders("       "));

    docsTable.addCell(makeCellleftNoBorderWithBoldFont("Manifisted"));
    docsTable.addCell(pCell);

    cell = makeCellleftNoBorder("");
    cell.setBorderWidthBottom(0.6f);
    cell.setBorderWidthLeft(0.6f);
    cell.addElement(docsTable);
    docsMainTable.addCell(cell);

    PdfPTable noteTable = makeTable(1);
    noteTable.setWidths(new float[] { 100 });
    noteTable.setWidthPercentage(100);
    noteTable.addCell(makeCellCenterNoBorder("Notes"));
    noteTable.addCell(makeCellNoBorders("       "));
    noteTable.addCell(makeCellleftwithUnderLine("            "));
    noteTable.addCell(makeCellNoBorders("       "));
    noteTable.addCell(makeCellleftwithUnderLine("            "));
    noteTable.addCell(makeCellNoBorders("       "));
    noteTable.addCell(makeCellleftwithUnderLine("            "));
    noteTable.addCell(makeCellNoBorders("       "));
    noteTable.addCell(makeCellleftwithUnderLine("            "));
    noteTable.addCell(makeCellNoBorders("       "));

    cell = makeCellleftNoBorder("");
    cell.setBorderWidthBottom(0.6f);
    cell.setBorderWidthRight(0.6f);
    cell.addElement(noteTable);
    docsMainTable.addCell(cell);
    document.add(docsMainTable);

}

From source file:com.krawler.esp.handlers.PdfGenHandler.java

License:Open Source License

public static ByteArrayOutputStream getInvoiceForm1(String invoice) {
    ByteArrayOutputStream os = null;
    try {//w w w  .  j ava  2  s.c  om
        os = new ByteArrayOutputStream();
        Document document = new Document(PageSize.A4, 15, 15, 15, 15);
        PdfWriter writer = PdfWriter.getInstance(document, os);
        Font font7 = FontFactory.getFont("Helvetica", 8, Font.BOLD, Color.BLACK);
        Font font10 = FontFactory.getFont("Helvetica", 14, Font.BOLD, Color.BLACK);
        HeaderFooter temp = new HeaderFooter(new Phrase(
                String.format("Note: This is a computer generated document and does not require signature"),
                font7), false);
        temp.setAlignment(Element.ALIGN_CENTER);
        document.setFooter(temp);
        document.open();
        JSONObject jbj = new JSONObject(invoice);
        String currency = "";
        com.krawler.utils.json.base.JSONArray gridinfo = jbj.getJSONArray("items");
        String ids[] = { "name", "address", "invoiceno", "paymentdate" };
        String uinfo[] = new String[ids.length];
        for (int i = 0; i < uinfo.length; i++) {
            uinfo[i] = jbj.getString(ids[i]);
        }
        PdfPTable tableinfo = new PdfPTable(1);
        PdfPTable table = new PdfPTable(2);
        Font font1 = FontFactory.getFont("Helvetica", 24, Font.BOLD, Color.BLACK);
        String cnxt = "";//StorageHandler.getProfileStorePath() + "/inceif-200.png";
        PdfPCell cell1 = null;
        try {
            Image img = Image.getInstance(cnxt);
            cell1 = new PdfPCell(img);
        } catch (Exception e) {
            cnxt = StorageHandler.GetProfileImgStorePath() + "/140-logo.png";
            Image img = Image.getInstance(cnxt);
            cell1 = new PdfPCell(img);
        }
        cell1.setBorder(0);
        cell1.setHorizontalAlignment(Element.ALIGN_RIGHT);
        tableinfo.addCell(cell1);
        tableinfo = addspace(1, tableinfo);
        tableinfo = addspace(4, tableinfo);
        cell1 = new PdfPCell(new Paragraph("INVOICE", font10));
        cell1.setBorder(0);
        cell1.setHorizontalAlignment(Element.ALIGN_RIGHT);
        tableinfo.addCell(cell1);
        tableinfo = addspace(2, tableinfo);
        table = addspace(1, table);
        //            cell1 = new PdfPCell(new Paragraph(uinfo[uinfo.length - 1],font9));
        //            cell1.setBorder(0);
        //            cell1.setHorizontalAlignment(Element.ALIGN_RIGHT);
        //            tableinfo.addCell(cell1);
        //            tableinfo = addspace(1, tableinfo);
        //            tableinfo = addspace(2, tableinfo);
        cell1 = new PdfPCell(tableinfo);
        cell1.setBorder(0);
        table.addCell(cell1);
        PdfPTable tb = new PdfPTable(1);
        document.add(new Paragraph("\u00a0"));
        tableinfo = addspace(1, tableinfo);

        Font font = FontFactory.getFont("Helvetica", 10, Font.BOLD, Color.BLACK);
        Font font2 = FontFactory.getFont("Helvetica", 10, Font.NORMAL, Color.BLACK);
        //Font font3 = FontFactory.getFont("Helvetica", 8, Font.ITALIC, Color.BLACK);
        Font font11 = FontFactory.getFont("Helvetica", 12, Font.BOLD, Color.BLACK);
        PdfPCell c1 = null;
        c1 = new PdfPCell(new Paragraph("Bill To :", font2));
        c1.setBorder(0);
        tb.addCell(c1);
        for (int i = 0; i < 2; i++) {
            PdfPCell c = null;
            if (i == 0)
                c = new PdfPCell(new Paragraph(uinfo[i], font11));
            else
                c = new PdfPCell(new Paragraph(uinfo[i]));
            //c.(20);
            c.setBorder(0);
            tb.addCell(c);
        }
        PdfPCell c = new PdfPCell(tb);
        c.setBorder(0);
        table.addCell(c);
        PdfPTable tb1 = new PdfPTable(1);
        for (int i = 2; i < 4; i++) {
            PdfPTable nested1 = new PdfPTable(3);
            c = new PdfPCell();
            c.setBorder(0);
            c.setPaddingRight(5);
            nested1.addCell(c);
            c = new PdfPCell(new Paragraph(invoiceheadings[i], font));
            c.setBorder(0);

            nested1.addCell(c);
            c = new PdfPCell(new Paragraph(uinfo[i], font2));
            c.setBorder(0);
            c.setHorizontalAlignment(Element.ALIGN_RIGHT);
            //c.setPaddingLeft(5);
            nested1.addCell(c);

            c = new PdfPCell(nested1);
            c.setBorder(0);
            tb1.addCell(c);
        }
        PdfPCell c2 = new PdfPCell(tb1);
        c2.setBorder(0);
        table.addCell(c2);
        PdfPTable tb2 = new PdfPTable(new float[] { 60, 40 });

        /*  for (int i = 6; i < 7; i++) {
        PdfPTable tb3 = new PdfPTable(2);//new float[]{20, 40});
        tb3.setWidths(new int[]{1, 3});
        c2 = new PdfPCell(new Paragraph(invoiceheadings[i], font));
        c2.setBorder(0);
        tb3.addCell(c2);
        c2 = new PdfPCell(new Paragraph(uinfo[i]));
        c2.setBorder(0);
        tb3.addCell(c2);
        c2 = new PdfPCell(tb3);
        c2.setBorder(0);
        c2.setHorizontalAlignment(Element.ALIGN_LEFT);
        tb2.addCell(c2);
        tb2 = addspace(1, tb2);
          }
        */
        PdfPTable maintable = new PdfPTable(1);
        c2 = new PdfPCell(table);
        c2.setBorder(0);
        maintable.addCell(c2);
        maintable = addspace(0, maintable);
        c2 = new PdfPCell(tb2);
        c2.setBorder(0);
        maintable.addCell(c2);
        document.add(maintable);
        //for (int i = 0; i < 2; i++) {
        document.add(new Paragraph("\u00a0"));
        //}
        String[] colwidth2 = { "Subscription date", "Description", "Rate ($/Project)", "Amount ($)" };

        PdfPTable table1 = new PdfPTable(4);
        table1.setWidths(new float[] { 2, 3, 1, 1 });
        for (int i = 0; i < colwidth2.length; i++) {
            PdfPCell cell = new PdfPCell(new Paragraph(colwidth2[i], font));
            cell.setBorder(0);
            if (i != 1) {
                cell.setBorderWidthLeft(1);
                cell.setBorderWidthRight(1);
            }
            if (i == 3) {
                cell.setBorderWidthLeft(0);
                cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            } else {
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            }
            cell.setBorderWidthTop(1);
            cell.setBackgroundColor(Color.getHSBColor(0f, 0f, 0.9f));
            cell.setBorderWidthBottom(1);
            cell.setPaddingBottom(5);
            cell.setPaddingTop(5);
            table1.addCell(cell);
        }
        //table1.setHeaderRows(1);
        double d = 0;
        String[] di = { "billdate", "description", "rate", "amount" };
        java.text.DecimalFormat df = new java.text.DecimalFormat("0.00");
        for (int i = 0; i < gridinfo.length(); i++) {
            currency = "USD";//gridinfo.getJSONObject(i).getString("currency");
            PdfPCell cell = null;
            for (int j = 0; j < di.length; j++) {
                if (j == 3) {
                    cell = new PdfPCell(new Paragraph(
                            df.format(Double.parseDouble(gridinfo.getJSONObject(i).getString(di[j]))), font2));
                    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
                } else {
                    cell = new PdfPCell(new Paragraph(gridinfo.getJSONObject(i).getString(di[j]), font2));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                }
                cell.setBorder(0);
                if (j != 1) {
                    cell.setBorderWidthLeft(1);
                    cell.setBorderWidthRight(1);
                }
                if (j == 3) {
                    cell.setBorder(0);
                    cell.setBorderWidthRight(1);
                }
                cell.setPaddingTop(10);
                cell.setFixedHeight(100);
                table1.addCell(cell);
            }
            d += Double.parseDouble(gridinfo.getJSONObject(i).getString(di[3]));

        }
        PdfPCell cell = null;
        cell = new PdfPCell(new Paragraph(" ", font));
        cell.setBorder(0);
        cell.setBorderWidthTop(1);
        cell.setBorderWidthBottom(1);
        cell.setBorderWidthLeft(1);
        cell.setBorderWidthRight(0);
        table1.addCell(cell);
        cell = new PdfPCell(new Paragraph("    ", font));
        cell.setBorder(0);
        cell.setBorderWidthTop(1);
        cell.setBorderWidthBottom(1);
        cell.setBorderWidthLeft(0);
        cell.setBorderWidthRight(0);
        table1.addCell(cell);
        cell = new PdfPCell(new Paragraph("     Total", font));
        cell.setBorder(0);
        cell.setBorderWidthTop(1);
        cell.setBorderWidthBottom(1);
        cell.setBorderWidthLeft(0);
        cell.setBorderWidthRight(0);
        cell.setPaddingBottom(5);
        table1.addCell(cell);
        cell = new PdfPCell(new Paragraph(" " + df.format(d), font));
        cell.setBorder(0);
        cell.setBorderWidthTop(1);
        cell.setBorderWidthBottom(1);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorderWidthLeft(0);
        cell.setBorderWidthRight(1);
        cell.setPaddingBottom(5);
        table1.addCell(cell);

        EnglishDecimalFormat f1 = new EnglishDecimalFormat();
        if (currency.equals("USD")) {
            cell = new PdfPCell(new Paragraph("Amount in words : " + CurrencyConvert(currency, d), font));
        } else {
            cell = new PdfPCell(new Paragraph(CurrencyConvert(currency, d), font));
        }
        cell.setColspan(4);
        cell.setBorder(0);
        //cell.setBorderWidthTop(1);
        cell.setBorderWidthBottom(1);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setBorderWidthLeft(1);
        cell.setBorderWidthRight(1);
        cell.setPaddingBottom(5);
        table1.addCell(cell);
        document.add(table1);
        document.add(new Paragraph("\u00a0"));
        PdfPTable inst = new PdfPTable(1);
        //            for (int i = 0; i < Inst1.length; i++) {
        //                c2 = new PdfPCell(new Paragraph(Inst1[i]));
        //                c2.setBorder(0);
        //                inst.addCell(c2);
        //            }
        document.add(inst);
        document.close();
        writer.close();
        os.close();

    }
    //        catch (ConfigurationException ex) {
    //            Logger.getLogger(PdfGenHandler.class.getName()).log(Level.SEVERE, null, ex);
    //        }
    catch (JSONException ex) {
        Logger.getLogger(PdfGenHandler.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(PdfGenHandler.class.getName()).log(Level.SEVERE, null, ex);
    } catch (DocumentException ex) {
        Logger.getLogger(PdfGenHandler.class.getName()).log(Level.SEVERE, null, ex);
    } catch (Exception exp) {
        Logger.getLogger(PdfGenHandler.class.getName()).log(Level.SEVERE, null, exp);
    }
    return os;
}

From source file:com.krawler.esp.handlers.PdfGenHandler.java

License:Open Source License

public static ByteArrayOutputStream getReceiptAcc1(String ackrecp) {
    ByteArrayOutputStream os = null;
    try {//  w  ww.  j a va 2  s . com
        os = new ByteArrayOutputStream();
        JSONObject jbj = new JSONObject(ackrecp);
        com.krawler.utils.json.base.JSONArray gridinfo = jbj.getJSONArray("items");
        String ginfo[] = new String[gridinfo.length() * 2];
        String ids[] = { "name", "receiptno", "paymentdate", "address" };
        String currency = "USD";
        //            String address = jbj.getString("address");
        String uinfo[] = new String[ids.length];
        for (int i = 0; i < uinfo.length; i++) {
            uinfo[i] = jbj.getString(ids[i]);
        }
        Font font = FontFactory.getFont("Helvetica", 10, Font.BOLD, Color.BLACK);
        Font font1 = FontFactory.getFont("Helvetica", 14, Font.BOLD, Color.BLACK);
        Font font3 = FontFactory.getFont("Helvetica", 12, Font.BOLD, Color.BLACK);
        //Font font4 = FontFactory.getFont("Helvetica", 12, Font.NORMAL, Color.BLACK);
        Font font7 = FontFactory.getFont("Helvetica", 8, Font.BOLD, Color.BLACK);
        Font font10 = FontFactory.getFont("Helvetica", 12, Font.BOLD, Color.BLACK);
        Font font11 = FontFactory.getFont("Helvetica", 12, Font.NORMAL, Color.BLACK);
        Font font12 = FontFactory.getFont("Helvetica", 10, Font.NORMAL, Color.BLACK);
        Document document1 = new Document(PageSize.A4, 15, 15, 15, 15);
        PdfWriter writer = PdfWriter.getInstance(document1, os);
        HeaderFooter temp = new HeaderFooter(new Phrase(
                String.format("Note: This is a computer generated document and does not require signature"),
                font7), false);
        temp.setAlignment(Element.ALIGN_CENTER);
        document1.setFooter(temp);
        document1.open();
        PdfPTable tableHinfo = new PdfPTable(1);
        PdfPTable table = new PdfPTable(1);
        font3.setStyle(Font.UNDERLINE);
        String cnxt = "";//StorageHandler.getProfileStorePath() + "/inceif-200.png";
        PdfPCell cell1 = null;
        try {
            Image img = Image.getInstance(cnxt);
            //                img.scalePercent(90);
            cell1 = new PdfPCell(img);
        } catch (Exception e) {
            cnxt = StorageHandler.GetProfileImgStorePath() + "/140-logo.png";
            Image img = Image.getInstance(cnxt);
            cell1 = new PdfPCell(img);
        }
        cell1.setBorder(0);
        cell1.setPaddingTop(18);
        cell1.setHorizontalAlignment(Element.ALIGN_RIGHT);
        tableHinfo.addCell(cell1);
        tableHinfo = addspace(1, tableHinfo);
        tableHinfo = addspace(4, tableHinfo);
        cell1 = new PdfPCell(new Paragraph("RECEIPT", font1));
        cell1.setBorder(0);
        cell1.setHorizontalAlignment(Element.ALIGN_RIGHT);
        tableHinfo.addCell(cell1);
        tableHinfo = addspace(0, tableHinfo);
        //            cell1 = new PdfPCell(new Paragraph(uinfo[4], font11));
        //            cell1.setBorder(0);
        //            cell1.setHorizontalAlignment(Element.ALIGN_RIGHT);
        //            tableHinfo.addCell(cell1);
        document1.add(tableHinfo);
        PdfPTable tableUinfo = new PdfPTable(1);

        cell1 = new PdfPCell(new Paragraph(receiptheading[0], font12));
        cell1.setBorder(0);
        cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
        tableUinfo.addCell(cell1);
        cell1 = new PdfPCell(new Paragraph(uinfo[0], font10));
        cell1.setBorder(0);
        cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
        tableUinfo.addCell(cell1);
        cell1 = new PdfPCell(new Paragraph(uinfo[3], font11));
        cell1.setBorder(0);
        cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
        tableUinfo.addCell(cell1);

        document1.add(new Paragraph("\u00a0"));
        tableUinfo = addspace(1, tableUinfo);
        String hed[] = { "", "Receipt No : ", "Date : ", "" };

        PdfPTable tableDinfo = new PdfPTable(1);
        //tableDinfo.setTotalWidth(100);
        for (int j = 1; j < 3; j++) {
            PdfPTable nested1 = new PdfPTable(3);
            cell1 = new PdfPCell();
            cell1.setBorder(0);
            nested1.addCell(cell1);

            cell1 = new PdfPCell(new Paragraph(hed[j], font));
            cell1.setBorder(0);
            nested1.addCell(cell1);

            cell1 = new PdfPCell(new Paragraph(uinfo[j], font12));
            cell1.setBorder(0);
            cell1.setHorizontalAlignment(Element.ALIGN_RIGHT);
            nested1.addCell(cell1);

            cell1 = new PdfPCell(nested1);
            cell1.setBorder(0);
            tableDinfo.addCell(cell1);
        }
        PdfPTable container = new PdfPTable(2);
        cell1 = new PdfPCell(tableUinfo);
        cell1.setBorder(0);
        cell1.setPaddingBottom(15);
        container.addCell(cell1);
        cell1 = new PdfPCell(tableDinfo);
        cell1.setBorder(0);
        container.addCell(cell1);
        document1.add(container);
        PdfPTable table1 = new PdfPTable(2);
        String[] colwidth2 = { "Invoice No.", "Amount Paid($)" };
        for (int i = 0; i < colwidth2.length; i++) {
            PdfPCell cell = new PdfPCell(new Paragraph(colwidth2[i], font));
            if (i == 1) {
                cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
                cell.setBorderWidthLeft(0);
            } else {
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setBorderWidthLeft(1);
            }
            cell.setBackgroundColor(Color.getHSBColor(0f, 0f, 0.9f));
            cell.setPaddingBottom(5);
            cell.setBorderWidthRight(1);
            cell.setBorderWidthTop(1);
            table1.addCell(cell);
        }
        table1.setHeaderRows(1);
        double d = 0;
        colwidth2 = new String[] { "invoicenum", "amount" };
        java.text.DecimalFormat df = new java.text.DecimalFormat("0.00");
        for (int i = 0; i < gridinfo.length(); i++) {
            for (int j = 0; j < colwidth2.length; j++) {
                PdfPCell cell = null;
                if (j == 1) {
                    cell = new PdfPCell(new Paragraph(
                            df.format(Double.parseDouble(gridinfo.getJSONObject(i).getString(colwidth2[j]))),
                            font12));
                    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
                    cell.setBorderWidthLeft(0);
                } else {
                    cell = new PdfPCell(
                            new Paragraph(gridinfo.getJSONObject(i).getString(colwidth2[j]), font12));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                    cell.setBorderWidthLeft(1);
                }
                //cell.setMinimumHeight(25);
                cell.setBorderWidthRight(1);
                cell.setPaddingTop(5);
                cell.setFixedHeight(100);
                table1.addCell(cell);
                if (j == colwidth2.length - 1) {
                    d += Double.parseDouble(gridinfo.getJSONObject(i).getString(colwidth2[j]));
                }
            }
        }
        //            EnglishDecimalFormat f1 = new EnglishDecimalFormat();
        PdfPCell cell = new PdfPCell(new Paragraph("", font));
        cell.setBorderWidthBottom(1);
        cell.setBorderWidthRight(0);
        cell.setBorderWidthLeft(1);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        table1.addCell(cell);
        cell = new PdfPCell(new Paragraph("Total              " + df.format(d), font));
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        //cell.setPaddingBottom(15);
        cell.setPaddingLeft(15);
        cell.setPaddingBottom(5);
        cell.setBorderWidthBottom(1);
        cell.setBorderWidthLeft(0);
        cell.setBorderWidthRight(1);
        table1.addCell(cell);
        PdfPTable table3 = new PdfPTable(1);
        cell = new PdfPCell(new Paragraph("Amount in words : " + CurrencyConvert(currency, d), font));
        //cell.setPaddingBottom(15);
        cell.setBorder(0);
        cell.setColspan(4);
        cell.setBorderWidthBottom(1);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setBorderWidthLeft(1);
        cell.setBorderWidthRight(1);
        cell.setPaddingBottom(5);
        table3.addCell(cell);
        document1.add(table1);
        document1.add(table3);
        document1.add(new Paragraph("\u00a0"));

        cell = new PdfPCell(new Paragraph(String.format(
                "All payments are non-refundable and non-transferable. \nThis Receipt is valid subject to clearance of the payments."),
                font11));
        //cell.setPaddingLeft(5);
        cell.setBorder(0);
        table.addCell(cell);

        //            String delFlag = jbj.getString("delflag");
        //            if(delFlag.compareTo("2")==0){
        //                BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED);
        //                PdfContentByte cb = writer.getDirectContentUnder();
        //                cb.saveState();
        //                cb.setColorFill(Color.BLACK);
        //                cb.beginText();
        //                cb.setFontAndSize(bf, 48);
        //                cb.showTextAligned(Element.ALIGN_CENTER, "Canceled Payment", document1.getPageSize().getWidth() / 2, document1.getPageSize().getHeight() / 2, 45);
        //                cb.endText();
        //                cb.restoreState();
        //            }   

        document1.add(table);
        document1.close();
        writer.close();
        os.close();
    } catch (Exception e) {
        System.out.println(e);
    }
    return os;
}

From source file:com.krawler.spring.exportFuctionality.ExportRecord.java

License:Open Source License

public ByteArrayOutputStream exportRatioAnalysis(HttpServletRequest request, JSONObject jobj, String logoPath,
        String comName) throws DocumentException, ServiceException, IOException {
    ByteArrayOutputStream baos = null;
    double total = 0;
    Document document = null;/* ww  w .j ava  2  s. c om*/
    PdfWriter writer = null;
    try {
        //flag 1 = BalanceSheet , 2 = P&L

        baos = new ByteArrayOutputStream();
        document = new Document(PageSize.A4, 15, 15, 15, 15);
        writer = PdfWriter.getInstance(document, baos);
        document.open();
        PdfPTable mainTable = new PdfPTable(1);
        mainTable.setWidthPercentage(100);

        PdfPTable tab1 = null;
        Rectangle page = document.getPageSize();

        int bmargin = 15; //border margin
        PdfContentByte cb = writer.getDirectContent();
        cb.rectangle(bmargin, bmargin, page.getWidth() - bmargin * 2, page.getHeight() - bmargin * 2);
        cb.setColorStroke(Color.WHITE);
        cb.stroke();

        //            addHeaderFooter(document, writer);

        PdfPTable table1 = new PdfPTable(4);
        table1.setWidthPercentage(100);
        table1.setWidths(new float[] { 25, 25, 25, 25 });

        PdfPCell blankCell = new PdfPCell();
        blankCell.setBorder(0);
        tab1 = addCompanyLogo(logoPath, comName);
        PdfPCell cell1 = new PdfPCell(tab1);
        cell1.setBorder(0);
        table1.addCell(cell1);
        table1.addCell(blankCell);
        table1.addCell(blankCell);
        table1.addCell(blankCell);

        PdfPCell cell2 = new PdfPCell(new Paragraph(comName, fontSmallRegular));
        cell2.setBorder(0);
        table1.addCell(cell2);
        table1.addCell(blankCell);
        table1.addCell(blankCell);
        table1.addCell(blankCell);

        PdfPCell headerCell = createCell(
                messageSource.getMessage("acc.ra.tabTT", null, RequestContextUtils.getLocale(request)),
                FontContext.TABLE_HEADER, Element.ALIGN_LEFT, 0, 5);
        headerCell.setBorder(0);
        table1.addCell(headerCell);
        table1.addCell(blankCell);
        table1.addCell(blankCell);
        table1.addCell(blankCell);

        table1.addCell(blankCell);
        table1.addCell(blankCell);
        table1.addCell(blankCell);
        table1.addCell(blankCell);

        JSONArray ObjArr = jobj.getJSONArray("data");

        PdfPCell HeaderCell1 = createCell(
                messageSource.getMessage("acc.ra.principalGroups", null,
                        RequestContextUtils.getLocale(request)),
                FontContext.SMALL_TEXT, Element.ALIGN_LEFT, 0, 5);
        HeaderCell1.setBorderWidthLeft(1);
        HeaderCell1.setBorderWidthBottom(1);
        HeaderCell1.setBorderWidthTop(1);
        PdfPCell HeaderCell2 = createCell(
                messageSource.getMessage("acc.ra.value", null, RequestContextUtils.getLocale(request)),
                FontContext.SMALL_TEXT, Element.ALIGN_RIGHT, 0, 5);
        HeaderCell2.setBorderWidthBottom(1);
        HeaderCell2.setBorderWidthTop(1);

        PdfPCell HeaderCell3 = createCell(
                messageSource.getMessage("acc.ra.principalRatios", null,
                        RequestContextUtils.getLocale(request)),
                FontContext.SMALL_TEXT, Element.ALIGN_LEFT, 0, 5);
        HeaderCell3.setBorderWidthBottom(1);
        HeaderCell3.setBorderWidthTop(1);
        HeaderCell3.setBorderWidthLeft(1);
        PdfPCell HeaderCell4 = createCell(
                messageSource.getMessage("acc.ra.value", null, RequestContextUtils.getLocale(request)),
                FontContext.SMALL_TEXT, Element.ALIGN_RIGHT, 0, 5);
        HeaderCell4.setBorderWidthBottom(1);
        HeaderCell4.setBorderWidthRight(1);
        HeaderCell4.setBorderWidthTop(1);
        table1.addCell(HeaderCell1);
        table1.addCell(HeaderCell2);
        table1.addCell(HeaderCell3);
        table1.addCell(HeaderCell4);
        PdfPCell objCell1 = null;
        PdfPCell objCell2 = null;
        PdfPCell objCell3 = null;
        PdfPCell objCell4 = null;
        int objArrLength = ObjArr.length();
        for (int i = 0; i < objArrLength; i++) {
            JSONObject leftObj = ObjArr.getJSONObject(i);
            objCell1 = createBalanceSheetCell(leftObj.getString("lname"), FontContext.TABLE_DATA,
                    Element.ALIGN_LEFT, 0, 5, 0);
            objCell2 = createBalanceSheetCell(leftObj.getString("lvalue"), FontContext.TABLE_DATA,
                    Element.ALIGN_RIGHT, 0, 0, 0);
            objCell3 = createBalanceSheetCell(leftObj.getString("rname"), FontContext.TABLE_DATA,
                    Element.ALIGN_LEFT, 0, 5, 0);
            objCell4 = createBalanceSheetCell(leftObj.getString("rvalue"), FontContext.TABLE_DATA,
                    Element.ALIGN_RIGHT, 0, 0, 0);
            objCell1.setBorderWidthLeft(1);
            objCell3.setBorderWidthLeft(1);
            objCell4.setBorderWidthRight(1);
            if (i != (objArrLength - 1)) {
                table1.addCell(objCell1);
                table1.addCell(objCell2);
                table1.addCell(objCell3);
                table1.addCell(objCell4);
            }
        }
        objCell1.setBorderWidthBottom(1);
        objCell2.setBorderWidthBottom(1);
        objCell3.setBorderWidthBottom(1);
        objCell4.setBorderWidthBottom(1);
        table1.addCell(objCell1);
        table1.addCell(objCell2);
        table1.addCell(objCell3);
        table1.addCell(objCell4);

        PdfPCell mainCell11 = new PdfPCell(table1);
        mainCell11.setBorder(0);
        mainCell11.setPadding(10);
        mainTable.addCell(mainCell11);

        document.add(mainTable);
    } catch (Exception ex) {
        return null;
    } finally {
        if (document != null) {
            document.close();
        }
        if (writer != null) {
            writer.close();
        }
        if (baos != null) {
            baos.close();
        }
    }
    return baos;
}

From source file:com.krawler.spring.exportFuctionality.ExportRecord.java

License:Open Source License

public ByteArrayOutputStream exportCashFlow(JSONObject jobj, String logoPath, String comName,
        HttpServletRequest request) throws DocumentException, ServiceException, IOException {
    ByteArrayOutputStream baos = null;
    double total = 0;
    Document document = null;//from w  ww .  j a v  a  2  s.c  o  m
    PdfWriter writer = null;
    try {

        baos = new ByteArrayOutputStream();
        document = new Document(PageSize.A4, 15, 15, 15, 15);
        writer = PdfWriter.getInstance(document, baos);
        document.open();
        PdfPTable mainTable = new PdfPTable(1);
        mainTable.setWidthPercentage(100);

        PdfPTable tab1 = null;
        Rectangle page = document.getPageSize();

        int bmargin = 15; //border margin
        PdfContentByte cb = writer.getDirectContent();
        cb.rectangle(bmargin, bmargin, page.getWidth() - bmargin * 2, page.getHeight() - bmargin * 2);
        cb.setColorStroke(Color.WHITE);
        cb.stroke();

        PdfPTable table1 = new PdfPTable(2);
        table1.setWidthPercentage(100);
        table1.setWidths(new float[] { 30, 20 });

        PdfPCell blankCell = new PdfPCell();
        blankCell.setBorder(0);
        tab1 = addCompanyLogo(logoPath, comName);
        PdfPCell cell1 = new PdfPCell(tab1);
        cell1.setBorder(0);
        table1.addCell(cell1);
        table1.addCell(blankCell);
        table1.addCell(blankCell);
        table1.addCell(blankCell);

        PdfPCell cell2 = new PdfPCell(new Paragraph(comName, fontSmallRegular));
        cell2.setBorder(0);
        table1.addCell(cell2);
        table1.addCell(blankCell);
        table1.addCell(blankCell);
        table1.addCell(blankCell);

        PdfPCell headerCell = createCell(messageSource.getMessage("acc.dashboard.cashFlowStatement", null,
                RequestContextUtils.getLocale(request)), fontMediumBold, Element.ALIGN_LEFT, 0, 5);
        headerCell.setBorder(0);
        table1.addCell(headerCell);
        table1.addCell(blankCell);
        table1.addCell(blankCell);
        table1.addCell(blankCell);

        table1.addCell(blankCell);
        table1.addCell(blankCell);
        table1.addCell(blankCell);
        table1.addCell(blankCell);

        JSONArray ObjArr = jobj.getJSONArray("data");

        PdfPCell HeaderCell1 = createCell(
                messageSource.getMessage("acc.report.2", null, RequestContextUtils.getLocale(request)),
                fontSmallBold, Element.ALIGN_LEFT, 0, 5);
        HeaderCell1.setBorderWidthLeft(1);
        HeaderCell1.setBorderWidthBottom(1);
        HeaderCell1.setBorderWidthTop(1);
        HeaderCell1.setBorderWidthRight(1);
        PdfPCell HeaderCell2 = createCell(
                messageSource.getMessage("acc.ra.value", null, RequestContextUtils.getLocale(request)),
                fontSmallBold, Element.ALIGN_RIGHT, 0, 5);
        HeaderCell2.setBorderWidthBottom(1);
        HeaderCell2.setBorderWidthTop(1);
        HeaderCell2.setBorderWidthRight(1);

        table1.addCell(HeaderCell1);
        table1.addCell(HeaderCell2);
        PdfPCell objCell1 = null;
        PdfPCell objCell2 = null;
        int objArrLength = ObjArr.length();
        for (int i = 0; i < objArrLength; i++) {
            JSONObject leftObj = ObjArr.getJSONObject(i);
            if (leftObj.has("lfmt") && leftObj.getString("lfmt").equals("title"))
                objCell1 = createBalanceSheetCell(leftObj.getString("lname"), fontSmallBold,
                        Element.ALIGN_CENTER, 0, 5, 0);
            else
                objCell1 = createBalanceSheetCell(leftObj.getString("lname"), fontSmallRegular,
                        Element.ALIGN_LEFT, 0, 5, 0);
            objCell2 = createBalanceSheetCell(leftObj.getString("lvalue"), fontSmallRegular,
                    Element.ALIGN_RIGHT, 0, 0, 0);
            objCell1.setBorderWidthLeft(1);
            objCell2.setBorderWidthRight(1);
            objCell1.setBorderWidthRight(1);
            objCell1.setBorderWidthBottom(1);
            objCell2.setBorderWidthBottom(1);
            if (i != (objArrLength - 1)) {
                table1.addCell(objCell1);
                table1.addCell(objCell2);
            }
        }
        objCell1.setBorderWidthBottom(1);
        objCell2.setBorderWidthBottom(1);
        table1.addCell(objCell1);
        table1.addCell(objCell2);

        PdfPCell mainCell11 = new PdfPCell(table1);
        mainCell11.setBorder(0);
        mainCell11.setPadding(10);
        mainTable.addCell(mainCell11);

        document.add(mainTable);
    } catch (Exception ex) {
        return null;
    } finally {
        if (document != null) {
            document.close();
        }
        if (writer != null) {
            writer.close();
        }
        if (baos != null) {
            baos.close();
        }
    }
    return baos;
}