picqer / php-barcode-generator Goto Github PK
View Code? Open in Web Editor NEWBarcode generator in PHP that is easy to use, non-bloated and framework independent.
License: GNU Lesser General Public License v3.0
Barcode generator in PHP that is easy to use, non-bloated and framework independent.
License: GNU Lesser General Public License v3.0
Hi, is it possible to identify barcode type by provided code?
whenever i try to run barcodetest.php this error shows up.havent figured out this library yet.its not working
Any chance these will be supported in the near future?
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
)
hi, just wondering if there's an option to include the label or barcode value below the barcode?
HI, can you please change all array definitions [] to array().
php v5.3.29 throws error.
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)) . '">';
Firstly, good job! 👍
Will you support 2D barcode format? QR code specifically?
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 ?
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'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.
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);
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.
Hi,
Thanks for the useful library. I need to display or print a bar code with text below. How can I do that?
Screen shot:
https://prnt.sc/g0xc5l
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
{
.....
......
}
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?
How can I create a vertical barcode image? Essentially the horizontal one but just rotated 90 degrees to the right.
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).
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.
In the current 0.2 version the EAN13 barcode which should be generated, now generates a UPC-A barcode, if the barcode starts with a zero (0).
Test environment uses PHP 5.6.1.
I wanted to create the barcode which includes the actual numbers too. But couldn't find a way.
Hello there, I'm looking for a generator that can generate boarding pass barcodes in pdf417 format. Can this library do that? Thank you!
As the title states, is it possible?
This is what I have in mind; http://prntscr.com/e8y9ma
The picture is of a EAN13 barcode.
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
The example at the bottom of the ReadMe does not work.
Great library! I'd love to see ISBN and ISSN support though.
$g = new BarcodeGeneratorPNG; $g->getBarcode('A123', $g::TYPE_EAN_13);
result -> notice: undefined index 'A', exception would be nice.
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.
Please, implements suport for QR CODE
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
Hi, thanks for good plugin.
Anyway, after test to use it, i got the barcode has no title printed. is there possible to create a tittle like regular barcode? see this https://en.wikipedia.org/wiki/Code_128 below the barcode, has 'wikipedia' printed.
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.
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
This project is using code copied from:
https://github.com/tecnickcom/TCPDF
but all copyright and license terms were removed.
Please immediately delete all the copied code or adapt it to conform the original copyright and license requirements.
Please also note that the code you have copied has now been replaced by another project:
https://github.com/tecnickcom/tc-lib-barcode
Please carefully read the license and act promptly.
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
Hi, I'm trying to insert the FNC3 character at the beginning of a CODE128 barcode. I have passed the ASCII 128 character (Ç) in the Value, but it doesn't appear to be correct. I expect to see this:
http://is.am/k5
but instead I get this:
http://is.am/k6
What am I doing wrong?
Thanks,
Ryan
It's there any way to display the code below the generated image ?
Now only 13 chars are accepted, because the 13th is calculated. Well, accept also 13 chars and then do not calculate the checksum.
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
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
Hello,
I am not so familiar with the differences of EAN and ISBN.
Are they the same?
If not, ISBN is missing.
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
Hi,
would it be possible to save the generated barcode as a regular file?
Thank you,
Alex
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
Picqer\Barcode\Exceptions\InvalidCheckDigitException when I try to generate barcode out of these numbers:
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!
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
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 ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.