PHP code example of bigfish / pdf417

1. Go to this page and download the library: Download bigfish/pdf417 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/ */

    

bigfish / pdf417 example snippets




use BigFish\PDF417\PDF417;
use BigFish\PDF417\Renderers\ImageRenderer;
use BigFish\PDF417\Renderers\SvgRenderer;

// Text to be encoded into the barcode
$text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur
imperdiet sit amet magna faucibus aliquet. Aenean in velit in mauris imperdiet
scelerisque. Maecenas a auctor erat.';

// Encode the data, returns a BarcodeData object
$pdf417 = new PDF417();
$data = $pdf417->encode($text);

// Create a PNG image
$renderer = new ImageRenderer([
    'format' => 'png'
]);

$image = $renderer->render($data);

// Create an SVG representation
$renderer = new SvgRenderer([
    'color' => 'black',
]);

$svg = $renderer->render($data);

$pdf417 = new PDF417();
$data = $pdf417->encode("My hovercraft is full of eels");

// Create a PNG image, red on green background, extra big
$renderer = new ImageRenderer([
    'format' => 'png',
    'color' => '#FF0000',
    'bgColor' => '#00FF00',
    'scale' => 10,
]);

$image = $renderer->render($data);
$image->save('hovercraft.png');

$pdf417 = new PDF417();
$data = $pdf417->encode('My nipples explode with delight');

$renderer = new ImageRenderer([
    'format' => 'data-url'
]);
$img = $renderer->render($data);