homepage Welcome to WebmasterWorld Guest from 54.211.73.232
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Generate Barcodes images (EAN13)
Barcodes in graphical format
explorador

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4346753 posted 5:06 pm on Aug 2, 2011 (gmt 0)

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

 

explorador

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4346753 posted 5:17 pm on Aug 2, 2011 (gmt 0)

PS. I posted the code/fix just if anyone find it familiar, the code itself is of no use alone

physpeters



 
Msg#: 4346753 posted 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 ]

explorador

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4346753 posted 6:49 pm on Aug 2, 2011 (gmt 0)

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved