Example usage for com.itextpdf.text Font Font

List of usage examples for com.itextpdf.text Font Font

Introduction

In this page you can find the example usage for com.itextpdf.text Font Font.

Prototype


public Font(final FontFamily family, final float size, final int style) 

Source Link

Document

Constructs a Font.

Usage

From source file:comisionesafis.informes.LiquidacionComisionesCabecera.java

@Override
public void onStartPage(PdfWriter writer, Document document) {
    Font fontFecha = new Font(Font.FontFamily.COURIER, 8, Font.NORMAL);
    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_RIGHT,
            new Phrase("11/04/2014", fontFecha), 500, 830, 0);
    Font fontPaginaNum = new Font(Font.FontFamily.COURIER, 8, Font.NORMAL);
    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_RIGHT,
            new Phrase("Pgina " + document.getPageNumber(), fontPaginaNum), 500, 823, 0);
    Font fontLIQ03 = new Font(Font.FontFamily.COURIER, 8, Font.NORMAL);
    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_RIGHT,
            new Phrase("LIQ03_0202", fontLIQ03), 500, 816, 0);
    Font fontTitulo = new Font(Font.FontFamily.COURIER, 12, Font.NORMAL);
    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER,
            new Phrase("LIQUIDACIN DE COMISIONES: Marzo 2014", fontTitulo), 300, 800, 0);
    Font fontDireccion = new Font(Font.FontFamily.COURIER, 10, Font.NORMAL);
    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_RIGHT,
            new Phrase("PELAYO MUTUA DE SEGUROS", fontDireccion), 400, 750, 0);
    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_RIGHT,
            new Phrase("CL SANTA ENGRACIA, 67", fontDireccion), 400, 730, 0);
}

From source file:comisionesafis.informes.LiquidacionComisionesPie.java

@Override
public void onEndPage(PdfWriter writer, Document document) {
    Font font = new Font(Font.FontFamily.COURIER, 8, Font.NORMAL);
    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_LEFT,
            new Phrase("Ejemplar para el mediador", font), 60, 20, 0);
}

From source file:Compras.altaCompras.java

   private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed
    // TODO add your handling code here:
    if(t_datos.getRowCount()>0)
    {//from  www .  jav  a 2  s. com
        javax.swing.JFileChooser jF1= new javax.swing.JFileChooser();
        jF1.setFileFilter(new ExtensionFileFilter("Excel document (*.pdf)", new String[] { "pdf" }));
        String ruta = null;
        if(jF1.showSaveDialog(null)==jF1.APPROVE_OPTION)
        {
            ruta = jF1.getSelectedFile().getAbsolutePath();
            if(ruta!=null)
            {
                Session session = HibernateUtil.getSessionFactory().openSession();
                try
                {
                    DecimalFormat formatoPorcentaje = new DecimalFormat("#,##0.00");
                    formatoPorcentaje.setMinimumFractionDigits(2);
                    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);

                    reporte.Abrir2(PageSize.LETTER.rotate(), "Valuacin", ruta+".pdf");
                    Font font = new Font(Font.FontFamily.HELVETICA, 5, 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[]{10,10,80,5,5,5,5,5,14,10,25,23,8,8,8,10,10,10};
                        

                    PdfPTable tabla=reporte.crearTabla(tam.length, tam, 100, Element.ALIGN_LEFT);

                    cabecera(reporte, bf, tabla);
                    int ren=0;
                        
                    //double dm=0d, cam=0d, min=0d, med=0d, max=0d, pin=0d, tot=0d;

                    for(int i=0; i<t_datos.getRowCount(); i++)
                    {
                        tabla.addCell(reporte.celda(t_titulos.getValueAt(i, 0).toString(), font, contenido, derecha, 0,1,Rectangle.RECTANGLE));
                        tabla.addCell(reporte.celda(t_titulos.getValueAt(i, 1).toString(), font, contenido, derecha, 0,1,Rectangle.RECTANGLE));
                        tabla.addCell(reporte.celda(t_titulos.getValueAt(i, 2).toString(), font, contenido, izquierda, 0,1,Rectangle.RECTANGLE));
                        if( ((boolean)t_datos.getValueAt(i, 1)) ==true)
                            tabla.addCell(reporte.celda("x", font, contenido, derecha, 0,1,Rectangle.RECTANGLE));
                        else
                            tabla.addCell(reporte.celda(" ", font, contenido, derecha, 0,1,Rectangle.RECTANGLE));
                            
                        if( ((boolean)t_datos.getValueAt(i, 2)) ==true)
                            tabla.addCell(reporte.celda("x", font, contenido, derecha, 0,1,Rectangle.RECTANGLE));
                        else
                            tabla.addCell(reporte.celda(" ", font, contenido, derecha, 0,1,Rectangle.RECTANGLE));
                            
                        if( ((boolean)t_datos.getValueAt(i, 3)) ==true)
                            tabla.addCell(reporte.celda("x", font, contenido, derecha, 0,1,Rectangle.RECTANGLE));
                        else
                            tabla.addCell(reporte.celda(" ", font, contenido, derecha, 0,1,Rectangle.RECTANGLE));
                            
                        if( ((boolean)t_datos.getValueAt(i, 4)) ==true)
                            tabla.addCell(reporte.celda("x", font, contenido, derecha, 0,1,Rectangle.RECTANGLE));
                        else
                            tabla.addCell(reporte.celda(" ", font, contenido, derecha, 0,1,Rectangle.RECTANGLE));
                            
                        if( (t_datos.getValueAt(i, 6)) != null)
                            tabla.addCell(reporte.celda("x", font, contenido, derecha, 0,1,Rectangle.RECTANGLE));
                        else
                            tabla.addCell(reporte.celda(" ", font, contenido, derecha, 0,1,Rectangle.RECTANGLE));
                            
                        tabla.addCell(reporte.celda(formatoPorcentaje.format(t_datos.getValueAt(i, 14)), font, contenido, derecha, 0,1,Rectangle.RECTANGLE));
                            
                        tabla.addCell(reporte.celda(t_datos.getValueAt(i, 8).toString(), font, contenido, derecha, 0,1,Rectangle.RECTANGLE));
                            
                        tabla.addCell(reporte.celda(t_datos.getValueAt(i, 10).toString(), font, contenido, derecha, 0,1,Rectangle.RECTANGLE));
                            
                        tabla.addCell(reporte.celda(formatoPorcentaje.format(t_datos.getValueAt(i, 15)), font, contenido, derecha, 0,1,Rectangle.RECTANGLE));
                            
                        if( ((boolean)t_datos.getValueAt(i, 17)) ==true)
                            tabla.addCell(reporte.celda("x", font, contenido, derecha, 0,1,Rectangle.RECTANGLE));
                        else
                            tabla.addCell(reporte.celda(" ", font, contenido, derecha, 0,1,Rectangle.RECTANGLE));
                            
                        if( ((boolean)t_datos.getValueAt(i, 18)) ==true)
                            tabla.addCell(reporte.celda("x", font, contenido, derecha, 0,1,Rectangle.RECTANGLE));
                        else
                            tabla.addCell(reporte.celda(" ", font, contenido, derecha, 0,1,Rectangle.RECTANGLE));
                            
                        if( ((boolean)t_datos.getValueAt(i, 19)) ==true)
                            tabla.addCell(reporte.celda("x", font, contenido, derecha, 0,1,Rectangle.RECTANGLE));
                        else
                            tabla.addCell(reporte.celda(" ", font, contenido, derecha, 0,1,Rectangle.RECTANGLE));
                            
                        if(t_datos.getValueAt(i, 20)!=null)
                            tabla.addCell(reporte.celda(t_datos.getValueAt(i, 20).toString(), font, contenido, derecha, 0,1,Rectangle.RECTANGLE));
                        else
                            tabla.addCell(reporte.celda(" ", font, contenido, derecha, 0,1,Rectangle.RECTANGLE));
                            
                        if(t_datos.getValueAt(i, 26)!=null)
                            tabla.addCell(reporte.celda(t_datos.getValueAt(i, 26).toString(), font, contenido, derecha, 0,1,Rectangle.RECTANGLE));
                        else
                            tabla.addCell(reporte.celda(" ", font, contenido, derecha, 0,1,Rectangle.RECTANGLE));
                            
                        if( ((boolean)t_datos.getValueAt(i, 27)) ==true)
                            tabla.addCell(reporte.celda("x", font, contenido, derecha, 0,1,Rectangle.RECTANGLE));
                        else
                            tabla.addCell(reporte.celda(" ", font, contenido, derecha, 0,1,Rectangle.RECTANGLE));
                            
                    }
                        
                    tabla.setHeaderRows(1);
                    reporte.agregaObjeto(tabla);
                    reporte.cerrar();
                    reporte.visualizar2(ruta+".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.close();
            }
        }
    }
}

From source file:Compras.altaCompras.java

public void cabecera(PDF reporte, BaseFont bf, PdfPTable tabla) {
     Session session = HibernateUtil.getSessionFactory().openSession();
     try {/*  ww w.  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, 575, 0);
         reporte.contenido.setFontAndSize(bf, 8);
         reporte.contenido.setColorFill(BaseColor.BLACK);
         String titulo = "Reporte";
         reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, titulo, 35, 565, 0);
         reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT,
                 "Fecha:" + new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date()), 750, 575, 0);

         reporte.finTexto();
         //agregamos renglones vacios para dejar un espacio
         reporte.agregaObjeto(new Paragraph(" "));
         /*reporte.agregaObjeto(new Paragraph(" "));
         reporte.agregaObjeto(new Paragraph(" "));
         reporte.agregaObjeto(new Paragraph(" "));*/
         //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;

         tabla.addCell(reporte.celda("NO", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
         tabla.addCell(reporte.celda("#", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
         tabla.addCell(reporte.celda("DESCRIPCION", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
         tabla.addCell(reporte.celda("H", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
         tabla.addCell(reporte.celda("M", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
         tabla.addCell(reporte.celda("S", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
         tabla.addCell(reporte.celda("E", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
         tabla.addCell(reporte.celda("P", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
         tabla.addCell(reporte.celda("C. AUT", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
         tabla.addCell(reporte.celda("MED", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
         tabla.addCell(reporte.celda("NO PART", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
         tabla.addCell(reporte.celda("$ AUT", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
         tabla.addCell(reporte.celda("AUT", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
         tabla.addCell(reporte.celda("COT", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
         tabla.addCell(reporte.celda("COM", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
         tabla.addCell(reporte.celda("ORI", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
         tabla.addCell(reporte.celda("NO PED", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
         tabla.addCell(reporte.celda("OK", 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:Compras.Formatos.java

public void prefactura() {
    h = new Herramientas(usr, 0);
    h.session(sessionPrograma);/*from   ww  w.j a v a 2s  . co  m*/
    session = HibernateUtil.getSessionFactory().openSession();
    ord = (Orden) session.get(Orden.class, ord.getIdOrden());
    //factura=(Factura)session.get(Factura.class, factura.getIdFactura());
    try {
        DecimalFormat formatoPorcentaje = new DecimalFormat("#,##0.000");
        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);
        File folder = new File("reportes/" + ord.getIdOrden());
        folder.mkdirs();
        reporte.Abrir(PageSize.LETTER, "Pedido", "reportes/" + ord.getIdOrden() + "/" + valor + "-preFac.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[] { 40, 40, 350, 70, 70 };
        PdfPTable tabla = reporte.crearTabla(5, tam, 100, Element.ALIGN_LEFT);

        //Pedido ord = (Pedido)session.get(Pedido.class, Integer.parseInt(this.no_ped));
        cabeceraPre(reporte, bf, tabla);

        Partida[] cuentas = (Partida[]) session.createCriteria(Partida.class)
                .add(Restrictions.eq("ordenByIdOrden.idOrden", ord.getIdOrden()))
                .add(Restrictions.eq("facturado", true)).add(Restrictions.eq("incluida", false))
                .addOrder(Order.asc("idEvaluacion")).addOrder(Order.asc("subPartida")).list()
                .toArray(new Partida[0]);
        Partida[] enlazadas = (Partida[]) session.createCriteria(Partida.class)
                .add(Restrictions.eq("ordenByEnlazada.idOrden", ord.getIdOrden()))
                .add(Restrictions.eq("facturado", true)).addOrder(Order.asc("idEvaluacion"))
                .addOrder(Order.asc("subPartida")).list().toArray(new Partida[0]);
        Adicionales[] externas = (Adicionales[]) session.createCriteria(Adicionales.class)
                .add(Restrictions.eq("orden.idOrden", ord.getIdOrden())).addOrder(Order.asc("idAdicionales"))
                .list().toArray(new Adicionales[0]);

        //**********agregamos la mano de obra*******************
        double tot_mo = 0.0d;
        Query query = session.createQuery("SELECT SUM( " + "(CASE WHEN dm>0 THEN (dm*cant) ELSE 0 END) + "
                + "(CASE WHEN cam>0 THEN (cam*cant) ELSE 0 END) + "
                + "(CASE WHEN repMin>0 THEN (repMin*cant) ELSE 0 END) + "
                + "(CASE WHEN repMed>0 THEN (repMed*cant) ELSE 0 END) + "
                + "(CASE WHEN repMax>0 THEN (repMax*cant) ELSE 0 END) + "
                + "(CASE WHEN pint>0 THEN (pint*cant) ELSE 0 END) " + ") from Partida "
                + " where ordenByIdOrden.idOrden =" + ord.getIdOrden() + " OR ordenByEnlazada.idOrden ="
                + ord.getIdOrden());
        Object ent = query.uniqueResult();
        if (ent != null) {
            tot_mo = Double.parseDouble(ent.toString()) * ord.getCompania().getImporteHora();
        }
        if (ord.getMoDirecta() > 0d)
            tot_mo = ord.getMoDirecta();
        tabla.addCell(reporte.celda("1", font, contenido, derecha, 0, 1, 12));
        tabla.addCell(reporte.celda("NA", font, contenido, izquierda, 0, 1, 12));
        tabla.addCell(reporte.celda("MANO DE OBRA", font, contenido, izquierda, 0, 1, 12));
        tabla.addCell(reporte.celda("" + formatoPorcentaje.format(tot_mo), font, contenido, derecha, 0, 1, 12));
        tabla.addCell(reporte.celda("" + formatoPorcentaje.format(tot_mo), font, contenido, derecha, 0, 1, 12));
        int ren = 0;
        double total = tot_mo;
        if (cuentas.length > 0) {
            for (int i = 0; i < cuentas.length; i++) {
                tabla.addCell(reporte.celda("" + cuentas[i].getCantidadFactura(), font, contenido, derecha, 0,
                        1, 12));
                tabla.addCell(reporte.celda(cuentas[i].getMed(), font, contenido, izquierda, 0, 1, 12));
                tabla.addCell(reporte.celda(cuentas[i].getDescripcionFactura().toUpperCase(), font, contenido,
                        izquierda, 0, 1, 12));
                tabla.addCell(reporte.celda("" + formatoPorcentaje.format(cuentas[i].getPrecioFactura()), font,
                        contenido, derecha, 0, 1, 12));
                double tot = cuentas[i].getPrecioFactura() * cuentas[i].getCantidadFactura();
                total += tot;
                tabla.addCell(
                        reporte.celda("" + formatoPorcentaje.format(tot), font, contenido, derecha, 0, 1, 12));
                /*if(ren==30)
                {
                tabla.addCell(reporte.celda("", font, contenido, izquierda, 0,1,12));
                tabla.addCell(reporte.celda("", font, contenido, derecha, 0,1,12));
                tabla.addCell(reporte.celda(">> continua en la siguente hoja <<", font, contenido, derecha, 0,1,12));
                tabla.addCell(reporte.celda("", font, contenido, derecha, 0,1,12));
                tabla.addCell(reporte.celda("", font, contenido, derecha, 0,1,12));
                reporte.agregaObjeto(tabla);
                reporte.writer.newPage();
                tabla=reporte.crearTabla(5, tam, 100, Element.ALIGN_LEFT);
                this.cabeceraPre(reporte, bf, tabla);
                ren=-1;
                }
                ren++;*/
            }
        }
        if (enlazadas.length > 0) {
            for (int i = 0; i < enlazadas.length; i++) {
                tabla.addCell(reporte.celda("" + enlazadas[i].getCantidadFactura(), font, contenido, derecha, 0,
                        1, 12));
                tabla.addCell(reporte.celda(enlazadas[i].getMed(), font, contenido, izquierda, 0, 1, 12));
                tabla.addCell(reporte.celda(enlazadas[i].getDescripcionFactura().toUpperCase(), font, contenido,
                        izquierda, 0, 1, 12));
                tabla.addCell(reporte.celda("" + formatoPorcentaje.format(enlazadas[i].getPrecioFactura()),
                        font, contenido, derecha, 0, 1, 12));
                double tot = enlazadas[i].getPrecioFactura() * enlazadas[i].getCantidadFactura();
                total += tot;
                tabla.addCell(
                        reporte.celda("" + formatoPorcentaje.format(tot), font, contenido, derecha, 0, 1, 12));
                /*if(ren==30)
                {
                tabla.addCell(reporte.celda("", font, contenido, izquierda, 0,1,12));
                tabla.addCell(reporte.celda("", font, contenido, derecha, 0,1,12));
                tabla.addCell(reporte.celda(">> continua en la siguente hoja <<", font, contenido, derecha, 0,1,12));
                tabla.addCell(reporte.celda("", font, contenido, derecha, 0,1,12));
                tabla.addCell(reporte.celda("", font, contenido, derecha, 0,1,12));
                reporte.agregaObjeto(tabla);
                reporte.writer.newPage();
                tabla=reporte.crearTabla(17, tam, 100, Element.ALIGN_LEFT);
                this.cabeceraPre(reporte, bf, tabla);
                ren=-1;
                }
                ren++;*/
            }
        }
        if (externas.length > 0) {
            for (int ex = 0; ex < externas.length; ex++) {
                tabla.addCell(
                        reporte.celda("" + externas[ex].getCantidad(), font, contenido, derecha, 0, 1, 12));
                tabla.addCell(reporte.celda(externas[ex].getMedida(), font, contenido, izquierda, 0, 1, 12));
                tabla.addCell(reporte.celda(externas[ex].getDescripcion().toUpperCase(), font, contenido,
                        izquierda, 0, 1, 12));
                tabla.addCell(reporte.celda("" + formatoPorcentaje.format(externas[ex].getPrecio()), font,
                        contenido, derecha, 0, 1, 12));
                double tot = externas[ex].getPrecio() * externas[ex].getCantidad();
                total += tot;
                tabla.addCell(
                        reporte.celda("" + formatoPorcentaje.format(tot), font, contenido, derecha, 0, 1, 12));
                /*if(ren==30)
                {
                tabla.addCell(reporte.celda("", font, contenido, izquierda, 0,1,12));
                tabla.addCell(reporte.celda("", font, contenido, derecha, 0,1,12));
                tabla.addCell(reporte.celda(">> continua en la siguente hoja <<", font, contenido, derecha, 0,1,12));
                tabla.addCell(reporte.celda("", font, contenido, derecha, 0,1,12));
                tabla.addCell(reporte.celda("", font, contenido, derecha, 0,1,12));
                reporte.agregaObjeto(tabla);
                reporte.writer.newPage();
                tabla=reporte.crearTabla(17, tam, 100, Element.ALIGN_LEFT);
                this.cabeceraPre(reporte, bf, tabla);
                ren=-1;
                }
                ren++;*/
            }
        }
        PdfPTable tabla1 = reporte.crearTabla(5, tam, 100, Element.ALIGN_LEFT);
        tabla1.addCell(reporte.celda("Metodo de Pago: NO IDENTIFICADO", font, contenido, izquierda, 3, 1,
                Rectangle.TOP));
        tabla1.addCell(reporte.celda("SUB-TOTAL:", font, contenido, derecha, 0, 1,
                Rectangle.TOP + Rectangle.BOTTOM + 12));
        tabla1.addCell(reporte.celda(formatoPorcentaje.format(total), font, contenido, derecha, 0, 1,
                Rectangle.TOP + Rectangle.BOTTOM + 12));
        tabla1.addCell(
                reporte.celda("Lugar de Expedicin: ", font, contenido, izquierda, 3, 1, Rectangle.NO_BORDER));
        tabla1.addCell(reporte.celda("IVA:", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));
        Configuracion con = (Configuracion) session.get(Configuracion.class, 1);
        double iva = total * (con.getIva() * 0.01);
        tabla1.addCell(reporte.celda(formatoPorcentaje.format(iva), font, contenido, derecha, 0, 1,
                Rectangle.RECTANGLE));
        tabla1.addCell(
                reporte.celda("(CANTIDAD CON LETRA)", font, contenido, izquierda, 3, 2, Rectangle.NO_BORDER));
        tabla1.addCell(reporte.celda("DEDUCIBLE:", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));
        tabla1.addCell(reporte.celda("$0.00", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));
        tabla1.addCell(reporte.celda("TOTAL:", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));
        total += iva;
        tabla1.addCell(reporte.celda(formatoPorcentaje.format(total), font, contenido, derecha, 0, 1,
                Rectangle.RECTANGLE));
        tabla1.addCell(reporte.celda("PAGO EN UNA SOLA EXHIBICIN", font, contenido, izquierda, 3, 1,
                Rectangle.NO_BORDER));
        tabla1.addCell(
                reporte.celda("EFECTOS FISCALES AL PAGO", font, contenido, centro, 2, 1, Rectangle.NO_BORDER));
        session.beginTransaction().rollback();

        tabla.setHeaderRows(2);
        reporte.agregaObjeto(tabla);
        float tam1[] = new float[] { 180, 180, 180, 180 };
        PdfPTable tabla2 = reporte.crearTabla(4, tam1, 100, Element.ALIGN_LEFT);
        tabla2.addCell(
                reporte.celda(reporte.Imagen("imagenes/rq.png"), contenido, centro, 0, 8, Rectangle.NO_BORDER));
        tabla2.addCell(reporte.celda("Regimen Fiscal:REGIMEN GENERAL DE LEY DE PERSONAS MORALES", font,
                contenido, centro, 3, 1, Rectangle.BOTTOM));
        tabla2.addCell(reporte.celda("Sello Digital del SAT:", font, contenido, izquierda, 3, 1, 12));
        tabla2.addCell(reporte.celda(" ", font, contenido, izquierda, 3, 1, 12));
        tabla2.addCell(reporte.celda("Sello Digital del Emisor:", font, contenido, izquierda, 3, 1, 12));
        tabla2.addCell(reporte.celda(" ", font, contenido, izquierda, 3, 1, 12));
        tabla2.addCell(reporte.celda("Cadena original del complemento de certificacin digital del SAT:", font,
                contenido, izquierda, 3, 1, 12));
        tabla2.addCell(reporte.celda(" ", font, contenido, izquierda, 3, 1, 12));
        tabla2.addCell(reporte.celda("Este documento es una representacin impresa de un CFDI", font,
                contenido, izquierda, 3, 1, Rectangle.TOP));

        reporte.agregaObjeto(tabla1);
        reporte.agregaObjeto(tabla2);
        reporte.cerrar();
        reporte.visualizar("reportes/" + ord.getIdOrden() + "/" + valor + "-preFac.pdf");

    } catch (Exception e) {
        System.out.println(e);
        e.printStackTrace();
        JOptionPane.showMessageDialog(null, "No se pudo realizar el reporte si el archivo esta abierto.");
    }
}

From source file:Compras.Formatos.java

void pedidos() {
    h = new Herramientas(usr, 0);
    h.session(sessionPrograma);//w  w  w.j a v  a2s  . com
    session = HibernateUtil.getSessionFactory().openSession();
    ord = (Orden) session.get(Orden.class, ord.getIdOrden());
    try {
        DecimalFormat formatoPorcentaje = new DecimalFormat("#,##0.000");
        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);
        File folder = new File("reportes/" + ord.getIdOrden());
        folder.mkdirs();
        reporte.Abrir(PageSize.LETTER, "cabecera",
                "reportes/" + ord.getIdOrden() + "/" + valor + "-pedido.pdf");

        Font font = new Font(Font.FontFamily.TIMES_ROMAN, 8, 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[] { 20, 30, 25, 60, 190, 25, 30, 20, 40, 40 };
        PdfPTable tabla = reporte.crearTabla(10, tam, 100, Element.ALIGN_LEFT);

        Pedido ped = (Pedido) session.get(Pedido.class, Integer.parseInt(this.no_ped));
        if (ped.getUsuarioByAutorizo() != null && ped.getUsuarioByAutorizo2() != null) {
            reporte.estatusAutoriza(ped.getUsuarioByAutorizo().getEmpleado().getNombre(),
                    ped.getUsuarioByAutorizo2().getEmpleado().getNombre());
        } else
            reporte.estatusAutoriza("", "       NO AUTORIZADO");
        cabecera(reporte, bf, tabla, ped);

        Partida[] cuentas = (Partida[]) session.createCriteria(Partida.class)
                .add(Restrictions.eq("ordenByIdOrden.idOrden", ord.getIdOrden()))
                .add(Restrictions.eq("pedido.idPedido", Integer.parseInt(no_ped)))
                .addOrder(Order.asc("idEvaluacion")).addOrder(Order.asc("subPartida")).list()
                .toArray(new Partida[0]);

        int ren = 0;
        double total = 0d;
        if (cuentas.length > 0) {
            for (int i = 0; i < cuentas.length; i++) {
                int r = i + 1;
                //consecutivo
                tabla.addCell(reporte.celda("" + r, font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));

                //Partida y subpartida
                tabla.addCell(
                        reporte.celda("" + cuentas[i].getIdEvaluacion() + " " + cuentas[i].getSubPartida(),
                                font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));

                //folio del articulo de articulo
                tabla.addCell(reporte.celda("" + cuentas[i].getCatalogo().getIdCatalogo(), font, contenido,
                        derecha, 0, 1, Rectangle.RECTANGLE));
                if (cuentas[i].getEjemplar() != null) {
                    //No de parte
                    tabla.addCell(reporte.celda("" + cuentas[i].getEjemplar().getIdParte(), font, contenido,
                            derecha, 0, 1, Rectangle.RECTANGLE));
                } else
                    tabla.addCell(reporte.celda(" ", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));

                //Descripcion
                tabla.addCell(reporte.celda(cuentas[i].getCatalogo().getNombre(), font, contenido, izquierda, 0,
                        1, Rectangle.RECTANGLE));

                //Medida
                tabla.addCell(reporte.celda(cuentas[i].getMed(), font, contenido, derecha, 0, 1,
                        Rectangle.RECTANGLE));

                if (cuentas[i].getPlazo() != null)//plazo de entrega
                    tabla.addCell(reporte.celda("" + cuentas[i].getPlazo(), font, contenido, derecha, 0, 1,
                            Rectangle.RECTANGLE));
                else
                    tabla.addCell(reporte.celda("0", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));

                if (cuentas[i].getCantPcp() > 0)//cantidad a comprar
                    tabla.addCell(reporte.celda("" + cuentas[i].getCantPcp(), font, contenido, derecha, 0, 1,
                            Rectangle.RECTANGLE));
                else
                    tabla.addCell(reporte.celda("0", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));

                if (cuentas[i].getPcp() != null)//costo unit
                    tabla.addCell(reporte.celda(formatoPorcentaje.format(cuentas[i].getPcp()), font, contenido,
                            derecha, 0, 1, Rectangle.RECTANGLE));
                else
                    tabla.addCell(reporte.celda("0.00", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));

                if (cuentas[i].getCantPcp() > 0 && cuentas[i].getPcp() != null)//costo total
                {
                    double sum = cuentas[i].getCantPcp() * cuentas[i].getPcp();
                    total += sum;
                    tabla.addCell(reporte.celda(formatoPorcentaje.format(sum), font, contenido, derecha, 0, 1,
                            Rectangle.RECTANGLE));
                } else
                    tabla.addCell(reporte.celda("0.00", font, contenido, derecha, 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, ped);
                ren=-1;
                }*/
                ren++;
            }
        }
        tabla.addCell(reporte.celda("[Los montos estan en Pesos]", font, contenido, izquierda, 4, 1,
                Rectangle.NO_BORDER));
        tabla.addCell(reporte.celda("Sub-total:", font, contenido, derecha, 5, 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, 9, 1, Rectangle.NO_BORDER));
        double iva = total * 0.16d;
        tabla.addCell(reporte.celda(formatoPorcentaje.format(iva), font, contenido, derecha, 0, 1,
                Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("Total:", font, contenido, derecha, 9, 1, Rectangle.NO_BORDER));
        total += iva;
        tabla.addCell(reporte.celda(formatoPorcentaje.format(total), font, contenido, derecha, 0, 1,
                Rectangle.RECTANGLE));
        if (ped.getNotas() != null)
            tabla.addCell(reporte.celda("Notas: " + ped.getNotas(), font, contenido, izquierda, 10, 1,
                    Rectangle.NO_BORDER));
        tabla.setHeaderRows(1);
        session.beginTransaction().rollback();

        reporte.agregaObjeto(tabla);
        reporte.cerrar();
        reporte.visualizar("reportes/" + ord.getIdOrden() + "/" + valor + "-pedido.pdf");

    } catch (Exception e) {
        System.out.println(e);
        e.printStackTrace();
        JOptionPane.showMessageDialog(null, "No se pudo realizar el reporte si el archivo esta abierto.");
    }
}

From source file:Compras.Formatos.java

void pedidosExternos(int pedido) {
    h = new Herramientas(usr, 0);
    h.session(sessionPrograma);//www  .jav a2  s  . c  om
    session = HibernateUtil.getSessionFactory().openSession();
    Pedido ped = (Pedido) session.get(Pedido.class, pedido);
    try {
        DecimalFormat formatoPorcentaje = new DecimalFormat("#,##0.000");
        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);
        File folder = new File("reportes/externos");
        folder.mkdirs();
        reporte.Abrir(PageSize.LETTER, "cabecera", "reportes/externos/" + valor + "-pedido.pdf");
        //Font font = new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD);
        Font font = new Font(Font.FontFamily.TIMES_ROMAN, 8, 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[] { 20, 30, 25, 60, 190, 25, 30, 20, 40, 40 };
        PdfPTable tabla = reporte.crearTabla(10, tam, 100, Element.ALIGN_LEFT);

        //Pedido ped = (Pedido)session.get(Pedido.class, Integer.parseInt(this.no_ped));
        if (ped.getUsuarioByAutorizo() != null && ped.getUsuarioByAutorizo2() != null) {
            reporte.estatusAutoriza(ped.getUsuarioByAutorizo().getEmpleado().getNombre(),
                    ped.getUsuarioByAutorizo2().getEmpleado().getNombre());
        } else
            reporte.estatusAutoriza("", "       NO AUTORIZADO");
        cabecera(reporte, bf, tabla, ped);

        PartidaExterna[] cuentas = (PartidaExterna[]) session.createCriteria(PartidaExterna.class).
        //add(Restrictions.eq("ordenByIdOrden.idOrden", ord.getIdOrden())).
                add(Restrictions.eq("pedido.idPedido", pedido)).addOrder(Order.asc("idPartidaExterna")).list()
                .toArray(new PartidaExterna[0]);

        int ren = 0;
        double total = 0d;
        if (cuentas.length > 0) {
            for (int i = 0; i < cuentas.length; i++) {
                int r = i + 1;
                //consecutivo
                tabla.addCell(reporte.celda("" + r, font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));

                //Partida y subpartida
                if (cuentas[i].getPartida() != null)
                    tabla.addCell(
                            reporte.celda("" + cuentas[i].getPartida() + " " + cuentas[i].getIdValuacion(),
                                    font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));
                else
                    tabla.addCell(reporte.celda("", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));

                //folio del articulo de articulo
                tabla.addCell(reporte.celda("", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));
                tabla.addCell(reporte.celda("" + cuentas[i].getNoParte(), font, contenido, derecha, 0, 1,
                        Rectangle.RECTANGLE));

                //Descripcion
                tabla.addCell(reporte.celda(cuentas[i].getDescripcion(), font, contenido, izquierda, 0, 1,
                        Rectangle.RECTANGLE));

                //Medida
                tabla.addCell(reporte.celda(cuentas[i].getUnidad(), font, contenido, derecha, 0, 1,
                        Rectangle.RECTANGLE));

                if (cuentas[i].getPlazo() != null)//plazo de entrega
                    tabla.addCell(reporte.celda("" + cuentas[i].getPlazo(), font, contenido, derecha, 0, 1,
                            Rectangle.RECTANGLE));
                else
                    tabla.addCell(reporte.celda("0", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));

                //cantidad a compra
                tabla.addCell(reporte.celda("" + cuentas[i].getCantidad(), font, contenido, derecha, 0, 1,
                        Rectangle.RECTANGLE));

                tabla.addCell(reporte.celda(formatoPorcentaje.format(cuentas[i].getCosto()), font, contenido,
                        derecha, 0, 1, Rectangle.RECTANGLE));

                double sum = cuentas[i].getCantidad() * cuentas[i].getCosto();
                total += sum;
                tabla.addCell(reporte.celda(formatoPorcentaje.format(sum), font, contenido, derecha, 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, ped);
                    ren=-1;
                }
                ren++;*/
            }
        }

        tabla.addCell(reporte.celda("[Los montos estan en Pesos]", font, contenido, izquierda, 4, 1,
                Rectangle.NO_BORDER));
        tabla.addCell(reporte.celda("Sub-total:", font, contenido, derecha, 5, 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, 9, 1, Rectangle.NO_BORDER));
        double iva = total * 0.16d;
        tabla.addCell(reporte.celda(formatoPorcentaje.format(iva), font, contenido, derecha, 0, 1,
                Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("Total:", font, contenido, derecha, 9, 1, Rectangle.NO_BORDER));
        total += iva;
        tabla.addCell(reporte.celda(formatoPorcentaje.format(total), font, contenido, derecha, 0, 1,
                Rectangle.RECTANGLE));
        if (ped.getNotas() != null)
            tabla.addCell(reporte.celda("Notas: " + ped.getNotas(), font, contenido, izquierda, 10, 1,
                    Rectangle.NO_BORDER));

        tabla.setHeaderRows(1);
        session.beginTransaction().rollback();

        reporte.agregaObjeto(tabla);

        reporte.cerrar();
        reporte.visualizar("reportes/externos/" + valor + "-pedido.pdf");

    } catch (Exception e) {
        System.out.println(e);
        e.printStackTrace();
        JOptionPane.showMessageDialog(null, "No se pudo realizar el reporte si el archivo esta abierto.");
    }
}

From source file:Compras.Formatos.java

void ordenCompra() {
    h = new Herramientas(usr, 0);
    h.session(sessionPrograma);/*from   w  w w . j a v a  2 s  . co  m*/
    session = HibernateUtil.getSessionFactory().openSession();
    ord = (Orden) session.get(Orden.class, ord.getIdOrden());
    try {
        DecimalFormat formatoPorcentaje = new DecimalFormat("#,##0.000");
        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);
        File folder = new File("reportes/" + ord.getIdOrden());
        folder.mkdirs();
        reporte.Abrir(PageSize.LETTER, "cabecera", "reportes/" + ord.getIdOrden() + "/" + valor + "-orden.pdf");
        //Font font = new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD);
        Font font = new Font(Font.FontFamily.TIMES_ROMAN, 8, 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[] { 20, 20, 220, 40, 90, 50, 50 };
        PdfPTable tabla = reporte.crearTabla(7, tam, 100, Element.ALIGN_LEFT);

        Pedido ped = (Pedido) session.get(Pedido.class, Integer.parseInt(no_ped));
        if (ped.getUsuarioByAutorizo() != null && ped.getUsuarioByAutorizo2() != null) {
            reporte.estatusAutoriza(ped.getUsuarioByAutorizo().getEmpleado().getNombre(),
                    ped.getUsuarioByAutorizo2().getEmpleado().getNombre());
        } else
            reporte.estatusAutoriza("", "       NO AUTORIZADO");
        cabeceraCompra(reporte, bf, tabla, ped);

        Partida[] cuentas = (Partida[]) session.createCriteria(Partida.class)
                .add(Restrictions.eq("ordenByIdOrden.idOrden", ord.getIdOrden()))
                .add(Restrictions.eq("pedido.idPedido", Integer.parseInt(no_ped)))
                .addOrder(Order.asc("idEvaluacion")).addOrder(Order.asc("subPartida")).list()
                .toArray(new Partida[0]);

        int ren = 0;
        double total = 0d;
        if (cuentas.length > 0) {
            for (int i = 0; i < cuentas.length; i++) {
                int r = i + 1;
                //consecutivo
                tabla.addCell(reporte.celda("" + r, font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));

                if (cuentas[i].getCantPcp() > 0)//cantidad a comprar
                    tabla.addCell(reporte.celda("" + cuentas[i].getCantPcp(), font, contenido, derecha, 0, 1,
                            Rectangle.RECTANGLE));
                else
                    tabla.addCell(reporte.celda("0", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));

                //Descripcion
                tabla.addCell(reporte.celda(cuentas[i].getCatalogo().getNombre(), font, contenido, izquierda, 0,
                        1, Rectangle.RECTANGLE));

                //folio del articulo-partida-subpartida
                tabla.addCell(reporte.celda(
                        "" + cuentas[i].getCatalogo().getIdCatalogo() + "-" + cuentas[i].getIdEvaluacion() + "-"
                                + cuentas[i].getSubPartida(),
                        font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));

                if (cuentas[i].getEjemplar() != null) {
                    //No de parte
                    tabla.addCell(reporte.celda("" + cuentas[i].getEjemplar().getIdParte(), font, contenido,
                            derecha, 0, 1, Rectangle.RECTANGLE));
                } else
                    tabla.addCell(reporte.celda(" ", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));

                if (cuentas[i].getPcp() != null)//costo unit
                    tabla.addCell(reporte.celda(formatoPorcentaje.format(cuentas[i].getPcp()), font, contenido,
                            derecha, 0, 1, Rectangle.RECTANGLE));
                else
                    tabla.addCell(reporte.celda("0.00", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));

                if (cuentas[i].getCantPcp() > 0 && cuentas[i].getPcp() != null)//costo total
                {
                    double sum = cuentas[i].getCantPcp() * cuentas[i].getPcp();
                    total += sum;
                    tabla.addCell(reporte.celda(formatoPorcentaje.format(sum), font, contenido, derecha, 0, 1,
                            Rectangle.RECTANGLE));
                } else
                    tabla.addCell(reporte.celda("0.00", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));

                /*if(ren==38)
                {
                    reporte.agregaObjeto(tabla);
                    reporte.writer.newPage();
                    tabla=reporte.crearTabla(7, tam, 100, Element.ALIGN_LEFT);
                    cabeceraCompra(reporte, bf, tabla, ped);
                    ren=-1;
                }*/
                ren++;
            }
        }
        if (ped.getNotas() != null)
            tabla.addCell(reporte.celda("Notas:" + ped.getNotas(), font, contenido, izquierda, 7, 1,
                    Rectangle.BOTTOM));
        else
            tabla.addCell(reporte.celda("Notas:", font, contenido, izquierda, 7, 1, Rectangle.BOTTOM));
        tabla.addCell(reporte.celda("[Los montos estan en Pesos]", font, contenido, izquierda, 3, 1,
                Rectangle.NO_BORDER));
        tabla.addCell(reporte.celda("Sub-total:", font, contenido, derecha, 3, 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, 6, 1, Rectangle.NO_BORDER));
        double iva = total * 0.16d;
        tabla.addCell(reporte.celda(formatoPorcentaje.format(iva), font, contenido, derecha, 0, 1,
                Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("Total:", font, contenido, derecha, 6, 1, Rectangle.NO_BORDER));
        total += iva;
        tabla.addCell(reporte.celda(formatoPorcentaje.format(total), font, contenido, derecha, 0, 1,
                Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda(
                "[NO SE RECIBIR? MATERIAL EN ALMACN SIN ESTA ORDEN DE COMPRA Y REMISIN O FACTURA CORRESPONDIENTE]",
                font, contenido, centro, 7, 1, Rectangle.NO_BORDER));
        tabla.setHeaderRows(1);
        session.beginTransaction().rollback();

        reporte.agregaObjeto(tabla);

        reporte.cerrar();
        reporte.visualizar("reportes/" + ord.getIdOrden() + "/" + valor + "-orden.pdf");

    } catch (Exception e) {
        System.out.println(e);
        e.printStackTrace();
        JOptionPane.showMessageDialog(null, "No se pudo realizar el reporte si el archivo esta abierto.");
    }
}

From source file:Compras.Formatos.java

void ordenCompraDCG(String tipo) {
    h = new Herramientas(usr, 0);
    h.session(sessionPrograma);/*from w  w  w  .  j  a v  a 2  s . c  o m*/
    session = HibernateUtil.getSessionFactory().openSession();
    ord = (Orden) session.get(Orden.class, ord.getIdOrden());
    try {
        DecimalFormat formatoPorcentaje = new DecimalFormat("#,##0.000");
        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);
        File folder = new File("reportes/" + ord.getIdOrden());
        folder.mkdirs();
        reporte.Abrir(PageSize.LETTER, "cabecera",
                "reportes/" + ord.getIdOrden() + "/" + valor + "-ordenDCG.pdf");
        //Font font = new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD);
        Font font = new Font(Font.FontFamily.TIMES_ROMAN, 8, 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[] { 20, 20, 40, 220, 90, 50, 50 };
        PdfPTable tabla = reporte.crearTabla(7, tam, 100, Element.ALIGN_LEFT);

        Pedido ped = (Pedido) session.get(Pedido.class, Integer.parseInt(no_ped));
        if (ped.getUsuarioByAutorizo() != null && ped.getUsuarioByAutorizo2() != null) {
            reporte.estatusAutoriza(ped.getUsuarioByAutorizo().getEmpleado().getNombre(),
                    ped.getUsuarioByAutorizo2().getEmpleado().getNombre());
        } else
            reporte.estatusAutoriza("", "       NO AUTORIZADO");
        cabeceraCompraDCG(reporte, bf, tabla, ped, tipo);

        Partida[] cuentas = (Partida[]) session.createCriteria(Partida.class)
                .add(Restrictions.eq("ordenByIdOrden.idOrden", ord.getIdOrden()))
                .add(Restrictions.eq("pedido.idPedido", Integer.parseInt(no_ped)))
                .addOrder(Order.asc("idEvaluacion")).addOrder(Order.asc("subPartida")).list()
                .toArray(new Partida[0]);

        int ren = 0;
        double total = 0d;
        if (cuentas.length > 0) {
            for (int i = 0; i < cuentas.length; i++) {
                int r = i + 1;
                //consecutivo
                tabla.addCell(reporte.celda("" + r, font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));

                if (cuentas[i].getCantPcp() > 0)//cantidad a comprar
                    tabla.addCell(reporte.celda("" + cuentas[i].getCantPcp(), font, contenido, derecha, 0, 1,
                            Rectangle.RECTANGLE));
                else
                    tabla.addCell(reporte.celda("0", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));

                if (cuentas[i].getMed() != null)//Unidad
                    tabla.addCell(reporte.celda(cuentas[i].getMed(), font, contenido, derecha, 0, 1,
                            Rectangle.RECTANGLE));
                else
                    tabla.addCell(reporte.celda(" ", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));

                //Descripcion
                tabla.addCell(reporte.celda(cuentas[i].getCatalogo().getNombre(), font, contenido, izquierda, 0,
                        1, Rectangle.RECTANGLE));

                if (cuentas[i].getEjemplar() != null) {
                    //No de parte
                    tabla.addCell(reporte.celda("" + cuentas[i].getEjemplar().getIdParte(), font, contenido,
                            derecha, 0, 1, Rectangle.RECTANGLE));
                } else
                    tabla.addCell(reporte.celda(" ", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));

                if (cuentas[i].getPcp() != null)//costo unit
                    tabla.addCell(reporte.celda(formatoPorcentaje.format(cuentas[i].getPcp()), font, contenido,
                            derecha, 0, 1, Rectangle.RECTANGLE));
                else
                    tabla.addCell(reporte.celda("0.00", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));

                if (cuentas[i].getCantPcp() > 0 && cuentas[i].getPcp() != null)//costo total
                {
                    double sum = cuentas[i].getCantPcp() * cuentas[i].getPcp();
                    total += sum;
                    tabla.addCell(reporte.celda(formatoPorcentaje.format(sum), font, contenido, derecha, 0, 1,
                            Rectangle.RECTANGLE));
                } else
                    tabla.addCell(reporte.celda("0.00", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));

                ren++;
            }
        }
        if (ped.getNotas() != null)
            tabla.addCell(reporte.celda("Notas:" + ped.getNotas(), font, contenido, izquierda, 7, 1,
                    Rectangle.BOTTOM));
        else
            tabla.addCell(reporte.celda("Notas:", font, contenido, izquierda, 7, 1, Rectangle.BOTTOM));
        tabla.addCell(reporte.celda("[Los montos estan en Pesos]", font, contenido, izquierda, 4, 1,
                Rectangle.NO_BORDER));
        tabla.addCell(reporte.celda("Sub-total:", font, contenido, derecha, 2, 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, 6, 1, Rectangle.NO_BORDER));
        double iva = total * 0.16d;
        tabla.addCell(reporte.celda(formatoPorcentaje.format(iva), font, contenido, derecha, 0, 1,
                Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("Total:", font, contenido, derecha, 6, 1, Rectangle.NO_BORDER));
        total += iva;
        tabla.addCell(reporte.celda(formatoPorcentaje.format(total), font, contenido, derecha, 0, 1,
                Rectangle.RECTANGLE));
        tabla.setHeaderRows(1);
        session.beginTransaction().rollback();

        reporte.agregaObjeto(tabla);

        reporte.cerrar();
        reporte.visualizar("reportes/" + ord.getIdOrden() + "/" + valor + "-ordenDCG.pdf");

    } catch (Exception e) {
        System.out.println(e);
        e.printStackTrace();
        JOptionPane.showMessageDialog(null, "No se pudo realizar el reporte si el archivo esta abierto.");
    }
}

From source file:Compras.Formatos.java

void ordenCompraExternosDCG(int pedido, String tipo) {
    h = new Herramientas(usr, 0);
    h.session(sessionPrograma);//www  .  j  av a 2  s. c om
    session = HibernateUtil.getSessionFactory().openSession();
    //ord=(Orden)session.get(Orden.class, ord.getIdOrden());
    try {
        DecimalFormat formatoPorcentaje = new DecimalFormat("#,##0.000");
        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);
        File folder = new File("reportes/externos");
        folder.mkdirs();
        reporte.Abrir(PageSize.LETTER, "cabecera", "reportes/externos/" + valor + "-ordenDCG.pdf");
        //Font font = new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD);
        Font font = new Font(Font.FontFamily.TIMES_ROMAN, 8, 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[] { 20, 20, 40, 220, 90, 50, 50 };
        PdfPTable tabla = reporte.crearTabla(7, tam, 100, Element.ALIGN_LEFT);

        Pedido ped = (Pedido) session.get(Pedido.class, pedido);
        if (ped.getUsuarioByAutorizo() != null && ped.getUsuarioByAutorizo2() != null) {
            reporte.estatusAutoriza(ped.getUsuarioByAutorizo().getEmpleado().getNombre(),
                    ped.getUsuarioByAutorizo2().getEmpleado().getNombre());
        } else
            reporte.estatusAutoriza("", "       NO AUTORIZADO");
        if (ped.getTipoPedido().compareToIgnoreCase("Externo") == 0)
            cabeceraCompraExDCG(reporte, bf, tabla, ped, tipo);
        if (ped.getTipoPedido().compareToIgnoreCase("Adicional") == 0)
            cabeceraCompraDCG(reporte, bf, tabla, ped, tipo);

        PartidaExterna[] cuentas = (PartidaExterna[]) session.createCriteria(PartidaExterna.class).
        //add(Restrictions.eq("ordenByIdOrden.idOrden", ord.getIdOrden())).
                add(Restrictions.eq("pedido.idPedido", pedido)).addOrder(Order.asc("idPartidaExterna")).list()
                .toArray(new PartidaExterna[0]);
        int ren = 0;
        double total = 0d;
        if (cuentas.length > 0) {
            for (int i = 0; i < cuentas.length; i++) {
                int r = i + 1;
                //consecutivo
                tabla.addCell(reporte.celda("" + r, font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));

                //cantidad a comprar
                tabla.addCell(reporte.celda("" + cuentas[i].getCantidad(), font, contenido, derecha, 0, 1,
                        Rectangle.RECTANGLE));

                //Unidad
                tabla.addCell(reporte.celda(cuentas[i].getUnidad(), font, contenido, derecha, 0, 1,
                        Rectangle.RECTANGLE));

                //Descripcion
                tabla.addCell(reporte.celda(cuentas[i].getDescripcion(), font, contenido, izquierda, 0, 1,
                        Rectangle.RECTANGLE));

                tabla.addCell(reporte.celda("" + cuentas[i].getNoParte(), font, contenido, derecha, 0, 1,
                        Rectangle.RECTANGLE));

                //costo unit
                tabla.addCell(reporte.celda(formatoPorcentaje.format(cuentas[i].getCosto()), font, contenido,
                        derecha, 0, 1, Rectangle.RECTANGLE));

                double sum = cuentas[i].getCantidad() * cuentas[i].getCosto();
                total += sum;
                tabla.addCell(reporte.celda(formatoPorcentaje.format(sum), font, contenido, derecha, 0, 1,
                        Rectangle.RECTANGLE));

                /*if(ren==38)
                {
                    reporte.agregaObjeto(tabla);
                    reporte.writer.newPage();
                    tabla=reporte.crearTabla(7, tam, 100, Element.ALIGN_LEFT);
                    cabeceraCompraEx(reporte, bf, tabla, ped);
                    ren=-1;
                }*/
                ren++;
            }
        }
        if (ped.getNotas() != null)
            tabla.addCell(reporte.celda("Notas:" + ped.getNotas(), font, contenido, izquierda, 7, 1,
                    Rectangle.BOTTOM));
        else
            tabla.addCell(reporte.celda("Notas:", font, contenido, izquierda, 7, 1, Rectangle.BOTTOM));
        tabla.addCell(reporte.celda("[Los montos estan en Pesos]", font, contenido, izquierda, 4, 1,
                Rectangle.NO_BORDER));
        tabla.addCell(reporte.celda("Sub-total:", font, contenido, derecha, 2, 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, 6, 1, Rectangle.NO_BORDER));
        double iva = total * 0.16d;
        tabla.addCell(reporte.celda(formatoPorcentaje.format(iva), font, contenido, derecha, 0, 1,
                Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("Total:", font, contenido, derecha, 6, 1, Rectangle.NO_BORDER));
        total += iva;
        tabla.addCell(reporte.celda(formatoPorcentaje.format(total), font, contenido, derecha, 0, 1,
                Rectangle.RECTANGLE));
        tabla.setHeaderRows(1);
        session.beginTransaction().rollback();

        reporte.agregaObjeto(tabla);

        reporte.cerrar();
        reporte.visualizar("reportes/externos/" + valor + "-ordenDCG.pdf");

    } catch (Exception e) {
        System.out.println(e);
        e.printStackTrace();
        JOptionPane.showMessageDialog(null, "No se pudo realizar el reporte si el archivo esta abierto.");
    }
}