-
-
Save grekodev/a176a8120827b35a72eb8751aa62e30f to your computer and use it in GitHub Desktop.
Formato de ticket para impresora de ticket
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include "fpdf/fpdf.php"; | |
$pdf = new FPDF($orientation='P',$unit='mm', array(45,350)); | |
$pdf->AddPage(); | |
$pdf->SetFont('Arial','B',8); //Letra Arial, negrita (Bold), tam. 20 | |
$textypos = 5; | |
$pdf->setY(2); | |
$pdf->setX(2); | |
$pdf->Cell(5,$textypos,"NOMBRE DE LA EMPRESA"); | |
$pdf->SetFont('Arial','',5); //Letra Arial, negrita (Bold), tam. 20 | |
$textypos+=6; | |
$pdf->setX(2); | |
$pdf->Cell(5,$textypos,'-------------------------------------------------------------------'); | |
$textypos+=6; | |
$pdf->setX(2); | |
$pdf->Cell(5,$textypos,'CANT. ARTICULO PRECIO TOTAL'); | |
$total =0; | |
$off = $textypos+6; | |
$producto = array( | |
"q"=>1, | |
"name"=>"Computadora Lenovo i5", | |
"price"=>100 | |
); | |
$productos = array($producto, $producto, $producto, $producto, $producto ); | |
foreach($productos as $pro){ | |
$pdf->setX(2); | |
$pdf->Cell(5,$off,$pro["q"]); | |
$pdf->setX(6); | |
$pdf->Cell(35,$off, strtoupper(substr($pro["name"], 0,12)) ); | |
$pdf->setX(20); | |
$pdf->Cell(11,$off, "$".number_format($pro["price"],2,".",",") ,0,0,"R"); | |
$pdf->setX(32); | |
$pdf->Cell(11,$off, "$ ".number_format($pro["q"]*$pro["price"],2,".",",") ,0,0,"R"); | |
$total += $pro["q"]*$pro["price"]; | |
$off+=6; | |
} | |
$textypos=$off+6; | |
$pdf->setX(2); | |
$pdf->Cell(5,$textypos,"TOTAL: " ); | |
$pdf->setX(38); | |
$pdf->Cell(5,$textypos,"$ ".number_format($total,2,".",","),0,0,"R"); | |
$pdf->setX(2); | |
$pdf->Cell(5,$textypos+6,'GRACIAS POR TU COMPRA '); | |
$pdf->output(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment