Example usage for com.lowagie.text FontFactory getFont

List of usage examples for com.lowagie.text FontFactory getFont

Introduction

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

Prototype


public static Font getFont(String fontname, float size, int style) 

Source Link

Document

Constructs a Font-object.

Usage

From source file:br.com.moises.servlet.Embarque.java

@Override
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
    out.print("Pasou auqe");

    try {/*from w  w w. j  a va2 s.  co m*/
        Document document = new Document(PageSize.A4, 30, 20, 20, 30);
        OutputStream outputStream = new FileOutputStream("embarque.pdf");
        //   response.setContentType("application/pdf");
        Long id = Long.parseLong(request.getParameter("num_embarque"));
        //recupera o embarque
        embarque = embarqueSuport.getEmbarqueById(id);
        itens = itSuport.itensEmbarquePorEmbarque(embarque);
        out.print(itens.size());

        PdfWriter.getInstance(document, response.getOutputStream());

        document.open();
        // Titulo

        document.addTitle("Comprovante de Coleta");

        Paragraph titulo = new Paragraph("Comprovante de Coleta");
        //            //
        document.add(titulo);
        document.add(new Paragraph("\n\n"));
        PdfPTable topo = new PdfPTable(2);
        Image image = Image.getInstance("E:\\icons\\32\\cliente.png");

        topo.getDefaultCell().setBorder(0);
        topo.getDefaultCell().addElement(image);
        topo.addCell(image);
        topo.addCell("MOISES JUVENAL DA SILVA\n" + "Rua.: Bertioga N 49" + "Jardim Amrica I"
                + "Vrzea Paulista SP");

        document.add(topo);
        document.add(new Paragraph(
                "-------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(
                "TRANSP.: " + embarque.getTransportadora().getId() + " - "
                        + embarque.getTransportadora().getNome(),
                FontFactory.getFont(FontFactory.HELVETICA, 14, Color.BLUE)));
        document.add(new Paragraph(
                "-------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(new Date().toString()));

        PdfPTable table = new PdfPTable(2);
        table.addCell("");

        for (ItensEmbarque l : itens) {
            document.add(new Paragraph(String.valueOf(l.getId())));
        }
        // step 5
        document.close();
    } catch (DocumentException de) {
        throw new IOException(de.getMessage());
    }

}

From source file:br.org.acessobrasil.silvinha.util.GeraRelatorioPDF.java

License:Open Source License

public static boolean geraRelatorio(File file) {
    TradGeraRelatorioPDF.carregaTexto(TokenLang.LANG);
    Document document = new Document(PageSize.A4);
    try {/*  w ww .  j  a va 2  s .com*/
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file));
        writer.setPageEvent(new HeaderAndFooter());
        document.open();
        int linha = 0, j, tot_pg = ResumoDoRelatorio.getTotPage();
        //calcula o total de htmls
        float tot_link = 0.0f;
        for (j = 1; j <= tot_pg; j++) {
            String conteudo = ResumoDoRelatorio.getPage(j);
            String arr[] = conteudo.split("\n");
            tot_link += arr.length;
        }
        PainelStatusBar.showProgTarReq();
        //loop por todas as pginas da paginacao
        for (j = 1; j <= tot_pg; j++) {
            String conteudo = ResumoDoRelatorio.getPage(j);
            String arr[] = conteudo.split("\n");
            int tot = arr.length;
            int i;
            //loop por todos os links
            for (i = 0; i < tot; i++) {
                progresso = (linha++ / tot_link) * 100.0f;
                PainelStatusBar.setValueProgress((int) progresso);
                String arr2[] = arr[i].split("\t");

                if (arr2.length == 8) {

                    String strUrl = arr2[7];// URL
                    /*
                    int ap1 = Integer.parseInt(arr2[4]);// Aviso1
                    int ep1 = Integer.parseInt(arr2[1]);// Erro1
                    int ap2 = Integer.parseInt(arr2[5]);// Aviso2
                    int ep2 = Integer.parseInt(arr2[2]);// Erro2
                    int ap3 = Integer.parseInt(arr2[6]);// Aviso3
                    int ep3 = Integer.parseInt(arr2[3]);// Erro3
                    */
                    String myHash = arr2[0];

                    RelatorioDaUrl relatorio = new RelatorioDaUrl();
                    relatorio.recarregaArquivoRelatorioEmXml2(myHash);

                    document.add(new Phrase("\n"));
                    Font font = FontFactory.getFont(FontFactory.HELVETICA, Font.DEFAULTSIZE, Font.BOLD);

                    Chunk url = new Chunk(strUrl, font);
                    Paragraph p1 = new Paragraph(TradGeraRelatorioPDF.RELATORIO_URL);
                    p1.add(url);
                    p1.setAlignment(Paragraph.ALIGN_LEFT);
                    document.add(p1);
                    document.add(new Phrase("\n\n"));

                    if (relatorio.getErrosPrioridade1() <= 0 && relatorio.getErrosPrioridade2() <= 0
                            && relatorio.getErrosPrioridade3() <= 0) {
                        Paragraph p2 = new Paragraph(TradGeraRelatorioPDF.PAGINAS_SEM_ERROS);
                        p2.setAlignment(Paragraph.ALIGN_CENTER);
                        document.add(p2);

                    } else {

                        if (relatorio.getErrosPrioridade1() > 0) {
                            Paragraph p = new Paragraph(TradGeraRelatorioPDF.ERROS_P1, font);
                            p1.setAlignment(Paragraph.ALIGN_LEFT);
                            document.add(p);
                            document.add(new Chunk("\n"));
                            PdfPTable table = geraLista(relatorio.getListaErrosP1());
                            if (table != null) {
                                document.add(table);
                            }
                            document.add(new Phrase("\n\n"));
                        }

                        if (relatorio.getErrosPrioridade2() > 0) {
                            Paragraph p = new Paragraph(TradGeraRelatorioPDF.ERROS_P2, font);
                            p1.setAlignment(Paragraph.ALIGN_LEFT);
                            document.add(p);
                            document.add(new Chunk("\n"));
                            PdfPTable table = geraLista(relatorio.getListaErrosP2());
                            if (table != null) {
                                document.add(table);
                            }
                            document.add(new Phrase("\n\n"));
                        }

                        if (relatorio.getErrosPrioridade3() > 0) {
                            Paragraph p = new Paragraph(TradGeraRelatorioPDF.ERROS_P3, font);
                            p1.setAlignment(Paragraph.ALIGN_LEFT);
                            document.add(p);
                            document.add(new Chunk("\n"));
                            PdfPTable table = geraLista(relatorio.getListaErrosP3());
                            if (table != null) {
                                document.add(table);
                            }
                            document.add(new Phrase("\n\n"));
                        }
                        document.newPage();
                    }
                }
            }
        }
        writer.flush();
        document.close();
    } catch (DocumentException de) {
        log.error(de.getMessage(), de);
        PainelStatusBar.hideProgTarReq();
        return false;
    } catch (IOException ioe) {
        log.error(ioe.getMessage(), ioe);
        PainelStatusBar.hideProgTarReq();
        return false;
    }
    PainelStatusBar.hideProgTarReq();
    return true;
}

From source file:br.org.acessobrasil.silvinha.util.GeraRelatorioPDF.java

License:Open Source License

public static boolean geraRelatorio_bkp(File file, ResumoDoRelatorio resumo) {

    Document document = new Document(PageSize.A4);
    try {/*from   w  w w  . j  a  v a  2  s  . c o  m*/
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file));
        writer.setPageEvent(new HeaderAndFooter());
        document.open();

        ArrayList<RelatorioDaUrl> relatorios = resumo.getRelatorios();
        loop: for (RelatorioDaUrl relatorio : relatorios) {
            document.add(new Phrase("\n"));
            Font font = FontFactory.getFont(FontFactory.HELVETICA, Font.DEFAULTSIZE, Font.BOLD);

            Chunk url = new Chunk(relatorio.getUrl(), font);
            Paragraph p1 = new Paragraph(TradGeraRelatorioPDF.RELATORIO_URL);
            p1.add(url);
            p1.setAlignment(Paragraph.ALIGN_LEFT);
            document.add(p1);
            document.add(new Phrase("\n\n"));

            if (relatorio.getErrosPrioridade1() <= 0 && relatorio.getErrosPrioridade2() <= 0
                    && relatorio.getErrosPrioridade3() <= 0) {
                Paragraph p2 = new Paragraph(TradGeraRelatorioPDF.PAGINAS_SEM_ERROS);
                p2.setAlignment(Paragraph.ALIGN_CENTER);
                document.add(p2);
                continue loop;
            }

            if (relatorio.getErrosPrioridade1() > 0) {
                Paragraph p = new Paragraph(TradGeraRelatorioPDF.ERROS_P1_SEM_TAB, font);
                p1.setAlignment(Paragraph.ALIGN_LEFT);
                document.add(p);
                document.add(new Chunk("\n"));
                PdfPTable table = geraLista(relatorio.getListaErrosP1());
                if (table != null) {
                    document.add(table);
                }
                document.add(new Phrase("\n\n"));
            }

            if (relatorio.getErrosPrioridade2() > 0) {
                Paragraph p = new Paragraph(TradGeraRelatorioPDF.ERROS_P2_SEM_TAB, font);
                p1.setAlignment(Paragraph.ALIGN_LEFT);
                document.add(p);
                document.add(new Chunk("\n"));
                PdfPTable table = geraLista(relatorio.getListaErrosP2());
                if (table != null) {
                    document.add(table);
                }
                document.add(new Phrase("\n\n"));
            }

            if (relatorio.getErrosPrioridade3() > 0) {
                Paragraph p = new Paragraph(TradGeraRelatorioPDF.ERROS_P3_SEM_TAB, font);
                p1.setAlignment(Paragraph.ALIGN_LEFT);
                document.add(p);
                document.add(new Chunk("\n"));
                PdfPTable table = geraLista(relatorio.getListaErrosP3());
                if (table != null) {
                    document.add(table);
                }
                document.add(new Phrase("\n\n"));
            }
            document.newPage();
        }

        writer.flush();
        document.close();
    } catch (DocumentException de) {
        log.error(de.getMessage(), de);
        return false;
    } catch (IOException ioe) {
        log.error(ioe.getMessage(), ioe);
        return false;
    }
    return true;
}

From source file:ca.nines.ise.writer.RTFWriter.java

License:Open Source License

@Override
public void render(DOM dom, Annotation annotation) throws DocumentException, IOException {
    this.preprocess(dom, annotation);

    fontStack = new ArrayDeque<>();
    fontStack.push(FontFactory.getFont("Times New Roman", 12, Color.BLACK));
    Font font;/*from   www  . j a v  a  2 s  .c  o m*/

    boolean inSP = false; // in speech prefix
    boolean inSD = false; // in stage direction
    boolean inDQ = false; // in a double quote
    boolean inS = false; // in a speech
    boolean inHW = false;
    char part = 'i';

    String mode = "verse";

    doc.open();
    startParagraph();

    for (Node n : dom) {
        switch (n.type()) {
        case ABBR:
            break;
        case CHAR:
            addChunk(n.unicode());
            break;
        case EMPTY:
            switch (n.getName()) {
            case "FNLOC":
                EmptyNode fnloc = (EmptyNode) n;
                Note note = annotation.get(Integer.parseInt(fnloc.getAttribute("ref")) - 1);
                if (!note.hasNoteLevel("1")) {
                    break;
                }
                this.footnote(note);
                break;
            case "TLN":
            case "L":
                if (mode.equals("prose")) {
                    break;
                }
                if (inS) {
                    startParagraph(p2);
                } else {
                    startParagraph(p1);
                }
                EmptyNode en = (EmptyNode) n;
                if (en.hasAttribute("part")) {
                    part = en.getAttribute("part").charAt(0);
                } else {
                    part = 'i';
                }
                break;
            }
            break;
        case END:
            switch (n.getName()) {
            case "FOREIGN":
                fontStack.pop();
                break;
            case "HW":
                inHW = false;
                break;
            case "I":
                fontStack.pop();
                break;
            case "LD":
                startParagraph();
                break;
            case "S":
                inS = false;
                break;
            case "SD":
                fontStack.pop();
                inSD = false;
                break;
            case "SP":
                addChunk(". ");
                inSP = false;
                break;
            }
            break;
        case START:
            switch (n.getName()) {
            case "FOREIGN":
                font = new Font(fontStack.getFirst());
                font.setStyle(Font.ITALIC);
                fontStack.push(font);
                break;
            case "HW":
                inHW = true;
                break;
            case "I":
                font = new Font(fontStack.getFirst());
                font.setStyle(Font.ITALIC);
                fontStack.push(font);
                break;
            case "LD":
                startParagraph(ld);
                break;
            case "MODE":
                mode = ((TagNode) n).getAttribute("t");
                break;
            case "S":
                if (mode.equals("prose")) {
                    startParagraph(prose);
                }
                inS = true;
                break;
            case "SD":
                font = new Font(fontStack.getFirst());
                font.setStyle(Font.ITALIC);
                StartNode start = (StartNode) n;
                if (start.hasAttribute("t") && start.getAttribute("t").contains("exit")) {
                    startParagraph(exit);
                }
                if (start.hasAttribute("t") && start.getAttribute("t").contains("optional")) {
                    font.setColor(Color.GRAY);
                }
                fontStack.push(font);
                inSD = true;
                break;
            case "SP":
                inSP = true;
                break;
            }
            break;
        case TEXT:
            String txt = n.getText();
            txt = txt.replace("--", "\u2014");
            txt = txt.replace("\n", "");

            if (inSP) {
                addChunk(txt.toUpperCase());
                break;
            }

            if (inHW) {
                txt = txt.replaceFirst("[(]", "");
                inHW = false;
            }

            if (inSD) {
                // DOES NOT MATCH AFTER A TAG.
                if ((txt.indexOf('[') >= 0) || (txt.indexOf(']') >= 0)) {
                    StringBuilder sb = new StringBuilder();
                    for (int i = 0; i < txt.length(); i++) {
                        char c = txt.charAt(i);
                        if (c == '[' || c == ']') {
                            if (sb.length() > 0) {
                                addChunk(sb.toString());
                                sb = new StringBuilder();
                            }
                            addDirect("{\\i0" + String.valueOf(c) + "}");
                        } else {
                            sb.append(c);
                        }
                    }
                    if (sb.length() > 0) {
                        addChunk(sb.toString());
                    }
                    break;
                } else {
                    addChunk(txt);
                    break;
                }
            }

            if (part != 'i' && inS) {
                RtfTab tab = null;
                String tabStr = "";
                if (part == 'm') {
                    tab = new RtfTab(100, RtfTab.TAB_LEFT_ALIGN);
                    tabStr = "\t";
                }
                if (part == 'f') {
                    tab = new RtfTab(200, RtfTab.TAB_LEFT_ALIGN);
                    tabStr = "\t\t";
                }
                if (tab != null) {
                    p.add(tab);
                    addChunk(tabStr);
                }
                part = 'i'; // ensure it's only done once for m or f.
            }

            // fix quotation marks.
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < txt.length(); i++) {
                char c = txt.charAt(i);
                switch (c) {
                case '"':
                    if (inDQ) {
                        // typographer's end quote.
                        sb.append("\u201D");
                        inDQ = false;
                    } else {
                        // typographer's start quote.
                        sb.append("\u201C");
                        inDQ = true;
                    }
                    break;
                case '\'':
                    sb.append("\u2019"); // appostrophe
                    break;
                default:
                    sb.append(c);
                }
            }
            addChunk(sb.toString());
            break;
        }
    }

    startParagraph();

    doc.close();
}

From source file:com.actelion.research.spiritapp.print.CagePrinterPDF.java

License:Open Source License

private static void print(PdfContentByte canvas, String txt, float x, float y, float maxX, int maxHeight,
        int lineHeight, String fontName, Color color, float fontSize) throws Exception {
    float width = maxX - x - 5;
    float minY = Math.min(y, y - maxHeight + lineHeight - 3);
    if (txt == null)
        return;//w  ww  . j a va 2  s. co m

    canvas.setFontAndSize(BaseFont.createFont(fontName, "Cp1252", false), fontSize);
    while (txt.length() > 0 && y >= minY) {
        int index = 0;
        while (true) {
            int index2 = index + 1;
            if (index2 >= txt.length()) {
                index = index2;
                break;
            }
            float w = canvas.getEffectiveStringWidth(txt.substring(0, index2), true);
            System.out.println("CagePrinterPDF.print()   " + txt.substring(0, index2) + " " + w + "," + width);
            if (w > width)
                break;
            index = index2;
        }
        if (index < 0)
            index = txt.length();
        String t = txt.substring(0, index);
        System.out.println(
                "CagePrinterPDF.print() " + t + " at " + x + "x" + y + " (of " + txt + ") minY=" + minY);
        txt = txt.substring(index).trim();
        Phrase phrase = new Paragraph(t, FontFactory.getFont(fontName, fontSize, color));
        ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, phrase, x, y, 0);
        y -= lineHeight;
    }
}

From source file:com.amphisoft.epub2pdf.content.TextFactory.java

License:Open Source License

public static boolean setDefaultFontByName(String fontName) {
    fontName = fontName.toLowerCase().trim();
    if (TextFactory.fontFamilyRegistered(fontName)) {
        Font newDefaultFont = null;
        try {//from www.  ja  v  a 2s. com
            newDefaultFont = FontFactory.getFont(fontName, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
        } catch (ExceptionConverter eC) {
            if (eC.getException() instanceof UnsupportedEncodingException) {
                newDefaultFont = FontFactory.getFont(fontName, FontFactory.defaultEncoding, BaseFont.EMBEDDED);
            } else {
                throw new RuntimeException(eC);
            }
        }
        newDefaultFont.setSize(_defaultFontSize);
        _defaultFont = newDefaultFont;
        return true;
    } else {
        return false;
    }
}

From source file:com.amphisoft.epub2pdf.content.TextFactory.java

License:Open Source License

public static boolean setDefaultFontMonoByName(String fontName) {
    fontName = fontName.toLowerCase();// ww  w  .  jav  a2  s . c om
    if (TextFactory.fontFamilyRegistered(fontName)) {
        Font newDefaultMonoFont = FontFactory.getFont(fontName, FontFactory.defaultEncoding, BaseFont.EMBEDDED);
        newDefaultMonoFont.setSize(_defaultFontMonoSize);
        _defaultFontMono = newDefaultMonoFont;
        return true;
    } else {
        return false;
    }
}

From source file:com.efficio.fieldbook.service.LabelPrintingServiceImpl.java

License:Open Source License

/**
 * Gets the cell height./*ww w.j a va  2s .  co m*/
 *
 * @param numberOfRowsPerPage the number of rows per page
 * @param pageSizeId the page size id
 * @return the cell height
 */
/*
private float getCellHeight(int numberOfRowsPerPage, int pageSizeId){
if(pageSizeId == AppConstants.SIZE_OF_PAPER_A4){
    if(numberOfRowsPerPage == 7){
        return 108f; //ok
    }else if(numberOfRowsPerPage == 8){
        return 97f;//ok
    }else if(numberOfRowsPerPage == 10){
        return 72.5f;
    }
}else{
    if(numberOfRowsPerPage == 7){
        return 108f; //ok
    }else if(numberOfRowsPerPage == 8){
        return 98.1f;//ok
    }else if(numberOfRowsPerPage == 10){
        return 72.5f;//ok
    }
}
           
return 0f;
}
*/
/* (non-Javadoc)
 * @see com.efficio.fieldbook.service.api.LabelPrintingService#generateLabels(com.efficio.fieldbook.web.fieldmap.bean.UserFieldmap)
 */
@Override
public String generatePDFLabels(List<StudyTrialInstanceInfo> trialInstances,
        UserLabelPrinting userLabelPrinting, ByteArrayOutputStream baos) throws MiddlewareQueryException {

    // setUserLabelPrinting(form.getUserLabelPrinting());
    int pageSizeId = Integer.parseInt(userLabelPrinting.getSizeOfLabelSheet());
    int numberOfLabelPerRow = Integer.parseInt(userLabelPrinting.getNumberOfLabelPerRow());
    int numberofRowsPerPageOfLabel = Integer.parseInt(userLabelPrinting.getNumberOfRowsPerPageOfLabel());
    int totalPerPage = numberOfLabelPerRow * numberofRowsPerPageOfLabel;
    String leftSelectedFields = userLabelPrinting.getLeftSelectedLabelFields();
    String rightSelectedFields = userLabelPrinting.getRightSelectedLabelFields();
    String barcodeNeeded = userLabelPrinting.getBarcodeNeeded();

    String firstBarcodeField = userLabelPrinting.getFirstBarcodeField();
    String secondBarcodeField = userLabelPrinting.getSecondBarcodeField();
    String thirdBarcodeField = userLabelPrinting.getThirdBarcodeField();

    String currentDate = DateUtil.getCurrentDate();
    // String fileName = currentDate + ".pdf";

    String fileName = userLabelPrinting.getFilenameDLLocation();

    try {
        FileOutputStream fileOutputStream = new FileOutputStream(fileName);

        try {

            // Image image1 = Image.getInstance(imageLocation);

            // PageSize.A4
            LabelPaper paper = LabelPaperFactory.generateLabelPaper(numberOfLabelPerRow,
                    numberofRowsPerPageOfLabel, pageSizeId);

            Rectangle pageSize = PageSize.LETTER;

            if (pageSizeId == AppConstants.SIZE_OF_PAPER_A4.getInt())
                pageSize = PageSize.A4;

            Document document = new Document(pageSize);
            /*
             * 2, 2, 33.3f, 5
             * 15, 0, 42, 5
             * 10, 0, 17, 5
             * 10, 0, 17, 5
             * 5, 0, 0, 5
             * 15, 0, 37, 5
             * 10, 0, 17, 5
            if (pageSizeId == AppConstants.SIZE_OF_PAPER_LETTER) {
            if (numberofRowsPerPageOfLabel == 7)
                document.setMargins(10, 0, 17, 5);
            else if (numberofRowsPerPageOfLabel == 8)
                document.setMargins(5, 0, 0, 5);
            else if (numberofRowsPerPageOfLabel == 10)
                document.setMargins(2, 2, 33.3f, 5);
            } else if (pageSizeId == AppConstants.SIZE_OF_PAPER_A4) {
            if (numberofRowsPerPageOfLabel == 7)
                document.setMargins(15, 0, 42, 5);
            else if (numberofRowsPerPageOfLabel == 8)
                document.setMargins(15, 0, 37, 5);
            else if (numberofRowsPerPageOfLabel == 10)
                document.setMargins(6, 2, 17.5f, 5);
            }
            */
            //float marginLeft, float marginRight, float marginTop, float marginBottom
            document.setMargins(paper.getMarginLeft(), paper.getMarginRight(), paper.getMarginTop(),
                    paper.getMarginBottom());

            // PdfWriter writer = PdfWriter.getInstance(document, baos);
            PdfWriter writer = PdfWriter.getInstance(document, fileOutputStream);
            // step 3
            document.open();
            // step 4

            PdfContentByte canvas = writer.getDirectContent();

            int i = 0;
            int fixTableRowSize = numberOfLabelPerRow;
            PdfPTable table = new PdfPTable(fixTableRowSize);

            // table.writeSelectedRows(0, -1, 10, 12, canvas);
            float columnWidthSize = 265f;// 180f;
            float[] widthColumns = new float[fixTableRowSize];

            for (int counter = 0; counter < widthColumns.length; counter++) {
                widthColumns[counter] = columnWidthSize;
            }

            table.setWidths(widthColumns);
            table.setWidthPercentage(100);
            int width = 600;
            int height = 75;

            List<File> filesToBeDeleted = new ArrayList<File>();
            //float cellHeight = getCellHeight(numberofRowsPerPageOfLabel, pageSizeId);
            float cellHeight = paper.getCellHeight();

            for (StudyTrialInstanceInfo trialInstance : trialInstances) {
                FieldMapTrialInstanceInfo fieldMapTrialInstanceInfo = trialInstance.getTrialInstance();

                Map<String, String> moreFieldInfo = new HashMap<String, String>();
                moreFieldInfo.put("locationName", fieldMapTrialInstanceInfo.getLocationName());
                moreFieldInfo.put("blockName", fieldMapTrialInstanceInfo.getBlockName());
                moreFieldInfo.put("selectedName", trialInstance.getFieldbookName());
                moreFieldInfo.put("trialInstanceNumber", fieldMapTrialInstanceInfo.getTrialInstanceNo());

                for (FieldMapLabel fieldMapLabel : fieldMapTrialInstanceInfo.getFieldMapLabels()) {

                    i++;
                    String barcodeLabel = generateBarcodeField(moreFieldInfo, fieldMapLabel, firstBarcodeField,
                            secondBarcodeField, thirdBarcodeField, barcodeNeeded);
                    if ("0".equalsIgnoreCase(barcodeNeeded)) {
                        barcodeLabel = " ";
                    }

                    BitMatrix bitMatrix = new Code128Writer().encode(barcodeLabel, BarcodeFormat.CODE_128,
                            width, height, null);
                    String imageLocation = System.getProperty("user.home") + "/" + Math.random() + ".png";
                    File imageFile = new File(imageLocation);
                    FileOutputStream fout = new FileOutputStream(imageFile);
                    MatrixToImageWriter.writeToStream(bitMatrix, "png", fout);
                    filesToBeDeleted.add(imageFile);

                    Image mainImage = Image.getInstance(imageLocation);

                    PdfPCell cell = new PdfPCell();
                    cell.setFixedHeight(cellHeight);
                    cell.setNoWrap(false);
                    cell.setPadding(5f);
                    cell.setPaddingBottom(1f);

                    PdfPTable innerImageTableInfo = new PdfPTable(1);
                    innerImageTableInfo.setWidths(new float[] { 1 });
                    innerImageTableInfo.setWidthPercentage(82);
                    PdfPCell cellImage = new PdfPCell();
                    if ("1".equalsIgnoreCase(barcodeNeeded)) {
                        cellImage.addElement(mainImage);
                    } else {
                        cellImage.addElement(new Paragraph(" "));
                    }
                    cellImage.setBorder(Rectangle.NO_BORDER);
                    cellImage.setBackgroundColor(Color.white);
                    cellImage.setPadding(1.5f);

                    innerImageTableInfo.addCell(cellImage);

                    //float fontSize = 6.8f;
                    float fontSize = paper.getFontSize();
                    //if (numberofRowsPerPageOfLabel == 10)
                    //    fontSize = 4.8f;

                    Font fontNormal = FontFactory.getFont("Arial", fontSize, Font.NORMAL);

                    // cell.addElement(mainImage);
                    cell.addElement(innerImageTableInfo);

                    cell.addElement(new Paragraph());
                    for (int row = 0; row < 5; row++) {
                        if (row == 0) {
                            PdfPTable innerDataTableInfo = new PdfPTable(1);
                            innerDataTableInfo.setWidths(new float[] { 1 });
                            innerDataTableInfo.setWidthPercentage(85);

                            Font fontNormalData = FontFactory.getFont("Arial", 5.0f, Font.NORMAL);
                            PdfPCell cellInnerData = new PdfPCell(new Phrase(barcodeLabel, fontNormalData));

                            cellInnerData.setBorder(Rectangle.NO_BORDER);
                            cellInnerData.setBackgroundColor(Color.white);
                            cellInnerData.setPaddingBottom(0.2f);
                            cellInnerData.setPaddingTop(0.2f);
                            cellInnerData.setHorizontalAlignment(Element.ALIGN_MIDDLE);

                            innerDataTableInfo.addCell(cellInnerData);
                            innerDataTableInfo.setHorizontalAlignment(Element.ALIGN_MIDDLE);
                            cell.addElement(innerDataTableInfo);
                        }
                        PdfPTable innerTableInfo = new PdfPTable(2);
                        innerTableInfo.setWidths(new float[] { 1, 1 });
                        innerTableInfo.setWidthPercentage(85);

                        String leftText = generateBarcodeLabel(moreFieldInfo, fieldMapLabel, leftSelectedFields,
                                row);
                        PdfPCell cellInnerLeft = new PdfPCell(new Paragraph(leftText, fontNormal));

                        cellInnerLeft.setBorder(Rectangle.NO_BORDER);
                        cellInnerLeft.setBackgroundColor(Color.white);
                        cellInnerLeft.setPaddingBottom(0.5f);
                        cellInnerLeft.setPaddingTop(0.5f);

                        innerTableInfo.addCell(cellInnerLeft);

                        String rightText = generateBarcodeLabel(moreFieldInfo, fieldMapLabel,
                                rightSelectedFields, row);
                        PdfPCell cellInnerRight = new PdfPCell(new Paragraph(rightText, fontNormal));

                        cellInnerRight.setBorder(Rectangle.NO_BORDER);
                        cellInnerRight.setBackgroundColor(Color.white);
                        cellInnerRight.setPaddingBottom(0.5f);
                        cellInnerRight.setPaddingTop(0.5f);

                        innerTableInfo.addCell(cellInnerRight);

                        cell.addElement(innerTableInfo);
                    }

                    cell.setBorder(Rectangle.NO_BORDER);
                    cell.setBackgroundColor(Color.white);

                    //cell.setBorderColor(Color.BLUE);

                    table.addCell(cell);

                    if (i % numberOfLabelPerRow == 0) {
                        // we go the next line

                        int needed = fixTableRowSize - numberOfLabelPerRow;

                        for (int neededCount = 0; neededCount < needed; neededCount++) {
                            PdfPCell cellNeeded = new PdfPCell();

                            cellNeeded.setBorder(Rectangle.NO_BORDER);
                            cellNeeded.setBackgroundColor(Color.white);

                            table.addCell(cellNeeded);
                        }

                        table.completeRow();
                        if (numberofRowsPerPageOfLabel == 10) {

                            //table.setSpacingAfter(9f);
                            table.setSpacingAfter(paper.getSpacingAfter());
                        }

                        document.add(table);

                        table = new PdfPTable(fixTableRowSize);
                        table.setWidths(widthColumns);
                        table.setWidthPercentage(100);

                    }
                    if (i % totalPerPage == 0) {
                        // we go the next page
                        document.newPage();
                    }
                    fout.flush();
                    fout.close();

                }
            }
            // we need to add the last row
            if (i % numberOfLabelPerRow != 0) {
                // we go the next line

                int needed = fixTableRowSize - numberOfLabelPerRow;
                int remaining = numberOfLabelPerRow - (i % numberOfLabelPerRow);
                for (int neededCount = 0; neededCount < remaining; neededCount++) {
                    PdfPCell cellNeeded = new PdfPCell();

                    cellNeeded.setBorder(Rectangle.NO_BORDER);
                    cellNeeded.setBackgroundColor(Color.white);

                    table.addCell(cellNeeded);
                }

                table.completeRow();
                if (numberofRowsPerPageOfLabel == 10) {

                    table.setSpacingAfter(paper.getSpacingAfter());
                }

                document.add(table);

                table = new PdfPTable(fixTableRowSize);
                table.setWidths(widthColumns);
                table.setWidthPercentage(100);

            }

            document.close();
            for (File file : filesToBeDeleted) {
                file.delete();
            }
            fileOutputStream.close();

        } catch (FileNotFoundException e) {
            LOG.error(e.getMessage(), e);
        } catch (IOException e) {
            LOG.error(e.getMessage(), e);
        }

    } catch (WriterException e) {
        LOG.error(e.getMessage(), e);
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
    }
    return fileName;
}

From source file:com.googlecode.openmpis.action.UserAction.java

License:Open Source License

/**
 * Writes the users to a PDF file.//from www. ja va2 s . c o m
 *
 * @param mapping       the ActionMapping used to select this instance
 * @param form          the optional ActionForm bean for this request
 * @param request       the HTTP Request we are processing
 * @param response      the HTTP Response we are processing
 * @return              the forwarding instance
 * @throws java.lang.Exception
 */
public ActionForward printUsers(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    User currentUser = null;

    // Check if there exists a session
    if (request.getSession().getAttribute("currentuser") != null) {
        currentUser = (User) request.getSession().getAttribute("currentuser");
    }

    // Set the paper size and margins
    Document document = new Document(PageSize.LETTER.rotate(), 50, 50, 50, 50);

    // Create the PDF writer
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PdfWriter.getInstance(document, baos);

    // Add some meta information to the document
    document.addTitle("Case Statistics");
    document.addAuthor("OpenMPIS");
    document.addSubject("Statistics for All Cases");
    document.addKeywords("OpenMPIS, missing, found, unidentified");
    document.addProducer();
    document.addCreationDate();
    document.addCreator("OpenMPIS version " + Constants.VERSION);

    // Set the header
    String date = simpleDateFormat.format(System.currentTimeMillis());
    document.setHeader(new HeaderFooter(new Phrase("List of users as of " + date), false));

    // Set the footer
    HeaderFooter footer = new HeaderFooter(new Phrase("Page : "), true);
    footer.setAlignment(Element.ALIGN_CENTER);
    document.setFooter(footer);

    // Open the document for writing
    document.open();
    Table table = new Table(2);
    table.setBorderWidth(1);
    table.setPadding(2);
    table.setSpacing(0);
    Paragraph paragraph = new Paragraph("Users", FontFactory.getFont(FontFactory.HELVETICA, 24, Font.BOLD));
    paragraph.setAlignment(Paragraph.ALIGN_CENTER);
    Cell cell = new Cell(paragraph);
    cell.setHeader(true);
    cell.setColspan(2);
    table.addCell(cell);
    table.endHeaders();
    table.addCell("Total Administrators");
    table.addCell("" + userService.countAdministrators());
    table.addCell("\t\t\t\t\tActive Administrators");
    table.addCell("\t\t\t\t\t\t\t\t\t\t" + userService.countActiveAdministrators());
    table.addCell("\t\t\t\t\tSuspended Administrators");
    table.addCell("\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" + userService.countSuspendedAdministrators());
    table.addCell("Total Encoders");
    table.addCell("" + userService.countEncoders());
    table.addCell("\t\t\t\t\tActive Encoders");
    table.addCell("\t\t\t\t\t\t\t\t\t\t" + userService.countActiveEncoders());
    table.addCell("\t\t\t\t\tSuspended Encoders");
    table.addCell("\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" + userService.countSuspendedEncoders());
    table.addCell("Total Investigators");
    table.addCell("" + userService.countInvestigators());
    table.addCell("\t\t\t\t\tActive Investigators");
    table.addCell("\t\t\t\t\t\t\t\t\t\t" + userService.countActiveInvestigators());
    table.addCell("\t\t\t\t\tSuspended Investigators");
    table.addCell("\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" + userService.countSuspendedInvestigators());
    table.addCell("Total Users");
    table.addCell("" + userService.countAllUsers());
    table.addCell("\t\t\t\t\tTotal Active Users");
    table.addCell("\t\t\t\t\t\t\t\t\t\t" + userService.countActiveUsers());
    table.addCell("\t\t\t\t\tTotal Suspended Users");
    table.addCell("\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" + userService.countSuspendedUsers());
    document.add(table);
    if (currentUser != null) {
        if ((currentUser.getGroupId() == 0) || (currentUser.getGroupId() == 1)) {
            // List administrators
            document.setHeader(new HeaderFooter(new Phrase("List of administrators as of " + date), false));
            document.newPage();
            float[] widths = { 0.03f, 0.07f, 0.1f, 0.1f, 0.1f, 0.1f, 0.2f, 0.05f };
            PdfPTable pdfptable = new PdfPTable(widths);
            pdfptable.setWidthPercentage(100);
            pdfptable.addCell(new Phrase("ID", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            pdfptable.addCell(new Phrase("Group", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            pdfptable.addCell(new Phrase("Last Name", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            pdfptable.addCell(new Phrase("First Name", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            pdfptable.addCell(new Phrase("Agency", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            pdfptable.addCell(new Phrase("Designation", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            pdfptable.addCell(new Phrase("E-mail Address", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            pdfptable.addCell(new Phrase("Status", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            List<User> administratorList = userService.listAdministrators();
            for (User administrator : administratorList) {
                pdfptable.addCell(
                        new Phrase("" + administrator.getId(), FontFactory.getFont(FontFactory.HELVETICA, 8)));
                pdfptable.addCell(
                        new Phrase(getResources(request).getMessage("group." + administrator.getGroupId()),
                                FontFactory.getFont(FontFactory.HELVETICA, 8)));
                pdfptable.addCell(
                        new Phrase(administrator.getLastName(), FontFactory.getFont(FontFactory.HELVETICA, 8)));
                pdfptable.addCell(new Phrase(administrator.getFirstName(),
                        FontFactory.getFont(FontFactory.HELVETICA, 8)));
                pdfptable.addCell(
                        new Phrase(administrator.getAgency(), FontFactory.getFont(FontFactory.HELVETICA, 8)));
                pdfptable.addCell(new Phrase(administrator.getDesignation(),
                        FontFactory.getFont(FontFactory.HELVETICA, 8)));
                pdfptable.addCell(
                        new Phrase(administrator.getEmail(), FontFactory.getFont(FontFactory.HELVETICA, 8)));
                pdfptable.addCell(
                        new Phrase(getResources(request).getMessage("status.user." + administrator.getStatus()),
                                FontFactory.getFont(FontFactory.HELVETICA, 8)));
            }
            document.add(pdfptable);

            // List encoders
            document.setHeader(new HeaderFooter(new Phrase("List of encoders as of " + date), false));
            document.newPage();
            pdfptable = new PdfPTable(widths);
            pdfptable.setWidthPercentage(100);
            pdfptable.addCell(new Phrase("ID", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            pdfptable.addCell(new Phrase("Group", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            pdfptable.addCell(new Phrase("Last Name", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            pdfptable.addCell(new Phrase("First Name", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            pdfptable.addCell(new Phrase("Agency", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            pdfptable.addCell(new Phrase("Designation", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            pdfptable.addCell(new Phrase("E-mail Address", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            pdfptable.addCell(new Phrase("Status", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            List<User> encoderList = userService.listEncoders();
            for (User encoder : encoderList) {
                pdfptable.addCell(
                        new Phrase("" + encoder.getId(), FontFactory.getFont(FontFactory.HELVETICA, 8)));
                pdfptable.addCell(new Phrase(getResources(request).getMessage("group." + encoder.getGroupId()),
                        FontFactory.getFont(FontFactory.HELVETICA, 8)));
                pdfptable.addCell(
                        new Phrase(encoder.getLastName(), FontFactory.getFont(FontFactory.HELVETICA, 8)));
                pdfptable.addCell(
                        new Phrase(encoder.getFirstName(), FontFactory.getFont(FontFactory.HELVETICA, 8)));
                pdfptable.addCell(
                        new Phrase(encoder.getAgency(), FontFactory.getFont(FontFactory.HELVETICA, 8)));
                pdfptable.addCell(
                        new Phrase(encoder.getDesignation(), FontFactory.getFont(FontFactory.HELVETICA, 8)));
                pdfptable
                        .addCell(new Phrase(encoder.getEmail(), FontFactory.getFont(FontFactory.HELVETICA, 8)));
                pdfptable.addCell(
                        new Phrase(getResources(request).getMessage("status.user." + encoder.getStatus()),
                                FontFactory.getFont(FontFactory.HELVETICA, 8)));
            }
            document.add(pdfptable);

            // List investigators
            document.setHeader(new HeaderFooter(new Phrase("List of investigators as of " + date), false));
            document.newPage();
            pdfptable = new PdfPTable(widths);
            pdfptable.setWidthPercentage(100);
            pdfptable.addCell(new Phrase("ID", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            pdfptable.addCell(new Phrase("Group", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            pdfptable.addCell(new Phrase("Last Name", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            pdfptable.addCell(new Phrase("First Name", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            pdfptable.addCell(new Phrase("Agency", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            pdfptable.addCell(new Phrase("Designation", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            pdfptable.addCell(new Phrase("E-mail Address", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            pdfptable.addCell(new Phrase("Status", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            List<User> investigatorList = userService.listInvestigators();
            for (User investigator : investigatorList) {
                pdfptable.addCell(
                        new Phrase("" + investigator.getId(), FontFactory.getFont(FontFactory.HELVETICA, 8)));
                pdfptable.addCell(
                        new Phrase(getResources(request).getMessage("group." + investigator.getGroupId()),
                                FontFactory.getFont(FontFactory.HELVETICA, 8)));
                pdfptable.addCell(
                        new Phrase(investigator.getLastName(), FontFactory.getFont(FontFactory.HELVETICA, 8)));
                pdfptable.addCell(
                        new Phrase(investigator.getFirstName(), FontFactory.getFont(FontFactory.HELVETICA, 8)));
                pdfptable.addCell(
                        new Phrase(investigator.getAgency(), FontFactory.getFont(FontFactory.HELVETICA, 8)));
                pdfptable.addCell(new Phrase(investigator.getDesignation(),
                        FontFactory.getFont(FontFactory.HELVETICA, 8)));
                pdfptable.addCell(
                        new Phrase(investigator.getEmail(), FontFactory.getFont(FontFactory.HELVETICA, 8)));
                pdfptable.addCell(
                        new Phrase(getResources(request).getMessage("status.user." + investigator.getStatus()),
                                FontFactory.getFont(FontFactory.HELVETICA, 8)));
            }
            document.add(pdfptable);
        }
    }
    document.close();

    // Set the response to return the poster (PDF file)
    response.setContentType("application/pdf");
    response.setContentLength(baos.size());
    response.setHeader("Content-disposition", "attachment; filename=User_Statistics.pdf");

    // Close the output stream
    baos.writeTo(response.getOutputStream());
    response.getOutputStream().flush();

    return null;
}

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;/*ww  w .ja  v a  2s  .  c om*/
    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);

}