Wednesday, January 13, 2016

Create and Embed Barcodes using PHP

Requirements: 
PHP GD Library 
In case of Debian Linux just run command :

#sudo apt-get install php5-gd

Barcode script : 
View the code here: https://github.com/davidscotttufts/php-barcode/

That Scripts generates barcodes in four barcode formats including Code 128, Code 39, Code 2of5, and Codabar. With a little over 100 lines of code you have the options of “vertical” or “horizontal” display, varying barcode heights, and one of four barcode formats.

How to embed in HTML code:
Example 1:
<img alt="testing" src="/yourfilelocation/barcode.php" />
Example 2 (with text data):
<img alt="testing" src="/yourfilelocation/barcode.php?text=testing" />
Example 3 (with codetype, size, text)
<img alt="TESTING" src="/yourfilelocation/barcode.php?codetype=Code39&size=40&text=TESTING" />

4 comments:

  1. My device does not read this barcode but my android app using mobile working fine

    ReplyDelete
    Replies
    1. MS900 Hand Held or Hands Free Barcode Laser Scanner

      Delete
    2. May be your barcode device does not support above mention barcode formats like Code 128, Code 39, Code 2of5, and Codabar.

      Delete