The text sent in the ticket is pasted

0

I'm using FPDF with php and the ticket goes like this:

I use MultiCell but it does not leave a line without quantity and price to see the detail. the code is:

$pdf = new FPDF('P','mm',array(100,150));
$pdf->SetLeftMargin(2);
$pdf->SetRightMargin(2);
//$pdf->AddPage('P','mio');
$pdf->AddPage();
$pdf->SetFont('Arial','B',10);
$pdf->Cell(75,10,'Burbujas',0,1,'C');
$pdf->SetFont('Times','',7);
$pdf->Cell(75,3,'TEL: (03456) 421606 - 9 de Julio 2480',0,1,'C');
$pdf->Cell(75,5,'VENTA DE ARTICULOS DE LIMPIEZA Y BAZAR',0,1,'C');


//$pdf->ln(2);
$pdf->SetFont('courier','B',7);
$pdf->Cell(70,5,$fecha,0,1,'R');

$pdf->SetFont('courier','B',7);
$pdf->Cell(76,2,'---------------------------------------------------------------------',0,1);
$pdf->Cell(10,4,'Cant',0,0);

$pdf->Cell(60,4,utf8_decode('Descripción'),0,0,"C");
$pdf->Cell(10,4,'P/U',0,0);
$pdf->Cell(10,4,'Subtotal',0,1);
$pdf->Cell(76,1,'---------------------------------------------------------------',0,0);
$pdf->Cell(76,1,'---------------------------------------------------------------',0,0);
$pdf->ln(2);



$sql="SELECT presupuesto_detalle.det_id_presupuesto,presupuesto_detalle.det_id_articulo,presupuesto_detalle.det_cantidad,presupuesto_detalle.det_precio,articulos.art_descripcion FROM presupuesto_detalle,articulos WHERE presupuesto_detalle.det_id_articulo=articulos.id_articulo AND presupuesto_detalle.det_id_presupuesto=$presupuesto";

$res=mysqli_query($link,$sql);

$posicion=0;
$total=0;
$CANT=0;
while ($reg_recep=mysqli_fetch_array($res))
    {
    	$det_cantidad=$reg_recep['det_cantidad'];
        $descripcion=$reg_recep['art_descripcion'];
        $pu=$reg_recep['det_precio'];
        $importe=$reg_recep['det_precio'];
        $total=$total+$importe;
        $CANT=$CANT+1;

            $pdf-> cell(10,6,$det_cantidad,0,0,'R');
            $y = $pdf->GetY();
			//$pdf-> cell(58,4,$descripcion,0,0,'R');
			$pdf-> Multicell(50,6,utf8_decode($descripcion),0,'L',0);
			//$pdf->SetY(40); /* Set 20 Eje Y */
		
			$pdf->SetXY(62,$y);
            $pdf->cell(16,6,'$'.$pu,0,0,'R',0);
			$pdf->cell(16,6,'$'.$importe,0,1,'R',0);


    }

$pdf->ln(4);
$pdf->Cell(76,6,'----------------------------------------------------------------',0,1);
$pdf->Cell(76,6,'----------------------------------------------------------------',0,1);
$pdf->ln(2);
$pdf->SetFont('Arial','B',14);
$pdf->Cell(25,6,'Items..:'.$CANT,0,'R',0);
$pdf->Cell(70,6,'Total............ $'.$total,0,'R',0);
//$pdf->Cell(76,1,'--------------------------------------------------',0,1);

$pdf->ln(10);

$pdf->SetFont('Times','I',7);
$pdf->Cell(75,5,'Las devoluciones se realizan dentro de las 24 hs. Gracias !!!',0,1,'C');

I do not know the truth that I have to do

    
asked by Caruso 21.12.2018 в 13:36
source

1 answer

2

The problem occurs because you are not "saving" the value of the% co_of% coordinate that results after printing the text with y ( as you know, it adds line breaks when the text does not enter the text line )

Solution:

After printing the "description" of the product, save the MultiCell coordinate (ex: y ). Then, at the end of printing the product data, use the value saved in $yFin to indicate the coordinate $yFin where the next product should start.

Example:

while ($reg_recep=mysqli_fetch_array($res)) {
    $det_cantidad=$reg_recep['det_cantidad'];
    $descripcion=$reg_recep['art_descripcion'];
    $pu=$reg_recep['det_precio'];
    $importe=$reg_recep['det_precio'];
    $total=$total+$importe;
    $CANT=$CANT+1;

    $y = $pdf->GetY(); // Guardamos la coord Y donde COMIENZA la linea
    $pdf-> cell(10,6,$det_cantidad,0,0,'R');

    $pdf-> Multicell(50,6,utf8_decode($descripcion),0,'L',0);
    $yFin = $pdf->GetY(); // Guardamos la coord Y donde TERMINA la linea

    $pdf->SetXY(62,$y); // Pisamos la coord Y con el valor donde COMIENZA la linea
    $pdf->cell(16,6,'$'.$pu,0,0,'R',0);
    $pdf->cell(16,6,'$'.$importe,0,1,'R',0);

    $pdf->SetY($yFin); // Pisamos la coord Y con el valor donde TERMINA la linea
}
    
answered by 21.12.2018 / 14:13
source