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:Almacen.Reporte2.java
public void cabecera1(PDF reporte, BaseFont bf, PdfPTable tabla, String titulo1, int op) { Session session = HibernateUtil.getSessionFactory().openSession(); try {//from w ww . j a v a 2s.c o m reporte.contenido.setLineWidth(0.5f); reporte.contenido.setColorStroke(new GrayColor(0.2f)); reporte.contenido.setColorFill(new GrayColor(0.9f)); Configuracion con = (Configuracion) session.get(Configuracion.class, 1); reporte.inicioTexto(); reporte.contenido.setFontAndSize(bf, 14); reporte.contenido.setColorFill(BaseColor.BLACK); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, con.getEmpresa(), 35, 755, 0); reporte.contenido.setFontAndSize(bf, 8); reporte.contenido.setColorFill(BaseColor.BLACK); String titulo = titulo1; reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, titulo, 35, 745, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Fecha:" + new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date()), 570, 745, 0); reporte.finTexto(); //agregamos renglones vacios para dejar un espacio reporte.agregaObjeto(new Paragraph(" ")); Font font = new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD); BaseColor cabecera = BaseColor.GRAY; BaseColor contenido = BaseColor.WHITE; int centro = Element.ALIGN_CENTER; for (int a = 0; a < tabla.getNumberOfColumns(); a++) { tabla.addCell(reporte.celda(t_datos2.getColumnName(a), font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); } } catch (Exception e) { System.out.println(e); } if (session != null) if (session.isOpen()) session.close(); }
From source file:Almacen.Responsiva.java
private void b_imprimirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b_imprimirActionPerformed // TODO add your handling code here: Session session = HibernateUtil.getSessionFactory().openSession(); try {/*from ww w . j a v a2s. c om*/ String empleado = ""; String puesto = ""; if (t_datos.getRowCount() > 0) { //consulta Query q = session.createSQLQuery( "select empleado.nombre as empleado, puestos.nombre as puesto from empleado inner join puestos on puestos.id_puestos=empleado.id_puesto where empleado.id_empleado=" + t_id_empleado.getText() + ";"); q.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP); List lista = q.list(); for (int i = 0; i < lista.size(); i++) { java.util.HashMap map = (java.util.HashMap) lista.get(i); empleado = (String) map.get("empleado"); puesto = (String) map.get("puesto"); } Date fecha = new Date(); DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyyHH-mm-ss");//YYYY-MM-DD HH:MM:SS String Mes[] = { "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre" }; Calendar fecha1 = new GregorianCalendar(); int anio = fecha1.get(Calendar.YEAR); int mes = fecha1.get(Calendar.MONTH); int dia = fecha1.get(Calendar.DAY_OF_MONTH); //DateFormat dateFormat1 = new SimpleDateFormat("dd-MM-yyyy");//YYYY-MM-DD HH:MM:SS String valor = dateFormat.format(fecha); File folder = new File("reportes/Responsivas"); folder.mkdirs(); PdfReader reader = new PdfReader("imagenes/CartaResponsiva.pdf"); PdfStamper stamp = new PdfStamper(reader, new FileOutputStream("reportes/Responsivas/" + valor + "CartaResponsiva.pdf")); PdfContentByte cb = stamp.getUnderContent(1); PdfContentByte cb2 = stamp.getUnderContent(2); AcroFields fdfDoc = stamp.getAcroFields(); // Creo una fuente BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); cb.beginText(); //dia try { if (dia < 9) fdfDoc.setField("Dia", "0" + String.valueOf(dia)); else fdfDoc.setField("Dia", String.valueOf(dia)); } catch (Exception e) { fdfDoc.setField("Dia", "error"); } //mes try { fdfDoc.setField("Mes", Mes[mes]); } catch (Exception e) { fdfDoc.setField("Mes", ""); } //ao try { fdfDoc.setField("Anio", String.valueOf(anio)); } catch (Exception e) { fdfDoc.setField("Anio", ""); } //nombre try { fdfDoc.setField("Nombre", empleado); } catch (Exception e) { fdfDoc.setField("Nombre", ""); } //puesto try { fdfDoc.setField("Puesto", puesto); } catch (Exception e) { fdfDoc.setField("Puesto", ""); } //tabla de herramientas float tam[] = new float[] { 250, 50, 180 }; Font font = new Font(Font.FontFamily.HELVETICA, 7, Font.BOLD); PDF reporte = new PDF(); PdfPTable tabla = reporte.crearTabla(3, tam, 100, Element.ALIGN_LEFT); tabla.setTotalWidth(tam); BaseColor cabecera = BaseColor.GRAY; BaseColor contenido = BaseColor.WHITE; int centro = Element.ALIGN_CENTER; int izquierda = Element.ALIGN_LEFT; int derecha = Element.ALIGN_RIGHT; tabla.addCell(reporte.celda("HERRAMIENTA", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("CANTIDAD", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("NOTAS", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); for (int i = 0; i < t_datos.getRowCount(); i++) { tabla.addCell(reporte.celda(t_datos.getValueAt(i, 1).toString(), font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda(String.valueOf((double) t_datos.getValueAt(i, 2)), font, contenido, centro, 0, 1, Rectangle.RECTANGLE)); if (t_datos.getValueAt(i, 3) != null) tabla.addCell(reporte.celda(t_datos.getValueAt(i, 3).toString(), font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); else tabla.addCell(reporte.celda("", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); } tabla.completeRow(); tabla.writeSelectedRows(0, -1, 70, 720, cb2); cb.endText(); stamp.close(); reporte.cerrar(); reporte.visualizar("reportes/Responsivas/" + valor + "CartaResponsiva.pdf"); } else { JOptionPane.showMessageDialog(this, "No Existe Ninguna Responsiva"); } } catch (Exception e) { System.out.println(e); JOptionPane.showMessageDialog(this, "No se pudo realizar el reporte si el archivo esta abierto"); } if (session != null) { if (session.isOpen()) { session.close(); } } }
From source file:application.OfferWindow_Controller.java
@SuppressWarnings("deprecation") public void angebot_erstellen() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException, FileNotFoundException, DocumentException { idangebot++;// w w w .j a v a 2 s . com fikusString = fikusText.getText(); perkusidtext = Integer.parseInt(perkusid.getText()); standortnametext = standortname.getText(); rabatttext = Integer.parseInt(rabatt.getText()); mengetext = Integer.parseInt(menge.getText()); gueltigkeit = Date.valueOf(todayplus30); java.sql.Connection conn = Connection.connecten(); String query3 = "SELECT * FROM Perkus WHERE idPerkus='" + perkusnametext + "'"; PreparedStatement stmt3 = conn.prepareStatement(query3); ResultSet set = stmt3.executeQuery(); while (set.next()) { customer = new PeopleCustomers(idangebot, set.getString(2), query3, query3, query3, query3, query3, query3, query3, query3, query3, query3, idangebot, idangebot); } String perkusnametext = customer.getname(); int idPerkus = perkusidtext; // PDF create step 1 // Using a custom page size /** Path to the resulting PDF file. */ final String RESULT = "./Offer_" + perkusnametext + ".pdf"; // step 2 PdfWriter.getInstance(document, new FileOutputStream(RESULT)); ; // step 3 document.open(); document.addTitle("Offer"); document.addCreationDate(); document.add(new Paragraph( "Created: " + today.getDayOfMonth() + "." + today.getMonthValue() + "." + today.getYear(), new Font(Font.FontFamily.HELVETICA, 9, Font.ITALIC))); document.add(new Paragraph(" ")); // step 4 document.add(new Paragraph("Sample Company", new Font(Font.FontFamily.HELVETICA, 9, Font.BOLD))); document.add(new Paragraph("Street House No.", new Font(Font.FontFamily.HELVETICA, 9))); document.add(new Paragraph("D-12345 City", new Font(Font.FontFamily.HELVETICA, 9))); document.add(new Paragraph("Telephone: 069-12345678, Fax: 069-23456789", new Font(Font.FontFamily.HELVETICA, 9))); document.add(new Paragraph("E-Mail: sampleCompany@email.de", new Font(Font.FontFamily.HELVETICA, 9))); document.add(new Paragraph("http://www.sampleCompany.de", new Font(Font.FontFamily.HELVETICA, 9))); document.add(new Paragraph(" ")); Paragraph paragraph = new Paragraph("To Customer:", new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD)); document.add(paragraph); document.add(new Paragraph("People Customer: " + fikusnametext, new Font(Font.FontFamily.HELVETICA, 9))); document.add( new Paragraph("Corporate Customer: " + perkusnametext, new Font(Font.FontFamily.HELVETICA, 9))); document.add(new Paragraph("Location: " + standortnametext, new Font(Font.FontFamily.HELVETICA, 9))); document.add(new Paragraph(" ")); Paragraph paragraph1 = new Paragraph("Offer " + idangebot, new Font(Font.FontFamily.HELVETICA, 20, Font.BOLDITALIC, BaseColor.BLUE)); document.add(paragraph1); document.add(new Paragraph(" ")); document.add(new Paragraph("Dear Sir or Madam, \n" + "attached you receive the following offer: \n", new Font(Font.FontFamily.HELVETICA, 13, Font.ITALIC))); document.add(new Paragraph(" ")); postion_hinzufuegen(); float preistextRabatt = erstesprodukt + zweitesprodukt; document.add(new Paragraph("Total price with discount: " + f.format(preistextRabatt) + "EUR", new Font(Font.FontFamily.HELVETICA, 15, Font.BOLD, BaseColor.BLUE))); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); if (size >= 2) { document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); } document.add(new Paragraph( "Terms and Conditions:, \n" + "- The Sample Company license terms are valid. \n" + "- All prices are quoted in addition of sales tax.\n" + "- Payment follows 30 days net. This offer is non-binding and is valid until " + +todayplus30.getDayOfMonth() + "." + todayplus30.getMonthValue() + "." + today.getYear(), new Font(Font.FontFamily.HELVETICA, 11, Font.ITALIC))); document.add(new Paragraph(" ")); document.add(new Paragraph("With kind regards,", new Font(Font.FontFamily.HELVETICA, 13))); document.add(new Paragraph("Sample Company", new Font(Font.FontFamily.HELVETICA, 13))); document.add(new Paragraph("Sample Company employee", new Font(Font.FontFamily.HELVETICA, 13))); // step 5 document.close(); Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle("Information"); alert.setHeaderText(null); alert.setContentText("The Offer PDF has been created!"); alert.showAndWait(); String query7 = "INSERT INTO Angebot(idAngebot,Produktname,Gesamtpreis,Rabatt,gueltig_bis,Perkus_idPerkus)" + "values('" + idangebot + "','" + produktnametext + "','" + preistextRabatt + "','" + rabatttext + "','" + gueltigkeit + "','" + idPerkus + "')"; PreparedStatement stmt7 = conn.prepareStatement(query7); stmt7.executeUpdate(); }
From source file:application.OfferWindow_Controller.java
public void postion_hinzufuegen() throws DocumentException { listsize = list.size();// w w w .j a v a2s . c o m size = listsize; while (listsize > 0) { System.out.println("Die: " + listsize); produkt = list.get(listsize - 1); float gesamtpreistext = produkt.getlistenspreis() * mengen.get(listsize - 1); float rabattsumme = ((float) rabatttext) / 100; float preistextRabatt = (float) (gesamtpreistext * (1 - rabattsumme)); float rabattEuro = (float) gesamtpreistext * rabattsumme; if (listsize == 2) { erstesprodukt = preistextRabatt; } zweitesprodukt = preistextRabatt; document.add(new Paragraph("Product: " + produkt.getname(), new Font(Font.FontFamily.HELVETICA, 13, Font.BOLD))); document.add(new Paragraph("Amount: " + mengen.get(listsize - 1), new Font(Font.FontFamily.HELVETICA, 13, Font.BOLD))); document.add(new Paragraph(" ")); document.add(new Paragraph( "Price of a single item without discount: " + f.format(produkt.getlistenspreis()) + "EUR", new Font(Font.FontFamily.HELVETICA, 13, Font.BOLD))); document.add(new Paragraph( "Total price for all items without discount: " + f.format(gesamtpreistext) + "EUR", new Font(Font.FontFamily.HELVETICA, 13, Font.BOLD))); document.add(new Paragraph(" ")); document.add(new Paragraph("Discount: " + rabatttext + "%", new Font(Font.FontFamily.HELVETICA, 13, Font.BOLD))); document.add(new Paragraph(" ")); document.add( new Paragraph( "Price of a single item with discount: " + f.format(preistextRabatt / mengen.get(listsize - 1)) + "EUR", new Font(Font.FontFamily.HELVETICA, 13, Font.BOLD))); document.add(new Paragraph("Total discount: " + f.format(rabattEuro) + "EUR", new Font(Font.FontFamily.HELVETICA, 13, Font.BOLD))); document.add(new Paragraph(" ")); if (listsize > 1) { document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); } listsize--; } }
From source file:AppPackage.printPDF.java
public void printNow(String id, String name, String dateRange, String underLate, String workedHours, String totalHours, String dateNow, String fDate, String lDate, String type, String empTypeRate, int lastRId, double salary) { this.id = id; this.name = name; this.dateRange = dateRange; this.underLate = underLate; this.workedHours = workedHours; this.totalHours = totalHours; this.dateNow = dateNow; this.fDate = fDate; this.lDate = lDate; this.type = type; this.empTypeRate = empTypeRate; this.lastRId = lastRId; this.salary = salary; try {/*from w w w .ja v a2 s .c om*/ Document document = new Document(); Connection conn = null; Statement st = null; conn = dbC.getConnection(); st = conn.createStatement(); String query = "SELECT * FROM schedule WHERE empId ='" + id + "'"; ResultSet rs = st.executeQuery(query); PdfWriter.getInstance(document, new FileOutputStream("reports/Report-" + reportCount + "." + lastRId + "-" + id + ".pdf")); document.open(); document.setPageSize(PageSize.LETTER); document.setMargins(0f, 0f, 0f, 0f); Image image = Image.getInstance("Resources/DTRHeaderTwo.png"); document.add(image); PdfPTable ICTable = new PdfPTable(5); ICTable.setWidthPercentage(100); ICTable.getDefaultCell().setBorder(0); //create a cell object PdfPCell ICTableCell; Phrase ICBlank = new Phrase(); Phrase ICharge = new Phrase(); Phrase ICBlanko = new Phrase(); Phrase ICBlankx = new Phrase(); Phrase IChargex = new Phrase(); ICBlank.add(new Chunk("", new Font(Font.FontFamily.HELVETICA, 7, Font.ITALIC))); ICTable.addCell(ICBlank); ICharge.add(new Chunk("_____________________", new Font(Font.FontFamily.HELVETICA, 8, Font.ITALIC))); ICTable.addCell(ICharge); ICBlanko.add(new Chunk("", new Font(Font.FontFamily.HELVETICA, 7, Font.ITALIC))); ICTable.addCell(ICBlanko); ICBlankx.add(new Chunk("", new Font(Font.FontFamily.HELVETICA, 7, Font.ITALIC))); ICTable.addCell(ICBlankx); IChargex.add(new Chunk("____________________", new Font(Font.FontFamily.HELVETICA, 8, Font.ITALIC))); ICTable.addCell(IChargex); ICTableCell = new PdfPCell(new Phrase("", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); ICTableCell.setBorder(PdfPCell.NO_BORDER); ICTable.addCell(ICTableCell); ICTableCell = new PdfPCell( new Phrase("In - Charge", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); ICTableCell.setBorder(PdfPCell.NO_BORDER); ICTable.addCell(ICTableCell); ICTableCell = new PdfPCell(new Phrase("", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); ICTableCell.setBorder(PdfPCell.NO_BORDER); ICTable.addCell(ICTableCell); ICTableCell = new PdfPCell(new Phrase("", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); ICTableCell.setBorder(PdfPCell.NO_BORDER); ICTable.addCell(ICTableCell); ICTableCell = new PdfPCell( new Phrase("In - Charge", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); ICTableCell.setBorder(PdfPCell.NO_BORDER); ICTable.addCell(ICTableCell); PdfPTable dateRecTable = new PdfPTable(5); dateRecTable.setWidthPercentage(100); dateRecTable.getDefaultCell().setBorder(0); //create a cell object PdfPCell dateRecTableCell; Phrase dRDate = new Phrase(); Phrase dRNo = new Phrase(); Phrase dRBlank = new Phrase(); Phrase dRDatex = new Phrase(); Phrase dRNox = new Phrase(); dRDate.add( new Chunk("Released #: " + lastRId + "", new Font(Font.FontFamily.HELVETICA, 7, Font.ITALIC))); dateRecTable.addCell(dRDate); dRNo.add(new Chunk("" + dateNow + "", new Font(Font.FontFamily.HELVETICA, 7, Font.ITALIC))); dateRecTable.addCell(dRNo); dRBlank.add(new Chunk("", new Font(Font.FontFamily.HELVETICA, 7, Font.ITALIC))); dateRecTable.addCell(dRBlank); dRDatex.add( new Chunk("Released #: " + lastRId + "", new Font(Font.FontFamily.HELVETICA, 7, Font.ITALIC))); dateRecTable.addCell(dRDatex); dRNox.add(new Chunk("" + dateNow + "", new Font(Font.FontFamily.HELVETICA, 7, Font.ITALIC))); dateRecTable.addCell(dRNox); PdfPTable InfoTable = new PdfPTable(5); InfoTable.setWidthPercentage(100); InfoTable.getDefaultCell().setBorder(0); //create a cell object PdfPCell InfoTableCell; Phrase infoId = new Phrase(); Phrase infoType = new Phrase(); Phrase infoBlank = new Phrase(); Phrase infoIdx = new Phrase(); Phrase infoTypex = new Phrase(); infoId.add(new Chunk("ID: " + id + "", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); InfoTable.addCell(infoId); infoType.add(new Chunk("Type: " + type + "", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); InfoTable.addCell(infoType); infoBlank.add(new Chunk("", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); InfoTable.addCell(infoBlank); infoIdx.add(new Chunk("ID: " + id + "", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); InfoTable.addCell(infoIdx); infoTypex.add(new Chunk("Type: " + type + "", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); InfoTable.addCell(infoTypex); InfoTableCell = new PdfPCell( new Phrase("Fullname: " + name + "", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); InfoTableCell.setBorder(PdfPCell.NO_BORDER); InfoTable.addCell(InfoTableCell); InfoTableCell = new PdfPCell(new Phrase("Hourly Rate: " + empTypeRate + "", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); InfoTableCell.setBorder(PdfPCell.NO_BORDER); InfoTable.addCell(InfoTableCell); InfoTableCell = new PdfPCell(new Phrase("", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); InfoTableCell.setBorder(PdfPCell.NO_BORDER); InfoTable.addCell(InfoTableCell); InfoTableCell = new PdfPCell( new Phrase("Fullname: " + name + "", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); InfoTableCell.setBorder(PdfPCell.NO_BORDER); InfoTable.addCell(InfoTableCell); InfoTableCell = new PdfPCell(new Phrase("Hourly Rate: " + empTypeRate + "", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); InfoTableCell.setBorder(PdfPCell.NO_BORDER); InfoTable.addCell(InfoTableCell); InfoTableCell = new PdfPCell(new Phrase("Date Range: \n" + dateRange + "", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); InfoTableCell.setBorder(PdfPCell.NO_BORDER); InfoTable.addCell(InfoTableCell); InfoTableCell = new PdfPCell(new Phrase("Total Hours: " + totalHours + "", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); InfoTableCell.setBorder(PdfPCell.NO_BORDER); InfoTable.addCell(InfoTableCell); InfoTableCell = new PdfPCell(new Phrase("", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); InfoTableCell.setBorder(PdfPCell.NO_BORDER); InfoTable.addCell(InfoTableCell); InfoTableCell = new PdfPCell(new Phrase("Date Range: \n" + dateRange + "", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); InfoTableCell.setBorder(PdfPCell.NO_BORDER); InfoTable.addCell(InfoTableCell); InfoTableCell = new PdfPCell(new Phrase("Total Hours: " + totalHours + "", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); InfoTableCell.setBorder(PdfPCell.NO_BORDER); InfoTable.addCell(InfoTableCell); InfoTableCell = new PdfPCell(new Phrase("Late & Under Time: " + underLate + "", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); InfoTableCell.setBorder(PdfPCell.NO_BORDER); InfoTable.addCell(InfoTableCell); InfoTableCell = new PdfPCell(new Phrase("Worked Hours: " + workedHours + "", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); InfoTableCell.setBorder(PdfPCell.NO_BORDER); InfoTable.addCell(InfoTableCell); InfoTableCell = new PdfPCell(new Phrase("", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); InfoTableCell.setBorder(PdfPCell.NO_BORDER); InfoTable.addCell(InfoTableCell); InfoTableCell = new PdfPCell(new Phrase("Late & Under Time: " + underLate + "", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); InfoTableCell.setBorder(PdfPCell.NO_BORDER); InfoTable.addCell(InfoTableCell); InfoTableCell = new PdfPCell(new Phrase("Worked Hours: " + workedHours + "", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); InfoTableCell.setBorder(PdfPCell.NO_BORDER); InfoTable.addCell(InfoTableCell); InfoTableCell = new PdfPCell( new Phrase("Salary: " + salary + " PHP", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); InfoTableCell.setBorder(PdfPCell.NO_BORDER); InfoTable.addCell(InfoTableCell); InfoTableCell = new PdfPCell(new Phrase("", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); InfoTableCell.setBorder(PdfPCell.NO_BORDER); InfoTable.addCell(InfoTableCell); InfoTableCell = new PdfPCell(new Phrase("", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); InfoTableCell.setBorder(PdfPCell.NO_BORDER); InfoTable.addCell(InfoTableCell); InfoTableCell = new PdfPCell( new Phrase("Salary: " + salary + " PHP", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); InfoTableCell.setBorder(PdfPCell.NO_BORDER); InfoTable.addCell(InfoTableCell); InfoTableCell = new PdfPCell(new Phrase("", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); InfoTableCell.setBorder(PdfPCell.NO_BORDER); InfoTable.addCell(InfoTableCell); PdfPTable SchedTable = new PdfPTable(17); SchedTable.setWidthPercentage(100); SchedTable.getDefaultCell().setBorder(0); //create a cell object PdfPCell SchedTableCell; Phrase phraseDayS = new Phrase(); Phrase phraseAMTotal = new Phrase(); Phrase phraseAMStart = new Phrase(); Phrase phraseAMEnd = new Phrase(); Phrase phrasePMTotal = new Phrase(); Phrase phrasePMStart = new Phrase(); Phrase phrasePMEnd = new Phrase(); Phrase phraseTotalTime = new Phrase(); Phrase phraseBlankS = new Phrase(); Phrase phraseDaySx = new Phrase(); Phrase phraseAMTotalx = new Phrase(); Phrase phraseAMStartx = new Phrase(); Phrase phraseAMEndx = new Phrase(); Phrase phrasePMTotalx = new Phrase(); Phrase phrasePMStartx = new Phrase(); Phrase phrasePMEndx = new Phrase(); Phrase phraseTotalTimex = new Phrase(); phraseDayS.add(new Chunk("Day", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); SchedTable.addCell(phraseDayS); phraseAMStart.add(new Chunk("AM Start", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); SchedTable.addCell(phraseAMStart); phraseAMEnd.add(new Chunk("AM End", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); SchedTable.addCell(phraseAMEnd); phraseAMTotal.add(new Chunk("AM Total", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); SchedTable.addCell(phraseAMTotal); phrasePMStart.add(new Chunk("PM Start", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); SchedTable.addCell(phrasePMStart); phrasePMEnd.add(new Chunk("PM End", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); SchedTable.addCell(phrasePMEnd); phrasePMTotal.add(new Chunk("PM Total", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); SchedTable.addCell(phrasePMTotal); phraseTotalTime.add(new Chunk("Total", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); SchedTable.addCell(phraseTotalTime); phraseBlankS.add(new Chunk(" ", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); SchedTable.addCell(phraseBlankS); phraseDaySx.add(new Chunk("Day", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); SchedTable.addCell(phraseDaySx); phraseAMStartx.add(new Chunk("AM Start", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); SchedTable.addCell(phraseAMStartx); phraseAMEndx.add(new Chunk("AM End", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); SchedTable.addCell(phraseAMEndx); phraseAMTotalx.add(new Chunk("AM Total", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); SchedTable.addCell(phraseAMTotalx); phrasePMStartx.add(new Chunk("PM Start", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); SchedTable.addCell(phrasePMStartx); phrasePMEndx.add(new Chunk("PM End", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); SchedTable.addCell(phrasePMEndx); phrasePMTotalx.add(new Chunk("PM Total", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); SchedTable.addCell(phrasePMTotalx); phraseTotalTimex.add(new Chunk("Total", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); SchedTable.addCell(phraseTotalTimex); while (rs.next()) { SimpleDateFormat readingFormat = new SimpleDateFormat("HH:mm:ss"); SimpleDateFormat outputFormat = new SimpleDateFormat("hh:mm a"); String dayxxx = rs.getString("day"); String amStartxx = rs.getString("amStart"); String amEndxx = rs.getString("amEnd"); String pmStartxx = rs.getString("pmStart"); String pmEndxx = rs.getString("pmEnd"); String amTotalxx = rs.getString("amTotal"); String pmTotalxx = rs.getString("pmTotal"); String totalHoursxx = rs.getString("totalTime"); String blank = " "; String amStart = null; String amEnd = null; String amTotal = null; String pmStart = null; String pmEnd = null; String pmTotal = null; String totalHoursx = null; Date dayx = new SimpleDateFormat("EEEE").parse(dayxxx); SimpleDateFormat sdfxxx = new SimpleDateFormat("EEE"); String day = sdfxxx.format(dayx); System.out.println(day + " day"); try { Date amStartTxx = readingFormat.parse(amStartxx); amStart = outputFormat.format(amStartTxx); if (amStart.equals("12:00 AM")) { amStart = "00:00"; } } catch (Exception e) { e.printStackTrace(); } try { Date amEndTx = readingFormat.parse(amEndxx); amEnd = outputFormat.format(amEndTx); if (amEnd.equals("12:00 AM")) { amEnd = "00:00"; } } catch (Exception e) { e.printStackTrace(); } try { Date amTotalTx = readingFormat.parse(amTotalxx); amTotal = outputFormat.format(amTotalTx); if (amTotal.equals("12:00 AM")) { amTotal = "00:00"; } } catch (Exception e) { e.printStackTrace(); } try { Date pmStartTxx = readingFormat.parse(pmStartxx); pmStart = outputFormat.format(pmStartTxx); if (pmStart.equals("12:00 AM")) { pmStart = "00:00"; } } catch (Exception e) { e.printStackTrace(); } try { Date pmEndTxx = readingFormat.parse(pmEndxx); pmEnd = outputFormat.format(pmEndTxx); if (pmEnd.equals("12:00 AM")) { pmEnd = "00:00"; } } catch (Exception e) { e.printStackTrace(); } try { Date pmTotalTxx = readingFormat.parse(pmTotalxx); pmTotal = outputFormat.format(pmTotalTxx); if (pmTotal.equals("12:00 AM")) { pmTotal = "00:00"; } } catch (Exception e) { e.printStackTrace(); } try { Date totalHoursxT = readingFormat.parse(totalHoursxx); totalHoursx = outputFormat.format(totalHoursxT); if (totalHoursx.equals("12:00 AM")) { totalHoursx = "00:00"; } } catch (Exception e) { e.printStackTrace(); } System.out.println(day); System.out.println(amStart); System.out.println(amEnd); System.out.println(amTotal); System.out.println(pmStart); System.out.println(pmEnd); System.out.println(pmTotal); System.out.println(totalHoursx); SchedTableCell = new PdfPCell(new Phrase(day, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); SchedTableCell.setBorder(PdfPCell.NO_BORDER); SchedTable.addCell(SchedTableCell); SchedTableCell = new PdfPCell( new Phrase(amStart, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); SchedTableCell.setBorder(PdfPCell.NO_BORDER); SchedTable.addCell(SchedTableCell); SchedTableCell = new PdfPCell( new Phrase(amEnd, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); SchedTableCell.setBorder(PdfPCell.NO_BORDER); SchedTable.addCell(SchedTableCell); SchedTableCell = new PdfPCell( new Phrase(amTotal, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); SchedTableCell.setBorder(PdfPCell.NO_BORDER); SchedTable.addCell(SchedTableCell); SchedTableCell = new PdfPCell( new Phrase(pmStart, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); SchedTableCell.setBorder(PdfPCell.NO_BORDER); SchedTable.addCell(SchedTableCell); SchedTableCell = new PdfPCell( new Phrase(pmEnd, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); SchedTableCell.setBorder(PdfPCell.NO_BORDER); SchedTable.addCell(SchedTableCell); SchedTableCell = new PdfPCell( new Phrase(pmTotal, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); SchedTableCell.setBorder(PdfPCell.NO_BORDER); SchedTable.addCell(SchedTableCell); SchedTableCell = new PdfPCell( new Phrase(totalHoursx, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); SchedTableCell.setBorder(PdfPCell.NO_BORDER); SchedTable.addCell(SchedTableCell); SchedTableCell = new PdfPCell(new Phrase(blank)); SchedTableCell.setBorder(PdfPCell.NO_BORDER); SchedTable.addCell(SchedTableCell); SchedTableCell = new PdfPCell(new Phrase(day, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); SchedTableCell.setBorder(PdfPCell.NO_BORDER); SchedTable.addCell(SchedTableCell); SchedTableCell = new PdfPCell( new Phrase(amStart, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); SchedTableCell.setBorder(PdfPCell.NO_BORDER); SchedTable.addCell(SchedTableCell); SchedTableCell = new PdfPCell( new Phrase(amEnd, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); SchedTableCell.setBorder(PdfPCell.NO_BORDER); SchedTable.addCell(SchedTableCell); SchedTableCell = new PdfPCell( new Phrase(amTotal, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); SchedTableCell.setBorder(PdfPCell.NO_BORDER); SchedTable.addCell(SchedTableCell); SchedTableCell = new PdfPCell( new Phrase(pmStart, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); SchedTableCell.setBorder(PdfPCell.NO_BORDER); SchedTable.addCell(SchedTableCell); SchedTableCell = new PdfPCell( new Phrase(pmEnd, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); SchedTableCell.setBorder(PdfPCell.NO_BORDER); SchedTable.addCell(SchedTableCell); SchedTableCell = new PdfPCell( new Phrase(pmTotal, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); SchedTableCell.setBorder(PdfPCell.NO_BORDER); SchedTable.addCell(SchedTableCell); SchedTableCell = new PdfPCell( new Phrase(totalHoursx, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); SchedTableCell.setBorder(PdfPCell.NO_BORDER); SchedTable.addCell(SchedTableCell); } PdfPTable DTRTable = new PdfPTable(17); DTRTable.setWidthPercentage(100); DTRTable.getDefaultCell().setBorder(0); //create a cell object PdfPCell DTRTableCell; Phrase phraseDay = new Phrase(); Phrase phraseDate = new Phrase(); Phrase phraseAMIn = new Phrase(); Phrase phraseAMOut = new Phrase(); Phrase phrasePMIn = new Phrase(); Phrase phrasePMOut = new Phrase(); Phrase phraseHours = new Phrase(); Phrase phraseUTL = new Phrase(); Phrase phraseBlank = new Phrase(); Phrase phraseDayx = new Phrase(); Phrase phraseDatex = new Phrase(); Phrase phraseAMInx = new Phrase(); Phrase phraseAMOutx = new Phrase(); Phrase phrasePMInx = new Phrase(); Phrase phrasePMOutx = new Phrase(); Phrase phraseHoursx = new Phrase(); Phrase phraseUTLx = new Phrase(); phraseDay.add(new Chunk("Day", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); DTRTable.addCell(phraseDay); phraseDate.add(new Chunk("Date", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); DTRTable.addCell(phraseDate); phraseAMIn.add(new Chunk("AM IN", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); DTRTable.addCell(phraseAMIn); phraseAMOut.add(new Chunk("AM OUT", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); DTRTable.addCell(phraseAMOut); phrasePMIn.add(new Chunk("PM IN", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); DTRTable.addCell(phrasePMIn); phrasePMOut.add(new Chunk("PM OUT", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); DTRTable.addCell(phrasePMOut); phraseHours.add(new Chunk("Hours", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); DTRTable.addCell(phraseHours); phraseUTL.add(new Chunk("Late/U.T", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); DTRTable.addCell(phraseUTL); phraseBlank.add(new Chunk(" ", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); DTRTable.addCell(phraseBlank); phraseDayx.add(new Chunk("Day", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); DTRTable.addCell(phraseDayx); phraseDatex.add(new Chunk("Date", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); DTRTable.addCell(phraseDatex); phraseAMInx.add(new Chunk("AM IN", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); DTRTable.addCell(phraseAMInx); phraseAMOutx.add(new Chunk("AM OUT", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); DTRTable.addCell(phraseAMOutx); phrasePMInx.add(new Chunk("PM IN", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); DTRTable.addCell(phrasePMInx); phrasePMOutx.add(new Chunk("PM OUT", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); DTRTable.addCell(phrasePMOutx); phraseHoursx.add(new Chunk("Hours", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); DTRTable.addCell(phraseHoursx); phraseUTLx.add(new Chunk("Late/U.T", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD))); DTRTable.addCell(phraseUTLx); try { Connection connx = null; Statement stx = null; connx = dbC.getConnection(); stx = connx.createStatement(); String queryx = "SELECT timeinout.day, timeinout.date, schedule.totalTime, schedule.amTotal, " + "schedule.amStart, timeinout.amTimeIn, schedule.amEnd, timeinout.amTimeOut, " + "schedule.pmTotal, schedule.pmStart, timeinout.pmTimeIn, schedule.pmEnd, " + "timeinout.pmTimeOut FROM timeinout LEFT JOIN " + "(schedule) ON (schedule.empId = timeinout.empId AND timeinout.day = schedule.day) WHERE " + "timeinout.empId ='" + id + "' AND schedule.empId = '" + id + "' AND date(`Date`) >= '" + fDate + "' " + "AND date(`Date`) <= '" + lDate + "'"; ResultSet rsx = stx.executeQuery(queryx); while (rsx.next()) { String day = rsx.getString("timeinout.day"); String date = rsx.getString("timeinout.date"); String amStartDB = rsx.getString("schedule.amStart"); String amIn = rsx.getString("timeinout.amTimeIn"); String amEndDB = rsx.getString("schedule.amEnd"); String amOut = rsx.getString("timeinout.amTimeOut"); String pmStartDB = rsx.getString("schedule.pmStart"); String pmIn = rsx.getString("timeinout.pmTimeIn"); String pmEndDB = rsx.getString("schedule.pmEnd"); String pmOut = rsx.getString("timeinout.pmTimeOut"); String totTime = rsx.getString("schedule.totalTime"); String wHours; String blank = " "; String dayx = rsx.getString("timeinout.day"); String datex = rsx.getString("timeinout.date"); // String amStartDBx = rsx.getString("schedule.amStart"); // String amInx = rsx.getString("timeinout.amTimeIn"); // String amEndDBx = rsx.getString("schedule.amEnd"); // String amOutx = rsx.getString("timeinout.amTimeOut"); // String pmStartDBx = rsx.getString("schedule.pmStart"); // String pmInx = rsx.getString("timeinout.pmTimeIn"); // String pmEndDBx = rsx.getString("schedule.pmEnd"); String pmOutx = rsx.getString("timeinout.pmTimeOut"); String totalAM = rsx.getString("schedule.amTotal"); String totalPM = rsx.getString("schedule.pmTotal"); String totTimex = rsx.getString("schedule.totalTime"); String wHoursx; parser.setTimeZone(TimeZone.getTimeZone("UTC")); if (!amEndDB.equals("00:00:00") && !amOut.equals("00:00:00")) { Start = parser.parse(amEndDB); In = parser.parse(amOut); if (Start.after(In)) { amOutDiff = tDiff.timeDiff(amOut, amEndDB); amOutDiffT = parser.parse(amOutDiff); amOutDiffTotal += amOutDiffT.getTime(); } else { amOutDiff = "00:00:00"; } } else { amOutDiff = totalAM; amOutDiffT = parser.parse(amOutDiff); amOutDiffTotal += amOutDiffT.getTime(); } Start = parser.parse(amStartDB); In = parser.parse(amIn); if (Start.after(In)) { amInDiff = "00:00:00"; } else if (amOutDiff.equals(totalAM)) { amInDiff = "00:00:00"; } else { amInDiff = tDiff.timeDiff(amStartDB, amIn); amInDiffT = parser.parse(amInDiff); amInDiffTotal += amInDiffT.getTime(); } if (!pmEndDB.equals("00:00:00") && !pmOut.equals("00:00:00")) { Start = parser.parse(pmEndDB); In = parser.parse(pmOut); if (Start.after(In)) { pmOutDiff = tDiff.timeDiff(pmOut, pmEndDB); pmOutDiffT = parser.parse(pmOutDiff); pmOutDiffTotal += pmOutDiffT.getTime(); } else { pmOutDiff = "00:00:00"; } } else { pmOutDiff = totalPM; pmOutDiffT = parser.parse(pmOutDiff); pmOutDiffTotal += pmOutDiffT.getTime(); } Start = parser.parse(pmStartDB); In = parser.parse(pmIn); if (Start.after(In)) { pmInDiff = "00:00:00"; } else if (pmOutDiff.equals(totalPM)) { pmInDiff = "00:00:00"; } else { pmInDiff = tDiff.timeDiff(pmStartDB, pmIn); pmInDiffT = parser.parse(pmInDiff); pmInDiffTotal += pmInDiffT.getTime(); } Date totH = parser.parse(totTimex); long totHTotal = 0; totHTotal += totH.getTime(); Date amInDiffx = parser.parse(amInDiff); Date amOutDiffx = parser.parse(amOutDiff); Date pmInDiffx = parser.parse(pmInDiff); Date pmOutDiffx = parser.parse(pmOutDiff); long workedHoursxxx = amInDiffx.getTime() + amOutDiffx.getTime() + pmInDiffx.getTime() + pmOutDiffx.getTime(); long hoursx = workedHoursxxx / 3600000; long minutesx = (workedHoursxxx % 3600000) / 60000; wHours = String.format("%02d:%02d", hoursx, minutesx); wHoursx = String.format("%02d:%02d", hoursx, minutesx); Date dayxxx = new SimpleDateFormat("EEEE").parse(day); SimpleDateFormat sdfxxx = new SimpleDateFormat("EEE"); String newDayxx = sdfxxx.format(dayxxx); System.out.println(newDayxx); DTRTableCell = new PdfPCell( new Phrase(newDayxx, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); DTRTableCell.setBorder(PdfPCell.NO_BORDER); DTRTable.addCell(DTRTableCell); Date datexx = new SimpleDateFormat("yyyy-MM-dd").parse(date); SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yy"); String newDate = sdf.format(datexx); System.out.println(newDate); DTRTableCell = new PdfPCell( new Phrase(newDate, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); DTRTableCell.setBorder(PdfPCell.NO_BORDER); DTRTable.addCell(DTRTableCell); System.out.println(amIn); DTRTableCell = new PdfPCell( new Phrase(amIn, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); DTRTableCell.setBorder(PdfPCell.NO_BORDER); DTRTable.addCell(DTRTableCell); System.out.println(amOut); DTRTableCell = new PdfPCell( new Phrase(amOut, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); DTRTableCell.setBorder(PdfPCell.NO_BORDER); DTRTable.addCell(DTRTableCell); System.out.println(pmIn); DTRTableCell = new PdfPCell( new Phrase(pmIn, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); DTRTableCell.setBorder(PdfPCell.NO_BORDER); DTRTable.addCell(DTRTableCell); System.out.println(pmOut); DTRTableCell = new PdfPCell( new Phrase(pmOut, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); DTRTableCell.setBorder(PdfPCell.NO_BORDER); DTRTable.addCell(DTRTableCell); System.out.println(totTime); DTRTableCell = new PdfPCell( new Phrase(totTime, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); DTRTableCell.setBorder(PdfPCell.NO_BORDER); DTRTable.addCell(DTRTableCell); System.out.println(wHours); DTRTableCell = new PdfPCell( new Phrase(wHours, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); DTRTableCell.setBorder(PdfPCell.NO_BORDER); DTRTable.addCell(DTRTableCell); System.out.println(blank); DTRTableCell = new PdfPCell(new Phrase(blank)); DTRTableCell.setBorder(PdfPCell.NO_BORDER); DTRTable.addCell(DTRTableCell); Date dayxx = new SimpleDateFormat("EEEE").parse(dayx); SimpleDateFormat sdfxx = new SimpleDateFormat("EEE"); String newDayx = sdfxx.format(dayxx); System.out.println(newDayx); DTRTableCell = new PdfPCell( new Phrase(newDayx, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); DTRTableCell.setBorder(PdfPCell.NO_BORDER); DTRTable.addCell(DTRTableCell); Date datexxx = new SimpleDateFormat("yyyy-MM-dd").parse(datex); SimpleDateFormat sdfx = new SimpleDateFormat("dd-MM-yy"); String newDatex = sdfx.format(datexxx); System.out.println(newDatex); DTRTableCell = new PdfPCell( new Phrase(newDatex, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); DTRTableCell.setBorder(PdfPCell.NO_BORDER); DTRTable.addCell(DTRTableCell); System.out.println(amIn); DTRTableCell = new PdfPCell( new Phrase(amIn, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); DTRTableCell.setBorder(PdfPCell.NO_BORDER); DTRTable.addCell(DTRTableCell); System.out.println(amOut); DTRTableCell = new PdfPCell( new Phrase(amOut, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); DTRTableCell.setBorder(PdfPCell.NO_BORDER); DTRTable.addCell(DTRTableCell); System.out.println(pmIn); DTRTableCell = new PdfPCell( new Phrase(pmIn, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); DTRTableCell.setBorder(PdfPCell.NO_BORDER); DTRTable.addCell(DTRTableCell); System.out.println(pmOutx); DTRTableCell = new PdfPCell( new Phrase(pmOutx, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); DTRTableCell.setBorder(PdfPCell.NO_BORDER); DTRTable.addCell(DTRTableCell); System.out.println(totTimex); DTRTableCell = new PdfPCell( new Phrase(totTimex, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); DTRTableCell.setBorder(PdfPCell.NO_BORDER); DTRTable.addCell(DTRTableCell); System.out.println(wHoursx); DTRTableCell = new PdfPCell( new Phrase(wHoursx, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL))); DTRTableCell.setBorder(PdfPCell.NO_BORDER); DTRTable.addCell(DTRTableCell); } } catch (Exception e) { JOptionPane.showMessageDialog(null, e); } document.add(dateRecTable); document.add(InfoTable); document.add(new Paragraph( "----------------------------------------------------------------------- ----------------------------------------------------------------------", FontFactory.getFont(FontFactory.HELVETICA, 10, Font.BOLD, BaseColor.BLACK))); document.add(new Paragraph( " Schedule Schedule\n", FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL, BaseColor.BLACK))); document.add(SchedTable); document.add(new Paragraph( "----------------------------------------------------------------------- ----------------------------------------------------------------------", FontFactory.getFont(FontFactory.HELVETICA, 10, Font.BOLD, BaseColor.BLACK))); document.add(new Paragraph( " Dailty Time Record Dailty Time Record\n", FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL, BaseColor.BLACK))); document.add(DTRTable); document.add(ICTable); try { conn = dbC.getConnection(); PreparedStatement stmtx = conn.prepareStatement("INSERT INTO released" + "(empId, firstDate, lastDate, totalHours, lateUnderTime, workedHours, fileName, salary) VALUES (?,?,?,?,?,?,?,?)"); stmtx.setString(1, id); stmtx.setString(2, fDate); stmtx.setString(3, lDate); stmtx.setString(4, totalHours); stmtx.setString(5, workedHours); stmtx.setString(6, totalHours); stmtx.setString(7, "Report-" + reportCount + "." + lastRId + "-" + id + ".pdf"); stmtx.setString(8, salary + ""); stmtx.executeUpdate(); } catch (SQLException se) { //Handle errors for JDBC se.printStackTrace(); } catch (Exception e) { //Handle errors for Class.forName e.printStackTrace(); } finally { //finally block used to close resources try { if (stmt != null) conn.close(); } catch (SQLException se) { } // do nothing try { if (conn != null) conn.close(); } catch (SQLException se) { se.printStackTrace(); } //end finally try } //end try document.close(); } catch (DocumentException | IOException | SQLException e) { JOptionPane.showMessageDialog(null, e); } catch (ParseException ex) { Logger.getLogger(printPDF.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:ara.Confirmsec.java
public void myfunction() throws IOException, DocumentException { String a = preres.getText();/*from w ww .j av a2s . com*/ File file = new File(DEST); file.getParentFile().mkdirs(); Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(DEST)); document.open(); Image image = Image.getInstance("logo.jpg"); document.add(image); Font chapterFont = FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD); Font paragraphFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL); Font small = FontFactory.getFont(FontFactory.HELVETICA, 5, Font.BOLD); String date = new Date().toString(); Paragraph paragraph1 = new Paragraph(date); Paragraph paragraph2 = new Paragraph("To Whom it May Concern", chapterFont); paragraph2.setAlignment(Element.ALIGN_CENTER); paragraph1.setAlignment(Element.ALIGN_RIGHT); paragraph2.setSpacingBefore(20f); paragraph2.setSpacingAfter(10f); Paragraph paragraph3 = new Paragraph(a, paragraphFont); paragraph3.setSpacingAfter(20f); Paragraph paragraph4 = new Paragraph("Registrar"); paragraph4.setAlignment(Element.ALIGN_RIGHT); paragraph4.setSpacingAfter(100f); Paragraph paragraph5 = new Paragraph( "This is a digitally signed document. Use Ref No. " + c + " to verify.", small); document.add(paragraph1); document.add(paragraph2); document.add(paragraph3); document.add(paragraph4); document.add(paragraph5); document.close(); JOptionPane.showMessageDialog(null, "Document Generated."); }
From source file:at.jps.sanction.core.io.file.PDFFileOutputWorker.java
License:Open Source License
@Override public void handleMessage(final AnalysisResult message) { super.handleMessage(message); try {/* w w w . j ava 2 s . c o m*/ logger.info("write Message: " + message.getMessage().getId()); final Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(getFilename())); document.open(); final Font chapterFont = FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD); final Font paragraphFont = FontFactory.getFont(FontFactory.HELVETICA, 14, Font.NORMAL); Chunk chunk = new Chunk("Message", chapterFont); Chapter chapter = new Chapter(new Paragraph(chunk), 1); chapter.setNumberDepth(0); chapter.add(new Paragraph(message.getMessage().toString(), paragraphFont)); document.add(chapter); getWriter().write(message.getMessage().toString()); if (message.getHitList() != null) { chapter.add(new Paragraph("Hits", paragraphFont)); for (final HitResult hit : message.getHitList()) { final PdfPTable table = new PdfPTable(2); table.addCell("Description"); table.addCell(hit.getHitDescripton()); table.addCell("Field"); table.addCell(hit.getHitDescripton()); table.addCell("Absolute Value"); table.addCell(hit.getAbsolutHit() + ""); table.addCell("Relative Value"); table.addCell(hit.getRelativeHit() + ""); table.addCell("Phrase Value"); table.addCell(hit.getPhraseHit() + ""); table.addCell("HitType"); table.addCell(hit.getHitType()); document.add(table); } } else { final String exception = message.getException(); if (exception != null) { chunk = new Chunk("Error:", chapterFont); chapter = new Chapter(new Paragraph(chunk), 1); chapter.add(new Paragraph(message.getException().toString(), paragraphFont)); document.add(chapter); } } document.close(); } catch (final Exception e) { logger.error("Error writing to file:" + getFilename()); logger.debug("Exception: ", e); } }
From source file:be.kcbj.placemat.Placemat.java
License:Open Source License
private PdfPCell generateCell(Sponsor sponsor, float cellHeight) throws IOException, BadElementException { int numLines = 0; Paragraph p = new Paragraph(); if (sponsor.image != null) { Image image = Image.getInstance(SponsorManager.getImageUrl(sponsor.image)); if (sponsor.imageWidth != 0) { image.scaleToFit(sponsor.imageWidth, 1000); } else if (sponsor.imageHeight != 0) { image.scaleToFit(1000, sponsor.imageHeight); }/*from w w w.ja va2 s.c om*/ Chunk imageChunk = new Chunk(image, 0, 0, true); p.add(imageChunk); } if (sponsor.twoColumns) { StringBuilder sb = new StringBuilder(); if (sponsor.name != null) { sb.append(sponsor.name); } if (sponsor.name2 != null) { if (sb.length() > 0) { sb.append(" - "); } sb.append(sponsor.name2); } if (sponsor.address != null) { if (sb.length() > 0) { sb.append(" - "); } sb.append(sponsor.address); } if (sponsor.address2 != null) { if (sb.length() > 0) { sb.append(" - "); } sb.append(sponsor.address2); } p.add(Chunk.NEWLINE); p.add(new Chunk(sb.toString(), new Font(Font.FontFamily.HELVETICA, 8, Font.NORMAL))); numLines++; } else { if (sponsor.twoRows && sponsor.image != null) { p.add(Chunk.NEWLINE); } if (sponsor.name != null) { p.add(generateFittedChunk(sponsor.name, Font.BOLD)); numLines++; } if (sponsor.name2 != null) { p.add(Chunk.NEWLINE); p.add(generateFittedChunk(sponsor.name2, Font.BOLD)); numLines++; } if (sponsor.address != null) { p.add(new Chunk("\n\n", new Font(Font.FontFamily.HELVETICA, 2, Font.NORMAL))); p.add(new Chunk(sponsor.address, new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); numLines++; } if (sponsor.address2 != null) { p.add(Chunk.NEWLINE); p.add(new Chunk(sponsor.address2, new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL))); numLines++; } } p.setPaddingTop(0); p.setSpacingBefore(0); p.setAlignment(Element.ALIGN_CENTER); p.setMultipliedLeading(numLines <= 3 ? 1.3f : 1.1f); PdfPCell cell = new PdfPCell(); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setFixedHeight(cellHeight); if (sponsor.twoColumns) { cell.setColspan(2); } if (sponsor.twoRows) { cell.setRowspan(2); if (sponsor.image == null) { p.setMultipliedLeading(p.getMultipliedLeading() * 1.5f); } } cell.setBorder(PdfPCell.NO_BORDER); cell.setCellEvent(CELL_EVENT); cell.setPaddingBottom(4); cell.addElement(p); if (sponsor.isTodo()) { cell.setBackgroundColor(BaseColor.ORANGE); } return cell; }
From source file:be.mxs.common.util.pdf.general.chuk.GeneralPDFCreator.java
public ByteArrayOutputStream generatePDFDocumentBytes(final HttpServletRequest req, ServletContext application, boolean filterApplied, int partsOfTransactionToPrint) throws DocumentException { ByteArrayOutputStream baosPDF = new ByteArrayOutputStream(); PdfWriter docWriter = null;/*from ww w .jav a2 s.c o m*/ this.req = req; this.application = application; sContextPath = req.getContextPath(); try { docWriter = PdfWriter.getInstance(doc, baosPDF); //*** META TAGS *********************************************************************** doc.addProducer(); doc.addAuthor(user.person.firstname + " " + user.person.lastname); doc.addCreationDate(); doc.addCreator("OpenClinic Software for Hospital Management"); doc.addTitle("Medical Record Data for " + patient.firstname + " " + patient.lastname); doc.addKeywords(patient.firstname + ", " + patient.lastname); doc.setPageSize(PageSize.A4); //*** FOOTER ************************************************************************** PDFFooter footer = new PDFFooter("OpenClinic pdf engine (c)2007, Post-Factum bvba\n" + MedwanQuery.getInstance().getLabel("web.occup", "medwan.common.patientrecord", sPrintLanguage) + " " + patient.getID("immatnew") + " " + patient.firstname + " " + patient.lastname); docWriter.setPageEvent(footer); doc.open(); //*** HEADER ************************************************************************** printDocumentHeader(req); //*** TITLE *************************************************************************** String title = getTran("Web.Occup", "medwan.common.occupational-health-record").toUpperCase(); // add date restriction to document title title += "\n(" + getTran("web", "printdate") + ": " + dateFormat.format(new Date()) + ")"; /* if(dateFrom!=null && dateTo!=null){ if(dateFrom.getTime() == dateTo.getTime()){ title+= "\n("+getTran("web","on")+" "+dateFormat.format(dateTo)+")"; } else{ title+= "\n("+getTran("pdf","date.from")+" "+dateFormat.format(dateFrom)+" "+getTran("pdf","date.to")+" "+dateFormat.format(dateTo)+")"; } } else if(dateFrom!=null){ title+= "\n("+getTran("web","since")+" "+dateFormat.format(dateFrom)+")"; } else if(dateTo!=null){ title+= "\n("+getTran("pdf","date.to")+" "+dateFormat.format(dateTo)+")"; }*/ Paragraph par = new Paragraph(title, FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD)); par.setAlignment(Paragraph.ALIGN_CENTER); doc.add(par); //*** OTHER DOCUMENT ELEMENTS ********************************************************* printAdminHeader(patient); //printKeyData(sessionContainerWO); printMedication(sessionContainerWO); printActiveDiagnosis(sessionContainerWO); printWarnings(sessionContainerWO); doc.add(new Paragraph(" ")); //*** VACCINATION CARD **************************************************************** new be.mxs.common.util.pdf.general.oc.examinations.PDFVaccinationCard().printCard(doc, sessionContainerWO, transactionVO, patient, req, sProject, sPrintLanguage, new Integer(partsOfTransactionToPrint)); //*** TRANSACTIONS ******************************************************************** Enumeration e = req.getParameterNames(); String paramName, paramValue, sTranID, sServerID; boolean transactionIDsSpecified = false; while (e.hasMoreElements()) { paramName = (String) e.nextElement(); // transactionIDs were specified as request-parameters if (paramName.startsWith("tranAndServerID_")) { transactionIDsSpecified = true; paramValue = checkString(req.getParameter(paramName)); sTranID = paramValue.substring(0, paramValue.indexOf("_")); sServerID = paramValue.substring(paramValue.indexOf("_") + 1); this.transactionVO = MedwanQuery.getInstance().loadTransaction(Integer.parseInt(sServerID), Integer.parseInt(sTranID)); loadTransaction(transactionVO, 2); // 2 = print whole transaction } } if (!transactionIDsSpecified) { printTransactions(filterApplied, partsOfTransactionToPrint); } doc.add(new Paragraph(" ")); printSignature(); } catch (DocumentException dex) { baosPDF.reset(); throw dex; } catch (Exception e) { e.printStackTrace(); } finally { if (doc != null) doc.close(); if (docWriter != null) docWriter.close(); } if (baosPDF.size() < 1) { throw new DocumentException("document has " + baosPDF.size() + " bytes"); } return baosPDF; }
From source file:be.mxs.common.util.pdf.general.chuk.GeneralPDFCreator.java
protected void printMedication(SessionContainerWO sessionContainerWO) { try {/*from w w w . j a v a2 s.com*/ doc.add(new Paragraph(" ")); table = new PdfPTable(2); table.setWidthPercentage(100); // main title cell = new PdfPCell(new Paragraph(getTran("curative", "medication.status.title").toUpperCase(), FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 8 * fontSizePercentage / 100.0), Font.ITALIC))); cell.setColspan(2); cell.setBorder(PdfPCell.BOX); cell.setBorderColor(BaseColor.LIGHT_GRAY); cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(cell); Vector chronicMedications = ChronicMedication.find(patient.personid, "", "", "", "OC_CHRONICMED_BEGIN", "ASC"), activePrescriptions = Prescription.getActivePrescriptions(patient.personid); //*** CHRONIC MEDICATION ****************************************** if (chronicMedications.size() > 0) { PdfPTable medicationTable = new PdfPTable(2); // sub title cell = new PdfPCell(new Paragraph(getTran("curative", "medication.chronic"), FontFactory.getFont( FontFactory.HELVETICA, Math.round((double) 8 * fontSizePercentage / 100.0), Font.ITALIC))); cell.setColspan(2); cell.setBorder(PdfPCell.BOX); cell.setBorderColor(BaseColor.LIGHT_GRAY); cell.setVerticalAlignment(PdfPCell.ALIGN_LEFT); cell.setBackgroundColor(BGCOLOR_LIGHT); medicationTable.addCell(cell); // run thru medications String sPrescrRule, sProductUnit, timeUnitTran; ChronicMedication medication; for (int n = 0; n < chronicMedications.size(); n++) { medication = (ChronicMedication) chronicMedications.elementAt(n); sPrescrRule = getTran("web.prescriptions", "prescriptionrule"); sPrescrRule = sPrescrRule.replaceAll("#unitspertimeunit#", medication.getUnitsPerTimeUnit() + ""); // productunits if (medication.getUnitsPerTimeUnit() == 1) { sProductUnit = getTran("product.unit", medication.getProduct().getUnit()); } else { sProductUnit = getTran("product.units", medication.getProduct().getUnit()); } sPrescrRule = sPrescrRule.replaceAll("#productunit#", sProductUnit.toLowerCase()); // timeunits if (medication.getTimeUnitCount() == 1) { sPrescrRule = sPrescrRule.replaceAll("#timeunitcount#", ""); timeUnitTran = getTran("prescription.timeunit", medication.getTimeUnit()); } else { sPrescrRule = sPrescrRule.replaceAll("#timeunitcount#", medication.getTimeUnitCount() + ""); timeUnitTran = getTran("prescription.timeunits", medication.getTimeUnit()); } sPrescrRule = sPrescrRule.replaceAll("#timeunit#", timeUnitTran.replaceAll(" ", " ").toLowerCase()); // product name cell = new PdfPCell(new Paragraph(medication.getProduct().getName(), FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD))); cell.setColspan(1); cell.setBorder(PdfPCell.LEFT + PdfPCell.TOP + PdfPCell.BOTTOM); // no right border cell.setBorderColor(BaseColor.LIGHT_GRAY); medicationTable.addCell(cell); // prescription rule cell = new PdfPCell(new Paragraph(sPrescrRule, FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.ITALIC))); cell.setColspan(1); cell.setBorder(PdfPCell.RIGHT + PdfPCell.TOP + PdfPCell.BOTTOM); // no left border cell.setBorderColor(BaseColor.LIGHT_GRAY); medicationTable.addCell(cell); } // add cells to make up with the chronic medications if (chronicMedications.size() < activePrescriptions.size()) { int missingCellCount = activePrescriptions.size() - chronicMedications.size(); for (int i = 0; i < missingCellCount; i++) { cell = new PdfPCell(); cell.setColspan(2); cell.setBorder(PdfPCell.NO_BORDER); medicationTable.addCell(cell); } } // add chronicmedicationtables to medicationtable cell = new PdfPCell(medicationTable); cell.setBorder(PdfPCell.BOX); cell.setBorderColor(BaseColor.LIGHT_GRAY); cell.setPadding(3); table.addCell(cell); } //*** PRESCRIPTIONS *********************************************** if (activePrescriptions.size() > 0) { PdfPTable medicationTable = new PdfPTable(2); // sub title cell = new PdfPCell(new Paragraph(getTran("curative", "medication.prescription"), FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 8 * fontSizePercentage / 100.0), Font.ITALIC))); cell.setColspan(2); cell.setBorder(PdfPCell.BOX); cell.setBorderColor(BaseColor.LIGHT_GRAY); cell.setVerticalAlignment(PdfPCell.ALIGN_LEFT); cell.setBackgroundColor(BGCOLOR_LIGHT); medicationTable.addCell(cell); // run thru medications String sPrescrRule, sProductUnit, timeUnitTran; Prescription prescription; int n; for (n = 0; n < activePrescriptions.size(); n++) { prescription = (Prescription) activePrescriptions.elementAt(n); sPrescrRule = getTran("web.prescriptions", "prescriptionrule"); sPrescrRule = sPrescrRule.replaceAll("#unitspertimeunit#", prescription.getUnitsPerTimeUnit() + ""); // productunits if (prescription.getUnitsPerTimeUnit() == 1) { sProductUnit = getTran("product.unit", prescription.getProduct().getUnit()); } else { sProductUnit = getTran("product.units", prescription.getProduct().getUnit()); } sPrescrRule = sPrescrRule.replaceAll("#productunit#", sProductUnit.toLowerCase()); // timeunits if (prescription.getTimeUnitCount() == 1) { sPrescrRule = sPrescrRule.replaceAll("#timeunitcount#", ""); timeUnitTran = getTran("prescription.timeunit", prescription.getTimeUnit()); } else { sPrescrRule = sPrescrRule.replaceAll("#timeunitcount#", prescription.getTimeUnitCount() + ""); timeUnitTran = getTran("prescription.timeunits", prescription.getTimeUnit()); } sPrescrRule = sPrescrRule.replaceAll("#timeunit#", timeUnitTran.toLowerCase()); // product name cell = new PdfPCell(new Paragraph(prescription.getProduct().getName(), FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD))); cell.setColspan(1); cell.setBorder(PdfPCell.LEFT + PdfPCell.TOP + PdfPCell.BOTTOM); // no right border cell.setBorderColor(BaseColor.LIGHT_GRAY); medicationTable.addCell(cell); // prescription rule cell = new PdfPCell(new Paragraph(sPrescrRule, FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.ITALIC))); cell.setColspan(1); cell.setBorder(PdfPCell.RIGHT + PdfPCell.TOP + PdfPCell.BOTTOM); // no left border cell.setBorderColor(BaseColor.LIGHT_GRAY); medicationTable.addCell(cell); } // add cells to make up with the active prescriptions if (activePrescriptions.size() < chronicMedications.size()) { int missingCellCount = chronicMedications.size() - activePrescriptions.size(); for (int i = 0; i < missingCellCount; i++) { cell = new PdfPCell(); cell.setColspan(2); cell.setBorder(PdfPCell.NO_BORDER); medicationTable.addCell(cell); } } // add presciptionssstable to medicationtable cell = new PdfPCell(medicationTable); cell.setBorder(PdfPCell.BOX); cell.setBorderColor(BaseColor.LIGHT_GRAY); cell.setPadding(3); table.addCell(cell); doc.add(table); } } catch (Exception e) { e.printStackTrace(); } }