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

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

Introduction

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

Prototype

public PdfPTable(PdfPTable table) 

Source Link

Document

Constructs a copy of a PdfPTable.

Usage

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 {/*  w  w w .  java2 s.co 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 {/*w w w.j av  a  2 s.c  o  m*/
        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

public ByteArrayOutputStream getInvoicePdfData(HttpServletRequest request, JSONObject obj,
        Map<String, Object> DataInfo, Company com, DateFormat formatter, String currencyid,
        JSONArray productDetails, int mode, String letterHead, String preText, String postText)
        throws ServiceException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PdfWriter writer = null;/*from   w w  w. j  a  va 2  s .c  om*/
    Document document = null;
    try {
        config = new com.krawler.utils.json.base.JSONObject(DataInfo.get("config").toString());
        String baseUrl = URLUtil.getRequestPageURL(request, UnprotectedLoginPageFull);
        Rectangle rec = null;
        if (config.getBoolean("landscape")) {
            Rectangle recPage = new Rectangle(PageSize.A4.rotate());
            recPage.setBackgroundColor(new java.awt.Color(Integer.parseInt(config.getString("bgColor"), 16)));
            document = new Document(recPage, 15, 15, 30, 30);
            rec = document.getPageSize();
        } else {
            Rectangle recPage = new Rectangle(PageSize.A4);
            recPage.setBackgroundColor(new java.awt.Color(Integer.parseInt(config.getString("bgColor"), 16)));
            document = new Document(recPage, 15, 15, 30, 30);
            rec = document.getPageSize();
        }
        writer = PdfWriter.getInstance(document, baos);
        writer.setPageEvent(new EndPage());
        document.open();
        if (config.getBoolean("showLogo")) {
            addComponyLogo(document, request);
        }

        if (!StringUtil.isNullOrEmpty(letterHead)) {
            PdfPTable letterHeadTable = new PdfPTable(1);
            getHtmlCell(letterHead, letterHeadTable, baseUrl);
            letterHeadTable.setHorizontalAlignment(Element.ALIGN_LEFT);
            document.add(letterHeadTable);
        }

        addTitleSubtitle(document);
        createInvoicePdf(document, mode, DataInfo, com, formatter, currencyid, productDetails, preText,
                postText, baseUrl);
    } catch (DocumentException ex) {
        errorMsg = ex.getMessage();
        throw ServiceException.FAILURE("exportDAOImpl.getInvoicePdfData", ex);
    } catch (JSONException e) {
        errorMsg = e.getMessage();
        throw ServiceException.FAILURE("exportDAOImpl.getInvoicePdfData", e);
    } catch (Exception e) {
        e.printStackTrace();
        errorMsg = e.getMessage();
        throw ServiceException.FAILURE("exportDAOImpl.getInvoicePdfData", e);
    } finally {
        if (document != null) {
            document.close();
        }
        if (writer != null) {
            writer.close();
        }
    }
    return baos;
}

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

License:Open Source License

public void createInvoicePdf(Document document, int mode, Map<String, Object> DataInfo, Company com,
        DateFormat formatter, String currencyid, JSONArray productDetails, String preText, String postText,
        String baseUrl) throws DocumentException, JSONException {
    // mode 1 = quotation
    try {//  w ww  . j  a  va  2 s  .c o  m
        KWLCurrency currencyObj = (KWLCurrency) hibernateTemplate.load(KWLCurrency.class, currencyid);
        config = new com.krawler.utils.json.base.JSONObject(DataInfo.get("config").toString());
        PdfPTable tab2 = null;
        PdfPTable tab3 = null;
        PdfPTable mainTable = new PdfPTable(1);
        mainTable.setWidthPercentage(100);
        String invno = "";
        String theader = "";
        double quotationDisc = 0;
        double quotationtaxamount = 0;
        String quotationtaxname = "";
        double totalAmount = 0;
        double quotationtaxpercent = 0;
        Date entryDate = null;
        String customerName = "";
        String shipTo = "";
        String memo = "";
        //                itr = idresult.getEntityList().iterator();

        if (mode == 1) {
            theader = "Quotation";
            invno = DataInfo.containsKey("invno") ? DataInfo.get("invno").toString() : "";
            entryDate = DataInfo.containsKey("entrydate") ? (Date) DataInfo.get("entrydate") : new Date();
            customerName = DataInfo.containsKey("customername") ? DataInfo.get("customername").toString() : "";
            shipTo = DataInfo.containsKey("address") ? DataInfo.get("address").toString() : "";
            memo = DataInfo.containsKey("memo") ? DataInfo.get("memo").toString() : "";
            quotationDisc = DataInfo.containsKey("quotationdisc")
                    ? Double.parseDouble(DataInfo.get("quotationdisc").toString())
                    : 0;
            quotationtaxamount = DataInfo.containsKey("quotationtax")
                    ? Double.parseDouble(DataInfo.get("quotationtax").toString())
                    : 0;
            quotationtaxname = DataInfo.containsKey("quotationtaxname")
                    ? DataInfo.get("quotationtaxname").toString()
                    : "";
            quotationtaxpercent = DataInfo.containsKey("quotationtaxpercent")
                    ? Double.parseDouble(DataInfo.get("quotationtaxpercent").toString())
                    : 0;
            totalAmount = DataInfo.containsKey("totalamount")
                    ? Double.parseDouble(DataInfo.get("totalamount").toString())
                    : 0;
        }
        String company[] = new String[4];
        company[0] = com.getCompanyName();
        company[1] = com.getAddress();
        company[2] = com.getEmailID();
        company[3] = com.getPhoneNumber();

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

        tab2 = new PdfPTable(1);
        PdfPCell invCell = null;
        invCell = createCell(theader, FontContext.TABLE_HEADER, Element.ALIGN_RIGHT, 0, 5);
        tab2.addCell(invCell);
        PdfPCell cel2 = new PdfPCell(tab2);
        cel2.setBorder(0);
        table1.addCell(cel2);

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

        PdfPTable userTable2 = new PdfPTable(2);
        userTable2.setWidthPercentage(100);
        userTable2.setWidths(new float[] { 60, 40 });

        tab3 = getCompanyInfo(company);

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

        PdfPCell cell2 = createCell(theader + " No.", FontContext.TABLE_HEADER, Element.ALIGN_LEFT, 0, 5);
        tab4.addCell(cell2);
        //                String invno = mode != StaticValues.AUTONUM_BILLINGINVOICE ? inv.getInvoiceNumber() : inv1.getBillingInvoiceNumber();
        cell2 = createCell(": " + invno, FontContext.SMALL_TEXT, Element.ALIGN_LEFT, 0, 5);
        tab4.addCell(cell2);

        cell2 = createCell("DATE  ", FontContext.SMALL_TEXT, Element.ALIGN_LEFT, 0, 5);
        tab4.addCell(cell2);
        cell2 = createCell(": " + formatter.format(entryDate), FontContext.SMALL_TEXT, Element.ALIGN_LEFT, 0,
                5);
        tab4.addCell(cell2);

        PdfPCell cell1 = new PdfPCell(tab3);
        cell1.setBorder(0);
        userTable2.addCell(cell1);
        cel2 = new PdfPCell(tab4);
        cel2.setBorder(0);
        userTable2.addCell(cel2);

        PdfPCell mainCell12 = new PdfPCell(userTable2);
        mainCell12.setBorder(0);
        mainCell12.setPadding(10);
        mainTable.addCell(mainCell12);

        PdfPTable tab5 = new PdfPTable(2);
        tab5.setWidthPercentage(100);
        tab5.setWidths(new float[] { 50, 50 });
        PdfPCell cell3 = createCell("To, ", FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 5);
        tab5.addCell(cell3);
        cell3 = createCell("", FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 0);
        tab5.addCell(cell3);
        //                cell3 = createCell("", fontRegularNormal, Element.ALIGN_LEFT, 0, 0);
        //                tab5.addCell(cell3);

        cell3 = createCell(customerName, FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 5);
        tab5.addCell(cell3);
        cell3 = createCell("", FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 0);
        tab5.addCell(cell3);
        cell3 = createCell(shipTo, FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 5);
        tab5.addCell(cell3);

        PdfPCell mainCell14 = new PdfPCell(tab5);
        mainCell14.setBorder(0);
        //mainCell14.setPadding(10);
        mainTable.addCell(mainCell14);
        getHtmlCell(preText.trim(), mainTable, baseUrl);
        getHtmlCell("<br>", mainTable, baseUrl);
        getHtmlCell("<br>", mainTable, baseUrl);
        String[] header = { "S.No.", "PRODUCT", "DESCRIPTION", "QUANTITY", "UNIT PRICE", "DISCOUNT", "TAX",
                "LINE TOTAL" };
        PdfPTable table = getBlankTable();
        PdfPCell invcell = null;

        for (int i = 0; i < header.length; i++) {
            invcell = new PdfPCell(
                    new Paragraph(fontFamilySelector.process(header[i], FontContext.TABLE_HEADER)));
            invcell.setHorizontalAlignment(Element.ALIGN_CENTER);
            invcell.setBackgroundColor(Color.LIGHT_GRAY);
            invCell.setBorder(0);
            invcell.setPadding(3);
            table.addCell(invcell);
        }
        addTableRow(mainTable, table); //Break table after adding header row
        table = getBlankTable();

        String prodName = "";
        String subtotal = "";
        String quantity = "";
        String rate = "";
        String description = "";
        String discount = "";
        String prodtax = "";
        int index = 0;
        double total = 0;
        for (int cnt = 0; cnt < productDetails.length(); cnt++) {
            JSONObject productInfo = productDetails.getJSONObject(cnt);
            prodName = productInfo.getString("productname");
            description = productInfo.getString("description");
            quantity = productInfo.getString("quantity");
            rate = productInfo.getString("orderrate");
            subtotal = productInfo.getString("amount");
            discount = productInfo.getString("prdiscountamount");
            prodtax = productInfo.getString("taxamount");

            invcell = createCell((++index) + ".", FontContext.TABLE_DATA, Element.ALIGN_RIGHT,
                    Rectangle.LEFT + Rectangle.RIGHT, 5);
            table.addCell(invcell);
            invcell = createCell(prodName, FontContext.TABLE_DATA, Element.ALIGN_LEFT,
                    Rectangle.LEFT + Rectangle.RIGHT, 5);
            table.addCell(invcell);
            invcell = createCell(description, FontContext.TABLE_DATA, Element.ALIGN_LEFT,
                    Rectangle.LEFT + Rectangle.RIGHT, 5);
            table.addCell(invcell);
            invcell = createCell(quantity, FontContext.TABLE_DATA, Element.ALIGN_CENTER,
                    Rectangle.LEFT + Rectangle.RIGHT, 5);
            table.addCell(invcell);
            invcell = createCell(currencyRender(rate, currencyObj), FontContext.TABLE_DATA, Element.ALIGN_RIGHT,
                    Rectangle.LEFT + Rectangle.RIGHT, 5);
            table.addCell(invcell);
            invcell = createCell(currencyRender(subtotal, currencyObj), FontContext.TABLE_DATA,
                    Element.ALIGN_RIGHT, Rectangle.LEFT + Rectangle.RIGHT, 5);
            table.addCell(invcell);
            invcell = createCell(currencyRender(prodtax, currencyObj), FontContext.TABLE_DATA,
                    Element.ALIGN_CENTER, Rectangle.LEFT + Rectangle.RIGHT, 5);
            table.addCell(invcell);
            invcell = createCell(currencyRender(subtotal, currencyObj), FontContext.TABLE_DATA,
                    Element.ALIGN_RIGHT, Rectangle.LEFT + Rectangle.RIGHT, 5);
            table.addCell(invcell);

            total += Double.valueOf(subtotal);

            addTableRow(mainTable, table); //Break table after adding detail's row
            table = getBlankTable();
        }

        for (int j = 0; j < 98; j++) {
            invcell = new PdfPCell(new Paragraph(fontFamilySelector.process("", FontContext.TABLE_DATA)));//fontRegularBold));
            invcell.setHorizontalAlignment(Element.ALIGN_CENTER);
            invcell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
            table.addCell(invcell);
        }
        addTableRow(mainTable, table); //Break table after adding extra space
        table = getBlankTable();

        cell3 = createCell("SUB TOTAL", FontContext.NOTE_TEXT, Element.ALIGN_RIGHT, Rectangle.TOP, 5);
        cell3.setColspan(7);
        table.addCell(cell3);

        cell3 = createCell(currencyRender(String.valueOf(total), currencyObj), FontContext.TABLE_DATA,
                Element.ALIGN_RIGHT, 15, 5);
        table.addCell(cell3);

        cell3 = createCell("DISCOUNT(-)", FontContext.NOTE_TEXT, Element.ALIGN_RIGHT, 0, 5);
        cell3.setColspan(7);
        table.addCell(cell3);
        cell3 = calculateDiscount(quotationDisc, currencyObj);
        table.addCell(cell3);

        StringBuffer taxNameStr = new StringBuffer();
        if (!StringUtil.isNullOrEmpty(quotationtaxname)) {
            taxNameStr.append(quotationtaxname);
            taxNameStr.append(" ");
            taxNameStr.append(quotationtaxpercent);
            taxNameStr.append("% (+)");
        } else {
            taxNameStr.append("TAX (+)");
        }
        cell3 = createCell(taxNameStr.toString(), FontContext.NOTE_TEXT, Element.ALIGN_RIGHT, 0, 5);
        cell3.setColspan(7);
        table.addCell(cell3);
        cell3 = createCell(currencyRender(String.valueOf(quotationtaxamount), currencyObj),
                FontContext.TABLE_DATA, Element.ALIGN_RIGHT, 15, 5);
        table.addCell(cell3);

        cell3 = createCell("TOTAL", FontContext.NOTE_TEXT, Element.ALIGN_RIGHT, 0, 5);
        cell3.setColspan(7);
        table.addCell(cell3);
        cell3 = createCell(currencyRender(String.valueOf(totalAmount), currencyObj), FontContext.TABLE_DATA,
                Element.ALIGN_RIGHT, 15, 5);
        table.addCell(cell3);

        addTableRow(mainTable, table);

        String netinword = EnglishNumberToWordsOjb.convert(Double.parseDouble(String.valueOf(totalAmount)),
                currencyObj);
        String currencyname = currencyObj.getName();

        cell3 = createCell("Amount (in words) : " + currencyname + " " + netinword + " Only.",
                FontContext.HEADER_NOTE, Element.ALIGN_LEFT,
                Rectangle.LEFT + Rectangle.RIGHT + Rectangle.BOTTOM + Rectangle.TOP, 5);

        PdfPTable table2 = new PdfPTable(1);
        table2.addCell(cell3);
        PdfPCell mainCell62 = new PdfPCell(table2);
        mainCell62.setBorder(0);
        mainCell62.setPadding(10);
        mainTable.addCell(mainCell62);

        PdfPTable helpTable = new PdfPTable(new float[] { 8, 92 });
        helpTable.setWidthPercentage(100);
        Phrase phrase1 = fontFamilySelector.process("Memo:  ", FontContext.NOTE_TEXT);
        Phrase phrase2 = fontFamilySelector.process(memo, FontContext.TABLE_DATA);//fontRegularBold);
        PdfPCell pcell1 = new PdfPCell(phrase1);
        PdfPCell pcell2 = new PdfPCell(phrase2);
        pcell1.setBorder(0);
        pcell1.setPadding(10);
        pcell1.setPaddingRight(0);
        pcell2.setBorder(0);
        pcell2.setPadding(10);
        helpTable.addCell(pcell1);
        helpTable.addCell(pcell2);

        PdfPCell mainCell61 = new PdfPCell(helpTable);
        mainCell61.setBorder(0);
        mainTable.addCell(mainCell61);
        getHtmlCell("<br>", mainTable, baseUrl);
        getHtmlCell("<br>", mainTable, baseUrl);
        getHtmlCell(postText.trim(), mainTable, baseUrl);
        document.add(mainTable);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

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

License:Open Source License

public PdfPTable getBlankTable() throws DocumentException {
    PdfPTable table = new PdfPTable(8);
    table.setWidthPercentage(100);/*from ww  w  .  j  a va 2 s .co m*/
    table.setWidths(new float[] { 5, 20, 15, 10, 15, 10, 10, 15 });
    return table;
}

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

License:Open Source License

public PdfPTable getCompanyInfo(String com[]) {
    PdfPTable tab1 = new PdfPTable(1);
    tab1.setHorizontalAlignment(Element.ALIGN_CENTER);
    PdfPCell cell = new PdfPCell(new Paragraph(fontFamilySelector.process(com[0], FontContext.TABLE_DATA)));//fontBoldMedium));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell.setBorder(0);//from   w  w  w.  ja v  a  2  s  .  co m
    tab1.addCell(cell);
    for (int i = 1; i < com.length; i++) {
        cell = new PdfPCell(new Paragraph(fontFamilySelector.process(com[i], FontContext.TABLE_DATA)));// fontRegularBold));
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setBorder(0);
        tab1.addCell(cell);
    }
    return tab1;
}

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

License:Open Source License

public void addComponyLogo(Document d, HttpServletRequest request) throws ServiceException {
    try {//from ww w. j  ava2s . co  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.HEADER_NOTE)));
        }
        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.exportMPXDAOImpl.java

License:Open Source License

public void addTitleSubtitle(Document d) throws ServiceException {
    try {/*w  w  w  .  ja v a2s . co m*/
        java.awt.Color tColor = new Color(Integer.parseInt(config.getString("textColor"), 16));
        //            fontBold.setColor(tColor);
        //            fontRegular.setColor(tColor);
        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)));
        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(
                    (new Phrase(fontFamilySelector.process(SubTitles[i], FontContext.FOOTER_NOTE)))));
            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.exportMPXDAOImpl.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, Document document, HttpServletRequest request)
        throws ServiceException {
    try {//  www . j  a v a 2 s.c  o m
        DateFormat formatter = authHandlerDAOObj.getUserDateFormatter(
                sessionHandlerImpl.getDateFormatID(request), sessionHandlerImpl.getTimeZoneDifference(request),
                true);
        DateFormat frmt = authHandler.getDateFormatter(request);
        String currencyid = sessionHandlerImpl.getCurrencyID(request);
        int mode = Integer.parseInt(request.getParameter("get"));
        double totalCre = 0;
        double totalDeb = 0;
        java.awt.Color tColor = new Color(Integer.parseInt(config.getString("textColor"), 16));
        //            fontSmallRegular.setColor(tColor);
        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(
                (new Phrase(fontFamilySelector.process("No.", FontContext.FOOTER_NOTE, 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++) {
            String headerStr = StringUtil.serverHTMLStripper(colHeader[hcol]);
            if (align[hcol].equals("currency") && !colHeader[hcol].equals("")) {
                String currency = currencyRender("", currencyid);
                h1 = new PdfPCell(new Paragraph((new Phrase(fontFamilySelector
                        .process(headerStr + "(" + currency + ")", FontContext.FOOTER_NOTE, tColor)))));
            } else {
                h1 = new PdfPCell(new Paragraph(
                        (new Phrase(fontFamilySelector.process(headerStr, FontContext.FOOTER_NOTE, 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)));
            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);
            if (mode == 116 || mode == 117) {
                totalCre = totalCre + Double
                        .parseDouble(temp.getString("c_amount") != "" ? temp.getString("c_amount") : "0");
                totalDeb = totalDeb + Double
                        .parseDouble(temp.getString("d_amount") != "" ? temp.getString("d_amount") : "0");
            }
            for (int col = 0; col < colwidth2.length; col++) {
                Paragraph para = null;
                String rowCurrencyId = temp.has("currencyid") ? temp.getString("currencyid") : currencyid;
                if (align[col].equals("currency") && !temp.getString(colwidth2[col]).equals("")) {
                    String currency = currencyRender(temp.getString(colwidth2[col]), currencyid);
                    para = new Paragraph(fontFamilySelector.process(currency, FontContext.TABLE_DATA));
                } else if (align[col].equals("rowcurrency") && !temp.getString(colwidth2[col]).equals("")) {
                    String withCurrency = currencyRender(temp.getString(colwidth2[col]), rowCurrencyId);
                    para = new Paragraph(fontFamilySelector.process(withCurrency, FontContext.TABLE_DATA));
                } else if (align[col].equals("date") && !temp.getString(colwidth2[col]).equals("")) {
                    try {
                        String d1 = formatter.format(frmt.parse(temp.getString(colwidth2[col])));
                        para = new Paragraph(fontFamilySelector.process(d1, FontContext.TABLE_DATA));
                    } catch (Exception ex) {
                        para = new Paragraph(fontFamilySelector.process(temp.getString(colwidth2[col]),
                                FontContext.TABLE_DATA));
                    }
                } else if (colwidth2[col].equals("taxrate")
                        || colwidth2[col].equals("permargin") && !colHeader[col].equals("")) {
                    para = new Paragraph(fontFamilySelector.process(
                            htmlPercentageRender(temp.getString(colwidth2[col]), true),
                            FontContext.TABLE_DATA));
                } else {
                    if (colwidth2[col].equals("invoiceno")) {
                        para = new Paragraph(fontFamilySelector.process(temp.getString("no").toString(),
                                FontContext.TABLE_DATA));
                    } else if (colwidth2[col].equals("invoicedate")) {
                        para = new Paragraph(fontFamilySelector.process(temp.getString("date").toString(),
                                FontContext.TABLE_DATA));
                    } else if ((temp.isNull(colwidth2[col])) && !(colwidth2[col].equals("invoiceno"))
                            && !(colwidth2[col].equals("invoicedate"))) {
                        para = new Paragraph(fontFamilySelector.process("", FontContext.TABLE_DATA));
                    } else if (colwidth2[col].equals("c_date")) {
                        para = new Paragraph(fontFamilySelector.process(formatter.format(
                                frmt.parse(temp.getString("c_date").toString() == "" ? temp.getString("d_date")
                                        : temp.getString("c_date"))),
                                FontContext.TABLE_DATA));
                    } else if (colwidth2[col].equals("c_accountname")) {
                        para = new Paragraph(
                                fontFamilySelector.process(
                                        temp.getString("c_accountname").toString() == ""
                                                ? temp.getString("d_accountname").toString()
                                                : temp.getString("c_accountname").toString(),
                                        FontContext.TABLE_DATA));
                    } else if (colwidth2[col].equals("c_entryno")) {
                        para = new Paragraph(
                                fontFamilySelector.process(
                                        temp.getString("c_entryno").toString() == ""
                                                ? temp.getString("d_entryno").toString()
                                                : temp.getString("c_entryno").toString(),
                                        FontContext.TABLE_DATA));
                    } else if (colwidth2[col].equals("d_date")) {
                        para = new Paragraph(fontFamilySelector.process(formatter.format(
                                frmt.parse(temp.getString("d_date").toString() == "" ? temp.getString("c_date")
                                        : temp.getString("d_date"))),
                                FontContext.TABLE_DATA));
                    } else if (colwidth2[col].equals("d_accountname")) {
                        para = new Paragraph(
                                fontFamilySelector.process(
                                        temp.getString("d_accountname").toString() == ""
                                                ? temp.getString("c_accountname").toString()
                                                : temp.getString("d_accountname").toString(),
                                        FontContext.TABLE_DATA));
                    } else if (colwidth2[col].equals("d_entryno")) {
                        para = new Paragraph(
                                fontFamilySelector.process(
                                        temp.getString("d_entryno").toString() == ""
                                                ? temp.getString("c_entryno").toString()
                                                : temp.getString("d_entryno").toString(),
                                        FontContext.TABLE_DATA));
                    } else if (colwidth2[col].equals("perioddepreciation")) {
                        double adj = temp.getDouble("perioddepreciation") - temp.getDouble("firstperiodamt");
                        String currency = currencyRender("" + adj, currencyid);
                        if (adj < 0.0001) {
                            para = new Paragraph(fontFamilySelector.process("", FontContext.TABLE_DATA));
                        } else {
                            para = new Paragraph(fontFamilySelector.process(currency, FontContext.TABLE_DATA));
                        }
                    } else if (colHeader[col].equals("Opening Balance")
                            || colHeader[col].equals("Asset Value")) {
                        String currency = currencyRender("" + Math.abs(temp.getDouble("openbalance")),
                                currencyid);
                        para = new Paragraph(fontFamilySelector.process(currency, FontContext.TABLE_DATA));
                    } else {
                        if (colHeader[col].equals("Opening Balance Type")) {
                            double bal = Double.parseDouble(temp.getString(colwidth2[col]));
                            String str = bal == 0 ? "" : (bal < 0 ? "Credit" : "Debit");
                            if (str.equals(""))
                                str = "N/A";
                            para = new Paragraph(fontFamilySelector.process(str, FontContext.TABLE_DATA));
                        } else {
                            para = new Paragraph(fontFamilySelector.process(
                                    temp.getString(colwidth2[col]).toString(), FontContext.TABLE_DATA));
                        }
                    }
                }
                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("currency") || align[col].equals("rowcurrency")
                        || colwidth2[col].equals("taxrate") || colwidth2[col].equals("permargin")) {
                    h1.setHorizontalAlignment(Element.ALIGN_RIGHT);
                    h1.setVerticalAlignment(Element.ALIGN_RIGHT);
                } else if (align[col].equals("date")) {
                    h1.setHorizontalAlignment(Element.ALIGN_CENTER);
                    h1.setVerticalAlignment(Element.ALIGN_CENTER);
                } else {
                    h1.setHorizontalAlignment(Element.ALIGN_LEFT);
                    h1.setVerticalAlignment(Element.ALIGN_LEFT);
                }
                table.addCell(h1);
            }
        }
        if (mode == 116 || mode == 117) {
            Paragraph para1 = null;
            PdfPCell h3 = null;
            String totCr = "";
            String totDb = "";
            h3 = new PdfPCell(new Paragraph(fontFamilySelector.process("", FontContext.TABLE_DATA)));
            if (config.getBoolean("gridBorder")) {
                h3.setBorder(PdfPCell.BOTTOM | PdfPCell.LEFT);
            } else {
                h3.setBorder(0);
            }
            h3.setPadding(4);
            h3.setBorderColor(Color.GRAY);
            h3.setBackgroundColor(Color.lightGray);
            h3.setHorizontalAlignment(Element.ALIGN_CENTER);
            h3.setVerticalAlignment(Element.ALIGN_CENTER);
            table.addCell(h3);
            para1 = new Paragraph(fontFamilySelector.process("Total", FontContext.REPORT_TITLE));
            h3 = new PdfPCell(para1);
            if (config.getBoolean("gridBorder")) {
                h3.setBorder(PdfPCell.BOTTOM | PdfPCell.LEFT | PdfPCell.RIGHT);
            } else {
                h3.setBorder(0);
            }
            h3.setPadding(4);
            h3.setBorderColor(Color.GRAY);
            h3.setBackgroundColor(Color.LIGHT_GRAY);
            h3.setHorizontalAlignment(Element.ALIGN_LEFT);
            h3.setVerticalAlignment(Element.ALIGN_LEFT);
            table.addCell(h3);

            for (int col = 1; col < colwidth2.length; col++) {
                if (colwidth2[col].equals("c_amount")) {
                    totCr = currencyRender(String.valueOf(totalCre), currencyid);
                    para1 = new Paragraph(fontFamilySelector.process(totCr, FontContext.TABLE_DATA));
                } else if (colwidth2[col].equals("d_amount")) {
                    totDb = currencyRender(String.valueOf(totalDeb), currencyid);
                    para1 = new Paragraph(fontFamilySelector.process(totDb, FontContext.TABLE_DATA));
                } else {
                    para1 = new Paragraph(fontFamilySelector.process("", FontContext.TABLE_DATA));
                }

                h3 = new PdfPCell(para1);
                if (config.getBoolean("gridBorder")) {
                    h3.setBorder(PdfPCell.BOTTOM | PdfPCell.LEFT | PdfPCell.RIGHT);
                } else {
                    h3.setBorder(0);
                }
                h3.setPadding(4);
                h3.setBorderColor(Color.GRAY);
                h3.setBackgroundColor(Color.LIGHT_GRAY);
                h3.setHorizontalAlignment(Element.ALIGN_RIGHT);
                h3.setVerticalAlignment(Element.ALIGN_RIGHT);
                table.addCell(h3);

            }
        }
        document.add(table);
        document.newPage();
    } catch (Exception e) {
        throw ServiceException.FAILURE("exportDAOImpl.addTable", e);
    }
    return stpcol;
}

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

License:Open Source License

public int addGroupableTable(JSONObject groupingConfig, String groupByField, String groupHeaderText, int stcol,
        int stpcol, int strow, int stprow, JSONArray store, String[] dataIndexArr, String[] colHeader,
        String[] widths, String[] align, Document document, HttpServletRequest request)
        throws ServiceException {
    try {//from  w  w  w. ja  v  a 2s .  co m
        String groupSummaryField = groupingConfig.getString("groupSummaryField");
        String groupSummaryText = groupingConfig.getString("groupSummaryText");
        String reportSummaryField = groupingConfig.getString("reportSummaryField");
        String reportSummaryText = groupingConfig.getString("reportSummaryText");

        DateFormat formatter = authHandlerDAOObj.getUserDateFormatter(
                sessionHandlerImpl.getDateFormatID(request), sessionHandlerImpl.getTimeZoneDifference(request),
                true);
        DateFormat frmt = authHandler.getDateFormatter(request);
        String currencyid = sessionHandlerImpl.getCurrencyID(request);
        java.awt.Color tColor = new Color(Integer.parseInt(config.getString("textColor"), 16));
        java.awt.Color gsBGColor = new Color(Integer.parseInt("E5E5E5", 16));
        java.awt.Color rsBGColor = new Color(Integer.parseInt("808080", 16));
        //            fontRegular.setColor(tColor);
        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 < dataIndexArr.length; hcol++) {
            if (align[hcol].equals("currency") && !colHeader[hcol].equals("")) {
                String currency = currencyRender("", currencyid);
                h1 = new PdfPCell(new Paragraph(fontFamilySelector
                        .process(colHeader[hcol] + "(" + currency + ")", FontContext.TABLE_HEADER, tColor)));
            } else {
                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);
        String groupName = "", rowCurrency = "";
        Double subTotal = 0.0;
        Double grandTotal = 0.0;
        int rowSpan = 0;
        for (int row = strow; row < stprow; row++) {
            rowSpan++;
            JSONObject rowData = store.getJSONObject(row);
            if (row == 0) {
                groupName = rowData.getString(groupByField);
                rowCurrency = rowData.has("currencyid") ? rowData.getString("currencyid") : currencyid;
                subTotal = 0.0;
                addGroupRow(groupHeaderText + ": " + groupName, currencyid, table, dataIndexArr);
            }
            if (!groupName.equalsIgnoreCase(rowData.getString(groupByField))) {
                addSummaryRow(groupSummaryText + groupName + " ", subTotal, rowCurrency, table, dataIndexArr,
                        false, gsBGColor);
                groupName = rowData.getString(groupByField);
                rowCurrency = rowData.has("currencyid") ? rowData.getString("currencyid") : currencyid;
                addGroupRow(groupHeaderText + ": " + groupName, currencyid, table, dataIndexArr);
                subTotal = 0.0;
                rowSpan = 1;
            }
            subTotal += Double.parseDouble(rowData.getString(groupSummaryField));
            grandTotal += Double.parseDouble(rowData.getString(reportSummaryField));
            rowCurrency = rowData.has("currencyid") ? rowData.getString("currencyid") : currencyid;

            h2 = new PdfPCell(new Paragraph(
                    fontFamilySelector.process(String.valueOf(row + 1), FontContext.TABLE_HEADER, 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);

            for (int col = 0; col < dataIndexArr.length; col++) {
                String cellData = null;
                if (align[col].equals("currency") && !rowData.getString(dataIndexArr[col]).equals("")) {
                    cellData = currencyRender(rowData.getString(dataIndexArr[col]),
                            rowData.getString("currencyid"));
                } else if (align[col].equals("date") && !rowData.getString(dataIndexArr[col]).equals("")) {
                    try {
                        cellData = formatter.format(frmt.parse(rowData.getString(dataIndexArr[col])));
                    } catch (Exception ex) {
                        cellData = rowData.getString(dataIndexArr[col]);
                    }
                } else {
                    cellData = rowData.getString(dataIndexArr[col]);
                }

                Paragraph para = new Paragraph(
                        fontFamilySelector.process(cellData, FontContext.TABLE_HEADER, 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("currency") && !align[col].equals("date")) {
                    h1.setHorizontalAlignment(Element.ALIGN_LEFT);
                    h1.setVerticalAlignment(Element.ALIGN_LEFT);
                } else if (align[col].equals("currency")) {
                    h1.setHorizontalAlignment(Element.ALIGN_RIGHT);
                    h1.setVerticalAlignment(Element.ALIGN_RIGHT);
                } else if (align[col].equals("date")) {
                    h1.setHorizontalAlignment(Element.ALIGN_CENTER);
                    h1.setVerticalAlignment(Element.ALIGN_CENTER);
                }
                table.addCell(h1);
            }
        }
        if (rowSpan > 0) {
            addSummaryRow(groupSummaryText + groupName + " ", subTotal, rowCurrency, table, dataIndexArr, false,
                    gsBGColor);
        }
        addSummaryRow(reportSummaryText, grandTotal, currencyid, table, dataIndexArr, false, rsBGColor);

        document.add(table);
        document.newPage();
    } catch (Exception e) {
        throw ServiceException.FAILURE("exportDAOImpl.addTable", e);
    }
    return stpcol;
}