Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created February 5, 2019 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/228cd5f20002769e85f06326d7feeccc to your computer and use it in GitHub Desktop.
Save parzibyte/228cd5f20002769e85f06326d7feeccc to your computer and use it in GitHub Desktop.
<?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