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

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

Introduction

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

Prototype

public PdfPCell(PdfPCell cell) 

Source Link

Document

Constructs a deep copy of a PdfPCell.

Usage

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

License:Open Source License

private PdfPTable addBlankLine(int count) {
    PdfPTable table = new PdfPTable(1);
    PdfPCell cell = null;/*from   ww  w .  j  a  v  a2s .  com*/
    for (int i = 0; i < count; i++) {
        cell = new PdfPCell(new Paragraph("", fontTblMediumBold));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setPadding(3);
        cell.setBorder(0);
        table.addCell(cell);
    }
    return table;
}

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

License:Open Source License

private PdfPCell calculateDiscount(Double disc, String currencyid) {
    PdfPCell cell = null;//from w ww  .ja  va2 s  .c o m
    if (disc == null) {
        cell = new PdfPCell(new Paragraph("--", fontSmallRegular));
    } else {
        cell = new PdfPCell(
                new Paragraph(authHandlerDAOObj.getFormattedCurrency(disc, currencyid), fontSmallRegular));
    }
    return cell;
}

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

License:Open Source License

private PdfPCell calculateDiscount(Discount disc, String currencyid) {
    PdfPCell cell = null;//w  w w  .  j  a  v a  2  s  .c o  m
    if (disc == null) {
        cell = new PdfPCell(new Paragraph("--", fontSmallRegular));
    } else if (disc.isInPercent()) {
        cell = new PdfPCell(new Paragraph(
                authHandlerDAOObj.getFormattedCurrency(disc.getDiscountValue(), currencyid), fontSmallRegular));
    } else {
        cell = new PdfPCell(new Paragraph(
                authHandlerDAOObj.getFormattedCurrency(disc.getDiscountValue(), currencyid), fontSmallRegular));
    }
    return cell;
}

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

License:Open Source License

private PdfPCell getCharges(JournalEntryDetail jEntry, String currencyid) {
    PdfPCell cell = null;/*w  ww.  j  a v a  2 s. c o  m*/
    if (jEntry == null) {
        cell = new PdfPCell(new Paragraph("--", fontSmallBold));
    } else {
        cell = new PdfPCell(new Paragraph(
                authHandlerDAOObj.getFormattedCurrency(jEntry.getAmount(), currencyid), fontSmallRegular));
    }
    return cell;
}

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

License:Open Source License

public void addTableRow(PdfPTable container, PdfPTable table) {
    PdfPCell tableRow = new PdfPCell(table);
    tableRow.setBorder(0);//  ww  w .j  a v  a  2  s.c om
    tableRow.setPaddingRight(10);
    tableRow.setPaddingLeft(10);
    container.addCell(tableRow);
}

From source file:com.krawler.spring.exportFunctionality.exportDAOImpl.java

License:Open Source License

public void addComponyLogo(Document d, HttpServletRequest request) throws ServiceException {
    try {//  ww w .  j  a v a2  s.c o m
        PdfPTable table = new PdfPTable(1);
        imgPath = getImgPath(request);
        table.setHorizontalAlignment(Element.ALIGN_LEFT);
        table.setWidthPercentage(50);
        PdfPCell cell = null;
        try {
            Image img = Image.getInstance(imgPath);
            cell = new PdfPCell(img);
        } catch (Exception e) {
            companyName = sessionHandlerImplObj.getCompanyName(request);
            cell = new PdfPCell(new Paragraph(fontFamilySelector.process(companyName, FontContext.LOGO_TEXT)));
        }
        cell.setBorder(0);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        table.addCell(cell);
        d.add(table);
    } catch (Exception e) {
        throw ServiceException.FAILURE("exportDAOImpl.addComponyLogo", e);
    }
}

From source file:com.krawler.spring.exportFunctionality.exportDAOImpl.java

License:Open Source License

public void addTitleSubtitle(Document d) throws ServiceException {
    try {//from w  w  w. j av  a  2s . c o m
        java.awt.Color tColor = new Color(Integer.parseInt(config.getString("textColor"), 16));
        PdfPTable table = new PdfPTable(1);
        table.setHorizontalAlignment(Element.ALIGN_CENTER);

        table.setWidthPercentage(100);
        table.setSpacingBefore(6);

        //Report Title
        PdfPCell cell = new PdfPCell(new Paragraph(
                fontFamilySelector.process(config.getString("title"), FontContext.REPORT_TITLE, tColor)));//fontBold));
        cell.setBorder(0);
        cell.setBorderWidth(0);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);

        //Report Subtitle(s)
        String[] SubTitles = config.getString("subtitles").split("~");// '~' as separator
        for (int i = 0; i < SubTitles.length; i++) {
            cell = new PdfPCell(
                    new Paragraph(fontFamilySelector.process(SubTitles[i], FontContext.REPORT_TITLE, tColor)));
            cell.setBorder(0);
            cell.setBorderWidth(0);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);
        }
        table.setSpacingAfter(6);
        d.add(table);

        //Separator line
        PdfPTable line = new PdfPTable(1);
        line.setWidthPercentage(100);
        PdfPCell cell1 = null;
        cell1 = new PdfPCell(new Paragraph(""));
        cell1.setBorder(PdfPCell.BOTTOM);
        line.addCell(cell1);
        d.add(line);
    } catch (Exception e) {
        throw ServiceException.FAILURE("exportDAOImpl.addTitleSubtitle", e);
    }
}

From source file:com.krawler.spring.exportFunctionality.exportDAOImpl.java

License:Open Source License

public int addTable(int stcol, int stpcol, int strow, int stprow, JSONArray store, String[] colwidth2,
        String[] colHeader, String[] widths, String[] align, String[] xtype, Document document)
        throws ServiceException {
    try {//from  ww  w .  jav  a2s  . c  o  m
        java.awt.Color tColor = new Color(Integer.parseInt(config.getString("textColor"), 16));
        PdfPTable table;
        float[] tcol;
        tcol = new float[colHeader.length + 1];
        tcol[0] = 40;
        for (int i = 1; i < colHeader.length + 1; i++) {
            tcol[i] = Float.parseFloat(widths[i - 1]);
        }
        table = new PdfPTable(colHeader.length + 1);
        table.setWidthPercentage(tcol, document.getPageSize());

        table.setSpacingBefore(15);

        PdfPCell h2 = new PdfPCell(
                new Paragraph(fontFamilySelector.process("No.", FontContext.TABLE_HEADER, tColor)));
        if (config.getBoolean("gridBorder")) {
            h2.setBorder(PdfPCell.BOX);
        } else {
            h2.setBorder(0);
        }
        h2.setPadding(4);
        h2.setBorderColor(Color.GRAY);
        h2.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(h2);
        PdfPCell h1 = null;
        for (int hcol = stcol; hcol < colwidth2.length; hcol++) {
            h1 = new PdfPCell(new Paragraph(
                    fontFamilySelector.process(colHeader[hcol], FontContext.TABLE_HEADER, tColor)));
            h1.setHorizontalAlignment(Element.ALIGN_CENTER);
            if (config.getBoolean("gridBorder")) {
                h1.setBorder(PdfPCell.BOX);
            } else {
                h1.setBorder(0);
            }
            h1.setBorderColor(Color.GRAY);
            h1.setPadding(4);
            table.addCell(h1);
        }
        table.setHeaderRows(1);

        for (int row = strow; row < stprow; row++) {
            h2 = new PdfPCell(new Paragraph(
                    fontFamilySelector.process(String.valueOf(row + 1), FontContext.TABLE_DATA, tColor)));
            if (config.getBoolean("gridBorder")) {
                h2.setBorder(PdfPCell.BOTTOM | PdfPCell.LEFT | PdfPCell.RIGHT);
            } else {
                h2.setBorder(0);
            }
            h2.setPadding(4);
            h2.setBorderColor(Color.GRAY);
            h2.setHorizontalAlignment(Element.ALIGN_CENTER);
            h2.setVerticalAlignment(Element.ALIGN_CENTER);
            table.addCell(h2);

            JSONObject temp = store.getJSONObject(row);
            for (int col = 0; col < colwidth2.length; col++) {
                String str = temp.optString((colwidth2[col]), "");
                try {
                    if (xtype.length > 0) {
                        str = formatValue(temp.optString((colwidth2[col]), ""), xtype[col]);
                    }
                } catch (Exception e) {

                }
                Paragraph para = new Paragraph(fontFamilySelector.process(str, FontContext.TABLE_DATA, tColor));
                h1 = new PdfPCell(para);
                if (config.getBoolean("gridBorder")) {
                    h1.setBorder(PdfPCell.BOTTOM | PdfPCell.LEFT | PdfPCell.RIGHT);
                } else {
                    h1.setBorder(0);
                }
                h1.setPadding(4);
                h1.setBorderColor(Color.GRAY);

                if (!align[col].equals("right") && !align[col].equals("left")) {
                    h1.setHorizontalAlignment(Element.ALIGN_CENTER);
                    h1.setVerticalAlignment(Element.ALIGN_CENTER);
                } else if (align[col].equals("right")) {
                    h1.setHorizontalAlignment(Element.ALIGN_RIGHT);
                    h1.setVerticalAlignment(Element.ALIGN_RIGHT);
                } else if (align[col].equals("left")) {
                    h1.setHorizontalAlignment(Element.ALIGN_LEFT);
                    h1.setVerticalAlignment(Element.ALIGN_LEFT);
                }
                table.addCell(h1);
            }
        }
        document.add(table);
        document.newPage();
    } catch (Exception e) {
        throw ServiceException.FAILURE("exportDAOImpl.addTable", e);
    }
    return stpcol;
}

From source file:com.krawler.spring.exportFunctionality.exportDAOImpl.java

License:Open Source License

public void getHeaderFooter(Document document) throws ServiceException {
    try {/*from  w w w .j  av a 2s . com*/
        java.awt.Color tColor = new Color(Integer.parseInt(config.getString("textColor"), 16));
        java.util.Date dt = new java.util.Date();
        String date = "yyyy-MM-dd";
        java.text.SimpleDateFormat dtf = new java.text.SimpleDateFormat(date);
        dtf.setTimeZone(TimeZone.getTimeZone("GMT" + this.tdiff));
        String DateStr = dtf.format(dt);

        // -------- header ----------------
        header = new PdfPTable(3);
        header.setWidthPercentage(100);
        header.setWidths(new float[] { 20, 60, 20 });
        String HeadDate = "";
        if (config.getBoolean("headDate")) {
            HeadDate = DateStr;
        }
        PdfPCell headerDateCell = new PdfPCell(
                fontFamilySelector.process(HeadDate, FontContext.SMALL_TEXT, tColor));//fontSmallRegular));
        headerDateCell.setBorder(0);
        headerDateCell.setPaddingBottom(4);
        headerDateCell.setHorizontalAlignment(PdfCell.ALIGN_LEFT);
        header.addCell(headerDateCell);

        PdfPCell headerNotecell = new PdfPCell(
                fontFamilySelector.process(config.getString("headNote"), FontContext.HEADER_NOTE, tColor));
        headerNotecell.setBorder(0);
        headerNotecell.setPaddingBottom(4);
        headerNotecell.setHorizontalAlignment(PdfCell.ALIGN_CENTER);
        header.addCell(headerNotecell);

        String HeadPager = "";
        if (config.getBoolean("headPager")) {
            HeadPager = String.valueOf(document.getPageNumber());//current page no
        }
        PdfPCell headerPageNocell = new PdfPCell(
                fontFamilySelector.process(HeadPager, FontContext.HEADER_NOTE, tColor));// fontSmallRegular));
        headerPageNocell.setBorder(0);
        headerPageNocell.setPaddingBottom(4);
        headerPageNocell.setHorizontalAlignment(PdfCell.ALIGN_RIGHT);
        header.addCell(headerPageNocell);

        PdfPCell headerSeparator = new PdfPCell(new Phrase(""));
        headerSeparator.setBorder(PdfPCell.BOX);
        headerSeparator.setPadding(0);
        headerSeparator.setColspan(3);
        header.addCell(headerSeparator);
        // -------- header end ----------------

        // -------- footer  -------------------
        footer = new PdfPTable(3);
        PdfPCell footerSeparator = new PdfPCell(new Phrase(""));
        footerSeparator.setBorder(PdfPCell.BOX);
        footerSeparator.setPadding(0);
        footerSeparator.setColspan(3);
        footer.addCell(footerSeparator);
        footer.setWidthPercentage(100);
        footer.setWidths(new float[] { 20, 60, 20 });
        String PageDate = "";
        if (config.getBoolean("footDate")) {
            PageDate = DateStr;
        }
        PdfPCell pagerDateCell = new PdfPCell(
                fontFamilySelector.process(PageDate, FontContext.SMALL_TEXT, tColor));//fontSmallRegular));
        pagerDateCell.setBorder(0);
        pagerDateCell.setHorizontalAlignment(PdfCell.ALIGN_LEFT);
        footer.addCell(pagerDateCell);

        PdfPCell footerNotecell = new PdfPCell(
                fontFamilySelector.process(config.getString("footNote"), FontContext.FOOTER_NOTE, tColor));// fontSmallRegular));
        footerNotecell.setBorder(0);
        footerNotecell.setHorizontalAlignment(PdfCell.ALIGN_CENTER);
        footer.addCell(footerNotecell);

        String FootPager = "";
        if (config.getBoolean("footPager")) {
            FootPager = String.valueOf(document.getPageNumber());//current page no
        }
        PdfPCell footerPageNocell = new PdfPCell(
                fontFamilySelector.process(FootPager, FontContext.SMALL_TEXT, tColor));// fontSmallRegular));
        footerPageNocell.setBorder(0);
        footerPageNocell.setHorizontalAlignment(PdfCell.ALIGN_RIGHT);
        footer.addCell(footerPageNocell);
        // -------- footer end   -----------
    } catch (Exception e) {
        throw ServiceException.FAILURE("exportDAOImpl.getHeaderFooter", e);
    }
}

From source file:com.krawler.spring.exportFunctionality.exportDAOImpl.java

License:Open Source License

private PdfPCell calculateDiscount(double disc, KWLCurrency cur) throws SessionExpiredException {
    PdfPCell cell = null;/*from ww  w .ja v  a  2s  .c om*/
    if (disc == 0) {
        cell = new PdfPCell(new Paragraph(fontFamilySelector.process("--", FontContext.NOTE_TEXT)));
    } else {
        cell = new PdfPCell(new Paragraph(
                fontFamilySelector.process(currencyRender(String.valueOf(disc), cur), FontContext.TABLE_DATA)));
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(15);
        cell.setPadding(5);
    }
    return cell;
}