List of usage examples for com.itextpdf.text FontFactory getFont
public static Font getFont(final String fontname, final float size, final int style)
Font
-object. From source file:employee.payroll.system.MainMenu.java
private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed JFileChooser dialog = new JFileChooser(); dialog.setSelectedFile(new File("Employees Report.pdf")); int dialogResult = dialog.showSaveDialog(null); if (dialogResult == JFileChooser.APPROVE_OPTION) { String filePath = dialog.getSelectedFile().getPath(); try {//from w w w .j a v a2 s . co m // TODO add your handling code here: String sql = "select * from Staff_information"; pst = conn.prepareStatement(sql); rs = pst.executeQuery(); Document myDocument = new Document(); PdfWriter myWriter = PdfWriter.getInstance(myDocument, new FileOutputStream(filePath)); PdfPTable table = new PdfPTable(13); myDocument.open(); float[] columnWidths = new float[] { 3, 8, 7, 5, 5, 9, 8, 9, 6, 6, 6, 8, 8 }; table.setWidths(columnWidths); table.setWidthPercentage(100); //set table width to 100% myDocument.add(new Paragraph("Employees List", FontFactory.getFont(FontFactory.TIMES_BOLD, 20, Font.BOLD))); myDocument.add(new Paragraph(new Date().toString())); myDocument.add(new Paragraph( "-------------------------------------------------------------------------------------------")); table.addCell(new PdfPCell( new Paragraph("ID", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("First Name", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Surname", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell(new Paragraph("Date of Birth", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Email", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Telephone", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Address", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Department", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Gender", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Salary", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Status", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Date Hired", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Job Title", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); while (rs.next()) { table.addCell(new PdfPCell(new Paragraph(rs.getString(1), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(2), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(3), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(4), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(5), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(6), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(7), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(8), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(10), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(11), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(16), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(17), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(18), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); } myDocument.add(table); myDocument.add(new Paragraph( "--------------------------------------------------------------------------------------------")); myDocument.close(); JOptionPane.showMessageDialog(null, "Report was successfully generated"); } catch (Exception e) { JOptionPane.showMessageDialog(null, e); } finally { try { rs.close(); pst.close(); } catch (Exception e) { JOptionPane.showMessageDialog(null, e); } } } }
From source file:employee.payroll.system.MainMenu.java
private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem7ActionPerformed // TODO add your handling code here: JFileChooser dialog = new JFileChooser(); dialog.setSelectedFile(new File("Employee Allowance Report.pdf")); int dialogResult = dialog.showSaveDialog(null); if (dialogResult == JFileChooser.APPROVE_OPTION) { String filePath = dialog.getSelectedFile().getPath(); try {//from w w w. j ava2s . c o m // TODO add your handling code here: String sql = "select * from Allowance"; pst = conn.prepareStatement(sql); rs = pst.executeQuery(); Document myDocument = new Document(); PdfWriter myWriter = PdfWriter.getInstance(myDocument, new FileOutputStream(filePath)); PdfPTable table = new PdfPTable(11); myDocument.open(); float[] columnWidths = new float[] { 3, 7, 7, 5, 5, 9, 6, 5, 8, 8, 8 }; table.setWidths(columnWidths); table.setWidthPercentage(100); //set table width to 100% myDocument.add(new Paragraph("Employees Allowance List", FontFactory.getFont(FontFactory.TIMES_BOLD, 20, Font.BOLD))); myDocument.add(new Paragraph(new Date().toString())); myDocument.add(new Paragraph( "-------------------------------------------------------------------------------------------")); table.addCell(new PdfPCell( new Paragraph("ID", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Overtime", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Medical", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Bonus", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Other", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Employee ID", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Salary", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Rate", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Allowance", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("First Name", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Surname", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); while (rs.next()) { table.addCell(new PdfPCell(new Paragraph(rs.getString(1), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(2), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(3), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(4), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(5), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(6), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(7), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(8), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(9), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(10), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(11), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); } myDocument.add(table); myDocument.add(new Paragraph( "--------------------------------------------------------------------------------------------")); myDocument.close(); JOptionPane.showMessageDialog(null, "Report was successfully generated"); } catch (Exception e) { JOptionPane.showMessageDialog(null, e); } finally { try { rs.close(); pst.close(); } catch (Exception e) { JOptionPane.showMessageDialog(null, e); } } } }
From source file:employee.payroll.system.MainMenu.java
private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed // TODO add your handling code here: JFileChooser dialog = new JFileChooser(); dialog.setSelectedFile(new File("Employee Deduction Report.pdf")); int dialogResult = dialog.showSaveDialog(null); if (dialogResult == JFileChooser.APPROVE_OPTION) { String filePath = dialog.getSelectedFile().getPath(); try {/*from www.ja v a 2 s .c o m*/ // TODO add your handling code here: String sql = "select * from Deductions"; pst = conn.prepareStatement(sql); rs = pst.executeQuery(); Document myDocument = new Document(); PdfWriter myWriter = PdfWriter.getInstance(myDocument, new FileOutputStream(filePath)); PdfPTable table = new PdfPTable(8); myDocument.open(); float[] columnWidths = new float[] { 3, 7, 7, 5, 5, 9, 6, 5 }; table.setWidths(columnWidths); table.setWidthPercentage(100); //set table width to 100% myDocument.add(new Paragraph("Employees Deduction List", FontFactory.getFont(FontFactory.TIMES_BOLD, 20, Font.BOLD))); myDocument.add(new Paragraph(new Date().toString())); myDocument.add(new Paragraph( "-------------------------------------------------------------------------------------------")); table.addCell(new PdfPCell( new Paragraph("ID", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("First Name", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Surname", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Salary", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell(new Paragraph("Deduction Amount", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell(new Paragraph("Deduction Reason", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Employee ID", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Created By", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); while (rs.next()) { table.addCell(new PdfPCell(new Paragraph(rs.getString(1), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(2), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(3), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(4), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(5), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(6), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(7), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(8), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); } myDocument.add(table); myDocument.add(new Paragraph( "--------------------------------------------------------------------------------------------")); myDocument.close(); JOptionPane.showMessageDialog(null, "Report was successfully generated"); } catch (Exception e) { JOptionPane.showMessageDialog(null, e); } finally { try { rs.close(); pst.close(); } catch (Exception e) { JOptionPane.showMessageDialog(null, e); } } } }
From source file:employee.payroll.system.searchEmpSalarySlip.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed // TODO add your handling code here: String value = txt_firstname.getText(); String value0 = txt_surname.getText(); String value1 = txt_id.getText(); String value2 = txt_desig.getText(); String value3 = txt_desig.getText(); JFileChooser dialog = new JFileChooser(); dialog.setSelectedFile(new File(value + " " + value0 + "-Salary Slip" + ".pdf")); int dialogResult = dialog.showSaveDialog(null); if (dialogResult == JFileChooser.APPROVE_OPTION) { String filePath = dialog.getSelectedFile().getPath(); try {/*www .j a v a 2s. co m*/ // TODO add your handling code here: String sql = "select * from Deductions where emp_id = '" + value1 + "'"; pst = conn.prepareStatement(sql); rs = pst.executeQuery(); String val = rs.getString(5); String reason = rs.getString(6); rs.close(); pst.close(); String sq = "select * from Allowance where emp_id = '" + value1 + "'"; pst = conn.prepareStatement(sq); rs = pst.executeQuery(); int calcTotal = Integer.parseInt(txt_salary.getText()); float x = Float.valueOf(rs.getString(9)); int v = Integer.parseInt(val); float total = calcTotal + x - v; Document myDocument = new Document(); PdfWriter myWriter = PdfWriter.getInstance(myDocument, new FileOutputStream(filePath)); myDocument.open(); myDocument .add(new Paragraph("PAY SLIP", FontFactory.getFont(FontFactory.TIMES_BOLD, 20, Font.BOLD))); myDocument.add(new Paragraph(new Date().toString())); myDocument.add(new Paragraph( "-------------------------------------------------------------------------------------------")); myDocument.add((new Paragraph("EMPLOYEE DETAILS", FontFactory.getFont(FontFactory.TIMES_ROMAN, 15, Font.BOLD)))); myDocument.add((new Paragraph("Name of Employee: " + value + " " + value0, FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.PLAIN)))); myDocument.add((new Paragraph("Designation: " + value2, FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.PLAIN)))); myDocument.add((new Paragraph("Department: " + value3, FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.PLAIN)))); myDocument.add(new Paragraph( "-------------------------------------------------------------------------------------------")); myDocument .add(new Paragraph("SALARY", FontFactory.getFont(FontFactory.TIMES_ROMAN, 15, Font.BOLD))); myDocument.add(new Paragraph("Basic Salary: $" + calcTotal, FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.PLAIN))); myDocument.add(new Paragraph("Overtime: " + rs.getString(2) + " Hours", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.PLAIN))); myDocument.add(new Paragraph("Medical: $" + rs.getString(3), FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.PLAIN))); myDocument.add(new Paragraph("Bonus: $" + rs.getString(4), FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.PLAIN))); myDocument.add(new Paragraph("Other: $" + rs.getString(5), FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.PLAIN))); myDocument.add(new Paragraph( "-------------------------------------------------------------------------------------------")); myDocument.add( new Paragraph("DEDUCTION", FontFactory.getFont(FontFactory.TIMES_ROMAN, 15, Font.BOLD))); myDocument.add(new Paragraph("Deduction Details: " + reason, FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.PLAIN))); myDocument.add(new Paragraph("Total Deductions : $" + val, FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.PLAIN))); myDocument.add(new Paragraph( "-------------------------------------------------------------------------------------------")); myDocument.add(new Paragraph("TOTAL PAYMENT", FontFactory.getFont(FontFactory.TIMES_ROMAN, 15, Font.BOLD))); myDocument.add(new Paragraph("Total Earnings: " + rs.getString(9), FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.PLAIN))); myDocument.add(new Paragraph("Net Pay : " + total, FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.PLAIN))); myDocument.add(new Paragraph( "-------------------------------------------------------------------------------------------")); myDocument.newPage(); myDocument.close(); JOptionPane.showMessageDialog(null, "Report was successfully generated"); } catch (Exception e) { JOptionPane.showMessageDialog(null, e); } finally { try { rs.close(); pst.close(); } catch (Exception e) { JOptionPane.showMessageDialog(null, e); } } } }
From source file:employeepayroll.mainMenu.java
private void emp_td_rpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_emp_td_rpActionPerformed // TODO add your handling code here: JFileChooser dialog = new JFileChooser(); dialog.setSelectedFile(new File("Employee Allowance Report.pdf")); int dialogResult = dialog.showSaveDialog(null); if (dialogResult == JFileChooser.APPROVE_OPTION) { String filePath = dialog.getSelectedFile().getPath(); try {//from ww w . j a v a2 s . c o m String sql = "select * from Allowance"; pst = conn.prepareStatement(sql); rs = pst.executeQuery(); Document myDocument = new Document(); PdfWriter myWriter = PdfWriter.getInstance(myDocument, new FileOutputStream(filePath)); PdfPTable table = new PdfPTable(11); myDocument.open(); float[] columnWidths = new float[] { 3, 7, 7, 5, 5, 9, 6, 5, 8, 8, 8 }; table.setWidths(columnWidths); table.setWidthPercentage(100); //set table width to 100% myDocument.add(new Paragraph("Employees Allowance List", FontFactory.getFont(FontFactory.TIMES_BOLD, 20, Font.BOLD))); myDocument.add(new Paragraph(new Date().toString())); myDocument.add(new Paragraph( "-------------------------------------------------------------------------------------------")); table.addCell(new PdfPCell( new Paragraph("ID", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Overtime", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Medical", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Bonus", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Other", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Employee ID", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Salary", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Rate", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Allowance", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("First Name", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Surname", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); while (rs.next()) { table.addCell(new PdfPCell(new Paragraph(rs.getString(1), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(2), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(3), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(4), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(5), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(6), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(7), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(8), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(9), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(10), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(11), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); } myDocument.add(table); myDocument.add(new Paragraph( "--------------------------------------------------------------------------------------------")); myDocument.close(); JOptionPane.showMessageDialog(null, "Allowance Report was successfully generated"); } catch (Exception e) { JOptionPane.showMessageDialog(null, e); } finally { try { rs.close(); pst.close(); } catch (Exception e) { JOptionPane.showMessageDialog(null, e); } } } }
From source file:employeepayroll.mainMenu.java
private void emp_ta_rpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_emp_ta_rpActionPerformed // TODO add your handling code here: JFileChooser dialog = new JFileChooser(); dialog.setSelectedFile(new File("Employees Report.pdf")); int dialogResult = dialog.showSaveDialog(null); if (dialogResult == JFileChooser.APPROVE_OPTION) { String filePath = dialog.getSelectedFile().getPath(); try {/*w ww. j a va 2 s . co m*/ String sql = "select * from emp_info"; pst = conn.prepareStatement(sql); rs = pst.executeQuery(); Document myDocument = new Document(); PdfWriter myWriter = PdfWriter.getInstance(myDocument, new FileOutputStream(filePath)); PdfPTable table = new PdfPTable(13); myDocument.open(); float[] columnWidths = new float[] { 3, 8, 7, 5, 5, 9, 8, 9, 6, 6, 6, 8, 8 }; table.setWidths(columnWidths); table.setWidthPercentage(100); //set table width to 100% myDocument.add(new Paragraph("Employees List", FontFactory.getFont(FontFactory.TIMES_BOLD, 20, Font.BOLD))); myDocument.add(new Paragraph(new Date().toString())); myDocument.add(new Paragraph( "-------------------------------------------------------------------------------------------")); table.addCell(new PdfPCell( new Paragraph("ID", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("First Name", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Surname", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell(new Paragraph("Date of Birth", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Email", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Telephone", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Address", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Department", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Gender", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Salary", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Status", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Date Hired", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Job Title", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); while (rs.next()) { table.addCell(new PdfPCell(new Paragraph(rs.getString(1), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(2), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(3), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(4), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(5), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(6), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(7), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(8), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(10), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(11), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(16), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(17), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(18), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); } myDocument.add(table); myDocument.add(new Paragraph( "--------------------------------------------------------------------------------------------")); myDocument.close(); JOptionPane.showMessageDialog(null, "Report was successfully generated"); } catch (Exception e) { JOptionPane.showMessageDialog(null, e); } finally { try { rs.close(); pst.close(); } catch (Exception e) { JOptionPane.showMessageDialog(null, e); } } } }
From source file:employeepayroll.mainMenu.java
private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed // TODO add your handling code here: JFileChooser dialog = new JFileChooser(); dialog.setSelectedFile(new File("Employee Deduction Report.pdf")); int dialogResult = dialog.showSaveDialog(null); if (dialogResult == JFileChooser.APPROVE_OPTION) { String filePath = dialog.getSelectedFile().getPath(); try {//ww w .j ava 2 s . co m String sql = "select * from Deductions"; pst = conn.prepareStatement(sql); rs = pst.executeQuery(); Document myDocument = new Document(); PdfWriter myWriter = PdfWriter.getInstance(myDocument, new FileOutputStream(filePath)); PdfPTable table = new PdfPTable(8); myDocument.open(); float[] columnWidths = new float[] { 3, 7, 7, 5, 5, 9, 6, 5 }; table.setWidths(columnWidths); table.setWidthPercentage(100); //set table width to 100% myDocument.add(new Paragraph("Employees Deduction List", FontFactory.getFont(FontFactory.TIMES_BOLD, 20, Font.BOLD))); myDocument.add(new Paragraph(new Date().toString())); myDocument.add(new Paragraph( "-------------------------------------------------------------------------------------------")); table.addCell(new PdfPCell( new Paragraph("ID", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("First Name", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Surname", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Salary", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell(new Paragraph("Deduction Amount", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell(new Paragraph("Deduction Reason", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Employee ID", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Created By", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); while (rs.next()) { table.addCell(new PdfPCell(new Paragraph(rs.getString(1), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(2), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(3), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(4), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(5), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(6), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(7), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(8), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); } myDocument.add(table); myDocument.add(new Paragraph( "--------------------------------------------------------------------------------------------")); myDocument.close(); JOptionPane.showMessageDialog(null, "Deductions Report was successfully generated"); } catch (Exception e) { JOptionPane.showMessageDialog(null, e); } finally { try { rs.close(); pst.close(); } catch (Exception e) { JOptionPane.showMessageDialog(null, e); } } } }
From source file:employeepayroll.Searchempsalary.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed // TODO add your handling code here: String value = txt_fname.getText(); String value0 = txt_sname.getText(); int value1 = parseInt(txt_id.getText()); String value2 = txt_dest.getText(); String value3 = txt_dept.getText(); String overtime = " "; String medical = " "; String bonus = " "; String other = " "; String earnings = " "; JFileChooser dialog = new JFileChooser(); dialog.setSelectedFile(new File(value + " " + value0 + "-SalarySlip" + ".pdf")); int dialogResult = dialog.showSaveDialog(null); if (dialogResult == JFileChooser.APPROVE_OPTION) { String filePath = dialog.getSelectedFile().getPath(); try {// w w w . j a v a2 s . c om String sql = "select * from deductions where emp_id =" + value1; pst = conn.prepareStatement(sql); rs = pst.executeQuery(); while (rs.next()) { val = rs.getString(5); reason = rs.getString(6); v = Integer.parseInt(val); } rs.close(); pst.close(); String sql2 = "select * from allowance where emp_id =" + value1; pst = conn.prepareStatement(sql2); rs = pst.executeQuery(); while (rs.next()) { x = Float.valueOf(rs.getString(9)); overtime = rs.getString(2); medical = rs.getString(3); bonus = rs.getString(4); other = rs.getString(5); earnings = rs.getString(9); } //v = Integer.parseInt(val); int calcTotal = Integer.parseInt(txt_sal.getText()); float total = calcTotal + x - v; Document myDocument = new Document(); PdfWriter myWriter = PdfWriter.getInstance(myDocument, new FileOutputStream(filePath)); myDocument.open(); myDocument .add(new Paragraph("PAY SLIP", FontFactory.getFont(FontFactory.TIMES_BOLD, 20, Font.BOLD))); myDocument.add(new Paragraph(new Date().toString())); myDocument.add(new Paragraph( "-------------------------------------------------------------------------------------------")); myDocument.add((new Paragraph("EMPLOYEE DETAILS", FontFactory.getFont(FontFactory.TIMES_ROMAN, 15, Font.BOLD)))); myDocument.add((new Paragraph("Name of Employee: " + value + " " + value0, FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.PLAIN)))); myDocument.add((new Paragraph("Designation: " + value2, FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.PLAIN)))); myDocument.add((new Paragraph("Department: " + value3, FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.PLAIN)))); myDocument.add(new Paragraph( "-------------------------------------------------------------------------------------------")); myDocument .add(new Paragraph("SALARY", FontFactory.getFont(FontFactory.TIMES_ROMAN, 15, Font.BOLD))); myDocument.add(new Paragraph("Basic Salary: $" + calcTotal, FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.PLAIN))); myDocument.add(new Paragraph("Overtime: " + overtime + " Hours", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.PLAIN))); myDocument.add(new Paragraph("Medical: $" + medical, FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.PLAIN))); myDocument.add(new Paragraph("Bonus: $" + bonus, FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.PLAIN))); myDocument.add(new Paragraph("Other: $" + other, FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.PLAIN))); myDocument.add(new Paragraph( "-------------------------------------------------------------------------------------------")); myDocument.add( new Paragraph("DEDUCTION", FontFactory.getFont(FontFactory.TIMES_ROMAN, 15, Font.BOLD))); myDocument.add(new Paragraph("Deduction Details: " + reason, FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.PLAIN))); myDocument.add(new Paragraph("Total Deductions : $" + val, FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.PLAIN))); myDocument.add(new Paragraph( "-------------------------------------------------------------------------------------------")); myDocument.add(new Paragraph("TOTAL PAYMENT", FontFactory.getFont(FontFactory.TIMES_ROMAN, 15, Font.BOLD))); myDocument.add(new Paragraph("Total Earnings: " + earnings, FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.PLAIN))); myDocument.add(new Paragraph("Net Pay : " + total, FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.PLAIN))); myDocument.add(new Paragraph( "-------------------------------------------------------------------------------------------")); myDocument.newPage(); myDocument.close(); JOptionPane.showMessageDialog(null, "Report was successfully generated"); } catch (Exception e) { JOptionPane.showMessageDialog(null, e + "\n creating report problem 00x333"); } finally { try { rs.close(); pst.close(); } catch (SQLException e) { JOptionPane.showMessageDialog(null, e + "/n creating report problem 00x341"); } } } }
From source file:ems.memu.java
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed JFileChooser dialog = new JFileChooser(); dialog.setSelectedFile(new File("Employees Report.pdf")); int dialogResult = dialog.showSaveDialog(null); if (dialogResult == JFileChooser.APPROVE_OPTION) { String filePath = dialog.getSelectedFile().getPath(); try {// w ww. j a v a 2 s . c o m // TODO add your handling code here: String sql = "select * from empinfo"; pst = conn.prepareStatement(sql); rs = pst.executeQuery(); Document myDocument = new Document(); PdfWriter myWriter = PdfWriter.getInstance(myDocument, new FileOutputStream(filePath)); PdfPTable table = new PdfPTable(13); myDocument.open(); float[] columnWidths = new float[] { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }; table.setWidths(columnWidths); table.setWidthPercentage(100); //set table width to 100% myDocument.add(new Paragraph("Employees List", FontFactory.getFont(FontFactory.TIMES_BOLD, 20, Font.BOLD))); myDocument.add(new Paragraph(new Date().toString())); myDocument.add(new Paragraph( "-------------------------------------------------------------------------------------------")); table.addCell(new PdfPCell( new Paragraph("ID", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("First Name", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Surname", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell(new Paragraph("Date of Birth", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Email", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Telephone", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Address", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Department", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Gender", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Salary", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Status", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Date Hired", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Job Title", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD)))); while (rs.next()) { table.addCell(new PdfPCell(new Paragraph(rs.getString(1), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(2), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(3), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(4), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(5), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(6), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(7), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(11), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(17), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(14), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(16), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(13), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(15), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN)))); } myDocument.add(table); myDocument.add(new Paragraph( "--------------------------------------------------------------------------------------------")); myDocument.close(); JOptionPane.showMessageDialog(null, "Report was successfully generated"); } catch (Exception e) { JOptionPane.showMessageDialog(null, e); } finally { try { rs.close(); pst.close(); } catch (Exception e) { JOptionPane.showMessageDialog(null, e); } } } }
From source file:ems.memu.java
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed JFileChooser dialog = new JFileChooser(); dialog.setSelectedFile(new File("Employee Deduction Report.pdf")); int dialogResult = dialog.showSaveDialog(null); if (dialogResult == JFileChooser.APPROVE_OPTION) { String filePath = dialog.getSelectedFile().getPath(); try {/* ww w .ja v a 2s . c o m*/ // TODO add your handling code here: String sql = "select * from deduction"; pst = conn.prepareStatement(sql); rs = pst.executeQuery(); Document myDocument = new Document(); PdfWriter myWriter = PdfWriter.getInstance(myDocument, new FileOutputStream(filePath)); PdfPTable table = new PdfPTable(7); myDocument.open(); float[] columnWidths = new float[] { 8, 8, 8, 8, 8, 8, 8 }; table.setWidths(columnWidths); table.setWidthPercentage(100); //set table width to 100% myDocument.add(new Paragraph("Employees Deduction List", FontFactory.getFont(FontFactory.TIMES_BOLD, 20, Font.BOLD))); myDocument.add(new Paragraph(new Date().toString())); myDocument.add(new Paragraph( "-------------------------------------------------------------------------------------------")); table.addCell(new PdfPCell( new Paragraph("ID", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("First Name", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Surname", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Salary", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell(new Paragraph("Deduction Amount", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell(new Paragraph("Deduction Reason", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); table.addCell(new PdfPCell( new Paragraph("Employee ID", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD)))); while (rs.next()) { table.addCell(new PdfPCell(new Paragraph(rs.getString(1), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(2), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(3), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(4), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(5), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(6), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); table.addCell(new PdfPCell(new Paragraph(rs.getString(7), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN)))); } myDocument.add(table); myDocument.add(new Paragraph( "--------------------------------------------------------------------------------------------")); myDocument.close(); JOptionPane.showMessageDialog(null, "Report was successfully generated"); } catch (Exception e) { JOptionPane.showMessageDialog(null, e); } finally { try { rs.close(); pst.close(); } catch (Exception e) { JOptionPane.showMessageDialog(null, e); } } } }