Last active
February 18, 2022 16:34
-
-
Save evilnapsis/583fbb73244452a4975ef4c71cd1ef15 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(); |
cley9
commented
Feb 18, 2022
via email
Si prueba con la librería de php de es phpmailer hay documentación amigo
🤗🤗
El jue., 17 de febrero de 2022 9:06 a. m., Alex Rodríguez Serrano <
***@***.***> escribió:
… ***@***.**** commented on this gist.
------------------------------
$pdf = new FPDF($orientation='P',$unit='mm', array(45,350));
Alguna idea para no tener que pasar un tamaño largo en el height?
En impresoras térmicas funciona a la maravilla porque corta el papel luego
de la última línea, pero en impresoras matriciales no(Si todavía hay quien
las usa :-) )
—
Reply to this email directly, view it on GitHub
<https://gist.github.com/583fbb73244452a4975ef4c71cd1ef15#gistcomment-4069018>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ANYE2ZTEG6QLS4KERMXCF4TU3T6F5ANCNFSM4JJXWIJA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you commented.Message ID:
***@***.***>
Voy a darle un vistazo, Gracias 👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment