List of usage examples for com.itextpdf.text Font BOLD
int BOLD
To view the source code for com.itextpdf.text Font BOLD.
Click Source Link
From source file:edu.uc.modulocontable.general.GenerarKardexPDF.java
private void cabeceraTabla() throws DocumentException { PdfPTable tablePanelInicial = new PdfPTable(4); tablePanelInicial.setWidthPercentage(100); tablePanelInicial.setWidths(new int[] { 28, 15, 15, 15 }); tablePanelInicial.getDefaultCell().setBorder(5); tablePanelInicial.setHorizontalAlignment(2); PdfPCell cell = new PdfPCell(new Paragraph("", FontFactory.getFont("arial", 10, Font.BOLD))); cell.setHorizontalAlignment(1);//from w ww . ja va 2 s . c o m cell.setBorder(0); tablePanelInicial.addCell(cell); cell = new PdfPCell(new Paragraph("Entrada", FontFactory.getFont("arial", 10, Font.BOLD))); cell.setHorizontalAlignment(1); tablePanelInicial.addCell(cell); cell = new PdfPCell(new Paragraph("Salida", FontFactory.getFont("arial", 10, Font.BOLD))); cell.setHorizontalAlignment(1); tablePanelInicial.addCell(cell); cell = new PdfPCell(new Paragraph("Saldo", FontFactory.getFont("arial", 10, Font.BOLD))); cell.setHorizontalAlignment(1); tablePanelInicial.addCell(cell); documento.add(tablePanelInicial); }
From source file:edu.uc.modulocontable.general.GenerarKardexPDF.java
private void comprobarLIFO() throws DocumentException { PdfPTable tablePanelInicial = new PdfPTable(1); tablePanelInicial.setWidthPercentage(100); tablePanelInicial.getDefaultCell().setBorder(0); tablePanelInicial.setHorizontalAlignment(2); PdfPCell cell = new PdfPCell(new Paragraph("Comprobacin", FontFactory.getFont("arial", 10, Font.BOLD))); cell.setHorizontalAlignment(2);//from ww w. ja va2s .c o m cell.setBorder(0); tablePanelInicial.addCell(cell); documento.add(espacioBlanco.getElemento()); documento.add(espacioBlanco.getElemento()); documento.add(tablePanelInicial); documento.add(espacioBlanco.getElemento()); tablaVertical.limpiar(); int[] alineamientos = { 0, 2 }; int[] tamanos = { 20, 17 }; Vector datos = new Vector(); Vector<String> titulos = new Vector<String>(); datos.add(0); titulos.add("Inv. inicial"); datos.add(getCantidadEntrada()); titulos.add("(+) U. entrada"); datos.add(getCantidadSalida()); titulos.add("(-) U. salida"); datos.add(getSaldoCantidad()); titulos.add("(=) Stock"); String[] anArray = new String[titulos.size()]; tablaVertical.setTitulos(titulos.toArray(anArray)); tablaVertical.setContenidos(datos.toArray()); tablaVertical.setAlineamientos(alineamientos); tablaVertical.llenarTabla(true); tablaVertical.setPosicion(2); tablaVertical.setAnchoTabla(42); tablaVertical.setTamanos(tamanos); documento.add(tablaVertical.getTabla()); }
From source file:edu.uc.modulocontable.transaccion.GenerarComprobacion.java
private void cabeceraTabla() throws DocumentException { PdfPTable tablePanelInicial = new PdfPTable(5); tablePanelInicial.setWidthPercentage(100); tablePanelInicial.setWidths(new int[] { 10, 5, 5, 5, 5 }); tablePanelInicial.getDefaultCell().setBorder(5); tablePanelInicial.setHorizontalAlignment(2); PdfPCell cell = new PdfPCell(new Paragraph("", FontFactory.getFont("arial", 10, Font.BOLD))); cell.setHorizontalAlignment(1);//from w w w . j a v a 2s. co m cell.setBorder(0); tablePanelInicial.addCell(cell); cell = new PdfPCell(new Paragraph("Suma", FontFactory.getFont("arial", 10, Font.BOLD))); cell.setHorizontalAlignment(1); tablePanelInicial.addCell(cell); cell = new PdfPCell(new Paragraph("Saldos", FontFactory.getFont("arial", 10, Font.BOLD))); cell.setHorizontalAlignment(1); tablePanelInicial.addCell(cell); documento.add(tablePanelInicial); }
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 .ja v a 2 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 ww w . j av a2 s. 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 w w w . java 2 s . com // 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: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 w w w. ja v a 2 s. com*/ 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 {/*from w w w . j a va2s . c om*/ 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 {/*w w w .j av a2 s. c om*/ 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:es.baudlord.pcpartpicker.controller.BuildViewController.java
License:Open Source License
@FXML public void onBillAction(ActionEvent event) { if (build.isComplete()) { try {/*from www. ja v a 2 s. c o m*/ FileChooser chooser = new FileChooser(); chooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("PDF", "*.pdf")); File file = chooser.showSaveDialog(((Node) event.getSource()).getScene().getWindow()); if (file == null) return; Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(file)); document.open(); // Begin header generation PdfPTable table = new PdfPTable(2); table.setWidths(new int[] { 3, 7 }); com.itextpdf.text.Image image = com.itextpdf.text.Image .getInstance(App.class.getResource("img/logo.png")); image.scaleToFit(100f, 100f); PdfPCell cell = new PdfPCell(image); cell.setBorder(0); PdfPCell cell2 = new PdfPCell( new Paragraph("Hipster PC Store", new Font(Font.FontFamily.HELVETICA, 30))); cell2.setBorder(0); cell2.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); table.addCell(cell2); document.add(table); // End header generation document.add(build.createPdfPTable(new Font(Font.FontFamily.COURIER, 7))); // Begin generate date warning Calendar cal = Calendar.getInstance(); Instant now = cal.toInstant(); cal.add(Calendar.DAY_OF_MONTH, 7); Instant end = cal.toInstant(); DateTimeFormatter localFormat = DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT) .withZone(ZoneId.systemDefault()); Paragraph p1 = new Paragraph(GENERAL_BUNDLE.getString("bill.date.warning"), new Font(Font.FontFamily.COURIER, 10, Font.BOLD)); Paragraph p2 = new Paragraph( GENERAL_BUNDLE.getString("bill.date.emitted") + " " + localFormat.format(now) + "\n" + GENERAL_BUNDLE.getString("bill.date.valid") + " " + localFormat.format(end), new Font(Font.FontFamily.COURIER, 10)); p1.setAlignment(Element.ALIGN_CENTER); p2.setAlignment(Element.ALIGN_CENTER); document.add(p1); document.add(p2); // End generate date warning document.close(); Alert dialog = new Alert(Alert.AlertType.CONFIRMATION); dialog.setTitle(GENERAL_BUNDLE.getString("bill.generated")); // TODO: translate dialog.setHeaderText(GENERAL_BUNDLE.getString("bill.validity")); dialog.getButtonTypes().setAll(ButtonType.CLOSE, new ButtonType(GENERAL_BUNDLE.getString("button.Print"), ButtonBar.ButtonData.FINISH), new ButtonType(GENERAL_BUNDLE.getString("button.ShowPDF"), ButtonBar.ButtonData.OK_DONE)); dialog.showAndWait(); if (dialog.getResult() != null) { ButtonBar.ButtonData result = dialog.getResult().getButtonData(); if (result.equals(ButtonBar.ButtonData.FINISH)) { Desktop.getDesktop().print(file); } else if (result.equals(ButtonBar.ButtonData.OK_DONE)) { Desktop.getDesktop().open(file); } } } catch (DocumentException | IOException e) { e.printStackTrace(); } } else { Alert dialog = new Alert(Alert.AlertType.WARNING); dialog.getButtonTypes().setAll( new ButtonType(GENERAL_BUNDLE.getString("button.tryAgain"), ButtonBar.ButtonData.OK_DONE), ButtonType.CANCEL); dialog.setTitle(GENERAL_BUNDLE.getString("dialog.build.incomplete")); List<Product.Category> missing = build.getMissingMandatoryParts(); dialog.setHeaderText(GENERAL_BUNDLE.getString("dialog.build.needed")); final HBox content = new HBox(10); missing.forEach(category -> { Button button = new Button(App.PART_NAMES_BUNDLE.getString(category.toString())); button.setGraphic(Category.getGraphic(category, 30)); button.setContentDisplay(ContentDisplay.TOP); button.setId(category.toString()); button.setOnAction(actionEvent -> { try { Part part = pickNewPart(category); if (part != null) { saved.set(false); build.add(part); displayBuild(); if (Category.isStorage(category)) { content.getChildren() .removeIf(node -> node.getId().equals(Product.Category.HDD_SSD.toString()) || node.getId().equals(Product.Category.HDD.toString())); content.autosize(); } else { content.getChildren().remove(button); } dialog.getDialogPane().getScene().getWindow().sizeToScene(); if (content.getChildren().isEmpty()) { buttonBill.fire(); dialog.close(); } } } catch (IOException e) { e.printStackTrace(); } }); content.getChildren().add(button); }); dialog.getDialogPane().setContent(content); dialog.showAndWait(); ButtonType result = dialog.getResult(); if (result != null && result.getButtonData().equals(ButtonBar.ButtonData.OK_DONE)) { dialog.hide(); onBillAction(event); } } }