PHPackages                             bigfish/pdf417 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. bigfish/pdf417

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

bigfish/pdf417
==============

A library for generating PDF417 barcodes in PHP

0.3.0(8y ago)95377.5k↓45.3%40MITPHPPHP &gt;=5.4

Since Dec 24Pushed 3y ago1 watchersCompare

[ Source](https://github.com/ihabunek/pdf417-php)[ Packagist](https://packagist.org/packages/bigfish/pdf417)[ RSS](/packages/bigfish-pdf417/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (5)Dependencies (3)Versions (6)Used By (0)

PDF 417 barcode generator
=========================

[](#pdf-417-barcode-generator)

[![Latest Version](https://camo.githubusercontent.com/a3d75c2347db867df8a7ac5a1e6b7b4f4fd46cd8e005704c46ee4e8aaa4a64e6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f626967666973682f7064663431372e7376673f7374796c653d666c61742d737175617265266c6162656c3d737461626c65)](https://packagist.org/packages/bigfish/pdf417)[![Total Downloads](https://camo.githubusercontent.com/d30f04618d69c24327646df99830e83cba36df58fe3c809b003a28701b989f88/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f626967666973682f7064663431372e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bigfish/pdf417)[![License](https://camo.githubusercontent.com/640110c151ebd5eb85e90604d8c9b387ac6bdb71b91b3be4dfa802377cb3f635/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f626967666973682f7064663431372e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bigfish/pdf417)[![Author](https://camo.githubusercontent.com/69b408c6aec50eff9454ac1a20958f67a280f207b611850f4c88a1815a14e87c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d25343069686162756e656b2d626c75652e7376673f7374796c653d666c61742d737175617265)](https://twitter.com/ihabunek)

This project is no longer maintained
------------------------------------

[](#this-project-is-no-longer-maintained)

I have moved on from PHP and this project will no longer be updated. If you wish to continue the legacy, please fork the project.

For a maintaned Python implementation check out [ihabunek/pdf417-py](https://github.com/ihabunek/pdf417-py/).

\-- Ivan

Requirements
------------

[](#requirements)

Requires the following components:

- PHP &gt;= 5.4
- PHP extensions: bcmath, fileinfo, gd

Installation
------------

[](#installation)

Add it to your `composer.json` file:

```
composer require bigfish/pdf417

```

Usage overview
--------------

[](#usage-overview)

```
require 'vendor/autoload.php';

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);
```

ImageRenderer
-------------

[](#imagerenderer)

Renders the barcode to an image using [Intervention Image](http://image.intervention.io/)

Render function returns an instance of `Intervention\Image\Image`.

#### Options

[](#options)

OptionDefaultDescriptionformatpngOutput format, one of: `jpg`, `png`, `gif`, `tif`, `bmp`, `data-url`quality90Jpeg encode quality (1-10)scale3Scale of barcode elements (1-20)ratio3Height to width ration of barcode elements (1-10)padding20Padding in pixels (0-50)color\#000000Foreground color as a hex codebgColor\#ffffffBackground color as a hex code#### Examples

[](#examples)

```
$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');
```

The `data-url` format is not like the others, it returns a base64 encoded PNG image which can be used in an image `src` or in CSS. When you create an image using this format:

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

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

You can use it directly in your HTML or CSS code:

```
