Welcome to WebmasterWorld Guest from 54.166.102.61

Forum Moderators: coopster & jatar k

Generate Barcodes images (EAN13)

Barcodes in graphical format

   
5:06 pm on Aug 2, 2011 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



Hi webmasters, do you know any way of creating EAN13 barcodes in graphic format?

I already have one php class doing it but it has a bug, the resulting barcodes have at least 3 differences and the barcode reader doesn't recognize them, so at the end this just doesn't work.

I searched/tried other perl and php tools but some create SVG output or pure text using TTF fonts, and another one that fills the entire page. I need a versatile solution with no need to install fancy modules.

I need it to output the barcode in graphical format as I'm adding price, code and name of the product depending on the needs, then composite the images to fill a page but as needed by the user.

Any help will be appreciated.

The php code I'm using was found on php classes, another user (out of reach) posted a fix but is not understandable, as when I try to replace the code is not clear what to replace with what, it also has references to code that is not present on the package.

_ean13CheckDigit() has bug?

input:
$barnumber = '123456789012'; //12 charactors.
output:
incorrect: '0123456789012'; //add no $checksumDigit, and '0' padding.
correct: '1234567890128'; //inputs plus $checksumDigit='8' .

patch:
========================================================
1559c1559
< if(strlen($barnumber) <= 11 )
---
> if(strlen($barnumber) <= 12 )
1561c1561
< $barnumber = str_pad($barnumber, 12, "0", STR_PAD_LEFT);
---
> $barnumber = str_pad($barnumber, 13, "0", STR_PAD_LEFT);
1579,1591c1579,1583
< if(strlen($barnumber) <= 12 )
< {
< if( $csumTotal % 10 == 0 )
< $checksumDigit = '';
< else
< $checksumDigit = 10 - ($csumTotal % 10);
< $barnumber .= $checksumDigit;
< }
< if(strlen($barnumber) <= 12 )
< {
< $barnumber = str_pad($barnumber, 13, "0", STR_PAD_LEFT);
< }
< return $barnumber;
---
> if( $csumTotal % 10 == 0 )
> $checksumDigit = '';
> else
> $checksumDigit = 10 - ($csumTotal % 10);
> return $barnumber.$checksumDigit;
========================================================

TWO:

Notice: Undefined variable: space in /path/to/barcode.inc.php on line 1669
========================================================
1669c1661
< if (empty($space))
---
> if (!$space)
========================================================
5:17 pm on Aug 2, 2011 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



PS. I posted the code/fix just if anyone find it familiar, the code itself is of no use alone
6:17 pm on Aug 2, 2011 (gmt 0)



PHPClasses has some scripts that say they'll do what you want.

[phpclasses.org ]
[phpclasses.org ]

And the search page: [phpclasses.org ]
6:49 pm on Aug 2, 2011 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



Thanks!, I was working with the first with no luck (its the one with bugs), just found the second one and is working, never showed up on the results before
 

Featured Threads

Hot Threads This Week

Hot Threads This Month