New question

Question:

Date: 25-05-2017 07:02:14 (In Spanish)

Problema al imprimir con HTML2PDF sobre una factura preimpresa[Resolved]

Buenos dias, necesito por favor mantener el tamaño de una tabla sin importar la cantidad de filas, pasa que al imprimir la cabecera, los detalles de mercaderias, y los totales, en una epson matricial lx-300 la cabecera me imprime bien, pero al imprimir los detalles, si es un solo item imprime muy arriba y si son varios imprime muy abajo, necesito que se imprima en un lugar sin importar la cantidad de item, este es mi codigo
<?php
  include ("./num_letras2.php");//convierte los nros a letras
  $sql_cliente=mysqli_query($con,"SELECT * FROM persona where id_persona='$id_cliente'");
  $rw_cliente=mysqli_fetch_array($sql_cliente);
?>
<page backtop="15mm" backbottom="15mm" backleft="10mm" backright="10mm" style="font-size: 13px; font-family: Arial;">
  <table width="897" cellspacing="" style="">
    <tr>
      <td height="">&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><?php echo date("d/m/Y",strtotime($fecha_factura));?></td>
      <td width="87">&nbsp;</td>
      <td width="36">&nbsp;</td>
      <td width="37"><?php if ($condicion==1){echo "X";}?></td>
      <td width="58">&nbsp;</td>
      <td width="17"><?php if ($condicion==2){echo "X";}?></td>
    </tr>
    <tr>
      <td height="">&nbsp;</td>
      <td><?php echo $rw_cliente['nombre']; ?></td>
      <td>&nbsp;</td>
      <td colspan="2"><?php echo $rw_cliente['nro_documento']; ?></td>
      <td colspan="2">&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><?php echo $rw_cliente['direccion']; ?></td>
      <td>&nbsp;</td>
      <td colspan="2">&nbsp;</td>
      <td colspan="2"><?php echo $rw_cliente['telefono']; ?></td>
    </tr>
    <tr>
      <td width="149">&nbsp;</td>
      <td width="497" height="" >&nbsp;</td>
      <td>&nbsp;</td>
      <td colspan="2">&nbsp;</td>
      <td colspan="2">&nbsp;</td>
    </tr>
  </table>
<?php
	$nums=1;
	$sumador_total=0;
	$sql=mysqli_query($con, "SELECT * FROM producto, detalle_venta , venta where producto.id_producto=detalle_venta.id_producto and detalle_venta.nro_factura=venta.nro_factura and venta.id_factura='".$id_factura."'");
	while ($row=mysqli_fetch_array($sql))
		{
		$id_producto=$row["id_producto"];
		$codigo_producto=$row['codigo_producto'];
		$cantidad=$row['cantidad'];
		$nombre_producto=$row['nombre_producto'];
		$impuesto_producto=$row['impuesto_producto'];
		$precio_venta=$row['precio_venta'];
		$precio_venta_f=number_format($precio_venta,0);//Formateo variables
		$precio_venta_r=str_replace(",","",$precio_venta_f);//Reemplazo las comas
		$precio_total=$precio_venta_r*$cantidad;
		$precio_total_f=number_format($precio_total,0);//Precio total formateado
		$precio_total_r=str_replace(",","",$precio_total_f);//Reemplazo las comas
		
	  $sumador_total+=$precio_total_r;//Sumador
	
		$V=new EnLetras(); 
		$con_letra=strtoupper($V->ValorEnLetras($sumador_total,""));
  
?>
<div style="width:897;height:230" class="">
<table height="24" style=" width:897; table-layout:fixed">
    <tr>
      <td width="118" valign="top"><?php echo $codigo_producto; ?></td>
      <td width="56"valign="top"><?php echo $cantidad; ?></td>
      <td width="428"valign="top"><?php echo $nombre_producto;?></td>
      <td width="96"valign="top"><?php echo $precio_venta_f;?></td>
      <td width="79"valign="top"><?php if ($impuesto_producto==0){ echo $precio_total_f ;} else{ echo "0"; };?></td>
      <td width="87"valign="top"><?php if ($impuesto_producto==5){ echo $precio_total_f ;} else{ echo "0"; };?></td>
      <td width="17"valign="top"><?php if ($impuesto_producto==10){ echo $precio_total_f ;} else{ echo "0"; };?></td>
    </tr>
</table>
</div>
<?php
	$nums++;
	}
   if ($nums>=10) {
    $error= "Cantidad de Items Excede a la Factura";
    }
	$subtotal=number_format($sumador_total,0,'.','');
	$total_iva=(($subtotal * $impuesto_producto )/11);
	$total_iva=number_format($total_iva,0,'.','');
	$total_iva=$subtotal-$total_iva;
	$total_iva_f=number_format($total_iva,0);
	$subtotal=number_format($sumador_total,0,'.','');
	$subtotal=$subtotal-$total_iva;
	$total_factura=$subtotal+$total_iva;	
	$total_factura_f=number_format($total_factura,0);
?>
  <table width="897" cellspacing="0" style="">
    <tr>
      <td height="20" align="" style="" ></td>
      <td colspan="4" align="" style="" >&nbsp;</td>
      <td colspan="" style="" >&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td width="39" height="" align="" style="" >&nbsp;</td>
      <td colspan="4" align="" style="" >&nbsp;</td>
      <td width="226" colspan="" style="" >&nbsp;</td>
      <td width="77"><?php if ($impuesto_producto==0){ echo $subtotal_f ; } else{ echo "0"; };?></td>
      <td width="87"><?php if ($impuesto_producto==5){ echo $subtotal_f ;} else{ echo "0"; };?></td>
      <td width="17"><?php if ($impuesto_producto==10){ echo $total_factura_f ;} else{ echo "0"; };?></td>
    </tr>
    <tr>
      <td height="25">&nbsp;</td>
      <td width="105">&nbsp;</td>
      <td colspan="4"><?php echo $con_letra; ?></td>
      <td align="" style="" >&nbsp;</td>
      <td align="" style="" >&nbsp;</td>
      <td style="17"><?php if ($impuesto_producto==10){ echo $total_factura_f ;} else{ echo "0"; };?></td>
    </tr>
    <tr>
      <td height="20" align="" style="width:;" >&nbsp;</td>
      <td colspan="" align="" style="width:;" >&nbsp;</td>
      <td align="" style="width:;" >&nbsp;</td>
      <td align="" style="width:;" ><?php if ($impuesto_producto==5){ echo $total_iva_f ;} else{ echo "0"; };?></td>
      <td align="" style="width:;" >&nbsp;</td>
      <td colspan="" style="width:;" ><?php if ($impuesto_producto==10){ echo $total_iva_f ;} else{ echo "0"; };?></td>
      <td></td>
      <td width="87"><?php if ($impuesto_producto==10){ echo $total_iva_f ;} else{ echo "0"; };?></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td height="20" align="" style="width:;" >&nbsp;</td>
      <td colspan="" align="" style="width:;" >&nbsp;</td>
      <td width="37" align="" style="width:;" >&nbsp;</td>
      <td width="73" align="" style="width:;" >&nbsp;</td>
      <td width="214" align="" style="width:;" >&nbsp;</td>
      <td><?php echo $error ;?></td>
      <td colspan="" style="width:;" >&nbsp;</td>
      <td></td>
      <td>&nbsp;</td>
    </tr>
  </table>
</page>

Tags: HTML - HTML2PDF - PHP - Question Votes: 0 - Answers: 4 - Views: 15 Share on: Google Facebook Twitter LinkedIn Link
 

Answers:

  • Date: 25-05-2017 08:41:11 Hola Ramon, esto que comentas solo te esta pasando con la impresora matricial "Epson LX-300"? con otra impresora te respeta la ubicación?

    Si es con todas las impresoras, intenta darle un alto fijo a tu tabla usando la propiedad css height, ya que todas tus facturas tendrán el mismo alto (definido por el comprobante preimpreso), solo restará hacer algunas pruebas para determinar el valor correcto para la propiedad height.

    Por otro lado, viendo tu código, yo comenzaría por limpiarlo un poco, tienes muchos atributos incluidos que no usas, o con valores erroneos, vemoas algunos casos:

    * Para el siguiente caso no es necesario el atributo align, ya que no se usa, y el atributo style tiene un valor no valido:
    <td height="20" align="" style="width:;" >&nbsp;</td>


    * Cuando especificas dentro de una etiqueta style el width y height debes indicar la unidad de medida junto al número, sino no funcionará, por ejemplo pixeles "px":
    style="width:897;height:230"

    Para el caso anterior, lo correcto sería:
    style="width:897px;height:230px;"

    Nota: no confundir las propiedades css width y height (dentro de la etiqueta style) con los atributos width y height de las etiquetas html (a los cuales puedes no especifiacar la unidad de medida y se asumirá como "px").

    Espero que mi respuesta te sea de ayuda, saludos y buen código!

    PD: que recuerdos me has traido con solo nombrar Epson LX-300, el ruido que hace es mortal... jajaja
      Votes: 1 - Link answer
     
  • Date: 25-05-2017 13:15:57 Buena tarde, no se si entendí bien tengo mis dudas pero si no te importa la cantidad de registros al imprimir mi aporte sería meter la tabla a un div, dejar el div de un alto y ancho fijo según requieres y colocar un scroll al div solo que con esto pues obviamente no te imprimirá todos, si tienes muchos registro solo se verán los que aparezcan en el div.
    Espero te sirva mi respuesta ;)
      Votes: 0 - Link answer
     
  • Date: 26-05-2017 13:24:56 que tal, probe con div, pero me imprime con espacios.
    C11016 PURPLE 8/10 1 CROCS C11016 PURPLE 8/10 300,000 0 0 300,000






    4172101 36 1 CALZADO DAMA 35 185,000 0 0 185,000



    así más o menos cada item.. deberia estar 1 debajo de otro
      Votes: 0 - Link answer
     
  • Date: 11-08-2017 06:07:17 Gracias a todos! hacia bien el div. el problema era que creaba una fila y una tabla, puse mal la tabla y la fila, en cada producto me creaba una tabla, por eso no se veia el espacio.   Votes: 0 - Link answer
     
To actively participate in the community first must authenticate, enter the system.Sign In
 
frjcbbae garagebible.com