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

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

Introduction

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

Prototype

public void addCell(Phrase phrase) 

Source Link

Document

Adds a cell element.

Usage

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

License:Open Source License

private PdfPTable createCreditTable(String header[], String values[], String currencyid, CreditNote cre)
        throws DocumentException, ServiceException, JSONException {
    PdfPTable table = new PdfPTable(header.length);
    table.setWidthPercentage(100);/*from   ww w. ja  v a2  s  . com*/
    table.setWidths(new float[] { 30, 30, 40 });
    PdfPCell cell = null;
    for (int i = 0; i < header.length; i++) {
        cell = new PdfPCell(new Paragraph(header[i], fontTblMediumBold));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setPadding(3);
        table.addCell(cell);
    }
    Iterator itr = cre.getRows().iterator();
    while (itr.hasNext()) {
        CreditNoteDetail creDet = (CreditNoteDetail) itr.next();
        cell = new PdfPCell(
                new Paragraph(creDet.getInvoiceRow().getInventory().getProduct().getName(), fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(
                Integer.toString(creDet.getQuantity()) + " "
                        + creDet.getInvoiceRow().getInventory().getProduct().getUnitOfMeasure().getName(),
                fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        cell = calculateDiscount(creDet.getDiscount(), currencyid);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
    }
    for (int i = 0; i < 3; i++) {
        PdfPCell cell1 = new PdfPCell(new Paragraph("", fontSmallRegular));
        cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell1.setBorder(Rectangle.TOP);
        table.addCell(cell1);
    }
    return table;
}

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

License:Open Source License

private PdfPTable createDebitTable(String header[], String values[], String currencyid, BillingDebitNote deb)
        throws DocumentException, ServiceException, JSONException {
    PdfPTable table = new PdfPTable(header.length);
    table.setWidthPercentage(100);/*from  w  w w  . jav a2 s . c  o m*/
    table.setWidths(new float[] { 30, 30, 40 });
    PdfPCell cell = null;
    for (int i = 0; i < header.length; i++) {
        cell = new PdfPCell(new Paragraph(header[i], fontTblMediumBold));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setPadding(3);
        table.addCell(cell);
    }
    Iterator itr = deb.getRows().iterator();
    while (itr.hasNext()) {
        BillingDebitNoteDetail debDet = (BillingDebitNoteDetail) itr.next();
        cell = new PdfPCell(new Paragraph(debDet.getGoodsReceiptRow().getProductDetail(), fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(Double.toString(debDet.getQuantity()), fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        cell = calculateDiscount(debDet.getDiscount(), currencyid);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
    }
    for (int i = 0; i < 3; i++) {
        PdfPCell cell1 = new PdfPCell(new Paragraph("", fontSmallRegular));
        cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell1.setBorder(Rectangle.TOP);
        table.addCell(cell1);
    }
    return table;
}

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

License:Open Source License

private PdfPTable createCreditTable(String header[], String values[], String currencyid, BillingCreditNote cre)
        throws DocumentException, ServiceException, JSONException {
    PdfPTable table = new PdfPTable(header.length);
    table.setWidthPercentage(100);//ww  w  .  j  av a2 s . c  om
    table.setWidths(new float[] { 30, 30, 40 });
    PdfPCell cell = null;
    for (int i = 0; i < header.length; i++) {
        cell = new PdfPCell(new Paragraph(header[i], fontTblMediumBold));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setPadding(3);
        table.addCell(cell);
    }
    Iterator itr = cre.getRows().iterator();
    while (itr.hasNext()) {
        BillingCreditNoteDetail creDet = (BillingCreditNoteDetail) itr.next();
        cell = new PdfPCell(new Paragraph(creDet.getInvoiceRow().getProductDetail(), fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(Double.toString(creDet.getQuantity()), fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        cell = calculateDiscount(creDet.getDiscount(), currencyid);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
    }
    for (int i = 0; i < 3; i++) {
        PdfPCell cell1 = new PdfPCell(new Paragraph("", fontSmallRegular));
        cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell1.setBorder(Rectangle.TOP);
        table.addCell(cell1);
    }
    return table;
}

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

License:Open Source License

private PdfPTable createGoodsReceiptTable(String[] header, String[] values, String currencyid, GoodsReceipt gr)
        throws DocumentException {
    double total = 0;
    PdfPTable table = new PdfPTable(header.length);
    table.setWidthPercentage(100);/*from  w w w.  j av a  2  s  .co m*/
    table.setWidths(new float[] { 30, 15, 15, 20, 20 });
    PdfPCell cell = null;
    for (int i = 0; i < header.length; i++) {
        cell = new PdfPCell(new Paragraph(header[i], fontTblMediumBold));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setPadding(3);
        table.addCell(cell);
    }
    Iterator itr = gr.getRows().iterator();
    while (itr.hasNext()) {
        GoodsReceiptDetail row = (GoodsReceiptDetail) itr.next();
        cell = new PdfPCell(new Paragraph(row.getInventory().getProduct().getName(), fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(Integer.toString(row.getInventory().getQuantity()) + " "
                + row.getInventory().getProduct().getUnitOfMeasure().getName(), fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(authHandlerDAOObj.getFormattedCurrency(row.getRate(), currencyid),
                fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        cell = calculateDiscount(row.getDiscount(), currencyid);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        double amount = row.getRate() * row.getInventory().getQuantity();
        if (row.getDiscount() != null) {
            amount -= row.getDiscount().getDiscountValue();
        }
        total += amount;
        cell = new PdfPCell(
                new Paragraph(authHandlerDAOObj.getFormattedCurrency(amount, currencyid), fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
    }

    for (int j = 0; j < 50; j++) {
        cell = new PdfPCell(new Paragraph("", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
    }
    for (int i = 0; i < 3; i++) {
        cell = new PdfPCell(new Paragraph("", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(Rectangle.TOP);
        table.addCell(cell);
    }
    cell = new PdfPCell(new Paragraph("  SUB TOTAL", fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.addCell(cell);
    cell = new PdfPCell(
            new Paragraph(authHandlerDAOObj.getFormattedCurrency(total, currencyid), fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    cell.setPadding(4);
    table.addCell(cell);

    for (int i = 0; i < 3; i++) {
        cell = new PdfPCell(new Paragraph("", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        table.addCell(cell);
    }
    cell = new PdfPCell(new Paragraph("  DISCOUNT", fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell.setPadding(4);
    table.addCell(cell);
    cell = calculateDiscount(gr.getDiscount(), currencyid);
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(cell);
    for (int i = 0; i < 3; i++) {
        cell = new PdfPCell(new Paragraph("", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        table.addCell(cell);
    }
    cell = new PdfPCell(new Paragraph("  SHIPPING CHARGES", fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.addCell(cell);
    cell = getCharges(gr.getShipEntry(), currencyid);
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(cell);
    for (int i = 0; i < 3; i++) {
        cell = new PdfPCell(new Paragraph("", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        table.addCell(cell);
    }
    cell = new PdfPCell(new Paragraph("  OTHER CHARGES", fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.addCell(cell);
    cell = getCharges(gr.getOtherEntry(), currencyid);
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(cell);
    for (int i = 0; i < 3; i++) {
        cell = new PdfPCell(new Paragraph("", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        table.addCell(cell);
    }
    cell = new PdfPCell(new Paragraph("  TOTAL", fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.addCell(cell);
    cell = new PdfPCell(
            new Paragraph(authHandlerDAOObj.getFormattedCurrency(gr.getVendorEntry().getAmount(), currencyid),
                    fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(cell);
    return table;
}

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

License:Open Source License

private PdfPTable createPurchaseOrderTable(String[] header, String[] values, String currencyid,
        PurchaseOrder po) throws DocumentException {
    double total = 0;
    PdfPTable table = new PdfPTable(header.length);
    table.setWidthPercentage(100);//from w ww.j a  v  a2 s  .c o  m
    table.setWidths(new float[] { 30, 15, 15, 20, 20 });
    PdfPCell cell = null;
    for (int i = 0; i < header.length; i++) {
        cell = new PdfPCell(new Paragraph(header[i], fontTblMediumBold));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setPadding(3);
        table.addCell(cell);
    }
    Iterator itr = po.getRows().iterator();
    while (itr.hasNext()) {
        PurchaseOrderDetail row = (PurchaseOrderDetail) itr.next();
        cell = new PdfPCell(new Paragraph(row.getProduct().getName(), fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(
                Integer.toString(row.getQuantity()) + " " + row.getProduct().getUnitOfMeasure().getName(),
                fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(authHandlerDAOObj.getFormattedCurrency(row.getRate(), currencyid),
                fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph("--", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        double amount = row.getRate() * row.getQuantity();
        total += amount;
        cell = new PdfPCell(
                new Paragraph(authHandlerDAOObj.getFormattedCurrency(amount, currencyid), fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
    }

    for (int j = 0; j < 50; j++) {
        cell = new PdfPCell(new Paragraph("", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
    }
    for (int i = 0; i < 3; i++) {
        cell = new PdfPCell(new Paragraph("", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(Rectangle.TOP);
        table.addCell(cell);
    }
    cell = new PdfPCell(new Paragraph("  SUB TOTAL", fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.addCell(cell);
    cell = new PdfPCell(
            new Paragraph(authHandlerDAOObj.getFormattedCurrency(total, currencyid), fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(cell);

    for (int i = 0; i < 3; i++) {
        cell = new PdfPCell(new Paragraph("", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        table.addCell(cell);
    }
    cell = new PdfPCell(new Paragraph("  DISCOUNT", fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph("--", fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(cell);
    for (int i = 0; i < 3; i++) {
        cell = new PdfPCell(new Paragraph("", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        table.addCell(cell);
    }
    cell = new PdfPCell(new Paragraph("  TOTAL", fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.addCell(cell);
    cell = new PdfPCell(
            new Paragraph(authHandlerDAOObj.getFormattedCurrency(total, currencyid), fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(cell);
    return table;
}

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

License:Open Source License

private PdfPTable createSalesOrderTable(String[] header, String[] values, String currencyid, SalesOrder so)
        throws DocumentException {
    double total = 0;
    PdfPTable table = new PdfPTable(header.length);
    table.setWidthPercentage(100);//from   www  . ja  v  a 2  s .  co m
    table.setWidths(new float[] { 30, 15, 15, 20, 20 });
    PdfPCell cell = null;
    for (int i = 0; i < header.length; i++) {
        cell = new PdfPCell(new Paragraph(header[i], fontTblMediumBold));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setPadding(3);
        table.addCell(cell);
    }
    Iterator itr = so.getRows().iterator();
    while (itr.hasNext()) {
        SalesOrderDetail row = (SalesOrderDetail) itr.next();
        cell = new PdfPCell(new Paragraph(row.getProduct().getName(), fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(
                Integer.toString(row.getQuantity()) + " " + row.getProduct().getUnitOfMeasure().getName(),
                fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(authHandlerDAOObj.getFormattedCurrency(row.getRate(), currencyid),
                fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph("--", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        double amount = row.getRate() * row.getQuantity();
        total += amount;
        cell = new PdfPCell(
                new Paragraph(authHandlerDAOObj.getFormattedCurrency(amount, currencyid), fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
    }

    for (int j = 0; j < 50; j++) {
        cell = new PdfPCell(new Paragraph("", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
    }
    for (int i = 0; i < 3; i++) {
        cell = new PdfPCell(new Paragraph("", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(Rectangle.TOP);
        table.addCell(cell);
    }
    cell = new PdfPCell(new Paragraph("  SUB TOTAL", fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.addCell(cell);
    cell = new PdfPCell(
            new Paragraph(authHandlerDAOObj.getFormattedCurrency(total, currencyid), fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(cell);

    for (int i = 0; i < 3; i++) {
        cell = new PdfPCell(new Paragraph("", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        table.addCell(cell);
    }
    cell = new PdfPCell(new Paragraph("  DISCOUNT", fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph("--", fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(cell);
    for (int i = 0; i < 3; i++) {
        cell = new PdfPCell(new Paragraph("", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        table.addCell(cell);
    }
    cell = new PdfPCell(new Paragraph("  TOTAL", fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.addCell(cell);
    cell = new PdfPCell(
            new Paragraph(authHandlerDAOObj.getFormattedCurrency(total, currencyid), fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(cell);
    return table;
}

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

License:Open Source License

private PdfPTable createPurchaseOrderTable(String[] header, String[] values, String currencyid,
        BillingPurchaseOrder po) throws DocumentException {
    double total = 0;
    PdfPTable table = new PdfPTable(header.length);
    table.setWidthPercentage(100);/*w  w  w. ja  v a  2 s. c  om*/
    table.setWidths(new float[] { 30, 15, 15, 20, 20 });
    PdfPCell cell = null;
    for (int i = 0; i < header.length; i++) {
        cell = new PdfPCell(new Paragraph(header[i], fontTblMediumBold));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setPadding(3);
        table.addCell(cell);
    }
    Iterator itr = po.getRows().iterator();
    while (itr.hasNext()) {
        BillingPurchaseOrderDetail row = (BillingPurchaseOrderDetail) itr.next();
        cell = new PdfPCell(new Paragraph(row.getProductDetail(), fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(Double.toString(row.getQuantity()), fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(authHandlerDAOObj.getFormattedCurrency(row.getRate(), currencyid),
                fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph("--", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        double amount = row.getRate() * row.getQuantity();
        total += amount;
        cell = new PdfPCell(
                new Paragraph(authHandlerDAOObj.getFormattedCurrency(amount, currencyid), fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
    }

    for (int j = 0; j < 50; j++) {
        cell = new PdfPCell(new Paragraph("", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
    }
    for (int i = 0; i < 3; i++) {
        cell = new PdfPCell(new Paragraph("", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(Rectangle.TOP);
        table.addCell(cell);
    }
    cell = new PdfPCell(new Paragraph("  SUB TOTAL", fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.addCell(cell);
    cell = new PdfPCell(
            new Paragraph(authHandlerDAOObj.getFormattedCurrency(total, currencyid), fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(cell);

    for (int i = 0; i < 3; i++) {
        cell = new PdfPCell(new Paragraph("", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        table.addCell(cell);
    }
    cell = new PdfPCell(new Paragraph("  DISCOUNT", fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph("--", fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(cell);
    for (int i = 0; i < 3; i++) {
        cell = new PdfPCell(new Paragraph("", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        table.addCell(cell);
    }
    cell = new PdfPCell(new Paragraph("  TOTAL", fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.addCell(cell);
    cell = new PdfPCell(
            new Paragraph(authHandlerDAOObj.getFormattedCurrency(total, currencyid), fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(cell);
    return table;
}

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

License:Open Source License

private PdfPTable createSalesOrderTable(String[] header, String[] values, String currencyid,
        BillingSalesOrder so) throws DocumentException {
    double total = 0;
    PdfPTable table = new PdfPTable(header.length);
    table.setWidthPercentage(100);/*from   w  w  w  .j  a  va2 s. c o m*/
    table.setWidths(new float[] { 30, 15, 15, 20, 20 });
    PdfPCell cell = null;
    for (int i = 0; i < header.length; i++) {
        cell = new PdfPCell(new Paragraph(header[i], fontTblMediumBold));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setPadding(3);
        table.addCell(cell);
    }
    Iterator itr = so.getRows().iterator();
    while (itr.hasNext()) {
        BillingSalesOrderDetail row = (BillingSalesOrderDetail) itr.next();
        cell = new PdfPCell(new Paragraph(row.getProductDetail(), fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(Double.toString(row.getQuantity()), fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(authHandlerDAOObj.getFormattedCurrency(row.getRate(), currencyid),
                fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph("--", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        double amount = row.getRate() * row.getQuantity();
        total += amount;
        cell = new PdfPCell(
                new Paragraph(authHandlerDAOObj.getFormattedCurrency(amount, currencyid), fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
    }

    for (int j = 0; j < 50; j++) {
        cell = new PdfPCell(new Paragraph("", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
    }
    for (int i = 0; i < 3; i++) {
        cell = new PdfPCell(new Paragraph("", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(Rectangle.TOP);
        table.addCell(cell);
    }
    cell = new PdfPCell(new Paragraph("  SUB TOTAL", fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.addCell(cell);
    cell = new PdfPCell(
            new Paragraph(authHandlerDAOObj.getFormattedCurrency(total, currencyid), fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(cell);

    for (int i = 0; i < 3; i++) {
        cell = new PdfPCell(new Paragraph("", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        table.addCell(cell);
    }
    cell = new PdfPCell(new Paragraph("  DISCOUNT", fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph("--", fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(cell);
    for (int i = 0; i < 3; i++) {
        cell = new PdfPCell(new Paragraph("", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        table.addCell(cell);
    }
    cell = new PdfPCell(new Paragraph("  TOTAL", fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.addCell(cell);
    cell = new PdfPCell(
            new Paragraph(authHandlerDAOObj.getFormattedCurrency(total, currencyid), fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(cell);
    return table;
}

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

License:Open Source License

private PdfPTable createPaymentTable(String[] header, String[] values, String currencyid, Payment pay,
        DateFormat formatter) throws DocumentException {
    double total = 0;
    PdfPTable table = new PdfPTable(header.length);
    table.setWidthPercentage(100);//from ww w . j a  v a 2s. co m
    table.setWidths(new float[] { 30, 25, 25, 20 });
    PdfPCell cell = null;
    for (int i = 0; i < header.length; i++) {
        cell = new PdfPCell(new Paragraph(header[i], fontTblMediumBold));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setPadding(3);
        table.addCell(cell);
    }
    Iterator itr = pay.getRows().iterator();
    while (itr.hasNext()) {
        PaymentDetail row = (PaymentDetail) itr.next();
        cell = new PdfPCell(new Paragraph(row.getGoodsReceipt().getGoodsReceiptNumber(), fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        cell = new PdfPCell(
                new Paragraph(formatter.format(row.getGoodsReceipt().getShipDate()), fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        cell = new PdfPCell(
                new Paragraph(formatter.format(row.getGoodsReceipt().getDueDate()), fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(authHandlerDAOObj.getFormattedCurrency(row.getAmount(), currencyid),
                fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        double amount = row.getAmount();
        total += amount;
    }

    for (int j = 0; j < 40; j++) {
        cell = new PdfPCell(new Paragraph("", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
    }
    for (int i = 0; i < 2; i++) {
        cell = new PdfPCell(new Paragraph("", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(Rectangle.TOP);
        table.addCell(cell);
    }
    cell = new PdfPCell(new Paragraph("  TOTAL", fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.addCell(cell);
    cell = new PdfPCell(
            new Paragraph(authHandlerDAOObj.getFormattedCurrency(total, currencyid), fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(cell);
    return table;
}

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

License:Open Source License

private PdfPTable createQuotationTable(String[] header, String[] values, String currencyid, Quotation quotation)
        throws DocumentException {
    double total = 0;
    PdfPTable table = new PdfPTable(header.length);
    table.setWidthPercentage(100);/*  ww  w.  ja va  2  s  .  co  m*/
    table.setWidths(new float[] { 30, 15, 15, 20, 20 });
    PdfPCell cell = null;
    for (int i = 0; i < header.length; i++) {
        cell = new PdfPCell(new Paragraph(header[i], fontTblMediumBold));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setPadding(3);
        table.addCell(cell);
    }
    Iterator itr = quotation.getRows().iterator();
    while (itr.hasNext()) {
        QuotationDetail row = (QuotationDetail) itr.next();
        cell = new PdfPCell(new Paragraph(row.getProduct().getName(), fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(
                Integer.toString(row.getQuantity()) + " " + row.getProduct().getUnitOfMeasure().getName(),
                fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph(authHandlerDAOObj.getFormattedCurrency(row.getRate(), currencyid),
                fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph("--", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
        double amount = row.getRate() * row.getQuantity();
        total += amount;
        cell = new PdfPCell(
                new Paragraph(authHandlerDAOObj.getFormattedCurrency(amount, currencyid), fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
    }

    for (int j = 0; j < 50; j++) {
        cell = new PdfPCell(new Paragraph("", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(Rectangle.LEFT + Rectangle.RIGHT);
        table.addCell(cell);
    }
    for (int i = 0; i < 3; i++) {
        cell = new PdfPCell(new Paragraph("", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(Rectangle.TOP);
        table.addCell(cell);
    }
    cell = new PdfPCell(new Paragraph("  SUB TOTAL", fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.addCell(cell);
    cell = new PdfPCell(
            new Paragraph(authHandlerDAOObj.getFormattedCurrency(total, currencyid), fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(cell);

    for (int i = 0; i < 3; i++) {
        cell = new PdfPCell(new Paragraph("", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        table.addCell(cell);
    }
    cell = new PdfPCell(new Paragraph("  DISCOUNT", fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.addCell(cell);
    cell = new PdfPCell(new Paragraph("--", fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(cell);
    for (int i = 0; i < 3; i++) {
        cell = new PdfPCell(new Paragraph("", fontSmallRegular));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        table.addCell(cell);
    }
    cell = new PdfPCell(new Paragraph("  TOTAL", fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.addCell(cell);
    cell = new PdfPCell(
            new Paragraph(authHandlerDAOObj.getFormattedCurrency(total, currencyid), fontTblMediumBold));
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(cell);
    return table;
}