Created
February 5, 2019 19:55
-
-
Save parzibyte/228cd5f20002769e85f06326d7feeccc 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 3 para generar códigos de barras | |
* con PHP | |
* | |
* Generar imagen PNG y mostrarla en navegador | |
* | |
* @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); | |
# Encabezado para que el navegador sepa que es una imagen | |
header("Content-type: image/png"); | |
# Hora de imprimir | |
echo $imagen; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment