List of usage examples for com.itextpdf.text.pdf PdfPTable setHeaderRows
public void setHeaderRows(int headerRows)
From source file:Valuacion.valuacionDirecta.java
private void b_pdfActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b_pdfActionPerformed // TODO add your handling code here: h = new Herramientas(user, 0); h.session(sessionPrograma);/*from w w w .j a v a2 s . co m*/ Session session = HibernateUtil.getSessionFactory().openSession(); try { session.beginTransaction().begin(); BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED); //Orden ord=buscaApertura(); PDF reporte = new PDF(); Date fecha = new Date(); DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyyHH-mm-ss");//YYYY-MM-DD HH:MM:SS String valor = dateFormat.format(fecha); File folder = new File("reportes/" + ord.getIdOrden()); folder.mkdirs(); reporte.Abrir(PageSize.LETTER.rotate(), "Valuacin", "reportes/" + ord.getIdOrden() + "/" + valor + "-levantamiento.pdf"); Font font = new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD); BaseColor contenido = BaseColor.WHITE; int centro = Element.ALIGN_CENTER; int izquierda = Element.ALIGN_LEFT; int derecha = Element.ALIGN_RIGHT; float tam[] = new float[] { 15, 15, 7, 7, 7, 7, 7, 59, 125, 11, 11, 11, 11, 16, 12, 12, 12, 12, 12, 12, 12, 12, 100 }; PdfPTable tabla = reporte.crearTabla(23, tam, 100, Element.ALIGN_LEFT); cabecera(reporte, bf, tabla); session.beginTransaction().begin(); Orden ord = (Orden) session.get(Orden.class, Integer.parseInt(orden)); //Partida resp=(Partida[]) session.createCriteria(Partida.class).add(Restrictions.eq("ordenByIdOrden.idOrden", Integer.parseInt(orden))).addOrder(Order.desc("idEvaluacion")).addOrder(Order.desc("subPartida")); //Partida[] cuentas = (Partida[]) ord.getPartidas().toArray(new Partida[0]); List cuentas = null; switch (c_filtro.getSelectedItem().toString()) { case "Todos": cuentas = session.createCriteria(Partida.class) .add(Restrictions.eq("ordenByIdOrden.idOrden", Integer.parseInt(orden))) .addOrder(Order.asc("idEvaluacion")).addOrder(Order.asc("subPartida")).list(); break; case "Hojalateria": cuentas = session.createCriteria(Partida.class) .add(Restrictions.eq("ordenByIdOrden.idOrden", Integer.parseInt(orden))) .add(Restrictions.eq("espHoj", true)).addOrder(Order.asc("idEvaluacion")) .addOrder(Order.asc("subPartida")).list(); break; case "Mecanica": cuentas = session.createCriteria(Partida.class) .add(Restrictions.eq("ordenByIdOrden.idOrden", Integer.parseInt(orden))) .add(Restrictions.eq("espMec", true)).addOrder(Order.asc("idEvaluacion")) .addOrder(Order.asc("subPartida")).list(); break; case "Suspension": cuentas = session.createCriteria(Partida.class) .add(Restrictions.eq("ordenByIdOrden.idOrden", Integer.parseInt(orden))) .add(Restrictions.eq("espSus", true)).addOrder(Order.asc("idEvaluacion")) .addOrder(Order.asc("subPartida")).list(); break; case "Electricidad": cuentas = session.createCriteria(Partida.class) .add(Restrictions.eq("ordenByIdOrden.idOrden", Integer.parseInt(orden))) .add(Restrictions.eq("espEle", true)).addOrder(Order.asc("idEvaluacion")) .addOrder(Order.asc("subPartida")).list(); break; case "Pintura": cuentas = session.createCriteria(Partida.class) .add(Restrictions.eq("ordenByIdOrden.idOrden", Integer.parseInt(orden))) .add(Restrictions.ne("pint", -1.0d)).addOrder(Order.asc("idEvaluacion")) .addOrder(Order.asc("subPartida")).list(); break; } int ren = 0; if (cuentas.size() > 0) { for (int i = 0; i < cuentas.size(); i++) { Partida Part = (Partida) cuentas.get(i); /*if(Part.isRefCoti()) {*/ tabla.addCell(reporte.celda("" + Part.getCant(), font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); tabla.addCell( reporte.celda(Part.getMed(), font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda((Part.isEspHoj() == true ? "x" : ""), font, contenido, izquierda, 0, 0, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda((Part.isEspMec() == true ? "x" : ""), font, contenido, izquierda, 0, 0, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda((Part.isEspSus() == true ? "x" : ""), font, contenido, izquierda, 0, 0, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda((Part.isEspEle() == true ? "x" : ""), font, contenido, izquierda, 0, 0, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda((Part.getPint() > -1 ? "x" : ""), font, contenido, izquierda, 0, 0, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda(Part.getCatalogo().getEspecialidad().getDescripcion(), font, contenido, izquierda, 0, 0, Rectangle.RECTANGLE)); if (Part.getEjemplar() != null) tabla.addCell(reporte.celda( Part.getCatalogo().getNombre() + " [NP:" + Part.getEjemplar().getIdParte() + "]", font, contenido, izquierda, 0, 0, Rectangle.RECTANGLE)); else tabla.addCell(reporte.celda(Part.getCatalogo().getNombre(), font, contenido, izquierda, 0, 0, Rectangle.RECTANGLE)); if (Part.isOri() == true) tabla.addCell(reporte.celda("X", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); else tabla.addCell(reporte.celda(" ", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); if (Part.isNal() == true) tabla.addCell(reporte.celda("X", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); else tabla.addCell(reporte.celda(" ", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); if (Part.isDesm() == true) tabla.addCell(reporte.celda("X", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); else tabla.addCell(reporte.celda(" ", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); if (Part.isPd() == true) tabla.addCell(reporte.celda("X", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); else tabla.addCell(reporte.celda(" ", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); if (Part.getProveedor() != null) tabla.addCell(reporte.celda("" + Part.getProveedor().getIdProveedor(), font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); else tabla.addCell(reporte.celda(" ", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); if (Part.getIntDesm() > -1) tabla.addCell(reporte.celda("X", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); else tabla.addCell(reporte.celda(" ", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); if (Part.getIntCamb() > -1) tabla.addCell(reporte.celda("X", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); else tabla.addCell(reporte.celda(" ", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); if (Part.getIntRepMin() > -1) tabla.addCell(reporte.celda("X", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); else tabla.addCell(reporte.celda(" ", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); if (Part.getIntRepMed() > -1) tabla.addCell(reporte.celda("X", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); else tabla.addCell(reporte.celda(" ", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); if (Part.getIntRepMax() > -1) tabla.addCell(reporte.celda("X", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); else tabla.addCell(reporte.celda(" ", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); if (Part.getIntPinMin() > -1) tabla.addCell(reporte.celda("X", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); else tabla.addCell(reporte.celda(" ", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); if (Part.getIntPinMed() > -1) tabla.addCell(reporte.celda("X", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); else tabla.addCell(reporte.celda(" ", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); if (Part.getIntPinMax() > -1) tabla.addCell(reporte.celda("X", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); else tabla.addCell(reporte.celda(" ", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); if (Part.getInstruccion() != null) tabla.addCell(reporte.celda(Part.getInstruccion(), font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); else tabla.addCell(reporte.celda("", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); /*if(ren==38) { reporte.agregaObjeto(tabla); reporte.writer.newPage(); tabla=reporte.crearTabla(17, tam, 100, Element.ALIGN_LEFT); cabecera(reporte, bf, tabla); ren=-1; } ren++;*/ //} } } session.beginTransaction().rollback(); tabla.setHeaderRows(3); reporte.agregaObjeto(tabla); reporte.cerrar(); reporte.visualizar("reportes/" + ord.getIdOrden() + "/" + valor + "-levantamiento.pdf"); } catch (Exception e) { System.out.println(e); e.printStackTrace(); JOptionPane.showMessageDialog(this, "No se pudo realizar el reporte si el archivo esta abierto."); } if (session != null) if (session.isOpen()) { session.flush(); session.clear(); session.close(); } }
From source file:web.programmazione.ReportServlet.java
private void MakePDF(Document report, List<UserReport> lur, String groupName) throws DocumentException { report.add(new Paragraph("Report document for group " + groupName)); report.add(new Paragraph()); report.add(new Paragraph("This document has been automatically generated on " + new Date().toString())); report.add(new Paragraph(" ")); report.add(new Paragraph("In the following table, user statistics are given for the group")); report.add(new Paragraph(" ")); PdfPTable myTable = new PdfPTable(3); myTable.setHeaderRows(1); myTable.addCell("Username"); myTable.addCell("Post count"); myTable.addCell("Last activity in group"); for (UserReport ur : lur) { myTable.addCell(ur.getUsername()); myTable.addCell(String.valueOf(ur.getPostNumber())); myTable.addCell(ur.getLastPost().toString()); }/* ww w . ja va2s. c o m*/ report.add(myTable); }
From source file:wtw.ui.GeneratingPdfAction.java
private static void createTable(Section subCatPart) throws BadElementException { PdfPTable table = new PdfPTable(3); // t.setBorderColor(BaseColor.GRAY); // t.setPadding(4); // t.setSpacing(4); // t.setBorderWidth(1); PdfPCell c1 = new PdfPCell(new Phrase("Table Header 1")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1);/*from w w w. j a v a 2 s . c o m*/ c1 = new PdfPCell(new Phrase("Table Header 2")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Table Header 3")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); table.setHeaderRows(1); table.addCell("1.0"); table.addCell("1.1"); table.addCell("1.2"); table.addCell("2.1"); table.addCell("2.2"); table.addCell("2.3"); subCatPart.add(table); }