List of usage examples for com.lowagie.text Element ALIGN_RIGHT
int ALIGN_RIGHT
To view the source code for com.lowagie.text Element ALIGN_RIGHT.
Click Source Link
From source file:com.krawler.esp.servlets.ExportProjectReportServlet.java
License:Open Source License
private int addTableTimeLine(int stcol, int stpcol, int strow, int stprow, JSONArray store, String[] colwidth2, int maxlevel, Document document) throws JSONException, DocumentException { float[] f = new float[(stpcol - stcol) + 1]; for (int k = 0; k < f.length; k++) { f[k] = 20;//from w ww . j av a2 s . c o m } f[0] = f[0] + 10 * maxlevel; PdfPTable table = new PdfPTable(f); java.awt.Color tColor = new Color(Integer.parseInt(config.getString("textColor"), 16)); Font font = FontFactory.getFont("Helvetica", 8, Font.BOLD, tColor); Font font1 = FontFactory.getFont("Helvetica", 8, Font.NORMAL, tColor); Font f1; table.setWidthPercentage(90); PdfPCell h2 = new PdfPCell(new Paragraph("Name", font)); // new if (config.getBoolean("gridBorder")) h2.setBorder(PdfPCell.BOX); else h2.setBorder(0); h2.setPadding(2); // h2.setHorizontalAlignment(Element.ALIGN_UNDEFINED); // Paragraph(colwidth2[hcol],font); table.addCell(h2); int stpcol1 = 0; for (int hcol = stcol; hcol < stpcol; hcol++) { PdfPCell h1 = new PdfPCell(new Paragraph(colwidth2[hcol], font)); // new h1.setHorizontalAlignment(Element.ALIGN_RIGHT); if (config.getBoolean("gridBorder")) h1.setBorder(PdfPCell.BOX); else h1.setBorder(0); h1.setPadding(2); // Paragraph(colwidth2[hcol],font); table.addCell(h1); } table.setHeaderRows(1); for (int row = strow; row < stprow; row++) { if (row % 62 == 61) { document.add(table); table.deleteBodyRows(); table.setSkipFirstHeader(true); } if (store.getJSONObject(row).getBoolean("flag")) f1 = font; else f1 = font1; if (store.getJSONObject(row).getString("info").compareTo("") != 0) { h2 = new PdfPCell(new Paragraph(store.getJSONObject(row).getString("info"), f1)); // h2.setPaddingLeft((Integer.parseInt(store.getJSONObject(row).getString("level")) * 10) + 5); } else { h2 = new PdfPCell(new Paragraph(store.getJSONObject(row).getString("info"), f1)); // h2.setPaddingTop(9); // h2.setPaddingLeft((Integer.parseInt(store.getJSONObject(row).getString("level")) * 10) + 5); } // h2.setBorder(0); // h2.setPadding(1); // Color bColor = Color.decode("DDDDDD"); if (config.getBoolean("gridBorder")) { if (store.getJSONObject(row).getBoolean("flag")) { h2.setBackgroundColor(new Color(0xEEEEEE)); h2.setBorder(PdfPCell.LEFT | PdfPCell.BOTTOM); } else h2.setBorder(PdfPCell.BOX); } else { h2.setBorder(0); } h2.setPadding(2); h2.setBorderColor(Color.GRAY); if (store.getJSONObject(row).getBoolean("flag")) h2.setHorizontalAlignment(Element.ALIGN_LEFT); else h2.setHorizontalAlignment(Element.ALIGN_RIGHT); h2.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(h2); for (int col = stcol; col < stpcol; col++) { Paragraph para = new Paragraph(store.getJSONObject(row).getString(colwidth2[col]), f1); PdfPCell h1 = new PdfPCell(para); // h1.setBorder(0); // h1.setPadding(1); h1.setMinimumHeight(15); h1.setHorizontalAlignment(Element.ALIGN_RIGHT); h1.setVerticalAlignment(Element.ALIGN_CENTER); if (config.getBoolean("gridBorder")) { if (store.getJSONObject(row).getBoolean("flag")) { h1.setBorder(PdfPCell.BOTTOM); h1.setBackgroundColor(new Color(0xEEEEEE)); if (col == stpcol - 1) h1.setBorder(PdfPCell.BOTTOM | PdfPCell.RIGHT); } else h1.setBorder(PdfPCell.BOX); } else { h1.setBorder(0); } h1.setPadding(2); h1.setBorderColor(Color.GRAY); table.addCell(h1); // table.addCell(new Paragraph(store.getJSONObject(row) // .getString(colwidth2[col]), f1)); } } document.add(table); document.newPage(); if (stpcol != colwidth2.length) { if ((colwidth2.length - stpcol) > 5) // column limit stpcol1 = stpcol + 5; else stpcol1 = (colwidth2.length - stpcol) + stpcol; addTableTimeLine(stpcol, stpcol1, strow, stprow, store, colwidth2, maxlevel, document); } return stpcol; }
From source file:com.krawler.esp.servlets.ExportReportServlet.java
License:Open Source License
public static HeaderFooter addFooter() { HeaderFooter hf = new HeaderFooter(new Phrase("Page ", fontSmallRegular), new Phrase(" of " + pages, fontSmallRegular)); hf.setBorderWidth(0);/*w ww. j a v a 2 s .com*/ hf.setBorderWidthTop(1); hf.setAlignment(Element.ALIGN_RIGHT); return hf; }
From source file:com.krawler.esp.servlets.ExportReportServlet.java
License:Open Source License
private int addTable(int stcol, int stpcol, int strow, int stprow, JSONArray store, String[] colwidth2, int maxlevel, Document document) { float[] f = new float[(stpcol - stcol) + 1]; for (int k = 0; k < f.length; k++) { f[k] = 20;/*w w w .j ava2 s. c o m*/ } f[0] = f[0] + 10 * maxlevel; PdfPTable table = new PdfPTable(f); Font font = FontFactory.getFont("Helvetica", 8, Font.BOLD, Color.BLACK); Font font1 = FontFactory.getFont("Helvetica", 8, Font.NORMAL, Color.BLACK); Font f1; PdfPCell h2 = new PdfPCell(new Paragraph("", font)); // new h2.setBorder(0); h2.setPadding(1); // h2.setHorizontalAlignment(Element.ALIGN_UNDEFINED); // Paragraph(colwidth2[hcol],font); table.addCell(h2); int stpcol1 = 0; for (int hcol = stcol; hcol < stpcol; hcol++) { PdfPCell h1 = new PdfPCell(new Paragraph(colwidth2[hcol], font)); // new h1.setHorizontalAlignment(Element.ALIGN_RIGHT); h1.setBorder(0); h1.setPadding(1); // Paragraph(colwidth2[hcol],font); table.addCell(h1); } table.setHeaderRows(1); try { for (int row = strow; row < stprow; row++) { if (row % 62 == 61) { document.add(table); table.deleteBodyRows(); table.setSkipFirstHeader(true); } if (store.getJSONObject(row).getBoolean("flag")) f1 = font; else f1 = font1; if (store.getJSONObject(row).getString("info").compareTo("") != 0) { h2 = new PdfPCell(new Paragraph(store.getJSONObject(row).getString("info"), f1)); h2.setPaddingLeft((Integer.parseInt(store.getJSONObject(row).getString("level")) * 10) + 5); } else { h2 = new PdfPCell(new Paragraph(store.getJSONObject(row).getString("info"), f1)); h2.setPaddingTop(9); h2.setPaddingLeft((Integer.parseInt(store.getJSONObject(row).getString("level")) * 10) + 5); } h2.setBorder(0); h2.setPadding(1); if (store.getJSONObject(row).getBoolean("flag")) h2.setHorizontalAlignment(Element.ALIGN_LEFT); else h2.setHorizontalAlignment(Element.ALIGN_RIGHT); h2.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(h2); for (int col = stcol; col < stpcol; col++) { Paragraph para = null; if (store.getJSONObject(row).has(colwidth2[col])) para = new Paragraph(store.getJSONObject(row).getString(colwidth2[col]), f1); else para = new Paragraph("", f1); // Paragraph para = new Paragraph(store.getJSONObject(row).getString(colwidth2[col]), f1); PdfPCell h1 = new PdfPCell(para); h1.setBorder(0); h1.setPadding(1); h1.setHorizontalAlignment(Element.ALIGN_RIGHT); h1.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(h1); // table.addCell(new Paragraph(store.getJSONObject(row) // .getString(colwidth2[col]), f1)); } } document.add(table); document.newPage(); if (stpcol != colwidth2.length) { if ((colwidth2.length - stpcol) > 5) // column limit stpcol1 = stpcol + 5; else stpcol1 = (colwidth2.length - stpcol) + stpcol; addTable(stpcol, stpcol1, strow, stprow, store, colwidth2, maxlevel, document); } } catch (com.krawler.utils.json.base.JSONException j) { KrawlerLog.op.warn("Problem During Creating JSON Object :" + j.toString()); } catch (com.lowagie.text.DocumentException de) { KrawlerLog.op.warn("Problem While Creating PDF :" + de.toString()); } return stpcol; }
From source file:com.krawler.esp.servlets.ExportServlet.java
License:Open Source License
private int addTable(int stcol, int stpcol, int strow, int stprow, JSONArray store, String[] colwidth2, String[] colHeader, String[] widths, String[] align, Document document, HttpServletRequest request, Session session) throws JSONException, DocumentException, SessionExpiredException { java.awt.Color tColor = new Color(Integer.parseInt(config.getString("textColor"), 16)); fontSmallBold.setColor(tColor);//from w ww.j a v a2s . c om 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); Font f1 = FontFactory.getFont("Helvetica", 8, Font.NORMAL, tColor); PdfPCell h2 = new PdfPCell(new Paragraph("No.", fontSmallBold)); 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++) { if (align[hcol].equals("right") && !colHeader[hcol].equals("")) { String currency = currencyRender("", session, request); h1 = new PdfPCell(new Paragraph(colHeader[hcol] + "(" + currency + ")", fontSmallBold)); } else h1 = new PdfPCell(new Paragraph(colHeader[hcol], fontSmallBold)); 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(String.valueOf(row + 1), f1)); 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++) { Paragraph para = null; if (align[col].equals("right") && !temp.getString(colwidth2[col]).equals("")) { String currency = currencyRender(temp.getString(colwidth2[col]), session, request); para = new Paragraph(currency, f1); } else { if (colwidth2[col].equals("invoiceno")) { para = new Paragraph(temp.getString("no").toString(), f1); } else if (colwidth2[col].equals("invoicedate")) { para = new Paragraph(temp.getString("date").toString(), f1); } else if ((temp.isNull(colwidth2[col])) && !(colwidth2[col].equals("invoiceno")) && !(colwidth2[col].equals("invoicedate"))) { para = new Paragraph("", fontMediumRegular); } else { para = new Paragraph(temp.getString(colwidth2[col]).toString(), f1); } } 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(); return stpcol; }
From source file:com.krawler.spring.exportFuctionality.ExportinvController.java
License:Open Source License
private PdfPTable createDebitTable(String header[], String values[], String currencyid, DebitNote deb) throws DocumentException, ServiceException, JSONException { PdfPTable table = new PdfPTable(header.length); table.setWidthPercentage(100);//from w ww .j a va2 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 = deb.getRows().iterator(); while (itr.hasNext()) { DebitNoteDetail debDet = (DebitNoteDetail) itr.next(); cell = new PdfPCell(new Paragraph(debDet.getGoodsReceiptRow().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(debDet.getQuantity()) + " " + debDet.getGoodsReceiptRow().getInventory().getProduct().getUnitOfMeasure().getName(), 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, CreditNote cre) throws DocumentException, ServiceException, JSONException { PdfPTable table = new PdfPTable(header.length); table.setWidthPercentage(100);/*from w w w . j av a2 s.co 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 = 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);/* w ww . j a va2 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 = 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);/*from w w w.j a v a 2 s . co 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 = 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 a 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 = 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 www . j a va 2 s. com*/ 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; }