Ver Mensaje Individual
  #1 (permalink)  
Antiguo 28/10/2016, 11:34
Maru77
 
Fecha de Ingreso: agosto-2003
Mensajes: 524
Antigüedad: 20 años, 8 meses
Puntos: 5
imprimir directamente

Hola!

Tengo un sistema instalado en la pc y una impresora local, lo que quiero es que al hacer click en "imprimir" salga directamente a la impresora sin el cuadro de diálogo.
Busqué y probé varias cosas pero nada funciona.

este es el código que tengo

Código HTML:
<a id="imprimir" title="Imprimir" href=""> Imprimir</a> 
Código PHP:
<?php if($produtos != null){?>
              
                        <table class="table table-bordered table-condensed" id="tblProdutos">
                                    <thead>
                                        <tr>                                            
                                            <th style="font-size: 13px">Cantidad</th>
                                            <th style="font-size: 13px">Producto</th>
                                            <th style="font-size: 13px">Sub-total</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php
                                        
                                        
foreach ($produtos as $p) {

                                            
$totalProdutos $totalProdutos $p->subTotal;
                                            echo 
'<tr>';
                        echo 
'<td>'.$p->cantidad.'</td>';
                                            echo 
'<td>'.$p->descripcion.'</td>';
                                            
                                            echo 
'<td>$ '.number_format($p->subTotal,2,',','.').'</td>';
                                            echo 
'</tr>';
                                        }
?>

                                       
                                    </tbody>
                                </table>
                               <?php }?>

Código HTML:
<script type="text/javascript">
    $(document).ready(function(){
        $("#imprimir").click(function(){         
            PrintElem('#printOs');
        })

        function PrintElem(elem)
        {
            Popup($(elem).html());
        }

        function Popup(data)
        {
            var mywindow = window.open('', 'SISTEMA ', 'height=600,width=800');
            mywindow.document.write('<html><head><title>SISTEMA </title>');
            mywindow.document.write("<link rel='stylesheet' href='<?php echo base_url();?>assets/css/bootstrap.min.css' />");
           
            mywindow.document.write('</head><body>');
            mywindow.document.write(data);
            mywindow.document.write('</body></html>');

            setTimeout(function(){
 			mywindow.print();
			}, 100);

            return true;
        }

    });
</script> 
__________________
Saludos!!!
Maru.-