List of usage examples for com.lowagie.text.pdf PdfPTable PdfPTable
public PdfPTable(PdfPTable table)
PdfPTable
. 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);/* w w w. j a 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 = 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 ww w . j ava 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 va 2s .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 = 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 va 2s. 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 = 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 . c o 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);//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 = 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; }
From source file:com.krawler.spring.exportFuctionality.ExportinvController.java
License:Open Source License
private PdfPTable createTable(String header[], String values[]) { PdfPTable table = new PdfPTable(header.length); PdfPCell cell = null;/*from www. jav a 2 s . co m*/ 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); } for (int j = 0; j < values.length; j++) { cell = new PdfPCell(new Paragraph(values[j], fontSmallRegular)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); } return table; }
From source file:com.krawler.spring.exportFuctionality.ExportinvController.java
License:Open Source License
public PdfPTable getCompanyInfo(String com[]) { PdfPTable tab1 = new PdfPTable(1); tab1.setHorizontalAlignment(Element.ALIGN_LEFT); for (int i = 0; i < 3; i++) { PdfPCell cell = new PdfPCell(new Paragraph(com[i], fontMediumBold)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorder(0);/*from www.j a v a 2s. com*/ tab1.addCell(cell); } return tab1; }
From source file:com.krawler.spring.exportFuctionality.ExportRecord.java
License:Open Source License
public ByteArrayOutputStream exportRatioAnalysis(HttpServletRequest request, JSONObject jobj, String logoPath, String comName) throws DocumentException, ServiceException, IOException { ByteArrayOutputStream baos = null; double total = 0; Document document = null;/*from w w w. j a va2 s .c om*/ PdfWriter writer = null; try { //flag 1 = BalanceSheet , 2 = P&L baos = new ByteArrayOutputStream(); document = new Document(PageSize.A4, 15, 15, 15, 15); writer = PdfWriter.getInstance(document, baos); document.open(); PdfPTable mainTable = new PdfPTable(1); mainTable.setWidthPercentage(100); PdfPTable tab1 = null; Rectangle page = document.getPageSize(); int bmargin = 15; //border margin PdfContentByte cb = writer.getDirectContent(); cb.rectangle(bmargin, bmargin, page.getWidth() - bmargin * 2, page.getHeight() - bmargin * 2); cb.setColorStroke(Color.WHITE); cb.stroke(); // addHeaderFooter(document, writer); PdfPTable table1 = new PdfPTable(4); table1.setWidthPercentage(100); table1.setWidths(new float[] { 25, 25, 25, 25 }); PdfPCell blankCell = new PdfPCell(); blankCell.setBorder(0); tab1 = addCompanyLogo(logoPath, comName); PdfPCell cell1 = new PdfPCell(tab1); cell1.setBorder(0); table1.addCell(cell1); table1.addCell(blankCell); table1.addCell(blankCell); table1.addCell(blankCell); PdfPCell cell2 = new PdfPCell(new Paragraph(comName, fontSmallRegular)); cell2.setBorder(0); table1.addCell(cell2); table1.addCell(blankCell); table1.addCell(blankCell); table1.addCell(blankCell); PdfPCell headerCell = createCell( messageSource.getMessage("acc.ra.tabTT", null, RequestContextUtils.getLocale(request)), FontContext.TABLE_HEADER, Element.ALIGN_LEFT, 0, 5); headerCell.setBorder(0); table1.addCell(headerCell); table1.addCell(blankCell); table1.addCell(blankCell); table1.addCell(blankCell); table1.addCell(blankCell); table1.addCell(blankCell); table1.addCell(blankCell); table1.addCell(blankCell); JSONArray ObjArr = jobj.getJSONArray("data"); PdfPCell HeaderCell1 = createCell( messageSource.getMessage("acc.ra.principalGroups", null, RequestContextUtils.getLocale(request)), FontContext.SMALL_TEXT, Element.ALIGN_LEFT, 0, 5); HeaderCell1.setBorderWidthLeft(1); HeaderCell1.setBorderWidthBottom(1); HeaderCell1.setBorderWidthTop(1); PdfPCell HeaderCell2 = createCell( messageSource.getMessage("acc.ra.value", null, RequestContextUtils.getLocale(request)), FontContext.SMALL_TEXT, Element.ALIGN_RIGHT, 0, 5); HeaderCell2.setBorderWidthBottom(1); HeaderCell2.setBorderWidthTop(1); PdfPCell HeaderCell3 = createCell( messageSource.getMessage("acc.ra.principalRatios", null, RequestContextUtils.getLocale(request)), FontContext.SMALL_TEXT, Element.ALIGN_LEFT, 0, 5); HeaderCell3.setBorderWidthBottom(1); HeaderCell3.setBorderWidthTop(1); HeaderCell3.setBorderWidthLeft(1); PdfPCell HeaderCell4 = createCell( messageSource.getMessage("acc.ra.value", null, RequestContextUtils.getLocale(request)), FontContext.SMALL_TEXT, Element.ALIGN_RIGHT, 0, 5); HeaderCell4.setBorderWidthBottom(1); HeaderCell4.setBorderWidthRight(1); HeaderCell4.setBorderWidthTop(1); table1.addCell(HeaderCell1); table1.addCell(HeaderCell2); table1.addCell(HeaderCell3); table1.addCell(HeaderCell4); PdfPCell objCell1 = null; PdfPCell objCell2 = null; PdfPCell objCell3 = null; PdfPCell objCell4 = null; int objArrLength = ObjArr.length(); for (int i = 0; i < objArrLength; i++) { JSONObject leftObj = ObjArr.getJSONObject(i); objCell1 = createBalanceSheetCell(leftObj.getString("lname"), FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 5, 0); objCell2 = createBalanceSheetCell(leftObj.getString("lvalue"), FontContext.TABLE_DATA, Element.ALIGN_RIGHT, 0, 0, 0); objCell3 = createBalanceSheetCell(leftObj.getString("rname"), FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 5, 0); objCell4 = createBalanceSheetCell(leftObj.getString("rvalue"), FontContext.TABLE_DATA, Element.ALIGN_RIGHT, 0, 0, 0); objCell1.setBorderWidthLeft(1); objCell3.setBorderWidthLeft(1); objCell4.setBorderWidthRight(1); if (i != (objArrLength - 1)) { table1.addCell(objCell1); table1.addCell(objCell2); table1.addCell(objCell3); table1.addCell(objCell4); } } objCell1.setBorderWidthBottom(1); objCell2.setBorderWidthBottom(1); objCell3.setBorderWidthBottom(1); objCell4.setBorderWidthBottom(1); table1.addCell(objCell1); table1.addCell(objCell2); table1.addCell(objCell3); table1.addCell(objCell4); PdfPCell mainCell11 = new PdfPCell(table1); mainCell11.setBorder(0); mainCell11.setPadding(10); mainTable.addCell(mainCell11); document.add(mainTable); } catch (Exception ex) { return null; } finally { if (document != null) { document.close(); } if (writer != null) { writer.close(); } if (baos != null) { baos.close(); } } return baos; }
From source file:com.krawler.spring.exportFuctionality.ExportRecord.java
License:Open Source License
public ByteArrayOutputStream exportBalanceSheetPdf(HttpServletRequest request, String currencyid, DateFormat formatter, String logoPath, String comName, JSONObject jobj, Date startDate, Date endDate, int flag, int toggle) throws DocumentException, ServiceException, IOException { ByteArrayOutputStream baos = null; double total = 0; Document document = null;/*from w ww . j a v a 2s . co m*/ PdfWriter writer = null; try { //flag 1 = BalanceSheet , 2 = P&L String headingString = ""; String DateheadingString = ""; String value = ""; String subHeading1 = ""; String subHeading2 = ""; if (flag == 1) { headingString = messageSource.getMessage("acc.rem.123", null, RequestContextUtils.getLocale(request)); //"Balance Sheet For : "; DateheadingString = messageSource.getMessage("acc.rem.124", null, RequestContextUtils.getLocale(request)); //"Balance Sheet Till :"; value = formatter.format(endDate); subHeading1 = messageSource.getMessage("acc.balanceSheet.Amount(asset)", null, RequestContextUtils.getLocale(request)); //"Asset"; subHeading2 = messageSource.getMessage("acc.balanceSheet.Amount(liability)", null, RequestContextUtils.getLocale(request)); //"Liability"; if (toggle == 1) { subHeading1 = messageSource.getMessage("acc.balanceSheet.Amount(liability)", null, RequestContextUtils.getLocale(request)); //"Liability"; subHeading2 = messageSource.getMessage("acc.balanceSheet.Amount(asset)", null, RequestContextUtils.getLocale(request)); //"Asset"; } } else { headingString = messageSource.getMessage("acc.rem.125", null, RequestContextUtils.getLocale(request)); // "P&L Statement For : "; DateheadingString = messageSource.getMessage("acc.rem.126", null, RequestContextUtils.getLocale(request)); // "P&L Statement From-To :"; value = formatter.format(startDate) + " " + messageSource.getMessage("acc.common.to", null, RequestContextUtils.getLocale(request)) + " " + formatter.format(endDate); subHeading1 = messageSource.getMessage("acc.P&L.Amount(Debit)", null, RequestContextUtils.getLocale(request)); //"Debit"; subHeading2 = messageSource.getMessage("acc.P&L.Amount(Credit)", null, RequestContextUtils.getLocale(request)); //"Credit"; } baos = new ByteArrayOutputStream(); document = new Document(PageSize.A4, 15, 15, 15, 15); writer = PdfWriter.getInstance(document, baos); document.open(); PdfPTable mainTable = new PdfPTable(1); mainTable.setWidthPercentage(100); PdfPTable tab1 = null; Rectangle page = document.getPageSize(); int bmargin = 15; //border margin PdfContentByte cb = writer.getDirectContent(); cb.rectangle(bmargin, bmargin, page.getWidth() - bmargin * 2, page.getHeight() - bmargin * 2); cb.setColorStroke(Color.WHITE); cb.stroke(); // addHeaderFooter(document, writer); PdfPTable table1 = new PdfPTable(3); table1.setWidthPercentage(100); table1.setWidths(new float[] { 30, 30, 40 }); PdfPCell blankCell = new PdfPCell(); blankCell.setBorder(0); tab1 = addCompanyLogo(logoPath, comName); PdfPCell cell1 = new PdfPCell(tab1); cell1.setBorder(0); table1.addCell(cell1); table1.addCell(blankCell); table1.addCell(blankCell); PdfPCell headerCell = createCell(headingString, FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 5); headerCell.setBorder(0); table1.addCell(headerCell); PdfPCell headerNameCell = createCell(comName, FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 5); headerNameCell.setBorder(0); table1.addCell(headerNameCell); table1.addCell(blankCell); headerCell = createCell(DateheadingString, FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 5); headerCell.setBorder(0); table1.addCell(headerCell); headerNameCell = createCell(value, FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 5); headerNameCell.setBorder(0); table1.addCell(headerNameCell); table1.addCell(blankCell); table1.addCell(blankCell); table1.addCell(blankCell); table1.addCell(blankCell); jobj = jobj.getJSONObject("data"); JSONArray rightObjArr = flag == 1 ? jobj.getJSONArray("right") : jobj.getJSONArray("left"); JSONArray leftObjArr = flag == 1 ? jobj.getJSONArray("left") : jobj.getJSONArray("right"); if (toggle == 1) { rightObjArr = jobj.getJSONArray("left"); leftObjArr = jobj.getJSONArray("right"); } JSONArray finalValArr = jobj.getJSONArray("total"); PdfPCell HeaderCell1 = createCell( messageSource.getMessage("acc.P&L.particulars", null, RequestContextUtils.getLocale(request)), FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 5); HeaderCell1.setBorderWidthBottom(1); PdfPCell HeaderCell2 = createCell(subHeading1, FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 5); HeaderCell2.setBorderWidthBottom(1); table1.addCell(HeaderCell1); table1.addCell(HeaderCell2); table1.addCell(blankCell); double totalAsset = Double.parseDouble(finalValArr.getString(0)); double totalLibility = Double.parseDouble(finalValArr.getString(1)); for (int i = 0; i < rightObjArr.length(); i++) { JSONObject leftObj = rightObjArr.getJSONObject(i); addBalanceSheetCell(leftObj, table1, currencyid); // PdfPCell cell3 = createCell(leftObj.get("accountname").toString(), fontSmallBold, Element.ALIGN_LEFT, 0, 5); // PdfPCell cell4 = createCell(com.krawler.common.util.StringUtil.serverHTMLStripper(leftObj.get("amount").toString()), fontSmallBold, Element.ALIGN_LEFT, 0, 5); // cell3.setBorder(0); // table1.addCell(cell3); // cell4.setBorder(0); // table1.addCell(cell4); } PdfPCell totalAsscell = createBalanceSheetCell( messageSource.getMessage("acc.common.total", null, RequestContextUtils.getLocale(request)) + " " + subHeading1, FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 0, 0); table1.addCell(totalAsscell); PdfPCell totalAssValcell = createBalanceSheetCell( exportDaoObj.currencyRender(Double.toString(totalAsset), currencyid), fontSmallBold, Element.ALIGN_RIGHT, 0, 0, 0); table1.addCell(totalAssValcell); for (int i = 0; i < 16; i++) table1.addCell(blankCell); HeaderCell1 = createCell( messageSource.getMessage("acc.balanceSheet.particulars", null, RequestContextUtils.getLocale(request)), FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 5); HeaderCell1.setBorderWidthBottom(1); HeaderCell2 = createCell(subHeading2, FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 5); HeaderCell2.setBorderWidthBottom(1); table1.addCell(HeaderCell1); table1.addCell(HeaderCell2); table1.addCell(blankCell); for (int i = 0; i < leftObjArr.length(); i++) { JSONObject leftObj = leftObjArr.getJSONObject(i); addBalanceSheetCell(leftObj, table1, currencyid); // PdfPCell cell3 = createCell(leftObj.get("accountname").toString(), fontSmallBold, Element.ALIGN_LEFT, 0, 5); // PdfPCell cell4 = createCell(com.krawler.common.util.StringUtil.serverHTMLStripper(leftObj.get("amount").toString()), fontSmallBold, Element.ALIGN_LEFT, 0, 5); // cell3.setBorder(0); // table1.addCell(cell3); // cell4.setBorder(0); // table1.addCell(cell4); } PdfPCell totalLibcell = createBalanceSheetCell( messageSource.getMessage("acc.common.total", null, RequestContextUtils.getLocale(request)) + " " + subHeading2, FontContext.TABLE_DATA, Element.ALIGN_LEFT, 0, 0, 0); table1.addCell(totalLibcell); PdfPCell totalLibValcell = createBalanceSheetCell( exportDaoObj.currencyRender(Double.toString(totalLibility), currencyid), FontContext.TABLE_DATA, Element.ALIGN_RIGHT, 0, 0, 0); table1.addCell(totalLibValcell); table1.addCell(blankCell); PdfPCell mainCell11 = new PdfPCell(table1); mainCell11.setBorder(0); mainCell11.setPadding(10); mainTable.addCell(mainCell11); // document.add(mainTable); document.add(mainTable); } catch (Exception ex) { return null; } finally { if (document != null) { document.close(); } if (writer != null) { writer.close(); } if (baos != null) { baos.close(); } } return baos; }