Lefora Free Forum
119 views

Creating barcodes with PHP

Page 1
posts 1–8 of 8
Monitor Lizard - admin
548 posts

I'm wondering if anyone has done this?  I've found some scripts online, but can't get them to work for the life of me.  They all require php_gd to be installed and enabled, which I've done.

I realize this is an odd one, but one of you geniuses might have done it already.

__________________
www.suseunbound.com I'm a PC and I run on Linux
Iguana - member
299 posts



Nope never done it but just done it wink


cat public_html/test.php 
<?php
   require_once 'Image/Barcode.php';
   /* Data that will be encoded in the bar code */
    $bar_code_data = TRSD5656;
 
   /* The third parameter can accept any from the following,
    * jpg, png and gif.
    */
   Image_Barcode::draw($bar_code_data, 'code128', 'png');
 ?>


Did nothing to my php.ini neither did I install php_gd, but what I did do, I discovered php has an interface similar to cspan the things you learn. OK I haven't quite solved the config stuff interactively isn't quite doing it for me.


pear install --alldeps http://download.pear.php.net/package/Image_Barcode-1.1.0.tgz

neat heah 
So you can check I'm not doing anything horrible here is the page http://pear.php.net/package/Image_Barcode/

[OT] Now I've helped you, tell me how to configure django with ssl in virtual hosts using apache for static and dynamic surprise[/OT]

__________________
I've always used the new hardware that's out, a cellulose tube filled with carbon crystals working over a flexible cellulose base
Monitor Lizard - admin
548 posts

It seems their website is down at the moment.  I will have to try later.

Wish I could help you, but I've no idea.

__________________
www.suseunbound.com I'm a PC and I run on Linux
Monitor Lizard - admin
548 posts

Well their website came back up, so one thing has finally worked right for me tonight.  Your barcode example did not however.  I did have to add quotes around the string.  Just can't get good help these days  :P

The funny thing is that now my original tries are working now too.

If you want to see
The FM example: http://www.thebdquick.com/barcode.php

The code from http://www.ashberg.de/php-barcode/ (I think this one looks best)
http://www.thebdquick.com/barcode/barcode.php

Thanks FM

Now if I can get SSL working with vsftpd correctly, but that might be a thread for another day.

__________________
www.suseunbound.com I'm a PC and I run on Linux
Iguana - member
299 posts


As for ssl I might be able to help but no guarantee, I've set it up for a shop and finally sussed it for the virtual hosts(Got a nice rewrite rule that redirects to ssl) if you get can't find key create a pem with the key and cert together in it.  Now if I could only work out why my url confs are random, yet the documentation says it runs in order, not my experience.

As for the string strange, guess its because you're running an outdated php just checked mine it works fine and you can see my source :P.(Reckon you where missing the lib which you've installed why your example works now but guessing) I agree your example is nicer.

 But python is the challenge now too many things with php turn up bad for my liking.

__________________
I've always used the new hardware that's out, a cellulose tube filled with carbon crystals working over a flexible cellulose base
Iguana - member
299 posts




Edit

Hehe now I see what you mean when I first tested it I just used alpha which worked fine for some reason on code128(Teach me for echoing into files(Didn't notice the code obfuscation either before)). I also can make it look more or less the same. Your example seems to have a strange way of doing it using a 1x1 image to build it. If you use the lib I highlighted in /usr/share/pear/Image/Barcode/code files it has vars if I tweak 
font = 3
barwidth =2 
barcodeheight = 200

We get



__________________
I've always used the new hardware that's out, a cellulose tube filled with carbon crystals working over a flexible cellulose base
Monitor Lizard - admin
548 posts

Very true the size is easily tweak with either example.

And to be honest the problem with the other example was also needing quotes around number.  Not sure if it was a php4 vs php5 or what, but I am running php5.  The example you gave me just threw an error that actually said something helpful, rather than invalid image.

__________________
www.suseunbound.com I'm a PC and I run on Linux
Iguana - member
299 posts

Thought I would bump this I haven't got a clue what is going on but I've just been bumped to 5.3 its smashing bits for fun the barcode example I used now throws 

Fatal error: Call to undefined function imagefontheight() in /usr/share/pear/Image/Barcode/code128.php on line 137



The zencart install I have has just about disappeared and I have no real useful logs, this is mainly a fyi and if you intend to go the upgrade route starting the transition now may make it less painful at a later date.

As for me starting to like django more and more...
__________________
I've always used the new hardware that's out, a cellulose tube filled with carbon crystals working over a flexible cellulose base
Page 1
posts 1–8 of 8

This Topic Is Locked To Guest Posts

It's been a while since this topic was active, if you'd like to get it going again, please post as a registered member

join now