Login Register Wishes Forum About
Language Reference » Barcode 39 functions » pBarcode39
Help topics
Latest updates
2054d  replaceImageMapTitle
2054d  replaceImageMapValues
2054d  createFunctionSerie
2054d  setAbsicssaPosition
2054d  negateValues
  Download as PDF
  Print this page
  Share this page
  Create an account
  Feed the updates!
Google AdSense
pBarcode39 - Draw a code 39 barcode

This function allows you to embed a code 39 barcode on your pictures.

Code 39 (also known as "USS Code 39", "Code 3/9", "Code 3 of 9", "USD-3", "Alpha39", "Type 39") is a barcode symbology that can encode uppercase letters (A through Z), digits (0 through 9) and a handful of special characters like the $ sign. The barcode itself does not contain a check digit (in contrast to Code 128), but it can be considered self-checking by some, on the grounds that a single erroneously interpreted bar cannot generate another valid character. Possibly the most serious drawback of Code 39 is its low data density: It requires more space to encode data in Code 39 than, for example, in Code 128. This means that very small goods cannot be labeled with a Code 39 based barcode. However, Code 39 is still widely used and can be decoded with virtually any barcode reader.

The Code 39 (also known as 3 of 9 bar code) is a variable length, discrete, alphanumeric bar code. Its character set contains 43 meaningful characters: 0 - 9, A-Z, -, ., $, /, +, %, and space. Each character is composed of nine elements: five bars and four spaces. Three of the nine elements are wide (binary value 1), and six elements are narrow (binary value 0). An additional common character (*) is used for both start and stop delimiters.

Calling this function
Where :

$BasePath specify the top level path where the data folder stands.
$EnableMOD43 specify if we‘ll have a modulo 43 checksum to the barcode (default is FALSE).

Sample script

 /* pChart library inclusions */

 /* Create the pChart object */
 $myPicture = new pImage(700,230);

 /* Draw the background */
 $Settings = array("R"=>170, "G"=>183, "B"=>87, "Dash"=>1, "DashR"=>190, "DashG"=>203, "DashB"=>107);

 /* Overlay with a gradient */
 $Settings = array("StartR"=>219, "StartG"=>231, "StartB"=>139, "EndR"=>1, "EndG"=>138, "EndB"=>68, "Alpha"=>50);
 $myPicture->drawGradientArea(0,0,700,20,DIRECTION_VERTICAL,array("StartR"=>0,"StartG"=>0,"StartB"=>0,"EndR"=>50,"EndG"=>50, "EndB"=>50,"Alpha"=>80));

 /* Draw the picture border */

 /* Write the title */
 $myPicture->drawText(10,13,"Barcode 39 - Add barcode to your pictures",array("R"=>255,"G"=>255,"B"=>255));

 /* Create the barcode 39 object */
 $Barcode = new pBarcode39("../");

 /* Draw a simple barcode */
 $Settings = array("ShowLegend"=>TRUE,"DrawArea"=>TRUE);
 $Barcode->draw($myPicture,"pChart Rocks!",50,50,$Settings);

 /* Draw a rotated barcode */
 $Settings = array("ShowLegend"=>TRUE,"DrawArea"=>TRUE,"Angle"=>90);
 $Barcode->draw($myPicture,"Turn me on",650,50,$Settings);

 /* Draw a rotated barcode */
 $Settings = array("R"=>255,"G"=>255,"B"=>255,"AreaR"=>150,"AreaG"=>30,"AreaB"=>27,"ShowLegend"=>TRUE, "DrawArea"=>TRUE,"Angle"=>350,"AreaBorderR"=>70,"AreaBorderG"=>20,"AreaBorderB"=>20);
 $Barcode->draw($myPicture,"Do what you want !",290,140,$Settings);

 /* Render the picture (choose the best way) */

This will draw three barcodes.
Last updated on 12/02/2010 
by Jean-Damien 
Linked resources
Community comments
Message from mice32alpha on 02/12/2010
You‘ve lost $BasePath parameter of the constructor...
© Copyrights
Components used on this web site : Famfamfam icons has been made by Mark James, Rounded corners lite has been coded by Cameron Cooke and Tim Hutchison, SyntaxHighlighter has been written by Alex Gorbatchev. pChart and this web site have been created by Jean-Damien POGOLOTTI. This documentation contains 185 pages and 56 comments. 409 users have registered. This page has been rendered in 0,01 seconds. Wiki revision 1.37.