List of usage examples for com.lowagie.text Phrase Phrase
public Phrase()
Phrase
without specifying a leading. 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 {/* w w w . j a v a2 s . 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,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.centurylink.mdw.designer.pages.ExportHelper.java
License:Apache License
private void printAttributesPdf(Section section, List<AttributeVO> attrs, int parentLevel) { Paragraph sTitle = new Paragraph("Activity Attributes", subSectionFont); Section subsection = section.addSection(sTitle, parentLevel == 0 ? 0 : (parentLevel + 1)); com.lowagie.text.List list = new com.lowagie.text.List(false, false, 20.0f); for (AttributeVO attr : attrs) { if (excludeAttribute(attr.getAttributeName(), attr.getAttributeValue())) continue; Phrase phrase = new Phrase(); phrase.add(new Chunk(attr.getAttributeName(), fixedWidthFont)); String v = attr.getAttributeValue(); if (v == null) v = ""; phrase.add(new Chunk(": " + v, normalFont)); list.add(new ListItem(phrase)); }//from w w w.java 2s .co m subsection.add(list); }
From source file:com.centurylink.mdw.designer.pages.ExportHelper.java
License:Apache License
private void printVariablesPdf(Chapter chapter, List<VariableVO> variables, int parentLevel) { Paragraph sTitle = new Paragraph("Process Variables", sectionFont); Section section = chapter.addSection(sTitle, parentLevel == 0 ? 0 : (parentLevel + 1)); com.lowagie.text.List list = new com.lowagie.text.List(false, false, 10.0f); for (VariableVO var : variables) { Phrase phrase = new Phrase(); phrase.add(new Chunk(var.getVariableName(), fixedWidthFont)); String v = var.getVariableType(); if (var.getDescription() != null) v += " (" + var.getDescription() + ")"; phrase.add(new Chunk(": " + v + "\n", normalFont)); list.add(new ListItem(phrase)); }// w ww . j av a 2 s.com section.add(list); }
From source file:com.develog.utils.report.engine.export.JRPdfExporter.java
License:Open Source License
/** * */// w w w. ja v a2 s. c om protected Phrase getPhrase(JRStyledText styledText, Chunk hyperlinkInfoChunk) throws JRException, DocumentException, IOException { Phrase phrase = new Phrase(); String text = styledText.getText(); int runLimit = 0; AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator(); while (runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length()) { Chunk chunk = getChunk(iterator.getAttributes(), text.substring(iterator.getIndex(), runLimit)); chunk.setMarkupAttributes(hyperlinkInfoChunk.getMarkupAttributes()); phrase.add(chunk); iterator.setIndex(runLimit); } return phrase; }
From source file:com.dlya.facturews.DlyaPdfExporter2.java
License:Open Source License
/** * */// www .ja va2 s . c o m protected Phrase getPhrase(AttributedString as, String text, JRPrintText textElement) { Phrase phrase = new Phrase(); int runLimit = 0; AttributedCharacterIterator iterator = as.getIterator(); Locale locale = getTextLocale(textElement); boolean firstChunk = true; while (runLimit < text.length() && (runLimit = iterator.getRunLimit()) <= text.length()) { Map<Attribute, Object> attributes = iterator.getAttributes(); Chunk chunk = getChunk(attributes, text.substring(iterator.getIndex(), runLimit), locale); if (firstChunk) { // only set anchor + bookmark for the first chunk in the text setAnchor(chunk, textElement, textElement); } JRPrintHyperlink hyperlink = textElement; if (hyperlink.getHyperlinkTypeValue() == HyperlinkTypeEnum.NONE) { hyperlink = (JRPrintHyperlink) attributes.get(JRTextAttribute.HYPERLINK); } setHyperlinkInfo(chunk, hyperlink); phrase.add(chunk); iterator.setIndex(runLimit); firstChunk = false; } return phrase; }
From source file:com.efficio.fieldbook.web.demo.controller.BarCodeController.java
License:Open Source License
/** * Upload file./*from w ww . j av a2s. co m*/ * * @param uploadForm the upload form * @param result the result * @param model the model * @return the string */ @ResponseBody @RequestMapping(method = RequestMethod.POST) public String uploadFile(@ModelAttribute("barCodeForm") BarCodeForm barCodeForm, BindingResult result, Model model, HttpServletResponse response) { int width = 60; int height = 48; String delimeter = "|"; StringBuilder barCodeString = new StringBuilder(); barCodeString.append(barCodeForm.getEntryNo()).append(delimeter).append(barCodeForm.getGid()) .append(delimeter).append(barCodeForm.getDesignation()).append(delimeter) .append(barCodeForm.getName()).append(delimeter).append(barCodeForm.getRep()).append(delimeter) .append(barCodeForm.getColumn()).append(delimeter).append(barCodeForm.getRange()); BitMatrix bitMatrix; try { String barCodeLabel = "3|SM114-1A-1-1-1B"; //barCodeLabel = barCodeString.toString(); bitMatrix = new Code128Writer().encode(barCodeLabel, BarcodeFormat.CODE_128, width, height, null); String imageLocation = Math.random() + ".png"; //"src/test/resources/barcode/zxing_barcode.png"; MatrixToImageWriter.writeToStream(bitMatrix, "png", new FileOutputStream(new File(imageLocation))); String currentDate = DateUtil.getCurrentDate(); String fileName = currentDate + ".doc"; response.setHeader("Content-disposition", "attachment; filename=" + fileName); File xls = new File(fileName); // the selected name + current date FileInputStream in; try { Image image1 = Image.getInstance(imageLocation); //image1.scalePercent(50); //image1.setAbsolutePosition(10f, 10f); //document.add(image1); //PageSize.A4 Document document = new Document(PageSize.LETTER); // step 2 PdfWriter.getInstance(document, new FileOutputStream(fileName)); // step 3 document.open(); // step 4 // we'll use 4 images in this example /* Image[] img = { Image.getInstance(String.format(RESOURCE, "0120903")), Image.getInstance(String.format(RESOURCE, "0290334")), Image.getInstance(String.format(RESOURCE, "0376994")), Image.getInstance(String.format(RESOURCE, "0348150")) };*/ PdfPTable table = new PdfPTable(4); table.setWidthPercentage(100); // first movie table.getDefaultCell().setVerticalAlignment(Element.ALIGN_BOTTOM); Phrase phrase = new Phrase(); phrase.add("Entry # " + barCodeForm.getEntryNo()); phrase.add("\n"); phrase.add("Designation " + barCodeForm.getDesignation()); phrase.add("\n"); phrase.add("Rep " + barCodeForm.getRep()); phrase.add("\n"); phrase.add("GID " + barCodeForm.getGid()); phrase.add("\n"); phrase.add("Trial/Nursery Name " + barCodeForm.getName()); phrase.add("\n"); phrase.add("Col " + barCodeForm.getColumn()); phrase.add("\n"); phrase.add("Range " + barCodeForm.getRange()); table.addCell(phrase); // we add the image with addCell() table.addCell(image1); table.getDefaultCell().setVerticalAlignment(Element.ALIGN_BOTTOM); table.addCell("X-Men: The Last Stand"); // we add the image with addCell() table.addCell(image1); table.getDefaultCell().setVerticalAlignment(Element.ALIGN_BOTTOM); table.addCell("X-Men: The Last Stand"); // we add the image with addCell() table.addCell(image1); // we complete the table (otherwise the last row won't be rendered) table.completeRow(); document.add(table); document.close(); in = new FileInputStream(xls); OutputStream out = response.getOutputStream(); byte[] buffer = new byte[BUFFER_SIZE]; // use bigger if you want int length = 0; while ((length = in.read(buffer)) > 0) { out.write(buffer, 0, length); } in.close(); out.close(); } catch (FileNotFoundException e) { LOG.error(e.getMessage(), e); } catch (IOException e) { LOG.error(e.getMessage(), e); } return ""; } catch (WriterException e) { LOG.error(e.getMessage(), e); } catch (Exception e) { LOG.error(e.getMessage(), e); } return show(barCodeForm, model); }
From source file:com.krawler.accounting.fontsetting.FontFamilySelector.java
License:Open Source License
public Phrase process(String text, FontContext context, Color color, Float size, Integer style) { int fsize = families.size(); if (fsize == 0) throw new IndexOutOfBoundsException("No font is defined."); if (text == null) text = ""; char cc[] = text.toCharArray(); int len = cc.length; StringBuffer sb = new StringBuffer(); Font font = null;/*from ww w . j av a 2 s . c om*/ int lastidx = -1; Phrase ret = new Phrase(); for (int k = 0; k < len; ++k) { char c = cc[k]; if (c == '\n' || c == '\r') { sb.append(c); continue; } if (Utilities.isSurrogatePair(cc, k)) { int u = Utilities.convertToUtf32(cc, k); for (int f = 0; f < fsize; ++f) { font = (Font) families.get(f).getPrimaryFont(); if (font.getBaseFont().charExists(u)) { if (lastidx != f) { if (sb.length() > 0 && lastidx != -1) { FontFamily fm = families.get(lastidx); Font fnt = fm.getFont(context); applyPropertiesToFont(fnt, color, size, style); Chunk ck = new Chunk(sb.toString(), fnt); ret.add(ck); sb.setLength(0); } lastidx = f; } sb.append(c); sb.append(cc[++k]); break; } } } else { for (int f = 0; f < fsize; ++f) { font = (Font) families.get(f).getPrimaryFont(); if (font.getBaseFont().charExists(c)) { if (lastidx != f) { if (sb.length() > 0 && lastidx != -1) { FontFamily fm = families.get(lastidx); Font fnt = fm.getFont(context); applyPropertiesToFont(fnt, color, size, style); Chunk ck = new Chunk(sb.toString(), fnt); ret.add(ck); sb.setLength(0); } lastidx = f; } sb.append(c); break; } } } } if (sb.length() > 0) { FontFamily fm = families.get(lastidx == -1 ? 0 : lastidx); Font fnt = fm.getFont(context); applyPropertiesToFont(fnt, color, size, style); Chunk ck = new Chunk(sb.toString(), fnt); ret.add(ck); } return ret; }
From source file:com.krawler.common.fontsettings.FontFamilySelector.java
License:Open Source License
public Phrase process(String text, FontContext context, Color color, Float size, Integer style) { int fsize = families.size(); if (fsize == 0) throw new IndexOutOfBoundsException("No font is defined."); if (text == null) text = ""; char cc[] = text.toCharArray(); int len = cc.length; StringBuffer sb = new StringBuffer(); Font font = null;/*from w w w. j a v a 2 s.co m*/ int lastidx = -1; Phrase ret = new Phrase(); for (int k = 0; k < len; ++k) { char c = cc[k]; if (c == '\n' || c == '\r') { sb.append(c); continue; } if (Utilities.isSurrogatePair(cc, k)) { int u = Utilities.convertToUtf32(cc, k); for (int f = 0; f < fsize; ++f) { font = (Font) families.get(f).getPrimaryFont(); if (font.getBaseFont().charExists(u)) { if (lastidx != f) { if (sb.length() > 0 && lastidx != -1) { FontFamily fm = families.get(lastidx); Font fnt = fm.getFont(context); applyPropertiesToFont(fnt, color, size, style); Chunk ck = new Chunk(sb.toString(), fnt); ret.add(ck); sb.setLength(0); } lastidx = f; } sb.append(c); sb.append(cc[++k]); break; } } } else { for (int f = 0; f < fsize; ++f) { font = (Font) families.get(f).getPrimaryFont(); if (font.getBaseFont().charExists(c)) { if (lastidx != f) { if (sb.length() > 0 && lastidx != -1) { FontFamily fm = families.get(lastidx); Font fnt = fm.getFont(context); applyPropertiesToFont(fnt, color, size, style); Chunk ck = new Chunk(sb.toString(), fnt); ret.add(ck); sb.setLength(0); } lastidx = f; } sb.append(c); break; } } } } if (sb.length() > 0) { FontFamily fm = families.get(lastidx == -1 ? 0 : lastidx); Font fnt = fm.getFont(context); applyPropertiesToFont(fnt, color, size, style); Chunk ck = new Chunk(sb.toString(), fnt); ret.add(ck); } return ret; }
From source file:com.krawler.common.fontsettings.FontFamilySelector.java
License:Open Source License
public Phrase processElement(List<Chunk> chunks, FontContext context) { Phrase phrase = new Phrase(); try {//from ww w. ja v a2 s . c om for (Chunk chunk : chunks) { phrase.add(processChunk(chunk.getContent(), context)); } } catch (Exception e) { e.printStackTrace(); } return phrase; }
From source file:com.krawler.esp.servlets.AppraisalDetails.java
License:Open Source License
private ByteArrayOutputStream AppraisalDetail(HttpServletRequest request, Session session, boolean isEmm) throws JSONException, SessionExpiredException, DocumentException, ServiceException, IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); String[] colHeader = { "Employee Name", "Appraisal Cycle Name", "Appraisal Cycle Start Date", "Appraisal Cycle End Date", "Total No. of Appraisals", "No. of Appraisals submitted", "Overall Self Comment", "Overall Appraiser Comments", "Overall Competency Score", "Competencies" }; String[] dataIndex = { "empname", "appcylename", "appcylestdate", "appcylendate", "totalappraisal", "appraisalsubmitted", "empcomment", "mancom", "manavgwght", "" }; String[] compHeader = { "Name", "Description", "Self Appraisal Score", "Self Appraisal Comment", "Appraiser Competency Score", "Appraiser Comments" }; String[] compDataIndex = { "comptename", "comptdesc", "selfcompscore", "selfcomment", "compmanwght" }; String[] compGoalHeader = { "Goals", "Assigned By", "Appraiser Rating", "Appraiser Comment", "Self Rating", "Self Comments" }; String[] compGoalDataIndex = { "gname", "assignedby", "gmanrat", "mangoalcomment", "gemprat", "empgoalcomment" }; String managerComments = ""; String scoreAvg = ""; String companyid = null;/*from w w w .ja v a 2s . co m*/ Transaction tx = null; PdfWriter writer = null; try { Document document = new Document(PageSize.A4.rotate(), 25, 25, 25, 25); writer = PdfWriter.getInstance(document, baos); writer.setPageEvent(new EndPage()); document.open(); java.awt.Color tColor = new Color(9, 9, 9); fontSmallBold.setColor(tColor); Paragraph p = new Paragraph(); PdfPTable table = new PdfPTable(2); table.setWidthPercentage(100); table.setWidths(new float[] { 55, 75 }); PdfPTable mainTable = new PdfPTable(1); mainTable.setTotalWidth(90); mainTable.setWidthPercentage(100); mainTable.setSpacingBefore(20); PdfPCell headcell = null; headcell = new PdfPCell(new Paragraph("Appraisal Details", fontHeadingMediumBold)); headcell.setBackgroundColor(new Color(0xEEEEEE)); headcell.setPadding(5); mainTable.addCell(headcell); document.add(mainTable); String str = hrmsManager.getAppraisalReport(session, request); JSONObject jobjTemplate = new JSONObject(str); com.krawler.utils.json.base.JSONArray jarr = jobjTemplate.getJSONArray("data"); String goalstr = ""; User user = (User) session.get(User.class, request.getParameter("userid")); companyid = user.getCompany().getCompanyID(); if (hrmsManager.checkModule("goal", session, request, companyid)) goalstr = hrmsManager.getAppraisalReportGoalsforGrid(session, request); com.krawler.utils.json.base.JSONArray jarr2 = jarr.getJSONObject(0).getJSONArray("data"); JSONObject jobjAppraisal = new JSONObject(jarr2.getString(0)); jarr = jobjAppraisal.getJSONArray("competencies"); int headlen = colHeader.length; if (jarr.length() < 1) { headlen = headlen - 1; } for (int i = 0; i < headlen; i++) { PdfPCell pcell = new PdfPCell(new Paragraph(colHeader[i], fontMediumBold)); pcell.setBorder(0); if (i == 0) pcell.setPaddingTop(10); pcell.setPaddingLeft(15); pcell.setPaddingBottom(4); pcell.setBorderColor(new Color(0xF2F2F2)); pcell.setHorizontalAlignment(Element.ALIGN_LEFT); pcell.setVerticalAlignment(Element.ALIGN_LEFT); table.addCell(pcell); if (!dataIndex[i].equals("mancom")) { pcell = new PdfPCell(new Paragraph(!dataIndex[i].equals("") ? !jobjAppraisal.isNull(dataIndex[i]) ? jobjAppraisal.getString(dataIndex[i]) : "" : "", fontSmallRegular)); if (i == 0) pcell.setPaddingTop(10); pcell.setBorder(0); pcell.setPaddingLeft(10); pcell.setPaddingBottom(4); pcell.setBorderColor(new Color(0xF2F2F2)); pcell.setHorizontalAlignment(Element.ALIGN_LEFT); pcell.setVerticalAlignment(Element.ALIGN_LEFT); table.addCell(pcell); } else { if (!jobjAppraisal.isNull(dataIndex[i])) { String[] spl = jobjAppraisal.getString(dataIndex[i]).split(","); String strData = ""; for (int counter = 0; counter < spl.length; counter++) { strData += spl[counter] + " \n"; } pcell = new PdfPCell(new Paragraph(strData, fontSmallRegular)); if (i == 0) pcell.setPaddingTop(10); pcell.setBorder(0); pcell.setPaddingLeft(10); pcell.setPaddingBottom(4); pcell.setBorderColor(new Color(0xF2F2F2)); pcell.setHorizontalAlignment(Element.ALIGN_LEFT); pcell.setVerticalAlignment(Element.ALIGN_LEFT); table.addCell(pcell); } } } document.add(table); PdfPTable compTable = new PdfPTable(6); compTable.setWidthPercentage(100); compTable.setWidths(new float[] { 50, 60, 30, 50, 42, 70 }); compTable.setSpacingBefore(20); compTable.setHeaderRows(1); for (int i = 0; i < compHeader.length; i++) { PdfPCell pcell = new PdfPCell(new Paragraph(compHeader[i], fontMediumBold)); pcell.setBorder(0); pcell.setBorder(PdfPCell.BOX); pcell.setPadding(4); pcell.setBorderColor(Color.GRAY); pcell.setHorizontalAlignment(Element.ALIGN_CENTER); compTable.addCell(pcell); } for (int i = 0; i < jarr.length(); i++) { jobjAppraisal = jarr.getJSONObject(i); for (int k = 0; k < compHeader.length; k++) { if (k != compHeader.length - 1) { scoreAvg = ""; if (!jobjAppraisal.isNull(compDataIndex[k]) && compDataIndex[k].equals("compmanwght")) { scoreAvg = jobjAppraisal.getString("nominalRat"); Font font = new Font(Font.HELVETICA, 8, Font.BOLD, Color.BLACK); Chunk chunk1 = new Chunk(jobjAppraisal.getString(compDataIndex[k]) + "\n\n", fontSmallRegular); Chunk chunk2 = null; if (!StringUtil.isNullOrEmpty(request.getParameter("pdfEmail"))) { // user=(User)session.get(User.class,request.getParameter("userid")); // companyid=user.getCompany().getCompanyID(); if (hrmsManager.checkModule("modaverage", session, request, companyid)) { chunk2 = new Chunk("[Mod Avg: " + scoreAvg + " ]", font); } else { chunk2 = new Chunk("[Avg: " + scoreAvg + " ]", font); } } else { if (hrmsManager.checkModule("modaverage", session, request)) { chunk2 = new Chunk("[Mod Avg: " + scoreAvg + " ]", font); } else { chunk2 = new Chunk("[Avg: " + scoreAvg + " ]", font); } } Phrase phrase1 = new Phrase(); phrase1.add(chunk1); phrase1.add(chunk2); p = new Paragraph(); p.add(phrase1); } PdfPCell pcell = new PdfPCell(); if (!scoreAvg.equals("")) { pcell = new PdfPCell(new Paragraph(p)); pcell.setPadding(0); pcell.setPaddingTop(2); pcell.setPaddingBottom(4); } else { if (!jobjAppraisal.isNull(compDataIndex[k])) { String htmlStr = jobjAppraisal.getString(compDataIndex[k]); htmlStr = htmlStr.replaceAll("\n", "<br>"); StyleSheet st = new StyleSheet(); st.loadTagStyle("body", "face", "HELVETICA"); st.loadTagStyle("body", "size", "1"); st.loadTagStyle("body", "leading", "8,0"); HTMLWorker worker = new HTMLWorker(document); StringReader stringReader = new StringReader(htmlStr); ArrayList listStr = HTMLWorker.parseToList(stringReader, st); pcell.setPadding(4); for (int htmlCount = 0; htmlCount < listStr.size(); ++htmlCount) { if (!listStr.get(htmlCount).toString().equals("[]")) pcell.addElement((Element) listStr.get(htmlCount)); } } else pcell = new PdfPCell(new Paragraph( !jobjAppraisal.isNull(compDataIndex[k]) ? hrmsManager.serverHTMLStripper( jobjAppraisal.getString(compDataIndex[k])) : "", fontSmallRegular)); } pcell.setBorder(PdfPCell.BOTTOM | PdfPCell.LEFT | PdfPCell.RIGHT); pcell.setBorderColor(Color.GRAY); pcell.setHorizontalAlignment( compDataIndex[k].equals("comptename") || compDataIndex[k].equals("comptdesc") || compDataIndex[k].equals("selfcomment") ? Element.ALIGN_LEFT : Element.ALIGN_CENTER); pcell.setVerticalAlignment( compDataIndex[k].equals("comptdesc") || compDataIndex[k].equals("comptdesc") || compDataIndex[k].equals("selfcomment") ? Element.ALIGN_LEFT : Element.ALIGN_CENTER); compTable.addCell(pcell); } else { jarr2 = jobjAppraisal.getJSONArray("comments"); managerComments = ""; int commentCount = 1; for (int j = jarr2.length() - 1; j >= 0; j--) { jobjTemplate = jarr2.getJSONObject(j); managerComments += commentCount + ") " + jobjTemplate.getString("managercomment") + "\n\n"; commentCount++; } PdfPCell pcell = new PdfPCell(new Paragraph(managerComments, fontSmallRegular)); pcell.setBorder(PdfPCell.BOTTOM | PdfPCell.LEFT | PdfPCell.RIGHT); pcell.setPadding(4); pcell.setBorderColor(Color.GRAY); pcell.setHorizontalAlignment(Element.ALIGN_LEFT); pcell.setVerticalAlignment(Element.ALIGN_LEFT); compTable.addCell(pcell); } } } PdfPTable helpTable = new PdfPTable(1); helpTable.setTotalWidth(90); helpTable.setWidthPercentage(100); helpTable.setSpacingBefore(20); PdfPCell pcell = new PdfPCell(new Paragraph( "Mod Avg. : Average of ratings after excluding a minimum and a maximum rating. For e.g, mod average of 2, 3, 2, 4, 5, 3 is (2+3+4+3)/4", helpFont)); pcell.setBorder(0); pcell.setPadding(4); pcell.setHorizontalAlignment(Element.ALIGN_LEFT); helpTable.addCell(pcell); document.add(compTable); if (!StringUtil.isNullOrEmpty(request.getParameter("pdfEmail"))) { if (hrmsManager.checkModule("modaverage", session, request, companyid)) { document.add(helpTable); } } else { if (hrmsManager.checkModule("modaverage", session, request)) { document.add(helpTable); } } if (!StringUtil.isNullOrEmpty(goalstr)) { PdfPTable compgTable = new PdfPTable(6); compgTable.setWidthPercentage(100); compgTable.setWidths(new float[] { 50, 60, 30, 50, 42, 70 }); compgTable.setSpacingBefore(20); compgTable.setHeaderRows(1); for (int i = 0; i < compGoalHeader.length; i++) { PdfPCell pgcell = new PdfPCell(new Paragraph(compGoalHeader[i], fontMediumBold)); pgcell.setBorder(0); pgcell.setBorder(PdfPCell.BOX); pgcell.setPadding(4); pgcell.setBorderColor(Color.GRAY); pgcell.setHorizontalAlignment(Element.ALIGN_CENTER); compgTable.addCell(pgcell); } JSONObject jobjTemplates = new JSONObject(goalstr); com.krawler.utils.json.base.JSONArray jarr11 = jobjTemplates.getJSONArray("data"); JSONObject jobjl = new JSONObject(); for (int i = 0; i < jarr11.length(); i++) { jobjl = jarr11.getJSONObject(i); for (int k = 0; k < compGoalHeader.length; k++) { pcell = new PdfPCell( new Paragraph( !jobjl.isNull(compGoalDataIndex[k]) ? StringUtil .serverHTMLStripper(jobjl.getString(compGoalDataIndex[k])) : "", fontSmallRegular)); pcell.setBorder(PdfPCell.BOTTOM | PdfPCell.LEFT | PdfPCell.RIGHT); pcell.setBorderColor(Color.GRAY); pcell.setPadding(4); pcell.setHorizontalAlignment(Element.ALIGN_CENTER); pcell.setVerticalAlignment(Element.ALIGN_CENTER); compgTable.addCell(pcell); } } document.add(compgTable); document.newPage(); document.close(); } if (!StringUtil.isNullOrEmpty(request.getParameter("pdfEmail"))) { String ipaddr = ""; if (StringUtil.isNullOrEmpty(request.getHeader("x-real-ip"))) { ipaddr = request.getRemoteAddr(); } else { ipaddr = request.getHeader("x-real-ip"); } User u = (User) session.get(User.class, request.getParameter("d")); User u1 = (User) session.get(User.class, request.getParameter("userid")); Appraisalcycle appcy = (Appraisalcycle) session.get(Appraisalcycle.class, request.getParameter("appraisalcycid")); //AuditAction action = (AuditAction) session.load(AuditAction.class, AuditAction.Appraisal_Report_Download); String details = ""; if (StringUtil.equal(request.getParameter("d"), request.getParameter("userid"))) { details = "User " + u.getFirstName() + " " + u.getLastName() + " has downloaded self" + " appraisal report for appraisal cycle " + appcy.getCyclename() + " through email link"; } else { details = "Reviewer " + u.getFirstName() + " " + u.getLastName() + " has downloaded " + u1.getFirstName() + " " + u1.getLastName() + "'s" + " appraisal report for appraisal cycle " + appcy.getCyclename() + " through email link"; } tx = session.beginTransaction(); //@@ProfileHandler.insertAuditLog(session, action, details, ipaddr, u); tx.commit(); } else { String details = ""; User u = null; String appCycleID = request.getParameter("appraisalcycid"); Appraisalcycle appcy = (Appraisalcycle) session.get(Appraisalcycle.class, appCycleID); String userID = request.getParameter("userid"); if (StringUtil.isNullOrEmpty(userID)) { userID = AuthHandler.getUserid(request); u = (User) session.get(User.class, userID); details = "User " + AuthHandler.getFullName(u) + " has downloaded self" + " appraisal report for appraisal cycle " + appcy.getCyclename() + " through Deskera HRMS"; } else { u = (User) session.get(User.class, userID); details = "Reviewer " + AuthHandler .getFullName((User) session.get(User.class, AuthHandler.getUserid(request))) + " has downloaded " + AuthHandler.getFullName(u) + "'s" + " appraisal report for appraisal cycle " + appcy.getCyclename() + " through Deskera HRMS"; } tx = session.beginTransaction(); //@@ProfileHandler.insertAuditLog(session, AuditAction.Appraisal_Report_Download,details,request); tx.commit(); } } catch (DocumentException ex) { throw ServiceException.FAILURE("AppraisalDetails.AppraisalDetail", ex); } catch (JSONException e) { throw ServiceException.FAILURE("AppraisalDetails.AppraisalDetail", e); } catch (Exception ex) { if (tx != null) { tx.rollback(); } throw ServiceException.FAILURE(ex.getMessage(), ex); } finally { writer.close(); } return baos; }