PHP code example of antwerpes / barcodes-1d

1. Go to this page and download the library: Download antwerpes/barcodes-1d library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

antwerpes / barcodes-1d example snippets


use Antwerpes\Barcodes\Barcodes;
use Antwerpes\Barcodes\Enumerators\Format;

// SVG
$svg = Barcodes::create('12345678', Format::CODE_128);
file_put_contents('img.svg', $svg);

// Or as an image
$image = Barcodes::create('12345678', Format::CODE_128, 'png');
file_put_contents('img.png', base64_decode($image));

// Example for scaled up (4x) WEBP
$image = Barcodes::create('12345678', Format::CODE_128, 'webp', [
    'image_scale' => 4,
]);
file_put_contents('img.webp', base64_decode($image));

Barcodes::create('A12345', Format::CODE_128);

Barcodes::create('5901234123457', Format::EAN_13);
Barcodes::create('5901234123457', Format::EAN_13, 'svg', ['flat' => true]);
Barcodes::create('5901234123457', Format::EAN_13, 'svg', ['with_quiet_zone' => true]);

Barcodes::create('53', Format::EAN_2);
Barcodes::create('52495', Format::EAN_5);
Barcodes::create('96385074', Format::EAN_8);

Barcodes::create('123456789999', Format::UPC_A);
Barcodes::create('01245714', Format::UPC_E);
// These also work and will produce the same result
Barcodes::create('124571', Format::UPC_E);
Barcodes::create('01210000457', Format::UPC_E);
Barcodes::create('012100004574', Format::UPC_E);

Barcodes::create('A12345B', Format::CODABAR);

Barcodes::create('01234-5678', Format::CODE_11);

Barcodes::create('1234567', Format::CODE_25);
Barcodes::create('12345670', Format::CODE_25_INTERLEAVED);
Barcodes::create('98765432109213', Format::ITF_14);

Barcodes::create('AB12', Format::CODE_39);
Barcodes::create('TEST93', Format::CODE_93);

Barcodes::create('8052', Format::MSI);

Barcodes::create('1234', Format::PHARMACODE);