-
-
Save parzibyte/5bba052777fe683c11fb1f02c4a36836 to your computer and use it in GitHub Desktop.
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 | |
/** | |
* Ejemplo 5 para generar códigos de barras | |
* con PHP | |
* | |
* Forzar descarga de imagen con código de barras | |
* | |
* @author parzibyte | |
*/ | |
# Incluimos el autoload | |
require_once "vendor/autoload.php"; | |
# Indicamos que usaremos el namespace de BarcodeGeneratorPNG | |
use Picqer\Barcode\BarcodeGeneratorPNG; | |
# Crear generador | |
$generador = new BarcodeGeneratorPNG(); | |
# Ajustes | |
$texto = "parzibyte.me"; | |
$tipo = $generador::TYPE_CODE_128; | |
$imagen = $generador->getBarcode($texto, $tipo); | |
# Sugerir nombre para guardar | |
$nombreArchivo = "codigo_de_barras.png"; | |
# Imprimir encabezados | |
header('Content-Type: application/octet-stream'); | |
header("Content-Transfer-Encoding: Binary"); | |
header("Content-disposition: attachment; filename=$nombreArchivo"); | |
echo $imagen; | |
# No imprimas nada después de esto |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment