List of usage examples for com.itextpdf.text.pdf PdfPTable getNumberOfColumns
public int getNumberOfColumns()
From source file:Almacen.formatosPedido.java
void formato() { h = new Herramientas(usr, 0); h.session(sessionPrograma);// w w w .j av a2 s . c o m Session session = HibernateUtil.getSessionFactory().openSession(); try { miAlmacen = (Almacen) session.get(Almacen.class, miAlmacen.getIdAlmacen()); DecimalFormat formatoPorcentaje = new DecimalFormat("#,##0.00"); formatoPorcentaje.setMinimumFractionDigits(2); session.beginTransaction().begin(); BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED); 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); Movimiento[] mov = (Movimiento[]) session.createCriteria(Movimiento.class) .add(Restrictions.eq("almacen.idAlmacen", miAlmacen.getIdAlmacen())).list() .toArray(new Movimiento[0]); Orden ord = null; OrdenExterna ordEx = null; if (mov.length > 0) { if (miAlmacen.getOperacion() == 1) ord = mov[0].getPartida().getOrdenByIdOrden(); /*if(miAlmacen.getOperacion()==2) ordEx=miAlmacen.getPedido().getOrdenExterna();*/ if (miAlmacen.getOperacion() == 3) ord = miAlmacen.getPedido().getOrden(); //ord=miAlmacen.getPedido().getPartida().getOrdenByIdOrden(); } File folder = new File("reportes"); folder.mkdirs(); reporte.Abrir(PageSize.LETTER, "Almacen", "reportes/" + valor + "-" + miAlmacen.getIdAlmacen() + "-almacen.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[]; PdfPTable tabla; if (miAlmacen.getOperacion() != 6) { tam = new float[] { 20, 20, 80, 190, 20, 30, 50, 50 }; tabla = reporte.crearTabla(8, tam, 100, Element.ALIGN_LEFT); } else { tam = new float[] { 20, 20, 80, 190, 20, 30 }; tabla = reporte.crearTabla(6, tam, 100, Element.ALIGN_LEFT); } cabeceraCompra(reporte, bf, tabla, miAlmacen, ord); int ren = 0; double total = 0d; if (mov.length > 0) { int renglon = 0; for (int i = 0; i < mov.length; i++) { if (miAlmacen.getOperacion() == 1) { int r = i + 1; renglon++; tabla.addCell(reporte.celda("" + mov[i].getPartida().getIdEvaluacion(), font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("" + mov[i].getPartida().getSubPartida(), font, contenido, derecha, 0, 1, Rectangle.RECTANGLE)); if (mov[i].getPartida().getEjemplar() != null) tabla.addCell(reporte.celda("" + mov[i].getPartida().getEjemplar().getIdParte(), font, contenido, derecha, 0, 1, Rectangle.RECTANGLE)); else tabla.addCell(reporte.celda(" ", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda(mov[i].getPartida().getCatalogo().getNombre(), font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda(mov[i].getPartida().getMed(), font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda(formatoPorcentaje.format(mov[i].getCantidad()), font, contenido, derecha, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda(formatoPorcentaje.format(mov[i].getPartida().getPcp()), font, contenido, derecha, 0, 1, Rectangle.RECTANGLE)); double sum = mov[i].getCantidad() * mov[i].getPartida().getPcp(); total += sum; tabla.addCell(reporte.celda(formatoPorcentaje.format(sum), font, contenido, derecha, 0, 1, Rectangle.RECTANGLE)); if (ren == 20)//20 { reporte.writer.newPage(); reporte.agregaObjeto(tabla); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(tabla); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); tabla = reporte.crearTabla(8, tam, 100, Element.ALIGN_LEFT); cabeceraCompra(reporte, bf, tabla, miAlmacen, ord); ren = -1; renglon = 0; } ren++; } if (miAlmacen.getOperacion() == 2 || miAlmacen.getOperacion() == 6) { int r = i + 1; renglon++; tabla.addCell(reporte.celda("", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE)); if (mov[i].getPartidaExterna().getNoParte() != null) tabla.addCell(reporte.celda(mov[i].getPartidaExterna().getNoParte(), font, contenido, derecha, 0, 1, Rectangle.RECTANGLE)); else tabla.addCell(reporte.celda(" ", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda(mov[i].getPartidaExterna().getDescripcion(), font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda(mov[i].getPartidaExterna().getUnidad(), font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda(formatoPorcentaje.format(mov[i].getCantidad()), font, contenido, derecha, 0, 1, Rectangle.RECTANGLE)); if (miAlmacen.getOperacion() == 2) { tabla.addCell( reporte.celda(formatoPorcentaje.format(mov[i].getPartidaExterna().getCosto()), font, contenido, derecha, 0, 1, Rectangle.RECTANGLE)); double sum = mov[i].getCantidad() * mov[i].getPartidaExterna().getCosto(); total += sum; tabla.addCell(reporte.celda(formatoPorcentaje.format(sum), font, contenido, derecha, 0, 1, Rectangle.RECTANGLE)); } if (ren == 20)//20 { reporte.writer.newPage(); reporte.agregaObjeto(tabla); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(tabla); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); tabla = reporte.crearTabla(8, tam, 100, Element.ALIGN_LEFT); cabeceraCompra(reporte, bf, tabla, miAlmacen, ord); ren = -1; renglon = 0; } ren++; } if (miAlmacen.getOperacion() == 3) { int r = i + 1; renglon++; //tabla.addCell(reporte.celda(""+miAlmacen.getPedido().getPartida().getIdEvaluacion(), font, contenido, izquierda, 0,1,Rectangle.RECTANGLE)); //tabla.addCell(reporte.celda(""+miAlmacen.getPedido().getPartida().getSubPartida(), font, contenido, derecha, 0,1,Rectangle.RECTANGLE)); tabla.addCell(reporte.celda(" ", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda(" ", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE)); if (mov[i].getPartidaExterna().getNoParte() != null) tabla.addCell(reporte.celda(mov[i].getPartidaExterna().getNoParte(), font, contenido, derecha, 0, 1, Rectangle.RECTANGLE)); else tabla.addCell(reporte.celda(" ", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE)); //tabla.addCell(reporte.celda(miAlmacen.getPedido().getPartida().getCatalogo().getNombre()+"/"+mov[i].getPartidaExterna().getDescripcion(), font, contenido, izquierda, 0,1,Rectangle.RECTANGLE)); tabla.addCell(reporte.celda(mov[i].getPartidaExterna().getDescripcion(), font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda(mov[i].getPartidaExterna().getUnidad(), font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda(formatoPorcentaje.format(mov[i].getCantidad()), font, contenido, derecha, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda(formatoPorcentaje.format(mov[i].getPartidaExterna().getCosto()), font, contenido, derecha, 0, 1, Rectangle.RECTANGLE)); double sum = mov[i].getCantidad() * mov[i].getPartidaExterna().getCosto(); total += sum; tabla.addCell(reporte.celda(formatoPorcentaje.format(sum), font, contenido, derecha, 0, 1, Rectangle.RECTANGLE)); if (ren == 20)//20 { reporte.writer.newPage(); reporte.agregaObjeto(tabla); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(tabla); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); tabla = reporte.crearTabla(8, tam, 100, Element.ALIGN_LEFT); cabeceraCompra(reporte, bf, tabla, miAlmacen, ord); ren = -1; renglon = 0; } ren++; } } for (renglon = renglon; renglon < 20; renglon++) { tabla.addCell(reporte.celda(" ", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda(" ", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda(" ", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda(" ", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda(" ", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda(" ", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda(" ", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda(" ", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE)); } } tabla.addCell(reporte.celda("Notas: ", font, contenido, izquierda, 0, 1, Rectangle.BOTTOM)); tabla.addCell(reporte.celda(miAlmacen.getNotas(), font, contenido, izquierda, tabla.getNumberOfColumns() - 1, 1, Rectangle.BOTTOM)); if (miAlmacen.getOperacion() != 6) { tabla.addCell(reporte.celda("", font, contenido, izquierda, 3, 1, Rectangle.NO_BORDER)); tabla.addCell(reporte.celda("Sub-total:", font, contenido, derecha, 4, 1, Rectangle.NO_BORDER)); tabla.addCell(reporte.celda(formatoPorcentaje.format(total), font, contenido, derecha, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("IVA:", font, contenido, derecha, 7, 1, Rectangle.NO_BORDER)); Configuracion con = (Configuracion) session.get(Configuracion.class, 1); double iva = total * con.getIva() / 100; tabla.addCell(reporte.celda(formatoPorcentaje.format(iva), font, contenido, derecha, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Total:", font, contenido, derecha, 7, 1, Rectangle.NO_BORDER)); total += iva; tabla.addCell(reporte.celda(formatoPorcentaje.format(total), font, contenido, derecha, 0, 1, Rectangle.RECTANGLE)); } else { tabla.addCell(reporte.celda("", font, contenido, izquierda, 8, 1, Rectangle.NO_BORDER)); tabla.addCell(reporte.celda("", font, contenido, derecha, 8, 1, Rectangle.NO_BORDER)); tabla.addCell(reporte.celda("", font, contenido, derecha, 8, 1, Rectangle.RECTANGLE)); } session.beginTransaction().rollback(); reporte.agregaObjeto(tabla); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(tabla); reporte.cerrar(); reporte.visualizar("reportes/" + valor + "-" + miAlmacen.getIdAlmacen() + "-almacen.pdf"); } catch (Exception e) { System.out.println(e); e.printStackTrace(); JOptionPane.showMessageDialog(null, "No se pudo realizar el reporte si el archivo esta abierto"); } if (session != null) if (session.isOpen()) session.close(); }
From source file:Almacen.formatosPedido.java
private void cabeceraCompra(PDF reporte, BaseFont bf, PdfPTable tabla, Almacen almacen, Orden ord) { Session session = HibernateUtil.getSessionFactory().openSession(); try {// ww w . j a v a2s . co m reporte.contenido.setLineWidth(0.5f); reporte.contenido.setColorStroke(new GrayColor(0.2f)); reporte.contenido.setColorFill(new GrayColor(0.9f)); reporte.contenido.roundRectangle(35, 755, 280, 10, 0); reporte.contenido.roundRectangle(35, 735, 280, 20, 0); ////*2 reporte.contenido.roundRectangle(35, 388, 280, 10, 0); reporte.contenido.roundRectangle(35, 368, 280, 20, 0); //// reporte.inicioTexto(); reporte.contenido.setFontAndSize(bf, 13); reporte.contenido.setColorFill(BaseColor.BLACK); reporte.agregaObjeto(reporte.crearImagen("imagenes/grande300115.jpg", 335, -23, 30)); /*2*/reporte.agregarImagen(reporte.crearImagen("imagenes/grande300115.jpg", 100, -390, 30));//-390//-375 reporte.contenido.setFontAndSize(bf, 12); reporte.contenido.setColorFill(BaseColor.BLACK); if (miAlmacen.getTipoMovimiento() == 1) { if (miAlmacen.getOperacion() == 1 || miAlmacen.getOperacion() == 2 || miAlmacen.getOperacion() == 3) reporte.contenido.showTextAligned( PdfContentByte.ALIGN_LEFT, "Movimiento en Almacn (Entrada de Material): " + almacen.getIdAlmacen() + " Pedido:" + almacen.getPedido().getIdPedido(), 35, 767, 0); if (miAlmacen.getOperacion() == 5) reporte.contenido.showTextAligned( PdfContentByte.ALIGN_LEFT, "Movimientos de Almacn (Devolucin de ventas): " + almacen.getIdAlmacen() + " Pedido:" + almacen.getPedido().getIdPedido(), 35, 767, 0); ////*2 if (miAlmacen.getOperacion() == 1 || miAlmacen.getOperacion() == 2 || miAlmacen.getOperacion() == 3) reporte.contenido.showTextAligned( PdfContentByte.ALIGN_LEFT, "Movimiento en Almacn (Entrada de Material): " + almacen.getIdAlmacen() + " Pedido:" + almacen.getPedido().getIdPedido(), 35, 400, 0); if (miAlmacen.getOperacion() == 6) reporte.contenido.showTextAligned( PdfContentByte.ALIGN_LEFT, "Movimientos de Almacn (Devolucin de ventas): " + almacen.getIdAlmacen() + " Pedido:" + almacen.getPedido().getIdPedido(), 35, 400, 0); ///// } else { if (miAlmacen.getOperacion() == 1 || miAlmacen.getOperacion() == 2 || miAlmacen.getOperacion() == 3) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Movimiento de Almacn (Devolucin de material a proveedor): " + almacen.getIdAlmacen() + " Pedido:" + almacen.getPedido().getIdPedido(), 35, 767, 0); if (miAlmacen.getOperacion() == 6) reporte.contenido.showTextAligned( PdfContentByte.ALIGN_LEFT, "Movimientos de Almacn (Entrega de ventas): " + almacen.getIdAlmacen() + " Pedido:" + almacen.getPedido().getIdPedido(), 35, 767, 0); ///**2 if (miAlmacen.getOperacion() == 1 || miAlmacen.getOperacion() == 2 || miAlmacen.getOperacion() == 3) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Movimiento de Almacn (Devolucin de material a proveedor): " + almacen.getIdAlmacen() + " Pedido:" + almacen.getPedido().getIdPedido(), 35, 400, 0); if (miAlmacen.getOperacion() == 6) reporte.contenido.showTextAligned( PdfContentByte.ALIGN_LEFT, "Movimientos de Almacn (Entrega de ventas): " + almacen.getIdAlmacen() + " Pedido:" + almacen.getPedido().getIdPedido(), 35, 400, 0); /// } reporte.contenido.setFontAndSize(bf, 7); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Fecha:" + new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date()), 306, 757, 0); /*2*/reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Fecha:" + new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date()), 306, 390, 0); if (ord != null) ord = (Orden) session.get(Orden.class, ord.getIdOrden()); //************************datos de movimiento**************************** DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");//YYYY-MM-DD HH:MM:SS reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Materiales y Refacciones del Almacn", 40, 757, 0); /*2*/reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Materiales y Refacciones del Almacn", 40, 390, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "N. Movimiento: " + almacen.getIdAlmacen(), 40, 747, 0); /*2*/reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "N. Movimiento: " + almacen.getIdAlmacen(), 40, 380, 0); if (almacen.getTipoMovimiento() == 1) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Movimiento : Entrada", 120, 747, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Movimiento : Salida", 120, 747, 0); ////2 if (almacen.getTipoMovimiento() == 1) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Movimiento : Entrada", 120, 380, 0); else reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Movimiento : Salida", 120, 380, 0); //// if (almacen.getOperacion() == 1) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Operacin : Pedido", 220, 747, 0); if (almacen.getOperacion() == 2) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Operacin : Pedido E.", 220, 747, 0); if (almacen.getOperacion() == 3) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Operacin : Pedido A.", 220, 747, 0); if (almacen.getOperacion() == 6) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Operacin : Venta", 220, 747, 0); ////2 if (almacen.getOperacion() == 1) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Operacin : Pedido", 220, 380, 0); if (almacen.getOperacion() == 2) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Operacin : Pedido E.", 220, 380, 0); if (almacen.getOperacion() == 3) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Operacin : Pedido A.", 220, 380, 0); if (almacen.getOperacion() == 6) reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Operacin : Venta", 220, 380, 0); //// if (ord != null) { reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "N. Orden: " + ord.getIdOrden(), 40, 737, 0); /*2*/reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "N. Orden: " + ord.getIdOrden(), 40, 370, 0); } //Firmas de material if (miAlmacen.getTipoMovimiento() == 1) { reporte.contenido.roundRectangle(45, 450, 130, 1, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "ENTREGA: " + almacen.getEntrego(), 45, 440, 0); reporte.contenido.roundRectangle(250, 450, 130, 1, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "AUTORIZA: ", 250, 440, 0); reporte.contenido.roundRectangle(440, 450, 130, 1, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "RECIBE: " + almacen.getUsuario().getEmpleado().getNombre(), 440, 440, 0); } else { reporte.contenido.roundRectangle(45, 450, 130, 1, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "ENTREGA: " + almacen.getUsuario().getEmpleado().getNombre(), 45, 440, 0); reporte.contenido.roundRectangle(250, 450, 130, 1, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "AUTORIZA: ", 250, 440, 0); reporte.contenido.roundRectangle(440, 450, 130, 1, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "RECIBE: " + almacen.getEntrego(), 440, 440, 0); } ///2 if (miAlmacen.getTipoMovimiento() == 1) { reporte.contenido.roundRectangle(45, 30, 130, 1, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "ENTREGA: " + almacen.getEntrego(), 45, 20, 0); reporte.contenido.roundRectangle(250, 30, 130, 1, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "AUTORIZA: ", 250, 20, 0); reporte.contenido.roundRectangle(440, 30, 130, 1, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "RECIBE: " + almacen.getUsuario().getEmpleado().getNombre(), 440, 20, 0); } else { reporte.contenido.roundRectangle(45, 30, 130, 1, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "ENTREGA: " + almacen.getUsuario().getEmpleado().getNombre(), 45, 20, 0); reporte.contenido.roundRectangle(250, 30, 130, 1, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "AUTORIZA: ", 250, 20, 0); reporte.contenido.roundRectangle(440, 30, 130, 1, 0); reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "RECIBE: " + almacen.getEntrego(), 440, 20, 0); } /// reporte.finTexto(); reporte.contenido.setFontAndSize(bf, 12); //agregamos renglones vacios para dejar un espacio(tabla) reporte.agregaObjeto(new Paragraph(" ")); reporte.agregaObjeto(new Paragraph(" ")); Font font = new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD); BaseColor cabecera = BaseColor.GRAY; int centro = Element.ALIGN_CENTER; tabla.addCell(reporte.celda("N", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("#", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("N Parte", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Descripcin", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Med", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Cant", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); if (tabla.getNumberOfColumns() > 6) { tabla.addCell(reporte.celda("Costo c/u", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda("Total", 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.Reporte2.java
public void cabecera(PDF reporte, BaseFont bf, PdfPTable tabla, String titulo1, int op) { Session session = HibernateUtil.getSessionFactory().openSession(); try {/*from w w w .j a va 2s . co 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; if (op == 1) { if (t_fecha1.getText().compareTo("AAAA-MM-DD") != 0) titulo += " del " + t_fecha1.getText(); if (t_fecha2.getText().compareTo("AAAA-MM-DD") != 0) titulo += " al " + t_fecha2.getText(); } 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; int izquierda = Element.ALIGN_LEFT; int derecha = Element.ALIGN_RIGHT; if (op == 1) { for (int a = 0; a < tabla.getNumberOfColumns(); a++) { tabla.addCell(reporte.celda(t_datos.getColumnName(a), font, cabecera, centro, 0, 1, Rectangle.RECTANGLE)); } } if (op == 2) { for (int a = 0; a < tabla.getNumberOfColumns(); a++) { tabla.addCell(reporte.celda(t_datos1.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.Reporte2.java
public void cabecera1(PDF reporte, BaseFont bf, PdfPTable tabla, String titulo1, int op) { Session session = HibernateUtil.getSessionFactory().openSession(); try {/*from w w w.j ava 2 s.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:be.mxs.common.util.pdf.general.dossierCreators.StaffDossierPDFCreator.java
private void addDisciplinaryRecordDetails(PdfPTable table, DisciplinaryRecord disRec) { if (disRec.followUp.length() > 0) { PdfPTable detailsTable = new PdfPTable(10); detailsTable.setWidthPercentage(100); // follow-up in grey and italic //detailsTable.addCell(createValueCell(disRec.followUp.replaceAll("\r\n"," "),10)); Font font = FontFactory.getFont(FontFactory.HELVETICA, 7, Font.ITALIC); font.setColor(BaseColor.GRAY);/* w ww. ja v a 2s . co m*/ cell = new PdfPCell(new Paragraph(disRec.followUp.replaceAll("\r\n", " "), font)); cell.setColspan(10); cell.setBorder(PdfPCell.BOX); cell.setBorderColor(innerBorderColor); cell.setVerticalAlignment(PdfPCell.ALIGN_TOP); cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT); detailsTable.addCell(cell); table.addCell(createCell(new PdfPCell(detailsTable), table.getNumberOfColumns(), PdfPCell.ALIGN_CENTER, PdfPCell.BOX)); } }
From source file:be.mxs.common.util.pdf.general.dossierCreators.StaffDossierPDFCreator.java
private void addLeaveDetails(PdfPTable table, Leave leave) { if (leave.comment.length() > 0) { PdfPTable detailsTable = new PdfPTable(10); detailsTable.setWidthPercentage(100); // follow-up in grey and italic //detailsTable.addCell(createValueCell(leave.comment.replaceAll("\r\n"," "),10)); Font font = FontFactory.getFont(FontFactory.HELVETICA, 7, Font.ITALIC); font.setColor(BaseColor.GRAY);/* ww w .ja v a 2s. c o m*/ cell = new PdfPCell(new Paragraph(leave.comment.replaceAll("\r\n", " "), font)); cell.setColspan(10); cell.setBorder(PdfPCell.BOX); cell.setBorderColor(innerBorderColor); cell.setVerticalAlignment(PdfPCell.ALIGN_TOP); cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT); detailsTable.addCell(cell); table.addCell(createCell(new PdfPCell(detailsTable), table.getNumberOfColumns(), PdfPCell.ALIGN_CENTER, PdfPCell.BOX)); } }
From source file:be.mxs.common.util.pdf.general.dossierCreators.StaffDossierPDFCreator.java
private void addContractDetails(PdfPTable table, Contract contract) { PdfPTable detailsTable = new PdfPTable(10); detailsTable.setWidthPercentage(100); if (contract.getLegalReferenceCode(1).length() > 0 || contract.getLegalReferenceCode(2).length() > 0 || contract.getLegalReferenceCode(3).length() > 0 || contract.getLegalReferenceCode(4).length() > 0 || contract.getLegalReferenceCode(5).length() > 0) { //detailsTable.addCell(createSubtitleCell(getTran("web.hr","legalReferenceCodes"),10)); // one LRC for (int i = 0; i < 4; i++) { if (contract.getLegalReferenceCode(i + 1).length() > 0) { detailsTable/*from w ww . j a va 2 s.c om*/ .addCell(createValueCell(getTran("web.hr", "legalReferenceCode") + " " + (i + 1), 4)); detailsTable.addCell(createValueCell(contract.getLegalReferenceCode(i + 1), 6)); } } } if (detailsTable.size() > 0) { table.addCell(emptyCell(2)); cell = createCell(new PdfPCell(detailsTable), table.getNumberOfColumns() - 2, PdfPCell.ALIGN_CENTER, PdfPCell.BOX); cell.setPadding(2); table.addCell(cell); } }
From source file:be.mxs.common.util.pdf.general.dossierCreators.StaffDossierPDFCreator.java
private void addCareerDetails(PdfPTable table, Career career) { if (career.comment.length() > 0) { PdfPTable detailsTable = new PdfPTable(10); detailsTable.setWidthPercentage(100); // comment in grey and italic //detailsTable.addCell(createValueCell(career.comment.replaceAll("\r\n"," "),10)); Font font = FontFactory.getFont(FontFactory.HELVETICA, 7, Font.ITALIC); font.setColor(BaseColor.GRAY);//from w ww . j ava 2 s .c o m cell = new PdfPCell(new Paragraph(career.comment.replaceAll("\r\n", " "), font)); cell.setColspan(10); cell.setBorder(PdfPCell.BOX); cell.setBorderColor(innerBorderColor); cell.setVerticalAlignment(PdfPCell.ALIGN_TOP); cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT); detailsTable.addCell(cell); table.addCell(createCell(new PdfPCell(detailsTable), table.getNumberOfColumns(), PdfPCell.ALIGN_CENTER, PdfPCell.BOX)); } }
From source file:be.mxs.common.util.pdf.general.dossierCreators.StaffDossierPDFCreator.java
private void addSalaryDetails(PdfPTable table, Salary salary) { PdfPTable detailsTable = new PdfPTable(10); detailsTable.setWidthPercentage(100); //*** XML 1 - benefits (multi-add) ************************** if (salary.benefits.length() > 0) { detailsTable.addCell(createSubtitleCell(getTran("web.hr", "benefits"), 10)); // header detailsTable.addCell(createHeaderCell(getTran("web.hr", "beginDate"), 1)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "endDate"), 1)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "period"), 2)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "type"), 3)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "amount"), 3)); try {/*from w w w . jav a 2 s. c o m*/ // parse benefits from xml SAXReader reader = new SAXReader(false); org.dom4j.Document document = reader.read(new StringReader(salary.benefits)); org.dom4j.Element benefitsElem = document.getRootElement(); if (benefitsElem != null) { String sTmpBegin, sTmpEnd, sTmpPeriod, sTmpType, sTmpAmount; org.dom4j.Element benefitElem; Iterator benefitsIter = benefitsElem.elementIterator("Benefit"); while (benefitsIter.hasNext()) { benefitElem = (org.dom4j.Element) benefitsIter.next(); sTmpBegin = checkString(benefitElem.elementText("Begin")); sTmpEnd = checkString(benefitElem.elementText("End")); sTmpPeriod = checkString(benefitElem.elementText("Period")); sTmpType = checkString(benefitElem.elementText("Type")); sTmpAmount = checkString(benefitElem.elementText("Amount")); // one benefit detailsTable.addCell(createValueCell(sTmpBegin, 1)); detailsTable.addCell(createValueCell(sTmpEnd, 1)); detailsTable.addCell(createValueCell(getTran("hr.salary.period", sTmpPeriod), 2)); detailsTable.addCell(createValueCell(getTran("hr.salary.benefit.type", sTmpType), 3)); cell = createValueCell( sTmpAmount + " " + MedwanQuery.getInstance().getConfigParam("currency", ""), 3); cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); detailsTable.addCell(cell); } } } catch (Exception e) { Debug.printStackTrace(e); } } //*** XML 2 - bonuses (multi-add) ************************** if (salary.bonuses.length() > 0) { table.addCell(createSubtitleCell(getTran("web.hr", "bonuses"), 10)); // header detailsTable.addCell(createHeaderCell(getTran("web.hr", "beginDate"), 1)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "endDate"), 1)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "period"), 2)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "type"), 2)); detailsTable.addCell(createHeaderCell(getTran("web", "percentage"), 2)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "amount"), 2)); try { // parse bonuses from xml SAXReader reader = new SAXReader(false); org.dom4j.Document document = reader.read(new StringReader(salary.bonuses)); org.dom4j.Element bonusesElem = document.getRootElement(); if (bonusesElem != null) { String sTmpBegin, sTmpEnd, sTmpPeriod, sTmpType, sTmpPercentage, sTmpAmount; org.dom4j.Element bonusElem; Iterator bonusesIter = bonusesElem.elementIterator("Bonus"); while (bonusesIter.hasNext()) { bonusElem = (org.dom4j.Element) bonusesIter.next(); sTmpBegin = checkString(bonusElem.elementText("Begin")); sTmpEnd = checkString(bonusElem.elementText("End")); sTmpPeriod = checkString(bonusElem.elementText("Period")); sTmpType = checkString(bonusElem.elementText("Type")); sTmpPercentage = checkString(bonusElem.elementText("Percentage")); sTmpAmount = checkString(bonusElem.elementText("Amount")); // one record detailsTable.addCell(createValueCell(sTmpBegin, 1)); detailsTable.addCell(createValueCell(sTmpEnd, 1)); detailsTable.addCell(createValueCell(sTmpPeriod, 2)); detailsTable.addCell(createValueCell(sTmpType, 2)); detailsTable.addCell(createValueCell(sTmpPercentage + "%", 2)); cell = createValueCell( sTmpAmount + " " + MedwanQuery.getInstance().getConfigParam("currency", ""), 2); cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); detailsTable.addCell(cell); } } } catch (Exception e) { Debug.printStackTrace(e); } } //*** XML 3 - otherIncome (multi-add) *********************** if (salary.otherIncome.length() > 0) { table.addCell(createSubtitleCell(getTran("web.hr", "otherIncome"), 10)); // header detailsTable.addCell(createHeaderCell(getTran("web.hr", "beginDate"), 1)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "endDate"), 1)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "period"), 2)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "type"), 3)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "amount"), 3)); try { // parse otherIncome from xml SAXReader reader = new SAXReader(false); org.dom4j.Document document = reader.read(new StringReader(salary.otherIncome)); org.dom4j.Element benefitsElem = document.getRootElement(); if (benefitsElem != null) { String sTmpBegin, sTmpEnd, sTmpPeriod, sTmpType, sTmpAmount; org.dom4j.Element otherIncomeElem; Iterator otherIncomesIter = benefitsElem.elementIterator("OtherIncome"); while (otherIncomesIter.hasNext()) { otherIncomeElem = (org.dom4j.Element) otherIncomesIter.next(); sTmpBegin = checkString(otherIncomeElem.elementText("Begin")); sTmpEnd = checkString(otherIncomeElem.elementText("End")); sTmpPeriod = checkString(otherIncomeElem.elementText("Period")); sTmpType = checkString(otherIncomeElem.elementText("Type")); sTmpAmount = checkString(otherIncomeElem.elementText("Amount")); // one record detailsTable.addCell(createValueCell(sTmpBegin, 1)); detailsTable.addCell(createValueCell(sTmpEnd, 1)); detailsTable.addCell(createValueCell(sTmpPeriod, 2)); detailsTable.addCell(createValueCell(sTmpType, 3)); cell = createValueCell( sTmpAmount + " " + MedwanQuery.getInstance().getConfigParam("currency", ""), 3); cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); detailsTable.addCell(cell); } } } catch (Exception e) { Debug.printStackTrace(e); } } //*** XML 4 - deductions (multi-add) ************************ if (salary.deductions.length() > 0) { detailsTable.addCell(createSubtitleCell(getTran("web.hr", "deductions"), 10)); // header detailsTable.addCell(createHeaderCell(getTran("web.hr", "beginDate"), 1)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "endDate"), 1)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "period"), 2)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "type"), 3)); detailsTable.addCell(createHeaderCell(getTran("web.hr", "amount"), 3)); try { // parse deductions from xml SAXReader reader = new SAXReader(false); org.dom4j.Document document = reader.read(new StringReader(salary.deductions)); org.dom4j.Element deductionsElem = document.getRootElement(); if (deductionsElem != null) { String sTmpBegin, sTmpEnd, sTmpPeriod, sTmpType, sTmpAmount; org.dom4j.Element deductionElem; Iterator deductionsIter = deductionsElem.elementIterator("Deduction"); while (deductionsIter.hasNext()) { deductionElem = (org.dom4j.Element) deductionsIter.next(); sTmpBegin = checkString(deductionElem.elementText("Begin")); sTmpEnd = checkString(deductionElem.elementText("End")); sTmpPeriod = checkString(deductionElem.elementText("Period")); sTmpType = checkString(deductionElem.elementText("Type")); sTmpAmount = checkString(deductionElem.elementText("Amount")); // one record detailsTable.addCell(createValueCell(sTmpBegin, 1)); detailsTable.addCell(createValueCell(sTmpEnd, 1)); detailsTable.addCell(createValueCell(sTmpPeriod, 2)); detailsTable.addCell(createValueCell(sTmpType, 3)); cell = createValueCell( sTmpAmount + " " + MedwanQuery.getInstance().getConfigParam("currency", ""), 3); cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); detailsTable.addCell(cell); } } } catch (Exception e) { Debug.printStackTrace(e); } } if (detailsTable.size() > 0) { table.addCell(emptyCell(3)); cell = createCell(new PdfPCell(detailsTable), table.getNumberOfColumns() - 3, PdfPCell.ALIGN_CENTER, PdfPCell.BOX); cell.setPadding(2); table.addCell(cell); } }
From source file:be.mxs.common.util.pdf.general.dossierCreators.StaffDossierPDFCreator.java
private void addWorkscheduleDetails(PdfPTable table, Workschedule schedule) throws Exception { PdfPTable detailsTable = new PdfPTable(10); detailsTable.setWidthPercentage(100); if (schedule.type.equals("day")) displayDaySchedule(detailsTable, schedule); else if (schedule.type.equals("week")) displayWeekSchedule(detailsTable, schedule); else if (schedule.type.equals("month")) displayMonthSchedule(detailsTable, schedule); if (detailsTable.size() > 0) { cell = createCell(new PdfPCell(detailsTable), table.getNumberOfColumns(), PdfPCell.ALIGN_CENTER, PdfPCell.BOX);//from w ww . j av a2 s.c o m cell.setPadding(2); table.addCell(cell); } }