List of usage examples for com.lowagie.text Rectangle RIGHT
int RIGHT
To view the source code for com.lowagie.text Rectangle RIGHT.
Click Source Link
Rectangle
. From source file:com.afrisoftech.hospinventory.mtrhreports.PurchaseReqInternalMtrhPdf.java
public void generatePdf(java.lang.String memNo) { java.lang.Process wait_for_Pdf2Show; java.util.Calendar cal = java.util.Calendar.getInstance(); java.util.Date dateStampPdf = cal.getTime(); java.lang.String pdfDateStamp = dateStampPdf.toString(); try {/*w w w .j av a2s . c om*/ java.io.File tempFile = java.io.File.createTempFile("REP" + this.getDateLable() + "_", ".pdf"); tempFile.deleteOnExit(); java.lang.Runtime rt = java.lang.Runtime.getRuntime(); java.lang.String debitTotal = null; java.lang.String creditTotal = null; // com.lowagie.text.Document docPdf = new com.lowagie.text.Document(com.lowagie.text.PageSize.A4,40,40,40,40); // com.lowagie.text.Document docPdf = new com.lowagie.text.Document(com.lowagie.text.PageSize.A4); com.lowagie.text.Document docPdf = new com.lowagie.text.Document(); try { try { com.lowagie.text.pdf.PdfWriter.getInstance(docPdf, new java.io.FileOutputStream(tempFile)); // pdfWriter = com.lowagie.text.pdf.PdfWriter.getInstance(docPdf, new java.io.FileOutputStream(tempFile)); // System.out.println("Current Doc size 1 "+ pdfWriter.getCurrentDocumentSize()); String compName = null; String date = null; try { java.sql.Statement st6 = connectDB.createStatement(); java.sql.Statement st4 = connectDB.createStatement(); // com.lowagie.text.HeaderFooter footer = new com.lowagie.text.HeaderFooter(new Phrase("Internal Requisition - Page:",pFontHeader ), true);// FontFactory.getFont(com.lowagie.text.FontFactory.HELVETICA, 12, Font.BOLDITALIC,java.awt.Color.blue)); // docPdf.setFooter(footer); } catch (java.sql.SQLException SqlExec) { javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), SqlExec.getMessage()); } docPdf.open(); String Username = null; int numColumns = 9; try { java.util.Calendar calendar = java.util.Calendar.getInstance(); long dateNow = calendar.getTimeInMillis(); java.sql.Date datenowSql = new java.sql.Date(dateNow); System.out.println(datenowSql.toString()); // java.lang.Object listofStaffNos[] = this.getListofStaffNos(); com.lowagie.text.pdf.PdfPTable table1 = new com.lowagie.text.pdf.PdfPTable(6); // com.lowagie.text.Table table = new com.lowagie.text.Table(7); // table.endHeaders(); int headerwidths[] = { 15, 15, 30, 15, 15, 15 }; table1.setWidths(headerwidths); // if (docPdf.getPageNumber() > 1) { // table1.setHeaderRows(4); // } table1.setWidthPercentage((100)); table1.getDefaultCell().setBorder(Rectangle.BOTTOM); table1.getDefaultCell().setColspan(7); Phrase phrase = new Phrase(); // table.addCell(phrase); table1.getDefaultCell().setColspan(1); // table1.getDefaultCell().setBackgroundColor(java.awt.Color.WHITE); // table1.getDefaultCell().setBorderColor(java.awt.Color.WHITE); try { Image img = Image.getInstance(com.afrisoftech.lib.CompanyLogo.getPath2Logo()); //Image imgWaterMark = Image.getInstance(System.getProperty("company.watermark")); table1.getDefaultCell().setColspan(10); table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER); table1.getDefaultCell().setFixedHeight(50); table1.addCell(Image.getInstance(com.afrisoftech.lib.CompanyLogo.getPath2Logo())); table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER); table1.getDefaultCell().setFixedHeight(25); java.sql.Statement st3 = connectDB.createStatement(); java.sql.ResultSet rset3 = st3 .executeQuery("SELECT DISTINCT hospital_name FROM pb_hospitalprofile"); while (rset3.next()) { table1.getDefaultCell().setColspan(6); table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER); phrase = new Phrase(rset3.getObject(1).toString(), pFontHeader11); table1.addCell(phrase); } } catch (java.sql.SQLException SqlExec) { javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), SqlExec.getMessage()); } docPdf.add(table1); } catch (com.lowagie.text.BadElementException BadElExec) { javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), BadElExec.getMessage()); } try { com.lowagie.text.pdf.PdfPTable table1 = new com.lowagie.text.pdf.PdfPTable(10); table1.getDefaultCell().setPadding(3); int headerwidths1[] = { 24, 10, 8, 8, 6, 8, 6, 10, 12, 8 }; // table1.setWidths(headerwidths1); table1.setWidthPercentage((100)); table1.getDefaultCell().setBackgroundColor(java.awt.Color.WHITE); table1.getDefaultCell().setBorderColor(java.awt.Color.WHITE); Phrase phrase = new Phrase("", pFontHeader); try { // java.sql.Statement st3 = conDB.createStatement(); // java.sql.Connection conDb = java.sql.DriverManager.getConnection("jdbc:postgresql://localhost:5432/purchase","postgres","pilsiner"); // java.sql.Statement st3 = conDb.createStatement(); java.sql.Statement st3 = connectDB.createStatement(); //java.sql.Statement st1 = connectDB.createStatement(); java.sql.Statement st2 = connectDB.createStatement(); java.sql.Statement st11 = connectDB.createStatement(); java.sql.Statement st4 = connectDB.createStatement(); java.sql.Statement st5 = connectDB.createStatement(); java.sql.Statement st6 = connectDB.createStatement(); java.sql.ResultSet rset3 = st3.executeQuery( "select hospital_name,box_no,main_telno||' '||other_telno,initcap(street),initcap(town),main_faxno,email,initcap(building_name),room_no from pb_hospitalprofile"); //java.sql.ResultSet rset2 = st2.executeQuery("select supplier_name,short_name,postal_address,tel1,initcap(street),initcap(avenue),fax_no,email_address,initcap(building_name) from st_suppliers WHERE supplier_name ilike '"+selectSupp+"'"); java.sql.ResultSet rset4 = st4.executeQuery( "select DISTINCT REQUISITION_no,date_due,cost_center, case when supplier is null then '-' else supplier end as supplier," + " received_requisation,reason,date,store_name FROM st_receive_requisation where REQUISITION_no = '" + OrderNo + "'");// where supplier_name = 'Uchumi'member_no = '"+memNo+"' AND date BETWEEN '"+beginDate+"' AND '"+endDate+"'"); java.sql.ResultSet rset5 = st5.executeQuery( "select DISTINCT date_due from st_receive_requisation where requisition_no = '" + OrderNo + "'");// where supplier_name = 'Uchumi'member_no = '"+memNo+"' AND date BETWEEN '"+beginDate+"' AND '"+endDate+"'"); java.sql.ResultSet rset11 = st11.executeQuery( "select initcap(user_name) from st_receive_requisation where requisition_no = '" + OrderNo + "'");// where supplier_name = 'Uchumi'member_no = '"+memNo+"' AND date BETWEEN '"+beginDate+"' AND '"+endDate+"'"); while (rset11.next()) { Username = rset11.getObject(1).toString(); } table1.getDefaultCell().setBorderColor(java.awt.Color.white); while (rset4.next()) { table1.getDefaultCell().setColspan(10); table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER); phrase = new Phrase(" ", pFontHeader); //table1.addCell(phrase); table1.getDefaultCell().setColspan(10); table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER); phrase = new Phrase("INTERNAL PURCHASE REQUISITION", pFontHeader5); table1.addCell(phrase); table1.getDefaultCell().setColspan(10); table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER); phrase = new Phrase("FROM TEAM LEADER LOGISTICS", pFontHeader5); table1.addCell(phrase); table1.getDefaultCell().setColspan(10); table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER); phrase = new Phrase("TO SUPPLY CHAIN MANAGER", pFontHeader5); table1.addCell(phrase); // table1.getDefaultCell().setColspan(10); // table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER); // phrase = new Phrase("NUMBER KNH/SCM-MTCE STORES/......", pFontHeader5); // table1.addCell(phrase); table1.getDefaultCell().setColspan(10); table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase(" ", pFontHeader); table1.getDefaultCell().setColspan(10); table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase(" ", pFontHeader); table1.getDefaultCell().setColspan(10); table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER); phrase = new Phrase("PLEASE ORDER THE FOLLOWING MATERIALS/ITEMS", pFontHeader5); table1.addCell(phrase); table1.getDefaultCell().setColspan(10); table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase(" ", pFontHeader); table1.getDefaultCell().setColspan(10); table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase(" ", pFontHeader); //table1.addCell(phrase); table1.getDefaultCell().setColspan(6); phrase = new Phrase("FROM : " + rset4.getObject(8).toString(), pFontHeader); table1.addCell(phrase); table1.getDefaultCell().setColspan(4); phrase = new Phrase("DATE: " + rset4.getObject(7).toString() + "PR NO: " + rset4.getObject(1).toString(), pFontHeader); table1.addCell(phrase); table1.getDefaultCell().setColspan(10); table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase("TO : " + rset4.getObject(3).toString(), pFontHeader); table1.addCell(phrase); // table1.getDefaultCell().setColspan(10); // phrase = new Phrase(" " + rset4.getObject(2).toString(), pFontHeader); // table1.addCell(phrase); /* * table1.getDefaultCell().setColspan(5); * table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); * phrase = new Phrase(" ", pFontHeader); * table1.addCell(phrase); phrase = new * Phrase("PROCUREMENT METHOD : ", pFontHeader); * table1.addCell(phrase); * * table1.getDefaultCell().setColspan(5); phrase * = new Phrase(" ", pFontHeader); * table1.addCell(phrase); * table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); * phrase = new Phrase("REQUISITION NO: " + * rset4.getObject(1).toString(), pFontHeader); * table1.addCell(phrase); * * table1.getDefaultCell().setColspan(5); phrase * = new Phrase(" ", pFontHeader); * table1.addCell(phrase); * table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); * phrase = new Phrase("ACCOUNT NO: ", * pFontHeader); table1.addCell(phrase); * * table1.getDefaultCell().setColspan(5); phrase * = new Phrase(" ", pFontHeader); * table1.addCell(phrase); * table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); * phrase = new Phrase("REASON FOR PURCHASE " + * rset4.getObject(6).toString(), pFontHeader); * table1.addCell(phrase); * * table1.getDefaultCell().setColspan(5); * * table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); * phrase = new Phrase("", pFontHeader); * table1.addCell(phrase); * * table1.getDefaultCell().setColspan(5); phrase * = new Phrase("NAME OF THE SUPPLIER " + * rset4.getObject(4).toString(), pFontHeader); * table1.addCell(phrase); * table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); * phrase = new Phrase("CONTRACT NO: ", * pFontHeader); table1.addCell(phrase); * */ } docPdf.add(table1); } catch (java.sql.SQLException SqlExec) { javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), SqlExec.getMessage()); } } catch (com.lowagie.text.BadElementException BadElExec) { javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), BadElExec.getMessage()); } double Total = 0.00; double discount = 0.00; double vat = 0.00; double qty = 0.00; double price = 0.00; double value = 0.00; try { com.lowagie.text.pdf.PdfPTable table = new com.lowagie.text.pdf.PdfPTable(9); table.getDefaultCell().setPadding(3); int headerwidths[] = { 8, 30, 14, 14, 14, 14, 14, 16, 15 }; table.setWidths(headerwidths); table.setWidthPercentage((100)); com.lowagie.text.pdf.PdfPTable table3 = new com.lowagie.text.pdf.PdfPTable(9); // table3.getDefaultCell().setPadding(3); int headerwidths3[] = { 8, 30, 14, 14, 14, 14, 14, 16, 15 }; table3.setWidths(headerwidths3); table3.setWidthPercentage((100)); //table.getDefaultCell().setBorderColor(java.awt.Color.black); //table.getDefaultCell().setBorder(Rectangle.BOTTOM); table.getDefaultCell().setBorderColor(java.awt.Color.WHITE); table.getDefaultCell().setColspan(9); Phrase phrase = new Phrase(" ", pFontHeader); table.addCell(phrase); table3.getDefaultCell() .setBorder(Rectangle.BOTTOM | Rectangle.LEFT | Rectangle.RIGHT | Rectangle.TOP); table3.getDefaultCell().setColspan(1); phrase = new Phrase("NOs ", pFontHeader); table3.addCell(phrase); table3.getDefaultCell().setColspan(1); phrase = new Phrase("Item No/Code ", pFontHeader); table3.addCell(phrase); table3.getDefaultCell().setColspan(2); phrase = new Phrase("Item Description", pFontHeader); table3.addCell(phrase); table3.getDefaultCell().setColspan(1); phrase = new Phrase("Units of Issue. ", pFontHeader); table3.addCell(phrase); table3.getDefaultCell().setColspan(1); phrase = new Phrase("Qty Required. ", pFontHeader); table3.addCell(phrase); table3.getDefaultCell().setColspan(1); phrase = new Phrase("Monthly Usage ", pFontHeader); table3.addCell(phrase); table3.getDefaultCell().setColspan(2); phrase = new Phrase("Remarks", pFontHeader); table3.addCell(phrase); // phrase = new Phrase("Est.Cost ", pFontHeader); // table3.addCell(phrase); // // phrase = new Phrase("Actual Cost", pFontHeader); // table3.addCell(phrase); // // phrase = new Phrase("Tender/Qtn Ref.", pFontHeader); // table3.addCell(phrase); phrase = new Phrase("", pFontHeader); //table.addCell(phrase); table3.setHeaderRows(1); // table3.getDefaultCell().setColspan(1); // // table3.getDefaultCell().setBackgroundColor(java.awt.Color.WHITE); // table.getDefaultCell().setBorderColor(java.awt.Color.BLACK); String coment = ""; try { // java.sql.Statement st6 = connectDB.createStatement(); java.sql.Statement st1 = connectDB.createStatement(); java.sql.ResultSet rset1 = st1 .executeQuery("SELECT initcap(item_description),units,cos_glcode," + " quantity,price,round(quantity*price,2),mainstore_bal,terms,item_code,monthly_usage from st_receive_requisation" + " WHERE requisition_no = '" + OrderNo + "'");// where supplier_name = 'Uchumi'member_no = '"+memNo+"' AND date BETWEEN '"+beginDate+"' AND '"+endDate+"'"); table.getDefaultCell().setBorderColor(java.awt.Color.lightGray); while (rset1.next()) { // value = qty * price; cnt = cnt + 1; table3.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); table3.getDefaultCell().setColspan(1); phrase = new Phrase("" + cnt, pFontHeader2); table3.getDefaultCell().setBorderColor(java.awt.Color.black); table3.addCell(phrase); table3.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); table3.getDefaultCell().setColspan(1); phrase = new Phrase(rset1.getObject(9).toString(), pFontHeader2); table3.getDefaultCell().setBorderColor(java.awt.Color.black); table3.addCell(phrase); table3.getDefaultCell().setColspan(2); table3.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase(rset1.getObject(1).toString(), pFontHeader2); table3.addCell(phrase); table3.getDefaultCell().setColspan(1); phrase = new Phrase(rset1.getObject(2).toString(), pFontHeader2); table3.addCell(phrase); table3.getDefaultCell().setColspan(1); phrase = new Phrase(rset1.getObject(4).toString(), pFontHeader2); table3.addCell(phrase); table3.getDefaultCell().setColspan(1); // JOptionPane.showMessageDialog(null, "this "+rset1.getObject(10).toString()); phrase = new Phrase(rset1.getObject(10).toString(), pFontHeader); table3.addCell(phrase); table3.getDefaultCell().setColspan(2); phrase = new Phrase(rset1.getObject(8).toString(), pFontHeader2); table3.addCell(phrase); // table3.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT); // phrase = new Phrase(new com.afrisoftech.sys.Format2Currency().Format2Currency(rset1.getObject(4).toString()), pFontHeader2); // // table3.addCell(phrase); // // table3.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT); // phrase = new Phrase(new com.afrisoftech.sys.Format2Currency().Format2Currency(rset1.getObject(5).toString()), pFontHeader2); // table3.addCell(phrase); // // // System.out.println("Second "+docPdf.top()); // table3.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT); // phrase = new Phrase(new com.afrisoftech.sys.Format2Currency().Format2Currency(rset1.getString(6)), pFontHeader2); // // table3.addCell(phrase); // // phrase = new Phrase(new com.afrisoftech.sys.Format2Currency().Format2Currency(rset1.getString(7)), pFontHeader2); // // table3.addCell(phrase); // // // table3.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT); // value = value + rset1.getDouble(6); // table3.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // // phrase = new Phrase(rset1.getObject(8).toString(), pFontHeader2); // // // table.addCell(phrase); // // coment = rset1.getObject(12).toString(); } table.getDefaultCell().setBorderColor(java.awt.Color.BLACK); table.getDefaultCell() .setBorder(Rectangle.BOTTOM | Rectangle.TOP | Rectangle.RIGHT | Rectangle.LEFT); table.getDefaultCell().setFixedHeight(350); table.addCell(table3); table.getDefaultCell().setFixedHeight(20); // table.getDefaultCell().setColspan(3); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER); // phrase = new Phrase("TOTAL COST", pFontHeader); // // table.addCell(phrase); // table.getDefaultCell().setColspan(1); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT); // phrase = new Phrase("", pFontHeader); // // table.addCell(phrase); // table.getDefaultCell().setColspan(1); // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT); // phrase = new Phrase("", pFontHeader); // // table.addCell(phrase); // table.getDefaultCell().setColspan(1); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT); // phrase = new Phrase("", pFontHeader); // // table.addCell(phrase); // table.getDefaultCell().setColspan(1); // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT); // phrase = new Phrase("", pFontHeader); // // table.addCell(phrase); // table.getDefaultCell().setColspan(5); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT); // // phrase = new Phrase(new com.afrisoftech.sys.Format2Currency().Format2Currency(java.lang.String.valueOf(value)), pFontHeader); // // table.addCell(phrase); // table.getDefaultCell().setColspan(1); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT); // phrase = new Phrase("", pFontHeader); // table3.addCell(phrase); table.getDefaultCell().setColspan(9); table.getDefaultCell() .setBorder(Rectangle.TOP | Rectangle.BOTTOM | Rectangle.RIGHT | Rectangle.LEFT); phrase = new Phrase(" ", pFontHeader); table.addCell(phrase); table.getDefaultCell().setBorder(Rectangle.TOP); table.addCell(phrase); //table.getDefaultCell().setBorder(Rectangle.TOP); /* * * * table.getDefaultCell().setColspan(6); * * table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); * phrase = new Phrase("Prepared By :" * +Username.toUpperCase(), pFontHeader); * * table.addCell(phrase); */ table.getDefaultCell().setColspan(3); table.getDefaultCell().setBorderColor(java.awt.Color.WHITE); table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase("PREPARED BY.................................", pFontHeader); table.addCell(phrase); table.getDefaultCell().setColspan(2); table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase("Sign.................................", pFontHeader); table.addCell(phrase); phrase = new Phrase("Date.................................", pFontHeader); table.addCell(phrase); phrase = new Phrase("Time.................................\n", pFontHeader); table.addCell(phrase); table.getDefaultCell().setColspan(3); table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase("AIE HOLDER/USER.................................", pFontHeader); table.addCell(phrase); table.getDefaultCell().setColspan(2); table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase("Sign.................................", pFontHeader); table.addCell(phrase); phrase = new Phrase("Date.................................", pFontHeader); table.addCell(phrase); phrase = new Phrase("Time.................................\n", pFontHeader); table.addCell(phrase); table.getDefaultCell().setColspan(3); table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase("APPROVED BY(TL LOGISTICS).................................", pFontHeader); table.addCell(phrase); table.getDefaultCell().setColspan(2); table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase("Sign.................................", pFontHeader); table.addCell(phrase); phrase = new Phrase("Date.................................", pFontHeader); table.addCell(phrase); phrase = new Phrase("Time.................................\n", pFontHeader); table.addCell(phrase); // table.getDefaultCell().setColspan(4); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("Amount Voted..................................................", pFontHeader); // table.addCell(phrase); // // table.getDefaultCell().setColspan(5); // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("Vote Balance.........................................................", pFontHeader); // table.addCell(phrase); // // // table.getDefaultCell().setColspan(3); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("Vote Holder's Authority.................................", pFontHeader); // // table.addCell(phrase); // // table.getDefaultCell().setColspan(2); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("Sign.................................", pFontHeader); // // table.addCell(phrase); // // phrase = new Phrase("Date.................................", pFontHeader); // // table.addCell(phrase); // // phrase = new Phrase("Time.................................", pFontHeader); // // table.addCell(phrase); table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("SIGN..........................................................", pFontHeader); //table.addCell(phrase); table.getDefaultCell().setColspan(9); //table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER); phrase = new Phrase("", pFontHeader); table.addCell(phrase); //phrase = new Phrase("FOR PROCUREMENT USE ONLY", pFontHeader); //table.addCell(phrase); //table.getDefaultCell().setBorder(Rectangle.TOP | Rectangle.LEFT | Rectangle.RIGHT | Rectangle.BOTTOM); //table.getDefaultCell().setBorderColor(java.awt.Color.BLACK); // table.getDefaultCell().setColspan(3); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("Approved/Not Approved.....................", pFontHeader); // // table.addCell(phrase); // // //table.getDefaultCell().setColspan(5); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("Date............................", pFontHeader); // // table.addCell(phrase); // // phrase = new Phrase("Time............................", pFontHeader); // // table.addCell(phrase); // // phrase = new Phrase("ACTION:- I/C Supplies & Proc .....................", pFontHeader); // // table.addCell(phrase); // // //table.getDefaultCell().setColspan(5); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("Date............................", pFontHeader); // // table.addCell(phrase); // // phrase = new Phrase("Time............................", pFontHeader); // // table.addCell(phrase); // // phrase = new Phrase("Procurement Section.....................", pFontHeader); // // table.addCell(phrase); // // //table.getDefaultCell().setColspan(5); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("Date............................", pFontHeader); // // table.addCell(phrase); // // phrase = new Phrase("Time............................", pFontHeader); // // table.addCell(phrase); // // table.getDefaultCell().setColspan(2); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("Stock Ctr/: D/Note.............................", pFontHeader); // // table.addCell(phrase); // // table.getDefaultCell().setColspan(2); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("Inv No.......................", pFontHeader); // // table.addCell(phrase); // // // table.getDefaultCell().setColspan(2); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("Sign....................................", pFontHeader); // // table.addCell(phrase); // // table.getDefaultCell().setColspan(2); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("Date.......................................", pFontHeader); // // table.addCell(phrase); // // table.getDefaultCell().setColspan(1); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("Time...........................", pFontHeader); // // table.addCell(phrase); /* * table.getDefaultCell().setColspan(5); * * table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); * phrase = new * Phrase("REMARK___________________________________", * pFontHeader); * * table.addCell(phrase); * table.getDefaultCell().setColspan(4); * * table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); * phrase = new Phrase("DATE * RECEIVED____________________________", * pFontHeader); table.addCell(phrase); * * table.getDefaultCell().setColspan(5); * * table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); * phrase = new Phrase(" ", pFontHeader); * table.addCell(phrase); * * table.getDefaultCell().setColspan(9); * * table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER); * phrase = new Phrase(" ", pFontHeader); * * table.addCell(phrase); * table.getDefaultCell().setBorder(Rectangle.TOP); * * table.getDefaultCell().setBorderColor(java.awt.Color.WHITE); * * * table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); * phrase = new Phrase("1. Original__________ Use * department", pFontHeader); * * table.addCell(phrase); * * table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); * phrase = new Phrase("2. Duplicate________ * Procurement office", pFontHeader); * * table.addCell(phrase); * * * table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); * phrase = new Phrase("3. Triplicate_________ Book * copy", pFontHeader); * * table.addCell(phrase); */ docPdf.add(table); } catch (java.sql.SQLException SqlExec) { javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), SqlExec.getMessage()); } // } } catch (com.lowagie.text.BadElementException BadElExec) { javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), BadElExec.getMessage()); } } catch (java.io.FileNotFoundException fnfExec) { javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), fnfExec.getMessage()); } } catch (com.lowagie.text.DocumentException lwDocexec) { javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), lwDocexec.getMessage()); } // System.out.println("Current Doc size "+ pdfWriter.getCurrentDocumentSize()); docPdf.close(); com.afrisoftech.lib.PDFRenderer.renderPDF(tempFile); } catch (java.io.IOException IOexec) { javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), IOexec.getMessage()); } }
From source file:com.afrisoftech.hospinventory.mtrhreports.PurchaseReqInternalMtrhPdf1_.java
public void generatePdf(java.lang.String memNo) { java.lang.Process wait_for_Pdf2Show; java.util.Calendar cal = java.util.Calendar.getInstance(); java.util.Date dateStampPdf = cal.getTime(); java.lang.String pdfDateStamp = dateStampPdf.toString(); try {/*from w ww . ja v a 2 s. c o m*/ java.io.File tempFile = java.io.File.createTempFile("REP" + this.getDateLable() + "_", ".pdf"); tempFile.deleteOnExit(); java.lang.Runtime rt = java.lang.Runtime.getRuntime(); java.lang.String debitTotal = null; java.lang.String creditTotal = null; // com.lowagie.text.Document docPdf = new com.lowagie.text.Document(com.lowagie.text.PageSize.A4,40,40,40,40); // com.lowagie.text.Document docPdf = new com.lowagie.text.Document(com.lowagie.text.PageSize.A4); com.lowagie.text.Document docPdf = new com.lowagie.text.Document(); try { try { com.lowagie.text.pdf.PdfWriter.getInstance(docPdf, new java.io.FileOutputStream(tempFile)); // pdfWriter = com.lowagie.text.pdf.PdfWriter.getInstance(docPdf, new java.io.FileOutputStream(tempFile)); // System.out.println("Current Doc size 1 "+ pdfWriter.getCurrentDocumentSize()); String compName = null; String date = null; try { java.sql.Statement st6 = connectDB.createStatement(); java.sql.Statement st4 = connectDB.createStatement(); // com.lowagie.text.HeaderFooter footer = new com.lowagie.text.HeaderFooter(new Phrase("Internal Requisition - Page:",pFontHeader ), true);// FontFactory.getFont(com.lowagie.text.FontFactory.HELVETICA, 12, Font.BOLDITALIC,java.awt.Color.blue)); // docPdf.setFooter(footer); } catch (java.sql.SQLException SqlExec) { javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), SqlExec.getMessage()); } docPdf.open(); String Username = null; int numColumns = 9; try { java.util.Calendar calendar = java.util.Calendar.getInstance(); long dateNow = calendar.getTimeInMillis(); java.sql.Date datenowSql = new java.sql.Date(dateNow); System.out.println(datenowSql.toString()); // java.lang.Object listofStaffNos[] = this.getListofStaffNos(); com.lowagie.text.pdf.PdfPTable table1 = new com.lowagie.text.pdf.PdfPTable(6); // com.lowagie.text.Table table = new com.lowagie.text.Table(7); // table.endHeaders(); int headerwidths[] = { 15, 15, 30, 15, 15, 15 }; table1.setWidths(headerwidths); // if (docPdf.getPageNumber() > 1) { // table1.setHeaderRows(4); // } table1.setWidthPercentage((100)); table1.getDefaultCell().setBorder(Rectangle.BOTTOM); table1.getDefaultCell().setColspan(7); Phrase phrase = new Phrase(); // table.addCell(phrase); table1.getDefaultCell().setColspan(1); // table1.getDefaultCell().setBackgroundColor(java.awt.Color.WHITE); // table1.getDefaultCell().setBorderColor(java.awt.Color.WHITE); try { Image img = Image.getInstance(com.afrisoftech.lib.CompanyLogo.getPath2Logo()); //Image imgWaterMark = Image.getInstance(System.getProperty("company.watermark")); table1.getDefaultCell().setColspan(10); table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER); table1.getDefaultCell().setFixedHeight(50); table1.addCell(Image.getInstance(com.afrisoftech.lib.CompanyLogo.getPath2Logo())); table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER); table1.getDefaultCell().setFixedHeight(25); java.sql.Statement st3 = connectDB.createStatement(); java.sql.ResultSet rset3 = st3 .executeQuery("SELECT DISTINCT hospital_name FROM pb_hospitalprofile"); while (rset3.next()) { table1.getDefaultCell().setColspan(6); table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER); phrase = new Phrase(rset3.getObject(1).toString(), pFontHeader11); table1.addCell(phrase); } } catch (java.sql.SQLException SqlExec) { javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), SqlExec.getMessage()); } docPdf.add(table1); } catch (com.lowagie.text.BadElementException BadElExec) { javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), BadElExec.getMessage()); } try { com.lowagie.text.pdf.PdfPTable table1 = new com.lowagie.text.pdf.PdfPTable(10); table1.getDefaultCell().setPadding(3); int headerwidths1[] = { 24, 10, 8, 8, 6, 8, 6, 10, 12, 8 }; // table1.setWidths(headerwidths1); table1.setWidthPercentage((100)); table1.getDefaultCell().setBackgroundColor(java.awt.Color.WHITE); table1.getDefaultCell().setBorderColor(java.awt.Color.WHITE); Phrase phrase = new Phrase("", pFontHeader); try { // java.sql.Statement st3 = conDB.createStatement(); // java.sql.Connection conDb = java.sql.DriverManager.getConnection("jdbc:postgresql://localhost:5432/purchase","postgres","pilsiner"); // java.sql.Statement st3 = conDb.createStatement(); java.sql.Statement st3 = connectDB.createStatement(); //java.sql.Statement st1 = connectDB.createStatement(); java.sql.Statement st2 = connectDB.createStatement(); java.sql.Statement st11 = connectDB.createStatement(); java.sql.Statement st4 = connectDB.createStatement(); java.sql.Statement st5 = connectDB.createStatement(); java.sql.Statement st6 = connectDB.createStatement(); java.sql.ResultSet rset3 = st3.executeQuery( "select hospital_name,box_no,main_telno||' '||other_telno,initcap(street),initcap(town),main_faxno,email,initcap(building_name),room_no from pb_hospitalprofile"); //java.sql.ResultSet rset2 = st2.executeQuery("select supplier_name,short_name,postal_address,tel1,initcap(street),initcap(avenue),fax_no,email_address,initcap(building_name) from st_suppliers WHERE supplier_name ilike '"+selectSupp+"'"); java.sql.ResultSet rset4 = st4.executeQuery( "select DISTINCT REQUISITION_no,date_due,cost_center, case when supplier is null then '-' else supplier end as supplier," + " received_requisation,reason,date,store_name,requisation FROM st_receive_requisation where REQUISITION_no = '" + OrderNo + "'");// where supplier_name = 'Uchumi'member_no = '"+memNo+"' AND date BETWEEN '"+beginDate+"' AND '"+endDate+"'"); java.sql.ResultSet rset5 = st5.executeQuery( "select DISTINCT date_due from st_receive_requisation where requisition_no = '" + OrderNo + "'");// where supplier_name = 'Uchumi'member_no = '"+memNo+"' AND date BETWEEN '"+beginDate+"' AND '"+endDate+"'"); java.sql.ResultSet rset11 = st11.executeQuery( "select initcap(user_name) from st_receive_requisation where requisition_no = '" + OrderNo + "'");// where supplier_name = 'Uchumi'member_no = '"+memNo+"' AND date BETWEEN '"+beginDate+"' AND '"+endDate+"'"); while (rset11.next()) { Username = rset11.getObject(1).toString(); } table1.getDefaultCell().setBorderColor(java.awt.Color.white); while (rset4.next()) { table1.getDefaultCell().setColspan(10); table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER); phrase = new Phrase(" ", pFontHeader); //table1.addCell(phrase); table1.getDefaultCell().setColspan(10); table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER); phrase = new Phrase("INTERNAL PURCHASE REQUISITION", pFontHeader5); table1.addCell(phrase); table1.getDefaultCell().setColspan(10); table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER); phrase = new Phrase("FROM TEAM LEADER LOGISTICS- " + Department + " ", pFontHeader5); table1.addCell(phrase); table1.getDefaultCell().setColspan(10); table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER); phrase = new Phrase("TO SUPPLY CHAIN MANAGER", pFontHeader5); table1.addCell(phrase); table1.getDefaultCell().setColspan(10); table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER); phrase = new Phrase("NUMBER KNH/" + Department + "/ " + OrderNo, pFontHeader5); table1.addCell(phrase); table1.getDefaultCell().setColspan(10); table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase(" ", pFontHeader); table1.getDefaultCell().setColspan(10); table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase(" ", pFontHeader); table1.getDefaultCell().setColspan(10); table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER); phrase = new Phrase("PLEASE ORDER THE FOLLOWING MATERIALS/ITEMS", pFontHeader5); table1.addCell(phrase); table1.getDefaultCell().setColspan(10); table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase(" ", pFontHeader); table1.getDefaultCell().setColspan(10); table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase(" ", pFontHeader); //table1.addCell(phrase); table1.getDefaultCell().setColspan(6); phrase = new Phrase("Requisitioning Store : " + rset4.getObject(3).toString(), pFontHeader); table1.addCell(phrase); table1.getDefaultCell().setColspan(4); phrase = new Phrase("DATE: " + rset4.getObject(9).toString(), pFontHeader); table1.addCell(phrase); table1.getDefaultCell().setColspan(10); table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase("Receiving Store : " + rset4.getObject(8).toString(), pFontHeader); table1.addCell(phrase); // table1.getDefaultCell().setColspan(10); // phrase = new Phrase(" " + rset4.getObject(2).toString(), pFontHeader); // table1.addCell(phrase); /* * table1.getDefaultCell().setColspan(5); * table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); * phrase = new Phrase(" ", pFontHeader); * table1.addCell(phrase); phrase = new * Phrase("PROCUREMENT METHOD : ", pFontHeader); * table1.addCell(phrase); * * table1.getDefaultCell().setColspan(5); phrase * = new Phrase(" ", pFontHeader); * table1.addCell(phrase); * table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); * phrase = new Phrase("REQUISITION NO: " + * rset4.getObject(1).toString(), pFontHeader); * table1.addCell(phrase); * * table1.getDefaultCell().setColspan(5); phrase * = new Phrase(" ", pFontHeader); * table1.addCell(phrase); * table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); * phrase = new Phrase("ACCOUNT NO: ", * pFontHeader); table1.addCell(phrase); * * table1.getDefaultCell().setColspan(5); phrase * = new Phrase(" ", pFontHeader); * table1.addCell(phrase); * table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); * phrase = new Phrase("REASON FOR PURCHASE " + * rset4.getObject(6).toString(), pFontHeader); * table1.addCell(phrase); * * table1.getDefaultCell().setColspan(5); * * table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); * phrase = new Phrase("", pFontHeader); * table1.addCell(phrase); * * table1.getDefaultCell().setColspan(5); phrase * = new Phrase("NAME OF THE SUPPLIER " + * rset4.getObject(4).toString(), pFontHeader); * table1.addCell(phrase); * table1.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); * phrase = new Phrase("CONTRACT NO: ", * pFontHeader); table1.addCell(phrase); * */ } docPdf.add(table1); } catch (java.sql.SQLException SqlExec) { javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), SqlExec.getMessage()); } } catch (com.lowagie.text.BadElementException BadElExec) { javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), BadElExec.getMessage()); } double Total = 0.00; double discount = 0.00; double vat = 0.00; double qty = 0.00; double price = 0.00; double value = 0.00; try { com.lowagie.text.pdf.PdfPTable table = new com.lowagie.text.pdf.PdfPTable(9); table.getDefaultCell().setPadding(3); int headerwidths[] = { 8, 30, 14, 14, 14, 14, 14, 16, 15 }; table.setWidths(headerwidths); table.setWidthPercentage((100)); com.lowagie.text.pdf.PdfPTable table3 = new com.lowagie.text.pdf.PdfPTable(9); // table3.getDefaultCell().setPadding(3); int headerwidths3[] = { 8, 30, 14, 14, 14, 14, 14, 16, 15 }; table3.setWidths(headerwidths3); table3.setWidthPercentage((100)); //table.getDefaultCell().setBorderColor(java.awt.Color.black); //table.getDefaultCell().setBorder(Rectangle.BOTTOM); table.getDefaultCell().setBorderColor(java.awt.Color.WHITE); table.getDefaultCell().setColspan(9); Phrase phrase = new Phrase(" ", pFontHeader); table.addCell(phrase); table3.getDefaultCell() .setBorder(Rectangle.BOTTOM | Rectangle.LEFT | Rectangle.RIGHT | Rectangle.TOP); table3.getDefaultCell().setColspan(1); phrase = new Phrase("NOs ", pFontHeader); table3.addCell(phrase); table3.getDefaultCell().setColspan(1); phrase = new Phrase("Item No/Code ", pFontHeader); table3.addCell(phrase); table3.getDefaultCell().setColspan(2); phrase = new Phrase("Item Description", pFontHeader); table3.addCell(phrase); table3.getDefaultCell().setColspan(1); phrase = new Phrase("Units of Issue. ", pFontHeader); table3.addCell(phrase); table3.getDefaultCell().setColspan(1); phrase = new Phrase("Qty Required. ", pFontHeader); table3.addCell(phrase); table3.getDefaultCell().setColspan(1); phrase = new Phrase("Store Balance ", pFontHeader); table3.addCell(phrase); table3.getDefaultCell().setColspan(2); phrase = new Phrase("Monthly Usage", pFontHeader); table3.addCell(phrase); // table3.getDefaultCell().setColspan(1); // phrase = new Phrase(" ", pFontHeader); // table3.addCell(phrase); // phrase = new Phrase("Est.Cost ", pFontHeader); // table3.addCell(phrase); // // phrase = new Phrase("Actual Cost", pFontHeader); // table3.addCell(phrase); // // phrase = new Phrase("Tender/Qtn Ref.", pFontHeader); // table3.addCell(phrase); phrase = new Phrase("", pFontHeader); //table.addCell(phrase); table3.setHeaderRows(1); // table3.getDefaultCell().setColspan(1); // // table3.getDefaultCell().setBackgroundColor(java.awt.Color.WHITE); // table.getDefaultCell().setBorderColor(java.awt.Color.BLACK); String coment = ""; try { // java.sql.Statement st6 = connectDB.createStatement(); java.sql.Statement st1 = connectDB.createStatement(); java.sql.ResultSet rset1 = st1 .executeQuery("SELECT initcap(item_description),units,cos_glcode," + " quantity,price,round(quantity*price,2),mainstore_bal,terms,item_code,monthly_usage from st_receive_requisation" + " WHERE requisition_no = '" + OrderNo + "'");// where supplier_name = 'Uchumi'member_no = '"+memNo+"' AND date BETWEEN '"+beginDate+"' AND '"+endDate+"'"); table.getDefaultCell().setBorderColor(java.awt.Color.lightGray); while (rset1.next()) { // value = qty * price; cnt = cnt + 1; table3.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); table3.getDefaultCell().setColspan(1); phrase = new Phrase("" + cnt, pFontHeader2); table3.getDefaultCell().setBorderColor(java.awt.Color.black); table3.addCell(phrase); table3.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); table3.getDefaultCell().setColspan(1); phrase = new Phrase(rset1.getObject(9).toString(), pFontHeader2); table3.getDefaultCell().setBorderColor(java.awt.Color.black); table3.addCell(phrase); table3.getDefaultCell().setColspan(2); table3.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase(rset1.getObject(1).toString(), pFontHeader2); table3.addCell(phrase); table3.getDefaultCell().setColspan(1); phrase = new Phrase(rset1.getObject(2).toString(), pFontHeader2); table3.addCell(phrase); table3.getDefaultCell().setColspan(1); phrase = new Phrase(rset1.getObject(4).toString(), pFontHeader2); table3.addCell(phrase); table3.getDefaultCell().setColspan(1); // JOptionPane.showMessageDialog(null, "this "+rset1.getObject(10).toString()); phrase = new Phrase(rset1.getObject(7).toString(), pFontHeader); table3.addCell(phrase); table3.getDefaultCell().setColspan(2); //change phrase = new Phrase(rset1.getObject(10).toString(), pFontHeader2); table3.addCell(phrase); // table3.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT); // phrase = new Phrase(new com.afrisoftech.sys.Format2Currency().Format2Currency(rset1.getObject(4).toString()), pFontHeader2); // // table3.addCell(phrase); // // table3.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT); // phrase = new Phrase(new com.afrisoftech.sys.Format2Currency().Format2Currency(rset1.getObject(5).toString()), pFontHeader2); // table3.addCell(phrase); // // // System.out.println("Second "+docPdf.top()); // table3.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT); // phrase = new Phrase(new com.afrisoftech.sys.Format2Currency().Format2Currency(rset1.getString(6)), pFontHeader2); // // table3.addCell(phrase); // // phrase = new Phrase(new com.afrisoftech.sys.Format2Currency().Format2Currency(rset1.getString(7)), pFontHeader2); // // table3.addCell(phrase); // // // table3.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT); // value = value + rset1.getDouble(6); // table3.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // // phrase = new Phrase(rset1.getObject(8).toString(), pFontHeader2); // // // table.addCell(phrase); // // coment = rset1.getObject(12).toString(); } // table.getDefaultCell().setBorderColor(java.awt.Color.BLACK); // // table.getDefaultCell().setBorder(Rectangle.BOTTOM | Rectangle.TOP | Rectangle.RIGHT | Rectangle.LEFT); // table.getDefaultCell().setFixedHeight(350); // table.addCell(table3); // // table.getDefaultCell().setFixedHeight(20); // //// // // // table.getDefaultCell().setColspan(9); // table.getDefaultCell().setBorder(Rectangle.TOP | Rectangle.BOTTOM | Rectangle.RIGHT | Rectangle.LEFT); // phrase = new Phrase(" ", pFontHeader); // // table.addCell(phrase); // table.getDefaultCell().setBorder(Rectangle.TOP); // // table.addCell(phrase); //table.getDefaultCell().setBorder(Rectangle.TOP); /* * * * table.getDefaultCell().setColspan(6); * * table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); * phrase = new Phrase("Prepared By :" * +Username.toUpperCase(), pFontHeader); * * table.addCell(phrase); */ // table.getDefaultCell().setColspan(3); // table.getDefaultCell().setBorderColor(java.awt.Color.WHITE); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("PREPARED BY.................................", pFontHeader); // // table.addCell(phrase); // // table.getDefaultCell().setColspan(2); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("Sign.................................", pFontHeader); // // table.addCell(phrase); // // phrase = new Phrase("Date.................................", pFontHeader); // // table.addCell(phrase); // // phrase = new Phrase("Time.................................\n", pFontHeader); // table.addCell(phrase); // // table.getDefaultCell().setColspan(3); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("AIE HOLDER/USER.................................", pFontHeader); // // table.addCell(phrase); // // table.getDefaultCell().setColspan(2); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("Sign.................................", pFontHeader); // // table.addCell(phrase); // // phrase = new Phrase("Date.................................", pFontHeader); // // table.addCell(phrase); // // phrase = new Phrase("Time.................................\n", pFontHeader); // // table.addCell(phrase); // // table.getDefaultCell().setColspan(3); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("APPROVED BY(TL LOGISTICS).................................", pFontHeader); // // table.addCell(phrase); // // table.getDefaultCell().setColspan(2); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("Sign.................................", pFontHeader); // // table.addCell(phrase); // // phrase = new Phrase("Date.................................", pFontHeader); // // table.addCell(phrase); // // phrase = new Phrase("Time.................................\n", pFontHeader); // // table.addCell(phrase); // table.getDefaultCell().setColspan(4); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("Amount Voted..................................................", pFontHeader); // table.addCell(phrase); // // table.getDefaultCell().setColspan(5); // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("Vote Balance.........................................................", pFontHeader); // table.addCell(phrase); // // // table.getDefaultCell().setColspan(3); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("Vote Holder's Authority.................................", pFontHeader); // // table.addCell(phrase); // // table.getDefaultCell().setColspan(2); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("Sign.................................", pFontHeader); // // table.addCell(phrase); // // phrase = new Phrase("Date.................................", pFontHeader); // // table.addCell(phrase); // // phrase = new Phrase("Time.................................", pFontHeader); // // table.addCell(phrase); table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("SIGN..........................................................", pFontHeader); //table.addCell(phrase); table.getDefaultCell().setColspan(9); //table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER); phrase = new Phrase("", pFontHeader); table.addCell(phrase); //phrase = new Phrase("FOR PROCUREMENT USE ONLY", pFontHeader); //table.addCell(phrase); //table.getDefaultCell().setBorder(Rectangle.TOP | Rectangle.LEFT | Rectangle.RIGHT | Rectangle.BOTTOM); //table.getDefaultCell().setBorderColor(java.awt.Color.BLACK); // table.getDefaultCell().setColspan(3); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("Approved/Not Approved.....................", pFontHeader); // // table.addCell(phrase); // // //table.getDefaultCell().setColspan(5); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("Date............................", pFontHeader); // // table.addCell(phrase); // // phrase = new Phrase("Time............................", pFontHeader); // // table.addCell(phrase); // // phrase = new Phrase("ACTION:- I/C Supplies & Proc .....................", pFontHeader); // // table.addCell(phrase); // // //table.getDefaultCell().setColspan(5); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("Date............................", pFontHeader); // // table.addCell(phrase); // // phrase = new Phrase("Time............................", pFontHeader); // // table.addCell(phrase); // // phrase = new Phrase("Procurement Section.....................", pFontHeader); // // table.addCell(phrase); // // //table.getDefaultCell().setColspan(5); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("Date............................", pFontHeader); // // table.addCell(phrase); // // phrase = new Phrase("Time............................", pFontHeader); // // table.addCell(phrase); // // table.getDefaultCell().setColspan(2); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("Stock Ctr/: D/Note.............................", pFontHeader); // // table.addCell(phrase); // // table.getDefaultCell().setColspan(2); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("Inv No.......................", pFontHeader); // // table.addCell(phrase); // // // table.getDefaultCell().setColspan(2); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("Sign....................................", pFontHeader); // // table.addCell(phrase); // // table.getDefaultCell().setColspan(2); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("Date.......................................", pFontHeader); // // table.addCell(phrase); // // table.getDefaultCell().setColspan(1); // // table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); // phrase = new Phrase("Time...........................", pFontHeader); // // table.addCell(phrase); /* * table.getDefaultCell().setColspan(5); * * table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); * phrase = new * Phrase("REMARK___________________________________", * pFontHeader); * * table.addCell(phrase); * table.getDefaultCell().setColspan(4); * * table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); * phrase = new Phrase("DATE * RECEIVED____________________________", * pFontHeader); table.addCell(phrase); * * table.getDefaultCell().setColspan(5); * * table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); * phrase = new Phrase(" ", pFontHeader); * table.addCell(phrase); * * table.getDefaultCell().setColspan(9); * * table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER); * phrase = new Phrase(" ", pFontHeader); * * table.addCell(phrase); * table.getDefaultCell().setBorder(Rectangle.TOP); * * table.getDefaultCell().setBorderColor(java.awt.Color.WHITE); * * * table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); * phrase = new Phrase("1. Original__________ Use * department", pFontHeader); * * table.addCell(phrase); * * table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); * phrase = new Phrase("2. Duplicate________ * Procurement office", pFontHeader); * * table.addCell(phrase); * * * table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); * phrase = new Phrase("3. Triplicate_________ Book * copy", pFontHeader); * * table.addCell(phrase); */ docPdf.add(table); } catch (java.sql.SQLException SqlExec) { javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), SqlExec.getMessage()); } // } } catch (com.lowagie.text.BadElementException BadElExec) { javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), BadElExec.getMessage()); } try { Phrase phrase = new Phrase(); com.lowagie.text.pdf.PdfPTable table = new com.lowagie.text.pdf.PdfPTable(9); table.getDefaultCell().setPadding(3); int headerwidths[] = { 8, 30, 14, 14, 14, 14, 14, 16, 15 }; table.setWidths(headerwidths); table.setWidthPercentage((100)); table.getDefaultCell().setBorderColor(java.awt.Color.BLACK); table.getDefaultCell() .setBorder(Rectangle.BOTTOM | Rectangle.TOP | Rectangle.RIGHT | Rectangle.LEFT); table.getDefaultCell().setFixedHeight(350); table.addCell(table); table.getDefaultCell().setFixedHeight(20); // table.getDefaultCell().setColspan(9); table.getDefaultCell() .setBorder(Rectangle.TOP | Rectangle.BOTTOM | Rectangle.RIGHT | Rectangle.LEFT); phrase = new Phrase(" ", pFontHeader); table.addCell(phrase); table.getDefaultCell().setBorder(Rectangle.TOP); table.addCell(phrase); table.getDefaultCell().setColspan(3); table.getDefaultCell().setBorderColor(java.awt.Color.WHITE); table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase("PREPARED BY.................................", pFontHeader); table.addCell(phrase); table.getDefaultCell().setColspan(2); table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase("Sign.................................", pFontHeader); table.addCell(phrase); phrase = new Phrase("Date.................................", pFontHeader); table.addCell(phrase); phrase = new Phrase("Time.................................\n", pFontHeader); table.addCell(phrase); table.getDefaultCell().setColspan(3); table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase("AIE HOLDER/USER.................................", pFontHeader); table.addCell(phrase); table.getDefaultCell().setColspan(2); table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase("Sign.................................", pFontHeader); table.addCell(phrase); phrase = new Phrase("Date.................................", pFontHeader); table.addCell(phrase); phrase = new Phrase("Time.................................\n", pFontHeader); table.addCell(phrase); table.getDefaultCell().setColspan(3); table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase("APPROVED BY(TL LOGISTICS).................................", pFontHeader); table.addCell(phrase); table.getDefaultCell().setColspan(2); table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase("Sign.................................", pFontHeader); table.addCell(phrase); phrase = new Phrase("Date.................................", pFontHeader); table.addCell(phrase); phrase = new Phrase("Time.................................\n", pFontHeader); table.addCell(phrase); //down docPdf.add(table); } catch (com.lowagie.text.BadElementException BadElExec) { javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), BadElExec.getMessage()); } } catch (java.io.FileNotFoundException fnfExec) { javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), fnfExec.getMessage()); } } catch (com.lowagie.text.DocumentException lwDocexec) { javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), lwDocexec.getMessage()); } // System.out.println("Current Doc size "+ pdfWriter.getCurrentDocumentSize()); docPdf.close(); com.afrisoftech.lib.PDFRenderer.renderPDF(tempFile); } catch (java.io.IOException IOexec) { javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), IOexec.getMessage()); } }
From source file:com.krawler.esp.servlets.ExportLeavePdfServlet.java
License:Open Source License
private ByteArrayOutputStream createLeaveForm(String cname, HttpServletRequest request, Session session, boolean isEmm) throws JSONException, SessionExpiredException, ParseException { String companyid = AuthHandler.getCompanyid(request); Company com = (Company) session.get(Company.class, companyid); String from = ""; String to = ""; String formTitle = "Absence Leave Form"; int i = 0;/*from w w w.j av a 2 s .co m*/ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); DecimalFormat decfm = new DecimalFormat("#,##0.00"); Date d2 = null; Date d3 = null; Calendar cal1 = Calendar.getInstance(); Calendar cal2 = Calendar.getInstance(); String month = ""; int days = 0; boolean showborder = true; if (!StringUtil.isNullOrEmpty(request.getParameter("showborder"))) { showborder = Boolean.parseBoolean(request.getParameter("showborder")); } SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy"); String stDate = request.getParameter("stdate").replace("/", "-"); String endDate = request.getParameter("enddate").replace("/", "-"); d2 = sdf.parse(stDate); d3 = sdf.parse(endDate); days = getWorkingDays(request, session, companyid); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter writer = null; try { String empname = ""; String design = ""; String historyid = ""; String net = ""; String name = ""; String wtot = ""; String dtot = ""; String ttot = ""; Date generatedOn = null; DateFormat monthformat = new SimpleDateFormat("MMMM"); DateFormat monthformat2 = new SimpleDateFormat("MMMM dd yyyy"); Query query = null; // if (request.getParameter("flagpdf").equals("datewise")) { // query = session.createQuery("from masterDB.Payhistory t where t.userID.userID=:empid and t.paymonth=:month"); // query.setString("empid", request.getParameter("empid")); // query.setString("month", month); // } // if (request.getParameter("flagpdf").equals("monthwise")) { // month = request.getParameter("month"); // query = session.createQuery("from masterDB.Payhistory t where t.userID.userID=:empid and t.paymonth=:month"); // query.setString("empid", request.getParameter("empid")); // query.setString("month", request.getParameter("month")); // } query = session.createQuery( "from masterDB.Payhistory t where t.userID.userID=:empid and t.paycyclestart=:paycyclestart and t.paycycleend=:paycycleend"); query.setString("empid", request.getParameter("empid")); query.setDate("paycyclestart", d2); query.setDate("paycycleend", d3); String currSymbol = ""; String curid = AuthHandler.getCurrencyID(request); Query queryx = session.createQuery("from KWLCurrency where currencyID=:curid"); queryx.setString("curid", curid); KWLCurrency curncy = (KWLCurrency) queryx.uniqueResult(); String currsym = curncy.getHtmlcode(); String currname = curncy.getName(); try { char a1 = (char) Integer.parseInt(currsym, 16); currSymbol = Character.toString(a1); } catch (Exception e) { currSymbol = currsym; } List lst = (List) query.list(); if (lst.size() == 0) { throw new Exception("Exception occured"); } if (lst.size() > 0) { masterDB.Payhistory wage = (masterDB.Payhistory) lst.get(0); empname = wage.getName(); design = wage.getDesign(); historyid = wage.getHistoryid(); net = String.format("%.2f", Float.valueOf(wage.getNet().trim()).floatValue()); name = wage.getName(); wtot = wage.getWagetot(); ttot = wage.getTaxtot(); dtot = wage.getDeductot(); double unpaidleaves = wage.getUnpaidleaves(); generatedOn = wage.getGeneratedon(); String gen = monthformat2.format(generatedOn); String startdate = monthformat2.format(wage.getCreatedon()); String enddate = monthformat2.format(wage.getCreatedfor()); Document document = new Document(PageSize.A4, 15, 15, 15, 15); writer = PdfWriter.getInstance(document, baos); writer.setPageEvent(new EndPage(request)); document.open(); String userid = request.getParameter("empid"); query = session.createQuery("from com.krawler.common.admin.User as t where t.userID=:empid "); query.setString("empid", userid); lst = (List) query.list(); com.krawler.common.admin.User userinfo = (com.krawler.common.admin.User) lst.get(0); Useraccount ua = (Useraccount) session.get(Useraccount.class, userinfo.getUserID()); String uname = userinfo.getLastName() != null ? userinfo.getLastName() : ""; String empid = ""; if (ua.getEmployeeIdFormat() == null) { empid = ua.getEmployeeid() == null ? "" : hrmsManager.getEmpidFormatEdit(session, request, ua.getEmployeeid()); } else { HashMap<String, Object> requestParams = new HashMap<String, Object>(); requestParams.put("standardEmpId", hrmsManager.getEmpidFormatEdit(session, request, ua.getEmployeeid())); requestParams.put("employeeIdFormat", ua.getEmployeeIdFormat()); empid = hrmsManager.getNewEmployeeIdFormat(requestParams); } String department = wage.getDepartment(); String designation = getUserDesignation(ua); String bankacc = ua.getAccno() != null ? ua.getAccno() : ""; Empprofile empprof = null; String epf = ""; String dateofjoin = ""; try { empprof = (Empprofile) session.get(Empprofile.class, userid); epf = StringUtil.isNullOrEmpty(empprof.getPfno()) ? "" : empprof.getPfno(); dateofjoin = empprof.getJoindate() != null ? empprof.getJoindate().toString() : ""; } catch (Exception ex) { epf = ""; } PdfPTable mainTable = new PdfPTable(1); mainTable.setWidthPercentage(100); PdfPTable table1 = new PdfPTable(3); table1.setWidthPercentage(100); table1.setWidths(new float[] { 40, 40, 20 }); PdfPTable userTable1 = new PdfPTable(1); imgPath = "images/logo1.gif"; String cmpid = AuthHandler.getCompanyid(request); ServletContext sc = getServletContext(); userTable1.setHorizontalAlignment(Element.ALIGN_MIDDLE); userTable1.setWidthPercentage(10); PdfPCell cell11 = null; PdfPCell cell1x = new PdfPCell(new Paragraph(" ", fontMediumBold)); cell1x.setBorder(0); userTable1.addCell(cell1x); try { Image img = Image.getInstance(StorageHandler.GetProfileImgStorePath() + cmpid + ".png"); cell11 = new PdfPCell(img); cell11.setPaddingLeft(5); } catch (Exception e) { cell11 = new PdfPCell(new Paragraph(AuthHandler.getCompanyName(request), fontTblLargeBold)); cell11.setHorizontalAlignment(Element.ALIGN_CENTER); } if (cell11 != null) { cell11.setBorder(0); userTable1.addCell(cell11); } PdfPCell cell1 = new PdfPCell(new Paragraph("", fontMediumBold)); cell1.setHorizontalAlignment(Element.ALIGN_LEFT); cell1.setBorder(0); userTable1.addCell(cell1); PdfPTable userTable2 = new PdfPTable(1); userTable2.setWidthPercentage(100); PdfPCell cell = new PdfPCell(new Paragraph(com.getCompanyName(), fontMediumBold)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorder(0); cell.setPaddingTop(15); userTable2.addCell(cell); cell = new PdfPCell(new Paragraph(com.getCity(), fontSmallRegular)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorder(0); userTable2.addCell(cell); cell = new PdfPCell(new Paragraph(com.getAddress(), fontSmallRegular)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorder(0); userTable2.addCell(cell); cell = new PdfPCell(new Paragraph(com.getState(), fontSmallRegular)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorder(0); userTable2.addCell(cell); cell = new PdfPCell(new Paragraph(com.getZipCode(), fontSmallRegular)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorder(0); userTable2.addCell(cell); cell = new PdfPCell(new Paragraph(messageSource.getMessage("hrms.payroll.payslip.period.params", new Object[] { request.getParameter("stdate"), request.getParameter("enddate") }, RequestContextUtils.getLocale(request)), fontSmallBold)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorder(0); userTable2.addCell(cell); PdfPTable userTable3 = new PdfPTable(1); userTable3.setWidthPercentage(100); PdfPCell cell2 = new PdfPCell(new Paragraph("", fontSmallBold)); cell2.setHorizontalAlignment(Element.ALIGN_LEFT); cell2.setBorder(0); userTable1.addCell(cell2); PdfPCell mainCell11 = new PdfPCell(userTable1); if (!showborder) { mainCell11.setBorder(0); } else { mainCell11.setBorder(Rectangle.LEFT); } table1.addCell(mainCell11); PdfPCell mainCell13 = new PdfPCell(userTable2); mainCell13.setBorder(0); table1.addCell(mainCell13); PdfPCell mainCell15 = new PdfPCell(userTable3); if (!showborder) { mainCell15.setBorder(0); } else { mainCell15.setBorder(Rectangle.RIGHT); } table1.addCell(mainCell15); PdfPCell mainCell12 = new PdfPCell(new Paragraph("")); if (!showborder) { mainCell12.setBorder(0); } else { mainCell12.setBorder(Rectangle.LEFT); } table1.addCell(mainCell12); PdfPCell mainCell14 = new PdfPCell(new Paragraph("")); mainCell14.setBorder(0); table1.addCell(mainCell14); PdfPCell mainCell16 = new PdfPCell(new Paragraph("")); if (!showborder) { mainCell16.setBorder(0); } else { mainCell16.setBorder(Rectangle.RIGHT); } table1.addCell(mainCell16); PdfPCell mainCell1 = new PdfPCell(table1); if (!showborder) { mainCell1.setBorder(0); } else { mainCell1.setBorder(1); } mainTable.addCell(mainCell1); // __________________________________________________________________________ PdfPTable table2 = new PdfPTable(4); table2.setWidthPercentage(100); table2.setWidths(new float[] { 20, 30, 20, 30 }); PdfPCell h11 = new PdfPCell(new Paragraph(messageSource.getMessage("hrms.common.employee.code", null, RequestContextUtils.getLocale(request)), fontSmallBold)); h11.setHorizontalAlignment(Element.ALIGN_LEFT); h11.setPadding(5); if (!showborder) { h11.setBorder(0); } // else{ // mainCell1.setBorder(1); // } table2.addCell(h11); PdfPCell h12 = new PdfPCell(new Paragraph("" + empid, fontSmallRegular)); h12.setHorizontalAlignment(Element.ALIGN_LEFT); h12.setPadding(5); if (!showborder) { h12.setBorder(0); } // else{ // mainCell1.setBorder(1); // } table2.addCell(h12); PdfPCell h13 = new PdfPCell(new Paragraph(messageSource.getMessage("hrms.common.employee.name", null, RequestContextUtils.getLocale(request)), fontSmallBold)); h13.setHorizontalAlignment(Element.ALIGN_LEFT); h13.setPadding(5); if (!showborder) { h13.setBorder(0); } // else{ // mainCell1.setBorder(1); // } table2.addCell(h13); PdfPCell h14 = new PdfPCell(new Paragraph(userinfo.getFirstName() + " " + uname, fontSmallRegular)); h14.setHorizontalAlignment(Element.ALIGN_LEFT); h14.setPadding(5); if (!showborder) { h14.setBorder(0); } // else{ // mainCell1.setBorder(1); // } table2.addCell(h14); PdfPCell h21 = new PdfPCell(new Paragraph(messageSource.getMessage("hrms.common.department", null, RequestContextUtils.getLocale(request)), fontTblMediumBold)); h21.setHorizontalAlignment(Element.ALIGN_LEFT); h21.setPadding(5); if (!showborder) { h21.setBorder(0); } // else{ // mainCell1.setBorder(1); // } table2.addCell(h21); PdfPCell h22 = new PdfPCell(new Paragraph(department, fontSmallRegular)); h22.setHorizontalAlignment(Element.ALIGN_LEFT); h22.setPadding(5); if (!showborder) { h22.setBorder(0); } // else{ // mainCell1.setBorder(1); // } table2.addCell(h22); PdfPCell h33 = new PdfPCell(new Paragraph(messageSource.getMessage("hrms.common.designation", null, RequestContextUtils.getLocale(request)), fontTblMediumBold)); h33.setHorizontalAlignment(Element.ALIGN_LEFT); h33.setPadding(5); if (!showborder) { h33.setBorder(0); } // else{ // mainCell1.setBorder(1); // } table2.addCell(h33); PdfPCell h34 = new PdfPCell(new Paragraph(designation, fontSmallRegular)); h34.setHorizontalAlignment(Element.ALIGN_LEFT); h34.setPadding(5); if (!showborder) { h34.setBorder(0); } // else{ // mainCell1.setBorder(1); // } table2.addCell(h34); PdfPCell h43 = new PdfPCell(new Paragraph(messageSource.getMessage("hrms.common.bank.ac.no", null, RequestContextUtils.getLocale(request)), fontTblMediumBold)); h43.setHorizontalAlignment(Element.ALIGN_LEFT); h43.setPadding(5); if (!showborder) { h43.setBorder(0); } // else{ // mainCell1.setBorder(1); // } table2.addCell(h43); PdfPCell h44 = new PdfPCell(new Paragraph(bankacc, fontSmallRegular)); h44.setHorizontalAlignment(Element.ALIGN_LEFT); h44.setPadding(5); if (!showborder) { h44.setBorder(0); } // else{ // mainCell1.setBorder(1); // } table2.addCell(h44); PdfPCell h61 = new PdfPCell(new Paragraph(messageSource.getMessage("hrms.common.working.days", null, RequestContextUtils.getLocale(request)), fontTblMediumBold)); h61.setHorizontalAlignment(Element.ALIGN_LEFT); h61.setPadding(5); if (!showborder) { h61.setBorder(0); } // else{ // mainCell1.setBorder(1); // } table2.addCell(h61); PdfPCell h62 = new PdfPCell(new Paragraph(String.valueOf(days), fontSmallRegular)); h62.setHorizontalAlignment(Element.ALIGN_LEFT); h62.setPadding(5); if (!showborder) { h62.setBorder(0); } // else{ // mainCell1.setBorder(1); // } table2.addCell(h62); PdfPCell h63 = new PdfPCell(new Paragraph( messageSource.getMessage("hrms.common.e.p.f", null, RequestContextUtils.getLocale(request)), fontTblMediumBold)); h63.setHorizontalAlignment(Element.ALIGN_LEFT); h63.setPadding(5); if (!showborder) { h63.setBorder(0); } // else{ // mainCell1.setBorder(1); // } table2.addCell(h63); PdfPCell h64 = new PdfPCell(new Paragraph(epf, fontSmallRegular)); h64.setHorizontalAlignment(Element.ALIGN_LEFT); h64.setPadding(5); if (!showborder) { h64.setBorder(0); } // else{ // mainCell1.setBorder(1); // } table2.addCell(h64); PdfPCell h65 = new PdfPCell(new Paragraph(messageSource.getMessage("hrms.common.DateofJoining", null, RequestContextUtils.getLocale(request)), fontTblMediumBold)); h65.setHorizontalAlignment(Element.ALIGN_LEFT); h65.setPadding(5); if (!showborder) { h65.setBorder(0); } // else{ // mainCell1.setBorder(1); // } table2.addCell(h65); PdfPCell h66 = new PdfPCell(new Paragraph(dateofjoin, fontSmallRegular)); h66.setHorizontalAlignment(Element.ALIGN_LEFT); h66.setPadding(5); if (!showborder) { h66.setBorder(0); } // else{ // mainCell1.setBorder(1); // } table2.addCell(h66); for (int y = 0; y < 2; y++) { PdfPCell h71 = new PdfPCell(new Paragraph(" ", fontTblMediumBold)); h71.setHorizontalAlignment(Element.ALIGN_LEFT); if (!showborder) { h71.setBorder(0); } else { h71.setBorder(Rectangle.LEFT); } table2.addCell(h71); for (i = 0; i < 2; i++) { h71 = new PdfPCell(new Paragraph(" ", fontTblMediumBold)); h71.setHorizontalAlignment(Element.ALIGN_LEFT); h71.setBorder(0); table2.addCell(h71); } h71 = new PdfPCell(new Paragraph(" ", fontTblMediumBold)); h71.setHorizontalAlignment(Element.ALIGN_LEFT); if (!showborder) { h71.setBorder(0); } else { h71.setBorder(Rectangle.RIGHT); } table2.addCell(h71); } PdfPCell mainCell2 = new PdfPCell(table2); if (!showborder) { mainCell2.setBorder(0); } else { mainCell2.setBorder(1); } mainTable.addCell(mainCell2); PdfPTable table3main = new PdfPTable(1); table3main.setWidthPercentage(100); PdfPTable table7main = new PdfPTable(1); table7main.setWidthPercentage(100); PdfPTable table31 = new PdfPTable(4); table31.setWidthPercentage(100); //table31.setWidths(new float[]{20,15,15,20,15,15}); table31.setWidths(new float[] { 30, 20, 30, 20 }); PdfPTable table41 = new PdfPTable(2); table41.setWidthPercentage(100); //table31.setWidths(new float[]{20,15,15,20,15,15}); table41.setWidths(new float[] { 50, 50 }); //*************************************************************************************************************** PdfPCell s11 = new PdfPCell(new Paragraph(messageSource.getMessage("hrms.payroll.Earnings", null, RequestContextUtils.getLocale(request)), fontTblMediumBold)); s11.setHorizontalAlignment(Element.ALIGN_LEFT); if (!showborder) { s11.setBorder(0); } else { s11.setBorder(Rectangle.LEFT + Rectangle.BOTTOM); } s11.setPadding(5); table31.addCell(s11); PdfPCell s12 = new PdfPCell(new Paragraph(messageSource.getMessage("hrms.payroll.amount.params", new Object[] { currSymbol }, RequestContextUtils.getLocale(request)), fontTblMediumBold)); s12.setHorizontalAlignment(Element.ALIGN_RIGHT); s12.setPadding(5); if (!showborder) { s12.setBorder(0); } else { s12.setBorder(Rectangle.LEFT + Rectangle.BOTTOM); } table31.addCell(s12); // PdfPCell s13 = new PdfPCell(new Paragraph("Year to Date", fontTblMediumBold)); // s13.setHorizontalAlignment(Element.ALIGN_RIGHT); // s13.setBorder(Rectangle.LEFT + Rectangle.BOTTOM); // s13.setPadding(5); // table31.addCell(s13); PdfPCell s14 = new PdfPCell(new Paragraph(messageSource.getMessage("hrms.payroll.Deduction", null, RequestContextUtils.getLocale(request)), fontTblMediumBold)); s14.setHorizontalAlignment(Element.ALIGN_LEFT); if (!showborder) { s14.setBorder(0); } else { s14.setBorder(Rectangle.LEFT + Rectangle.BOTTOM); } s14.setPadding(5); table31.addCell(s14); PdfPCell s15 = new PdfPCell(new Paragraph(messageSource.getMessage("hrms.payroll.amount.params", new Object[] { currSymbol }, RequestContextUtils.getLocale(request)), fontTblMediumBold)); s15.setHorizontalAlignment(Element.ALIGN_RIGHT); if (!showborder) { s15.setBorder(0); } else { s15.setBorder(Rectangle.LEFT + Rectangle.RIGHT + Rectangle.BOTTOM); } s15.setPadding(5); table31.addCell(s15); // PdfPCell s16 = new PdfPCell(new Paragraph("Year to Date", fontTblMediumBold)); // s16.setHorizontalAlignment(Element.ALIGN_RIGHT); // s16.setBorder(Rectangle.RIGHT + Rectangle.LEFT + Rectangle.BOTTOM); // s16.setPadding(5); // table31.addCell(s16); int Wcount = 0; float taxtotal = 0; Query queryw = session.createQuery( "from masterDB.Historydetail t where t.payhistory.userID=:userid and createdfor >=:stdate and createdfor <=:enddate and t.type =:type"); Query basicquery1 = session.createQuery( "from masterDB.Historydetail t where t.payhistory.historyid=:historyid and t.name=:name and t.type=:type "); basicquery1.setString("historyid", historyid); basicquery1.setString("name", "Wages"); basicquery1.setString("type", "Basic"); List lst1 = (List) basicquery1.list(); Query query1 = session.createQuery( "from masterDB.Historydetail t where t.payhistory.historyid=:historyid and t.name=:name and t.type<>:type order by t.amount"); query1.setString("historyid", historyid); query1.setString("name", "Wages"); query1.setString("type", "Basic"); lst1.addAll((List) query1.list()); Query query2 = session.createQuery( "from masterDB.Historydetail t where t.payhistory.historyid=:historyid and t.name=:name order by t.amount"); query2.setString("historyid", historyid); query2.setString("name", "Taxes"); List lst2 = (List) query2.list(); CompanyPreferences comp = (CompanyPreferences) session.get(CompanyPreferences.class, cmpid); int financialMonth = comp.getFinancialmonth(); Calendar c1 = Calendar.getInstance(); c1.setTime(d3); c1.set(Calendar.MONTH, financialMonth); c1.set(Calendar.DATE, 1); Date d = c1.getTime(); Date DOJ = new java.util.Date(empprof.getJoindate().getTime()); if (d3.before(d)) { int currentYear = c1.get(Calendar.YEAR) - 1; c1.set(Calendar.YEAR, currentYear); d = c1.getTime(); } if (DOJ.after(d)) { c1.setTime(DOJ); c1.set(Calendar.DATE, 1); d = c1.getTime(); } Query query3 = session.createQuery( "from masterDB.Historydetail t where t.payhistory.historyid=:historyid and t.name=:name order by t.amount"); query3.setString("historyid", historyid); query3.setString("name", "Deduction"); List lst3 = (List) query3.list(); int size = lst1.size() > (lst2.size() + lst3.size()) ? lst1.size() : lst2.size() + lst3.size(); float wagetotal = 0; double totalYTDEarning = 0, totalYTDDeduction = 0; for (i = 0; i < size; i++) { masterDB.Historydetail hd = null; if (i < lst1.size()) { hd = (masterDB.Historydetail) lst1.get(i); PdfPCell s21 = new PdfPCell(new Paragraph(hd.getType(), fontSmallRegular)); s21.setHorizontalAlignment(Element.ALIGN_LEFT); if (!showborder) { s21.setBorder(0); } else { s21.setBorder(Rectangle.LEFT); } s21.setPadding(5); table31.addCell(s21); BigDecimal bd = new BigDecimal(hd.getAmount()); bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP); double newamount = bd.doubleValue(); PdfPCell s22 = new PdfPCell( new Paragraph(String.valueOf(decfm.format(newamount)), fontSmallRegular)); s22.setHorizontalAlignment(Element.ALIGN_RIGHT); if (!showborder) { s22.setBorder(0); } else { s22.setBorder(Rectangle.LEFT); } s22.setPadding(5); table31.addCell(s22); queryw.setString("userid", request.getParameter("empid")); queryw.setTimestamp("stdate", d); queryw.setTimestamp("enddate", d3); queryw.setString("type", hd.getType()); List lstw = (List) queryw.list(); double wageAmt = 0; masterDB.Historydetail hd1 = null; for (int y = 0; y < lstw.size(); y++) { hd1 = (masterDB.Historydetail) lstw.get(y); wageAmt += Double.parseDouble(hd1.getAmount()); } // PdfPCell s23 = new PdfPCell(new Paragraph(String.valueOf(decfm.format(wageAmt)), fontSmallRegular)); // s23.setHorizontalAlignment(Element.ALIGN_RIGHT); // s23.setBorder(Rectangle.LEFT); // s23.setPadding(5); // table31.addCell(s23); wagetotal = wagetotal + Float.parseFloat(hd.getAmount()); totalYTDEarning = totalYTDEarning + wageAmt; Wcount++; } else { for (int j = 0; j < 2; j++) { PdfPCell s21 = new PdfPCell(new Paragraph("", fontSmallRegular)); s21.setHorizontalAlignment(Element.ALIGN_LEFT); if (!showborder) { s21.setBorder(0); } else { s21.setBorder(Rectangle.LEFT); } s21.setPadding(5); table31.addCell(s21); } } if (i < lst2.size()) { hd = (masterDB.Historydetail) lst2.get(i); PdfPCell s24 = new PdfPCell(new Paragraph(hd.getType(), fontSmallRegular)); s24.setHorizontalAlignment(Element.ALIGN_LEFT); if (!showborder) { s24.setBorder(0); } else { s24.setBorder(Rectangle.LEFT); } s24.setPadding(5); table31.addCell(s24); BigDecimal bd = new BigDecimal(hd.getAmount()); bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP); double newamount = bd.doubleValue(); PdfPCell s25 = new PdfPCell(new Paragraph(decfm.format(newamount), fontSmallRegular)); s25.setHorizontalAlignment(Element.ALIGN_RIGHT); if (!showborder) { s25.setBorder(0); } else { s25.setBorder(Rectangle.RIGHT + Rectangle.LEFT); } s25.setPadding(5); table31.addCell(s25); queryw.setString("userid", request.getParameter("empid")); queryw.setTimestamp("stdate", d); queryw.setTimestamp("enddate", d3); queryw.setString("type", hd.getType()); List lstw1 = (List) queryw.list(); double taxAmt = 0; masterDB.Historydetail hd2 = null; for (int y = 0; y < lstw1.size(); y++) { hd2 = (masterDB.Historydetail) lstw1.get(y); taxAmt += Double.parseDouble(hd2.getAmount()); } // PdfPCell s26 = new PdfPCell(new Paragraph(decfm.format(taxAmt), fontSmallRegular)); // s26.setHorizontalAlignment(Element.ALIGN_RIGHT); // s26.setBorder(Rectangle.RIGHT + Rectangle.LEFT); // s26.setPadding(5); // table31.addCell(s26); taxtotal = taxtotal + Float.parseFloat(hd.getAmount()); totalYTDDeduction = totalYTDDeduction + taxAmt; } else { if (i - lst2.size() < lst3.size()) { hd = (masterDB.Historydetail) lst3.get(i - lst2.size()); PdfPCell s24 = new PdfPCell(new Paragraph(hd.getType(), fontSmallRegular)); if (hd.getType().equals("Unpaid_leaves")) { s24 = new PdfPCell( new Paragraph(hd.getType() + "(" + unpaidleaves + ")", fontSmallRegular)); } s24.setHorizontalAlignment(Element.ALIGN_LEFT); if (!showborder) { s24.setBorder(0); } else { s24.setBorder(Rectangle.LEFT); } s24.setPadding(5); table31.addCell(s24); BigDecimal bd = new BigDecimal(hd.getAmount()); bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP); double newamount = bd.doubleValue(); PdfPCell s25 = new PdfPCell(new Paragraph(decfm.format(newamount), fontSmallRegular)); s25.setHorizontalAlignment(Element.ALIGN_RIGHT); if (!showborder) { s25.setBorder(0); } else { s25.setBorder(Rectangle.RIGHT + Rectangle.LEFT); ; } s25.setPadding(5); table31.addCell(s25); queryw.setString("userid", request.getParameter("empid")); queryw.setTimestamp("stdate", d); queryw.setTimestamp("enddate", d3); queryw.setString("type", hd.getType()); List lstw2 = (List) queryw.list(); masterDB.Historydetail hd3 = null; double deductAmt = 0; for (int y = 0; y < lstw2.size(); y++) { hd3 = (masterDB.Historydetail) lstw2.get(y); deductAmt += Double.parseDouble(hd3.getAmount()); } // PdfPCell s26 = new PdfPCell(new Paragraph(decfm.format(deductAmt), fontSmallRegular)); // s26.setHorizontalAlignment(Element.ALIGN_RIGHT); // s26.setBorder(Rectangle.RIGHT + Rectangle.LEFT); // s26.setPadding(5); // table31.addCell(s26); taxtotal = taxtotal + Float.parseFloat(hd.getAmount()); totalYTDDeduction = totalYTDDeduction + deductAmt; } else { // if(i-lst2.size()-lst3.size() < lst4.size()){ // hd = (masterDB.Historydetail) lst4.get(i-lst2.size()-lst3.size()); // PdfPCell v24 = new PdfPCell(new Paragraph(hd.getType(), fontSmallRegular)); // v24.setHorizontalAlignment(Element.ALIGN_LEFT); // v24.setBorder(Rectangle.LEFT); // v24.setPadding(5); // table31.addCell(v24); // // BigDecimal bd = new BigDecimal(hd.getAmount()); // bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP); // double newamount = bd.doubleValue(); // // PdfPCell s25 = new PdfPCell(new Paragraph(decfm.format(newamount), fontSmallRegular)); // s25.setHorizontalAlignment(Element.ALIGN_RIGHT); // s25.setBorder(Rectangle.RIGHT + Rectangle.LEFT);; // s25.setPadding(5); // table31.addCell(s25); // }else{ for (int j = 0; j < 2; j++) { PdfPCell s21 = new PdfPCell(new Paragraph("", fontSmallRegular)); s21.setHorizontalAlignment(Element.ALIGN_LEFT); if (!showborder) { s21.setBorder(0); } else { s21.setBorder(Rectangle.LEFT + Rectangle.RIGHT); } s21.setPadding(5); table31.addCell(s21); } } } } // } PdfPCell s91 = new PdfPCell(new Paragraph(messageSource.getMessage("hrms.payroll.total.earnings", null, RequestContextUtils.getLocale(request)), fontTblMediumBold)); s91.setHorizontalAlignment(Element.ALIGN_BASELINE); s91.setHorizontalAlignment(Element.ALIGN_LEFT); if (!showborder) { s91.setBorder(0); } else { s91.setBorder(Rectangle.LEFT + Rectangle.TOP + Rectangle.BOTTOM); } s91.setPadding(5); table31.addCell(s91); BigDecimal bd = new BigDecimal(String.valueOf(wagetotal)); bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP); double newamount = bd.doubleValue(); PdfPCell s92 = new PdfPCell(new Paragraph(decfm.format(newamount), fontSmallRegular)); s92.setHorizontalAlignment(Element.ALIGN_BASELINE); s92.setHorizontalAlignment(Element.ALIGN_RIGHT); if (!showborder) { s92.setBorder(0); } else { s92.setBorder(Rectangle.LEFT + Rectangle.TOP + Rectangle.BOTTOM); } s92.setPadding(5); table31.addCell(s92); // PdfPCell s93 = new PdfPCell(new Paragraph(decfm.format(totalYTDEarning), fontSmallRegular)); // s93.setHorizontalAlignment(Element.ALIGN_BASELINE); // s93.setHorizontalAlignment(Element.ALIGN_RIGHT); // s93.setBorder(Rectangle.LEFT + Rectangle.TOP); // s93.setPadding(5); // table31.addCell(s93); PdfPCell s94 = new PdfPCell(new Paragraph(messageSource.getMessage("hrms.payroll.total.deductions", null, RequestContextUtils.getLocale(request)), fontTblMediumBold)); s94.setHorizontalAlignment(Element.ALIGN_BASELINE); s94.setHorizontalAlignment(Element.ALIGN_LEFT); if (!showborder) { s94.setBorder(0); } else { s94.setBorder(Rectangle.LEFT + Rectangle.TOP + Rectangle.BOTTOM); } s94.setPadding(5); table31.addCell(s94); bd = new BigDecimal(String.valueOf(taxtotal)); bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP); newamount = bd.doubleValue(); PdfPCell s95 = new PdfPCell(new Paragraph(decfm.format(newamount), fontSmallRegular)); s95.setHorizontalAlignment(Element.ALIGN_BASELINE); s95.setHorizontalAlignment(Element.ALIGN_RIGHT); if (!showborder) { s95.setBorder(0); } else { s95.setBorder(Rectangle.RIGHT + Rectangle.LEFT + Rectangle.TOP + Rectangle.BOTTOM); } s95.setPadding(5); table31.addCell(s95); // PdfPCell s96 = new PdfPCell(new Paragraph(decfm.format(totalYTDDeduction), fontSmallRegular)); // s96.setHorizontalAlignment(Element.ALIGN_BASELINE); // s96.setHorizontalAlignment(Element.ALIGN_RIGHT); // s96.setBorder(Rectangle.RIGHT + Rectangle.LEFT + Rectangle.TOP); // s96.setPadding(5); // table31.addCell(s96); for (int y = 0; y < 2; y++) { PdfPCell he71 = new PdfPCell(new Paragraph(" ", fontTblMediumBold)); he71.setHorizontalAlignment(Element.ALIGN_LEFT); if (!showborder) { he71.setBorder(0); } else { he71.setBorder(Rectangle.LEFT); } table31.addCell(he71); for (i = 0; i < 2; i++) { he71 = new PdfPCell(new Paragraph(" ", fontTblMediumBold)); he71.setHorizontalAlignment(Element.ALIGN_LEFT); he71.setBorder(0); table31.addCell(he71); } he71 = new PdfPCell(new Paragraph(" ", fontTblMediumBold)); he71.setHorizontalAlignment(Element.ALIGN_LEFT); // he71.setBorder(Rectangle.RIGHT); if (!showborder) { he71.setBorder(0); } else { he71.setBorder(Rectangle.RIGHT); } table31.addCell(he71); } Query query4 = session.createQuery( "from masterDB.Historydetail t where t.payhistory.historyid=:historyid and t.name=:name order by t.amount"); query4.setString("historyid", historyid); query4.setString("name", "Employer Contribution"); List lst4 = (List) query4.list(); double ectotal = 0; PdfPCell ec11 = new PdfPCell( new Paragraph(messageSource.getMessage("hrms.payroll.EmployerContribution", null, RequestContextUtils.getLocale(request)), fontTblMediumBold)); ec11.setHorizontalAlignment(Element.ALIGN_LEFT); if (!showborder) { ec11.setBorder(0); } else { ec11.setBorder(Rectangle.LEFT + Rectangle.BOTTOM); } ec11.setPadding(5); table41.addCell(ec11); PdfPCell ec12 = new PdfPCell(new Paragraph(messageSource.getMessage("hrms.payroll.amount.params", new Object[] { currSymbol }, RequestContextUtils.getLocale(request)), fontTblMediumBold)); ec12.setHorizontalAlignment(Element.ALIGN_RIGHT); ec12.setPadding(5); if (!showborder) { ec12.setBorder(0); } else { ec12.setBorder(Rectangle.LEFT + Rectangle.BOTTOM + Rectangle.RIGHT); } table41.addCell(ec12); masterDB.Historydetail hd1 = null; for (i = 0; i < lst4.size(); i++) { hd1 = (masterDB.Historydetail) lst4.get(i); PdfPCell s24 = new PdfPCell(new Paragraph(hd1.getType(), fontSmallRegular)); s24.setHorizontalAlignment(Element.ALIGN_LEFT); if (!showborder) { s24.setBorder(0); } else { s24.setBorder(Rectangle.LEFT); } s24.setPadding(5); table41.addCell(s24); bd = new BigDecimal(hd1.getAmount()); bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP); newamount = bd.doubleValue(); ectotal = ectotal + newamount; PdfPCell s25 = new PdfPCell(new Paragraph(decfm.format(newamount), fontSmallRegular)); s25.setHorizontalAlignment(Element.ALIGN_RIGHT); if (!showborder) { s25.setBorder(0); } else { s25.setBorder(Rectangle.RIGHT + Rectangle.LEFT); } s25.setPadding(5); table41.addCell(s25); } PdfPCell se91 = new PdfPCell( new Paragraph(messageSource.getMessage("hrms.payroll.total.contribution", null, RequestContextUtils.getLocale(request)), fontTblMediumBold)); se91.setHorizontalAlignment(Element.ALIGN_BASELINE); se91.setHorizontalAlignment(Element.ALIGN_LEFT); if (!showborder) { se91.setBorder(0); } else { se91.setBorder(Rectangle.LEFT + Rectangle.TOP + Rectangle.BOTTOM); } se91.setPadding(5); table41.addCell(se91); bd = new BigDecimal(String.valueOf(ectotal)); bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP); newamount = bd.doubleValue(); PdfPCell se92 = new PdfPCell(new Paragraph(decfm.format(newamount), fontSmallRegular)); se92.setHorizontalAlignment(Element.ALIGN_BASELINE); se92.setHorizontalAlignment(Element.ALIGN_RIGHT); if (!showborder) { se92.setBorder(0); } else { se92.setBorder(Rectangle.LEFT + Rectangle.TOP + Rectangle.BOTTOM + Rectangle.RIGHT); } se92.setPadding(5); table41.addCell(se92); PdfPCell Cell31 = new PdfPCell(table31); if (!showborder) { Cell31.setBorder(0); } else { Cell31.setBorder(1); } table3main.addCell(Cell31); PdfPCell mainCell4 = new PdfPCell(table3main); if (!showborder) { mainCell4.setBorder(0); } else { mainCell4.setBorder(1); } mainTable.addCell(mainCell4); PdfPCell Cell41 = new PdfPCell(table41); if (!showborder) { Cell41.setBorder(0); } else { Cell41.setBorder(1); } table7main.addCell(Cell41); PdfPCell mainCell44 = new PdfPCell(table7main); if (!showborder) { mainCell44.setBorder(0); } else { mainCell44.setBorder(1); } mainTable.addCell(mainCell44); //*************************************************************************************************************** PdfPTable table4 = new PdfPTable(2); table4.setWidthPercentage(100); for (i = 0; i < 4; i++) { PdfPCell i33 = new PdfPCell(new Paragraph(" ", fontTblMediumBold)); i33.setHorizontalAlignment(Element.ALIGN_CENTER); if (!showborder) { i33.setBorder(0); } else { i33.setBorder(Rectangle.LEFT + Rectangle.RIGHT); } table4.addCell(i33); } PdfPCell i31 = new PdfPCell(new Paragraph(messageSource.getMessage("hrms.payroll.netpay", null, RequestContextUtils.getLocale(request)) + " ", fontTblMediumBold)); i31.setHorizontalAlignment(Element.ALIGN_LEFT); if (!showborder) { i31.setBorder(0); } else { i31.setBorder(Rectangle.LEFT + Rectangle.TOP); } i31.setPadding(5); table4.addCell(i31); double netpay = 0; netpay = wagetotal - taxtotal; netpay = Math.round(netpay); String amount = numberFormatter((double) netpay, currSymbol); //PdfPCell i33 = new PdfPCell(new Paragraph(currSymbol+String.valueOf((int)netpay+".00"), fontSmallRegular)); PdfPCell i33 = new PdfPCell(new Paragraph(amount, fontTblMediumBold)); // PdfPCell i33 = new PdfPCell(new Paragraph("Rs 13,350.00", fontTblMediumBold)); i33.setHorizontalAlignment(Element.ALIGN_RIGHT); if (!showborder) { i33.setBorder(0); } else { i31.setBorder(Rectangle.RIGHT); } i33.setPadding(5); table4.addCell(i33); PdfPCell i32 = new PdfPCell(new Paragraph(messageSource.getMessage("hrms.payroll.in.words", null, RequestContextUtils.getLocale(request)), fontTblMediumBold)); i32.setHorizontalAlignment(Element.ALIGN_LEFT); if (!showborder) { i32.setBorder(0); } else { i31.setBorder(Rectangle.LEFT); } i32.setPadding(5); table4.addCell(i32); int netpayi = (int) netpay; // String netinword = EnglishNumberToWords.convert(Long.parseLong(String.valueOf(netpayi))); String netinword = "";//new EnglishNumberToWords(request).convert(netpay); PdfPCell i34 = new PdfPCell(new Paragraph(messageSource.getMessage("hrms.payroll.only", new Object[] { currname, netinword }, RequestContextUtils.getLocale(request)), fontTblMediumBold)); i34.setHorizontalAlignment(Element.ALIGN_LEFT); if (!showborder) { i34.setBorder(0); } else { i31.setBorder(Rectangle.RIGHT); } i34.setPadding(5); table4.addCell(i34); PdfPCell mainCell5 = new PdfPCell(table4); if (!showborder) { mainCell5.setBorder(0); } else { mainCell5.setBorder(1); } mainTable.addCell(mainCell5); document.add(new Paragraph("\n\n")); PdfPTable table5 = new PdfPTable(2); table5.setWidthPercentage(80); cell = new PdfPCell(new Paragraph("___________________________")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorder(0); table5.addCell(cell); cell = new PdfPCell(new Paragraph("___________________________")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorder(0); table5.addCell(cell); cell = new PdfPCell(new Paragraph(messageSource.getMessage("hrms.payroll.employee.signature", null, RequestContextUtils.getLocale(request)), fontSmallBold)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorder(0); table5.addCell(cell); cell = new PdfPCell(new Paragraph(messageSource.getMessage("hrms.payroll.manager.signature", null, RequestContextUtils.getLocale(request)), fontSmallBold)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorder(0); table5.addCell(cell); document.add(mainTable); // document.add(new Paragraph("\n\n\n\n\n\n\n\n\n\n\n\n")); // document.add(table5); document.close(); } return baos; } catch (Exception ex) { ex.printStackTrace(); return null; } finally { writer.close(); } }
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 av 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()) { 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 www .j a v 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 = 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 w w. jav a2s.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);//from w w w .ja 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 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 = 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);/*w ww . ja v a2 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()) { 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 w ww .jav a 2 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()) { 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; }