Code Monkey home page Code Monkey logo

php-barcode-generator's Introduction

PHP Barcode Generator

Build Status Total Downloads Latest Stable Version

This is an easy to use, non-bloated, framework independent, barcode generator in PHP. It uses zero(!) composer dependencies and is only a handful of files. Probably the reason that this is the most downloaded barcode generator for PHP on Packagist. ;)

It creates SVG, PNG, JPG and HTML images, from the most used 1D barcode standards.

No support for...

  • No support for any 2D barcodes, like QR codes.
  • We only generate the 'bars' part of a barcode, without text below the barcode. If you want text of the code below the barcode, you could add it later to the output of this package.

Installation

Install through composer:

composer require picqer/php-barcode-generator

If you want to generate PNG or JPG images, you need the GD library or Imagick installed on your system as well.

Usage

You want a barcode for a specific "type" (for example Code 128 or UPC) in a specific image format (for example PNG or SVG).

  • First, encode the string you want the barcode of into a Barcode object with one of the barcode types.
  • Then, use one of the renderers to render the image of the bars in the Barcode object.

The "type" is a standard that defines which characters you can encode and which bars represent which character. The most used types are code 128 and EAN/UPC. Not all characters can be encoded into each barcode type, and not all barcode scanners can read all types.

<?php
require 'vendor/autoload.php';

// Make Barcode object of Code128 encoding.
$barcode = (new Picqer\Barcode\Types\TypeCode128())->getBarcode('081231723897');

// Output the barcode as HTML in the browser with a HTML Renderer
$renderer = new Picqer\Barcode\Renderers\HtmlRenderer();
echo $renderer->render($barcode);

Will result in this beauty:
Barcode 081231723897 as Code 128

Each renderer has their own options. For example, you can set the height, width and color of a PNG:

<?php
require 'vendor/autoload.php';

$colorRed = [255, 0, 0];

$barcode = (new Picqer\Barcode\Types\TypeCode128())->getBarcode('081231723897');
$renderer = new Picqer\Barcode\Renderers\PngRenderer();
$renderer->setForegroundColor($colorRed);

// Save PNG to the filesystem, with widthFactor 3 and height of 50 pixels
file_put_contents('barcode.png', $renderer->render($barcode, 3, 50));

Image renderers

Available image renderers: SVG, PNG, JPG and HTML.

Each renderer has their own options. Only the barcode is required, the rest is optional. Here are all the options for each renderers:

SVG

A vector based SVG image. Gives the best quality to print.

$renderer = new Picqer\Barcode\Renderers\SvgRenderer();
$renderer->setForegroundColor('red'); // Give a color for the bars, the background is always white
$renderer->setSvgType($renderer::TYPE_SVG_INLINE); // Changes the output to be used inline inside HTML documents, instead of a standalone SVG image (default)
$renderer->setSvgType($renderer::TYPE_SVG_STANDALONE); // If you want to force the default, create a stand alone SVG image

$renderer->render($barcode, 450.20, 75); // Width and height support floats

PNG + JPG

All options for PNG and JPG are the same.

$renderer = new Picqer\Barcode\Renderers\PngRenderer();
$renderer->setForegroundColor([255, 0, 0]); // Give a color for the bars, the background is always white. Give it as 3 times 0-255 values for red, green and blue. 
$renderer->useGd(); // If you have Imagick and GD installed, but want to use GD
$renderer->useImagick(); // If you have Imagick and GD installed, but want to use Imagick

$renderer->render($barcode, 5, 40); // Width factor (how many pixel wide every bar is), and the height in pixels

HTML

Gives HTML to use inline in a full HTML document.

$renderer = new Picqer\Barcode\Renderers\HtmlRenderer();
$renderer->setForegroundColor('red'); // Give a color for the bars, the background is always white

$renderer->render($barcode, 450.20, 75); // Width and height support floats

Dynamic HTML

Give HTML here the barcode is using the full width and height, to put inside a container/div that has a fixed size.

$renderer = new Picqer\Barcode\Renderers\DynamicHtmlRenderer();
$renderer->setForegroundColor('red'); // Give a color for the bars, the background is always white

$renderer->render($barcode);

You can put the rendered HTML inside a div like this:

<div style="width: 400px; height: 75px"><?php echo $renderedBarcode; ?></div>

Accepted barcode types

These barcode types are supported. All types support different character sets and some have mandatory lengths. Please see wikipedia for supported chars and lengths per type.

You can find all supported types in the src/Types folder.

Most used types are TYPE_CODE_128 and TYPE_CODE_39. Because of the best scanner support, variable length and most chars supported.

  • TYPE_CODE_32 (italian pharmaceutical code 'MINSAN')
  • TYPE_CODE_39
  • TYPE_CODE_39_CHECKSUM
  • TYPE_CODE_39E
  • TYPE_CODE_39E_CHECKSUM
  • TYPE_CODE_93
  • TYPE_STANDARD_2_5
  • TYPE_STANDARD_2_5_CHECKSUM
  • TYPE_INTERLEAVED_2_5
  • TYPE_INTERLEAVED_2_5_CHECKSUM
  • TYPE_CODE_128
  • TYPE_CODE_128_A
  • TYPE_CODE_128_B
  • TYPE_CODE_128_C
  • TYPE_EAN_2
  • TYPE_EAN_5
  • TYPE_EAN_8
  • TYPE_EAN_13
  • TYPE_ITF14 (Also known as GTIN-14)
  • TYPE_UPC_A
  • TYPE_UPC_E
  • TYPE_MSI
  • TYPE_MSI_CHECKSUM
  • TYPE_POSTNET
  • TYPE_PLANET
  • TYPE_RMS4CC
  • TYPE_KIX
  • TYPE_IMB
  • TYPE_CODABAR
  • TYPE_CODE_11
  • TYPE_PHARMA_CODE
  • TYPE_PHARMA_CODE_TWO_TRACKS

See example images for all supported barcode types

A note about PNG and JPG images

If you want to use PNG or JPG images, you need to install Imagick or the GD library. This package will use Imagick if that is installed, or fall back to GD. If you have both installed, but you want a specific method, you can use $renderer->useGd() or $renderer->useImagick() to force your preference.

Examples

Embedded PNG image in HTML

$barcode = (new Picqer\Barcode\Types\TypeCode128())->getBarcode('081231723897');
$renderer = new Picqer\Barcode\Renderers\PngRenderer();
echo '<img src="data:image/png;base64,' . base64_encode($renderer->render($barcode)) . '">';

Save JPG barcode to disk

$barcode = (new Picqer\Barcode\Types\TypeCodabar())->getBarcode('081231723897');
$renderer = new Picqer\Barcode\Renderers\JpgRenderer();

file_put_contents('barcode.jpg', $renderer->render($barcode));

Oneliner SVG output to disk

file_put_contents('barcode.svg', (new Picqer\Barcode\Renderers\SvgRenderer())->render((new Picqer\Barcode\Types\TypeKix())->getBarcode('6825ME601')));

Upgrading to v3

There is no need to change anything when upgrading from v2 to v3. Above you find the new preferred way of using this library since v3. But the old style still works.

If you want to convert to the new style, here is an example:

// Old style
$generator = new Picqer\Barcode\BarcodeGeneratorSVG();
echo $generator->getBarcode('081231723897', $generator::TYPE_CODE_128);

// New style
$barcode = (new Picqer\Barcode\Types\TypeCode128())->getBarcode('081231723897');
$renderer = new Picqer\Barcode\Renderers\SvgRenderer();
echo $renderer->render($barcode);

The width in the SVG and HTML renderer is now the width of the end result, instead of the widthFactor. If you want to keep dynamic widths, you can get the width of the encoded Barcode and multiply it by the widthFactor to get the same result as before. See here an example for a widthFactor of 2:

// Old style
$generator = new Picqer\Barcode\BarcodeGeneratorSVG();
echo $generator->getBarcode('081231723897', $generator::TYPE_CODE_128, 2. 30);

// New style
$barcode = (new Picqer\Barcode\Types\TypeCode128())->getBarcode('081231723897');
$renderer = new Picqer\Barcode\Renderers\SvgRenderer();
echo $renderer->render($barcode, $barcode->getWidth() * 2, 30);

Previous style generators

In version 3 the barcode type encoders and image renderers are completely separate. This makes building your own renderer way easier. The old way was using "generators". Below are the old examples of these generators, which still works in v3 as well.

Usage

Initiate the barcode generator for the output you want, then call the ->getBarcode() routine as many times as you want.

<?php
require 'vendor/autoload.php';

// This will output the barcode as HTML output to display in the browser
$generator = new Picqer\Barcode\BarcodeGeneratorHTML();
echo $generator->getBarcode('081231723897', $generator::TYPE_CODE_128);

Will result in this beauty:
Barcode 081231723897 as Code 128

The getBarcode() method accepts the following parameters:

  • $barcode String needed to encode in the barcode
  • $type Type of barcode, use the constants defined in the class
  • $widthFactor Width is based on the length of the data, with this factor you can make the barcode bars wider than default
  • $height The total height of the barcode in pixels
  • $foregroundColor Hex code as string, or array of RGB, of the colors of the bars (the foreground color)

Example of usage of all parameters:

<?php

require 'vendor/autoload.php';

$redColor = [255, 0, 0];

$generator = new Picqer\Barcode\BarcodeGeneratorPNG();
file_put_contents('barcode.png', $generator->getBarcode('081231723897', $generator::TYPE_CODE_128, 3, 50, $redColor));

Image types

$generatorSVG = new Picqer\Barcode\BarcodeGeneratorSVG(); // Vector based SVG
$generatorPNG = new Picqer\Barcode\BarcodeGeneratorPNG(); // Pixel based PNG
$generatorJPG = new Picqer\Barcode\BarcodeGeneratorJPG(); // Pixel based JPG
$generatorHTML = new Picqer\Barcode\BarcodeGeneratorHTML(); // Pixel based HTML
$generatorHTML = new Picqer\Barcode\BarcodeGeneratorDynamicHTML(); // Vector based HTML

Embedded PNG image in HTML

$generator = new Picqer\Barcode\BarcodeGeneratorPNG();
echo '<img src="data:image/png;base64,' . base64_encode($generator->getBarcode('081231723897', $generator::TYPE_CODE_128)) . '">';

Save JPG barcode to disk

$generator = new Picqer\Barcode\BarcodeGeneratorJPG();
file_put_contents('barcode.jpg', $generator->getBarcode('081231723897', $generator::TYPE_CODABAR));

Oneliner SVG output to disk

file_put_contents('barcode.svg', (new Picqer\Barcode\BarcodeGeneratorSVG())->getBarcode('6825ME601', Picqer\Barcode\BarcodeGeneratorSVG::TYPE_KIX));

The codebase is based on the TCPDF barcode generator by Nicola Asuni. This code is therefor licensed under LGPLv3.

php-barcode-generator's People

Contributors

amenk avatar bernhard-krop avatar binarix avatar bjdelange avatar casperbakker avatar cuchac avatar curtisgibby avatar dvrtech-us avatar frankirox avatar igor-tv avatar illuminatusds avatar keinbockwurst avatar mbaschnitzi avatar oskarstark avatar pilif avatar stephangroen avatar str4to avatar trandbert37 avatar turbopixel avatar vitkutny avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-barcode-generator's Issues

Text in the bottom of the barcode

Hello,

Is there any way I can show the actual code of the generated barcode or a custom text in the bottom part of the generated barcode image?

I would also like to suggest this as a feature for future versions, which I found useful.

Thanks in advance.

Install On Laravel 5.*

Hi.
How can I install this package in Laravel 5. *?
I try to install this package but it generates me error with the classes so I do not know if I am missing steps to make or if it is not possible

Can I save a barcode as a PDF?

Hi,

I have concern regarding saving a barcode as a PDF. I am building an Inventory Management System application in Laravel 5.2 and I need to generate printable number of barcodes.

Please help me!

Thanks!
Rutvij

array definition

HI, can you please change all array definitions [] to array().
php v5.3.29 throws error.

Need more examples

Hi I used your plugin it's very good. But I don't understand some variables.
Can you give me some example how to used this?
`The ->getBarcode() routine accepts the following:

$code Data for the barcode
$type Type of barcode, use the constants defined in the class
$widthFactor Width is based on the length of the data, with this factor you can make the barcode bars wider than default
$totalHeight The total height of the barcode
$color Hex code of the foreground color`

Many Thanks

Parse error

Any ideas why this error occurs? Is it the PHP version I'm using? 5.3.3

Parse error: syntax error, unexpected '[' in /usr/share/nginx/tickets/ticket/php-barcode-generator/src/BarcodeGenerator.php on line 228

ISBN needed

Hello,
I am not so familiar with the differences of EAN and ISBN.
Are they the same?
If not, ISBN is missing.

Too much memory is required

Hi.
I've got a problem with installation. What capacity should I use?
2017-03-15_17-21-14
I use macOS, laravel and homestead.

Add str_pad with min length

The function getBarcodeData() could automatically add leading zeros as necessary.
The example bellow doen't work.

$objBarcode = new Picqer\Barcode\BarcodeGeneratorPNG();
$strBarcode = $objBarcode->getBarcodeData(10, $objBarcode::TYPE_INTERLEAVED_2_5);

I should do like that:

$objBarcode = new Picqer\Barcode\BarcodeGeneratorPNG();
$strBarcode = $objBarcode->getBarcodeData(str_pad(10, 7, '0', STR_PAD_LEFT), $objBarcode::TYPE_INTERLEAVED_2_5);

Detect barcode type

Thanks for the great library!
Just a small suggestion, there are times when you don't know the barcode type in advance (some products use EAN some UPC), so it would be usefull to have an autodetection feature when type is not provided.

Regards

Problems with testing

I have tried to install the barcode library in to my setup, (first time using composer etc) and I am getting the following:
'
Fatal error: Uncaught Error: Class 'picqer\barcode\BarcodeGeneratorHTML' not found in C:\wamp64\www\bc\test.php:13 Stack trace: #0 {main} thrown in C:\wamp64\www\bc\test.php on line 13'

Do i need to place the barcode library in a certain location?

Code 128-Auto format error

Example code:

$Barcode = new Barcode();
$code = $Barcode->barcode_c128('12345' . chr(23) . '5678');

We expect to return an array as

Array
(
    [0] => 105
    [1] => 12
    [2] => 34
    [3] => 100
    [4] => 21
    [5] => 101
    [6] => 87
    [7] => 99
    [8] => 56
    [9] => 78
    [10] => 25
    [11] => 106
    [12] => 107
)

But the result is

Array
(
[0] => 105
[1] => 12
[2] => 34
[3] => 100
[4] => 21
[5] => 98
[6] => 87
[7] => 99
[8] => 56
[9] => 78
[10] => 25
[11] => 106
[12] => 107
)

Save to file?

Hi,
would it be possible to save the generated barcode as a regular file?
Thank you,
Alex

How to save the generated image

Hi
I can generate the image in the html page but how to save it as an image

echo '<img src="data:image/png;base64,' . base64_encode($generator->getBarcode('081231723897', $generator::TYPE_CODE_128)) . '">';

Mixup A/B/C in 128 barcodes

Hi,

I need to use A+C modes in same 128 barcode.
I tried to edit current code but it doesnt seems to work.
There is a way to adapt it to get this use case works ?

Thanks

Adding requirement for libgd in README

It'd be wise to add the libgd requirement for PHP in your README.md. It took me a few minutes to debug this (not all installations have it by default - especially if one is using PHP as a quick and dirty CLI scripting environment).

Error: Class 'Picqer\Barcode\BarcodeGenerator' not found

I'm using php-barcode-generator in CakePHP framework.
I have installed plugin in vendor directory and using it in my controller

require_once(ROOT.'/vendor/picqer/php-barcode-generator/src/BarcodeGeneratorHTML.php');
  public function shippingSlipPrint($order_id = null)
    {
        $generator = new BarcodeGeneratorHTML();
        $barcode = $generator->getBarcode('1234567890', $generator::TYPE_CODE_128);

        $this->set('barcode', $barcode);

    }

But this is giving error as

Error: Class 'Picqer\Barcode\BarcodeGenerator' not found
File /myapp/vendor/picqer/php-barcode-generator/src/BarcodeGeneratorHTML.php
Line: 6 

content of BarcodeGeneratorHTML.php

<?php

namespace Picqer\Barcode;

class BarcodeGeneratorHTML extends BarcodeGenerator
{
     .....
    ......
}

EAN13 Numbers

Hello!

First, thank you for the excellent work for with this SDK, works very well.
However, I can't seem to get the numbers to be printed along with the barcode for EAN13?

Is this possible with this library?
Something like this is what I have in mind:
http://prntscr.com/e8y0a1

Base 64 encoding

i am using this library for printing barcode in receipt but base64_encode in image tag makes data very big which alternately makes barcode big which prints only half of receipt paper as barcode size gets bigger than paper size
Please help how to fix ?

Is pdf417 suppported?

Hello there, I'm looking for a generator that can generate boarding pass barcodes in pdf417 format. Can this library do that? Thank you!

TYPE_UPC_A Fatal error: Uncaught Error

Hi
I´am trying to create a barcode with TYPE_UPC_A.

$generator = new \Picqer\Barcode\BarcodeGeneratorPNG();
echo '<img src="data:image/png;base64,' . base64_encode($generator->getBarcode("081231723897", $generator::TYPE_UPC_A)) . '">';

Send me this error:

Fatal error: Uncaught Error: Class 'Picqer\Barcode\Exceptions\InvalidCheckDigitException' not found in /home/fiesa/public_html/admin/classes/barcode/BarcodeGenerator.php:1509 Stack trace: #0 /home/fiesa/public_html/admin/classes/barcode/BarcodeGenerator.php(152): Picqer\Barcode\BarcodeGenerator->barcode_eanupc('081231723897', 12) #1 /home/fiesa/public_html/admin/classes/barcode/BarcodeGeneratorPNG.php(21): Picqer\Barcode\BarcodeGenerator->getBarcodeData('081231723897', 'UPCA') #2 /home/fiesa/public_html/includes/checkout-review.php(30): Picqer\Barcode\BarcodeGeneratorPNG->getBarcode('081231723897', 'UPCA') #3 /home/fiesa/public_html/index.php(58): include('/home/fiesa/pub...') #4 {main} thrown in /home/fiesa/public_html/classes/barcode/BarcodeGenerator.php on line 1509

I tried to fix the problem but I could not. Have try it most of TYPES and all look working fine except this one and TYPE_UPC_B.

Have someone have the same issue? Anyone know how can I fix that ?

GS1-128

I need to generate a barcode with the standard GS1-128, I had an almost satisfactory result following this post (http://stackoverflow.com/questions/34040995/how-to-properly-generate-a-gs1-128-formerly Barcode-in-tcpdf) but unfortunately the end of the barcode was not the same in comparison to one generated by other system that actually follows the standard and is accepted by our bank.

I expect to see this:
esperado

but instead I get this:
obtenido

I'm using this code:
$code = chr(241)."4157709998016989802000105385555480202016103470";
$generatorPNG = new Picqer\Barcode\BarcodeGeneratorPNG();
echo '<img '
. 'src="data:image/png;base64,' . base64_encode(
$generatorPNG->getBarcode($code,
Picqer\Barcode\BarcodeGeneratorPNG::TYPE_CODE_128_C))
. '" style="height: 50px; width: 300px ">';

I appreciate any help you can give me.

Simple Exception Raising

Hi,

I was testing my tavinus/cli-barcode script a bit and wanted to capture some simple errors.

For example, if someone passes something that is not a number for a CODE_128_C barcode, PHP is gonna show Warning messages because we will be looping an array that does not exist:

PHP Warning:  Invalid argument supplied for foreach() in /mnt/dados/user/barcode/vendor/picqer/php-barcode-generator/src/BarcodeGenerator.php on line 2820
Warning: Invalid argument supplied for foreach() in /mnt/dados/user/barcode/vendor/picqer/php-barcode-generator/src/BarcodeGenerator.php on line 2820

However, it is gonna continue execution, and even generate an "empty" barcode sometimes.
There is no way to identify this error when it happens.

So by the warning messages I went to try and throw an Exception

File:     picqer/php-barcode-generator/src/BarcodeGenerator.php
Line:     2815
Function: convertBarcodeArrayToNewStyle

Added: (Please revise the Exception message)

if (empty($oldBarcodeArray['bcode'])) throw new \Exception("Could not process barcode! Seems like your barcode string is empty or invalid for the proposed format.");

Like This:

    protected function convertBarcodeArrayToNewStyle($oldBarcodeArray)
    {
        if (empty($oldBarcodeArray['bcode'])) throw new \Exception("Could not process barcode! Seems like your barcode string is empty or invalid for the proposed format.");
        $newBarcodeArray = [];
        $newBarcodeArray['code'] = $oldBarcodeArray['code'];
        $newBarcodeArray['maxWidth'] = $oldBarcodeArray['maxw'];
        $newBarcodeArray['maxHeight'] = $oldBarcodeArray['maxh'];
        $newBarcodeArray['bars'] = [];
        foreach ($oldBarcodeArray['bcode'] as $oldbar) {
            $newBar = [];
            $newBar['width'] = $oldbar['w'];
            $newBar['height'] = $oldbar['h'];
            $newBar['positionVertical'] = $oldbar['p'];
            $newBar['drawBar'] = $oldbar['t'];
            $newBar['drawSpacing'] = ! $oldbar['t'];

            $newBarcodeArray['bars'][] = $newBar;
        }

        return $newBarcodeArray;
    }

Then you need to try and catch of course:

// generate de barcode
try {
    $bc_data  = $generator->getBarcode($bc_string, $bc_type, $width, $height, $color);    
} catch (Exception $e) {
    echo "Error: ".$e->getMessage()."\n";
    exit(1);
}

Here it running:

$ barcode -e code_128_c -f SVG "1231241asdasb2" $HOME/teste.svg 
Error: Could not process barcode! Seems like your barcode string is invalid for the proposed format.

Here if it is not in "try/catch":

$ barcode -e code_128_c -f SVG "1231241asdasb2" $HOME/teste.svg 
PHP Fatal error:  Uncaught exception 'Exception' with message 'convertBarcodeArrayToNewStyle: Invalid Input Barcode! $oldBarcodeArray['bcode'] empty' in /mnt/dados/user/barcode/vendor/picqer/php-barcode-generator/src/BarcodeGenerator.php:2815
Stack trace:
#0 /mnt/dados/user/barcode/vendor/picqer/php-barcode-generator/src/BarcodeGenerator.php(182): Picqer\Barcode\BarcodeGenerator->convertBarcodeArrayToNewStyle(false)
#1 /mnt/dados/user/barcode/vendor/picqer/php-barcode-generator/src/BarcodeGeneratorSVG.php(21): Picqer\Barcode\BarcodeGenerator->getBarcodeData('1231241asdasb2', 'C128C')
#2 /mnt/dados/user/barcode/barcode.php(287): Picqer\Barcode\BarcodeGeneratorSVG->getBarcode('1231241asdasb2', 'C128C', 2, 30, '#000000')
#3 {main}
  thrown in /mnt/dados/user/barcode/vendor/picqer/php-barcode-generator/src/BarcodeGenerator.php on line 2815
Fatal error: Uncaught exception 'Exception' with message 'convertBarcodeArrayToNewStyle: Invalid Input Barcode! $oldBarcodeArray['bcode'] empty' in /mnt/dados/user/barcode/vendor/picqer/php-barcode-generator/src/BarcodeGenerator.php:2815
Stack trace:
#0 /mnt/dados/user/barcode/vendor/picqer/php-barcode-generator/src/BarcodeGenerator.php(182): Picqer\Barcode\BarcodeGenerator->convertBarcodeArrayToNewStyle(false)
#1 /mnt/dados/user/barcode/vendor/picqer/php-barcode-generator/src/BarcodeGeneratorSVG.php(21): Picqer\Barcode\BarcodeGenerator->getBarcodeData('1231241asdasb2', 'C128C')
#2 /mnt/dados/user/barcode/barcode.php(287): Picqer\Barcode\BarcodeGeneratorSVG->getBarcode('1231241asdasb2', 'C128C', 2, 30, '#000000')
#3 {main}
  thrown in /mnt/dados/user/barcode/vendor/picqer/php-barcode-generator/src/BarcodeGenerator.php on line 2815

Prints heaps of stuff but should halt execution there anyways.
Maybe you want to really create your Exception classes and make that stuff proper, but that is what I am using right now so I decided to post here.

Maybe test with is_array() or isset()? Not sure.

Thanks for this awesome code!

Cheers!
Gus

PS: Maybe my little-script is useful to test your library in general.

Accept 13 chars in EAN13 code

Now only 13 chars are accepted, because the 13th is calculated. Well, accept also 13 chars and then do not calculate the checksum.

barcode + label below

hi, just wondering if there's an option to include the label or barcode value below the barcode?

Parse error: syntax error, unexpected '[' in BarcodeGenerator.php

In localhost works correctly, but when I upload to the server show this error:
Parse error: syntax error, unexpected '[' in /var/www/vhost/mywebsite.com/vendor/picqer/php-barcode-generator/src/BarcodeGenerator.php on line 228

I guess that the problem is the PHP version:
-Localhost PHP Version 5.6.7
-Online Server PHP Version 5.3.3

Picqer\Barcode\Exceptions\InvalidCheckDigitException

Picqer\Barcode\Exceptions\InvalidCheckDigitException when I try to generate barcode out of these numbers:

  • 1202033103088
  • 9472600573133
  • 9005024966350

I try to generate EAN13 barcode. I thought some of the digits are chars, but they're not. What could be the problem?
Here is the code:

(new BarcodeGeneratorSVG()) ->getBarcode($barcode, BarcodeGenerator::TYPE_EAN_13, 9, 240)

Please help!

I want to add label to the barcode image.

I want to add the label (which is the barcode number ) of the barcode image at bottom. like the image attached below. I don't know how to do it.. please help me... Thanks in Advance.
sample

Validate barcode generator input

$g = new BarcodeGeneratorPNG; $g->getBarcode('A123', $g::TYPE_EAN_13);
result -> notice: undefined index 'A', exception would be nice.

Vertical barcode image

How can I create a vertical barcode image? Essentially the horizontal one but just rotated 90 degrees to the right.

Barcode not redering in IE6 and IE7

I am generating TYPE_CODE_128_A barcode.
It works on Chrome and Mozilla. Also works on IE 8 and above versions.
But not rendering in IE6 and IE7.

Please help me.
Thanks in advance.

Height & Width Issue

I am using picqer bar code generator for generating bar code. My requirement for bar code height is 26.45 pixels and width is 185.19 pixels. Height is adjustable. But I want width to be precise 185 or 186. How can I do that? I have adjusted height as 27 but How can i set the width of bar code of 186. Your early reply will be appreciated.

README should specify minimum PHP version.

Running the library on PHP 5.3 will raise:

Parse error: syntax error, unexpected '[' in /path/to/project/vendor/picqer/php-barcode-generator/src/BarcodeGenerator.php on line 228

Line 228: $chr = [];

which is short array syntax introduced in PHP 5.4: http://php.net/manual/en/migration54.new-features.php

Such shortcode is unnecessary and reduce version compatibility. Can you change back to:

$chr = array();

p.s. multiple [] detected in the BarcodeGenerator.php

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.