Giter Club home page Giter Club logo

php-barcode-generator's People

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

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 ?

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 ?

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.

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).

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!

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.

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

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

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

Validate barcode generator input

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

array definition

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

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.

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.

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

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

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)) . '">';

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.

barcode + label below

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

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

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
{
     .....
    ......
}

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.

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

Vertical barcode image

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

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
)

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

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?

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

ISBN needed

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

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

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!

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.

Save to file?

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

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.