List of usage examples for com.itextpdf.text.pdf PdfPCell PdfPCell
public PdfPCell(PdfPCell cell)
PdfPCell
. From source file:CTD.planer2.util.ExportToPdf.java
/** * We create the table we want to add to our pdf * //from www . j a v a2 s .c om * @param subCatPart * @throws BadElementException */ private static void createTable(Section subCatPart, Room room) throws BadElementException { // Get the number of days per Week from the Settings int daysPerWeek = App.theSettings.getDaysPerWeek(); PdfPTable table = new PdfPTable(daysPerWeek + 1); String[] WeekDay = { "Zeit", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag" }; for (int i = 0; i < daysPerWeek + 1; i++) { PdfPCell c1 = new PdfPCell(new Phrase(WeekDay[i])); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); if (i == daysPerWeek) { table.setHeaderRows(1); } } double calc = 0; // Simplify the Date since we just need the time SimpleDateFormat df = new SimpleDateFormat("HH:mm"); Date start = null; Date uSize = null; try { start = df.parse(App.theSettings.getStartingTimeH() + ":" + App.theSettings.getStartingTimeM()); uSize = new Date(MINUTES.toMillis(App.theSettings.getUnitsSize())); } catch (ParseException e) { } // We take the first day to get the number of units and so the number of // times we have to run this. for (int j = 0; j < Tools.calcRows(); j++) { calc = j == 0 ? start.getTime() : (calc + (uSize.getTime())); // For each day available, we run this loop once. for (int k = 1; k < daysPerWeek + 1; k++) { Units u = room.getUnitByRowCol(k, j); // If it's the first day, we also want a first cell per line // containing the time this unit starts if (k == 1) { table.addCell(df.format(calc)); // Check whether a room is given String teacher = " "; if (u != null) { teacher = u.toString(); } table.addCell(teacher); } else { // If it's not the first day, we don't need to print the // start time again String teacher = " "; if (u != null) { teacher = u.toString(); } table.addCell(teacher); } } } // Add the whole table we've just created to the pdf file subCatPart.add(table); }
From source file:CTD.planer2.util.ExportToPdf.java
private static void createDayTable(Section subCatPart) throws BadElementException { List<Person> personList = App.theSemester.getPersonList(); PdfPTable table = new PdfPTable(personList.size() + 1); PdfPCell c1 = new PdfPCell(new Phrase(" ")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1);// w w w. j ava2 s .co m for (Person p : personList) { c1 = new PdfPCell(new Phrase(p.toString())); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); table.setHeaderRows(1); int k = 1; // We take the first person to get the number of units and so the // number // of // times we have to run this. for (int j = 1; j < p.getEntity().size(); j++) { // For each person available, we run this loop once. List<Units> tmp = p.getEntity(); if (k == 1) { SimpleDateFormat df = new SimpleDateFormat("HH:mm"); String time = df.format(tmp.get(j).getTime()); table.addCell(time); String classes = " "; // Check whether a class is given if (tmp.get(j).getClasses().size() < 1) { classes = " "; } else { classes = tmp.get(j).getClasses().get(0).toString(); } table.addCell(classes); } else { // If it's not the first day, we don't need to print the // start time again String classes = " "; // Check whether a class is given if (tmp.get(j).getClasses().size() < 1) { classes = " "; } else { classes = tmp.get(j).getClasses().get(0).toString(); } table.addCell(classes); } k = k + 1; } } // Add the whole table we've just created to the pdf file subCatPart.add(table); }
From source file:cz.zcu.kiv.eegdatabase.logic.pdf.ReservationPDF.java
License:Apache License
public static PdfPTable formatReservation(Reservation reservation) { int padding = 5; GregorianCalendar created = new GregorianCalendar(); created.setTime(reservation.getCreationTime()); GregorianCalendar startTime = new GregorianCalendar(); startTime.setTime(reservation.getStartTime()); GregorianCalendar endTime = new GregorianCalendar(); endTime.setTime(reservation.getEndTime()); String personName = BookingRoomUtils.formatPersonName(reservation.getPerson()); Font title = FontFactory.getFont("Trebuchet MS", "utf-8", 15, Font.BOLD, new BaseColor(59, 70, 00)); Font header = FontFactory.getFont(FontFactory.TIMES_BOLD, 13, Font.BOLD, BaseColor.BLACK); Font value = FontFactory.getFont(FontFactory.TIMES, 13); PdfPTable table = new PdfPTable(2); PdfPCell cell;/*from www . j a va 2 s . c o m*/ Phrase phrase; phrase = new Phrase("Reservation by " + personName); phrase.setFont(title); cell = new PdfPCell(phrase); cell.setColspan(2); cell.setBorder(0); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorderWidthTop(1); cell.setBorderWidthLeft(1); cell.setBorderWidthRight(1); cell.setPadding(padding); cell.setPaddingBottom(5); table.addCell(cell); phrase = new Phrase("Date: "); phrase.setFont(header); cell = new PdfPCell(phrase); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorder(0); cell.setBorderWidthLeft(1); cell.setPadding(padding); table.addCell(cell); phrase = new Phrase(BookingRoomUtils.getDate(startTime)); phrase.setFont(value); cell = new PdfPCell(phrase); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorder(0); cell.setBorderWidthRight(1); cell.setPadding(padding); table.addCell(cell); phrase = new Phrase("Start: "); phrase.setFont(header); cell = new PdfPCell(phrase); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorder(0); cell.setBorderWidthLeft(1); cell.setPadding(padding); table.addCell(cell); phrase = new Phrase(BookingRoomUtils.getHoursAndMinutes(startTime)); phrase.setFont(value); cell = new PdfPCell(phrase); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorder(0); cell.setBorderWidthRight(1); cell.setPadding(padding); table.addCell(cell); phrase = new Phrase("End: "); phrase.setFont(header); cell = new PdfPCell(phrase); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorder(0); cell.setBorderWidthLeft(1); cell.setBorderWidthBottom(1); cell.setPadding(padding); table.addCell(cell); phrase = new Phrase(BookingRoomUtils.getHoursAndMinutes(endTime)); phrase.setFont(value); cell = new PdfPCell(phrase); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorder(0); cell.setBorderWidthRight(1); cell.setBorderWidthBottom(1); cell.setPadding(padding); table.addCell(cell); table.setSpacingBefore(10); table.setSpacingAfter(10); return table; }
From source file:DataBase.DataBasePDF.java
public static String pdfVendedores(PdfPCell cell, PdfPTable tabla) { String id = ""; ControllerConnDBMS controller = new ControllerConnDBMS(); Connection conn = controller.connectDB(); try {//w w w .j a v a2 s . c om Statement sta = conn.createStatement(); String strQuery = "select * from usuario where eliminado!= 1 && tipo!=3;"; System.out.println(strQuery); ResultSet res = sta.executeQuery(strQuery); while (res.next()) { cell = new PdfPCell(new Paragraph(res.getString("idusuario"))); tabla.addCell(cell); cell = new PdfPCell(new Paragraph(res.getString("nombre"))); tabla.addCell(cell); cell = new PdfPCell(new Paragraph(res.getString("aPaterno"))); tabla.addCell(cell); cell = new PdfPCell(new Paragraph(res.getString("aMaterno"))); tabla.addCell(cell); cell = new PdfPCell(new Paragraph(res.getString("username"))); tabla.addCell(cell); } } catch (SQLException ex) { Logger.getLogger(DataBase.DataBaseCliente.class.getName()).log(Level.SEVERE, null, ex); } finally { try { if (conn != null && !conn.isClosed()) conn.close(); } catch (SQLException ex) { Logger.getLogger(ControllerConnDBMS.class.getName()).log(Level.SEVERE, null, ex); } } return id; }
From source file:DataBase.DataBasePDF.java
public static String pdfProveedores(PdfPCell cell, PdfPTable tabla) { String id = ""; ControllerConnDBMS controller = new ControllerConnDBMS(); Connection conn = controller.connectDB(); try {/*from w w w.ja v a 2s . c o m*/ Statement sta = conn.createStatement(); String strQuery = "select * from proveedor;"; System.out.println(strQuery); ResultSet res = sta.executeQuery(strQuery); while (res.next()) { cell = new PdfPCell(new Paragraph(res.getString("idProveedor"))); tabla.addCell(cell); cell = new PdfPCell(new Paragraph(res.getString("nombre"))); tabla.addCell(cell); cell = new PdfPCell(new Paragraph(res.getString("aPaterno"))); tabla.addCell(cell); cell = new PdfPCell(new Paragraph(res.getString("aMaterno"))); tabla.addCell(cell); cell = new PdfPCell(new Paragraph(res.getString("marca"))); tabla.addCell(cell); cell = new PdfPCell(new Paragraph(res.getString("email"))); tabla.addCell(cell); } } catch (SQLException ex) { Logger.getLogger(DataBase.DataBaseCliente.class.getName()).log(Level.SEVERE, null, ex); } finally { try { if (conn != null && !conn.isClosed()) conn.close(); } catch (SQLException ex) { Logger.getLogger(ControllerConnDBMS.class.getName()).log(Level.SEVERE, null, ex); } } return id; }
From source file:DataBase.DataBasePDF.java
public static String pdfClientes(PdfPCell cell, PdfPTable tabla) { String id = ""; ControllerConnDBMS controller = new ControllerConnDBMS(); Connection conn = controller.connectDB(); try {/*from w ww . jav a2s . c o m*/ Statement sta = conn.createStatement(); String strQuery = "select * from cliente;"; System.out.println(strQuery); ResultSet res = sta.executeQuery(strQuery); while (res.next()) { cell = new PdfPCell(new Paragraph(res.getString("idCliente"))); tabla.addCell(cell); cell = new PdfPCell(new Paragraph(res.getString("nombre"))); tabla.addCell(cell); cell = new PdfPCell(new Paragraph(res.getString("aPaterno"))); tabla.addCell(cell); cell = new PdfPCell(new Paragraph(res.getString("aMaterno"))); tabla.addCell(cell); cell = new PdfPCell(new Paragraph(res.getString("telFijo"))); tabla.addCell(cell); cell = new PdfPCell(new Paragraph(res.getString("telCel"))); tabla.addCell(cell); cell = new PdfPCell(new Paragraph(res.getString("email"))); tabla.addCell(cell); } } catch (SQLException ex) { Logger.getLogger(DataBase.DataBaseCliente.class.getName()).log(Level.SEVERE, null, ex); } finally { try { if (conn != null && !conn.isClosed()) conn.close(); } catch (SQLException ex) { Logger.getLogger(ControllerConnDBMS.class.getName()).log(Level.SEVERE, null, ex); } } return id; }
From source file:DataBase.DataBasePDF.java
public static String pdfVentas(PdfPCell cell, PdfPTable tabla) { String id = ""; ControllerConnDBMS controller = new ControllerConnDBMS(); Connection conn = controller.connectDB(); try {/*from www . jav a2s . co m*/ Statement sta = conn.createStatement(); String strQuery = "select idVenta, tipoVenta, fechaVenta, precioTotal, usuario_idusuario, SUM(precioTotal) as 'Total Ventas' from venta;"; System.out.println(strQuery); ResultSet res = sta.executeQuery(strQuery); while (res.next()) { cell = new PdfPCell(new Paragraph(res.getString("idVenta"))); tabla.addCell(cell); cell = new PdfPCell(new Paragraph(res.getString("tipoVenta"))); tabla.addCell(cell); cell = new PdfPCell(new Paragraph(res.getString("fechaVenta"))); tabla.addCell(cell); cell = new PdfPCell(new Paragraph(res.getString("precioTotal"))); tabla.addCell(cell); cell = new PdfPCell(new Paragraph(res.getString("usuario_idusuario"))); tabla.addCell(cell); cell = new PdfPCell(new Paragraph(res.getString("Total Ventas"))); } } catch (SQLException ex) { Logger.getLogger(DataBase.DataBaseCliente.class.getName()).log(Level.SEVERE, null, ex); } finally { try { if (conn != null && !conn.isClosed()) conn.close(); } catch (SQLException ex) { Logger.getLogger(ControllerConnDBMS.class.getName()).log(Level.SEVERE, null, ex); } } return id; }
From source file:DataBase.DataBasePDF.java
public static String pdfProductos(PdfPCell cell, PdfPTable tabla) { String id = ""; ControllerConnDBMS controller = new ControllerConnDBMS(); Connection conn = controller.connectDB(); try {/*from www. j a va 2 s . com*/ Statement sta = conn.createStatement(); String strQuery = "select idproducto,nombre,format(cantidad,0) as cantidad,preciocompra,precioventa,concat('$ ',format(((precioventa-preciocompra)*cantidad),2)) as ganancia from producto where eliminado != 1;"; System.out.println(strQuery); ResultSet res = sta.executeQuery(strQuery); while (res.next()) { cell = new PdfPCell(new Paragraph(res.getString("idProducto"))); tabla.addCell(cell); cell = new PdfPCell(new Paragraph(res.getString("nombre"))); tabla.addCell(cell); cell = new PdfPCell(new Paragraph(res.getString("cantidad"))); tabla.addCell(cell); cell = new PdfPCell(new Paragraph(res.getString("precioCompra"))); tabla.addCell(cell); cell = new PdfPCell(new Paragraph(res.getString("precioVenta"))); tabla.addCell(cell); cell = new PdfPCell(new Paragraph(res.getString("ganancia"))); tabla.addCell(cell); } } catch (SQLException ex) { Logger.getLogger(DataBase.DataBaseCliente.class.getName()).log(Level.SEVERE, null, ex); } finally { try { if (conn != null && !conn.isClosed()) conn.close(); } catch (SQLException ex) { Logger.getLogger(ControllerConnDBMS.class.getName()).log(Level.SEVERE, null, ex); } } return id; }
From source file:DataBase.DataBasePDF.java
public static String pdfPedidos(PdfPCell cell, PdfPTable tabla) { String id = ""; ControllerConnDBMS controller = new ControllerConnDBMS(); Connection conn = controller.connectDB(); try {/*from www . ja va 2s.co m*/ Statement sta = conn.createStatement(); String strQuery = "select idVenta, precioTotal, Cliente_idCliente,usuario_idusuario, fechaVenta, fechaEntrega from venta where tipoVenta=3 order by fechaEntrega ;"; System.out.println(strQuery); ResultSet res = sta.executeQuery(strQuery); while (res.next()) { cell = new PdfPCell(new Paragraph(res.getString("ventaPedido_idventaPedido"))); tabla.addCell(cell); cell = new PdfPCell(new Paragraph(res.getString("precioTotal"))); tabla.addCell(cell); cell = new PdfPCell(new Paragraph(res.getString("Clientee_idCliente"))); tabla.addCell(cell); cell = new PdfPCell(new Paragraph(res.getString("usuario_idusuario"))); tabla.addCell(cell); cell = new PdfPCell(new Paragraph(res.getString("fechaVenta"))); tabla.addCell(cell); } cell = new PdfPCell(new Paragraph(res.getString("fechaEntrega"))); tabla.addCell(cell); } catch (SQLException ex) { Logger.getLogger(DataBase.DataBaseCliente.class.getName()).log(Level.SEVERE, null, ex); } finally { try { if (conn != null && !conn.isClosed()) conn.close(); } catch (SQLException ex) { Logger.getLogger(ControllerConnDBMS.class.getName()).log(Level.SEVERE, null, ex); } } return id; }