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

This function allows you to draw a code 128 barcode on your pictures. It is possible to tune the rendering by playing with the $Format array. To learn more about this please read the Format array guide.

Code 128 is a very high-density barcode symbology. It is used for alphanumeric or numeric-only barcodes. It can encode all 128 characters of ASCII and is widely used in the industry to track packages.

Calling this function
Where :

$pChartObject is the reference to the pChart object where the barcode will be drawn.
$TextString is the text to be encoded.
X,Y are the coordinate of the top left point.
Format is an array containing the drawing parameters of the pixel.

Customisation array - Tune up your barcode!

It is possible to customize the barcode rendering by playing with this array. Providing a detailled configuration is not mandatory, by default the barcode will be drawn black with no transparency, no border and no subtitle.

The barcode color can be set with R, G, B.
The alpha transparency factor can be set with Alpha.
You can define the barcode height with Height. (default is 30)
You can define the barcode angle with Angle.
If you want to display the legend in clear text, set ShowLegend to TRUE.
You can define the legend offset with Angle. (default is 5)
You can draw a surrounding area by setting DrawArea to TRUE.
The area filling color can be set with R, G, B.
The area border color can be set with AreaBorderR, AreaBorderG, AreaBorderB.

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

 /* Draw the top bar */
 $myPicture->drawGradientArea(0,0,700,20,DIRECTION_VERTICAL,array("StartR"=>0,"StartG"=>0,"StartB"=>0, "EndR"=>50,"EndG"=>50,"EndB"=>50,"Alpha"=>100));
 $myPicture->drawText(10,13,"Barcode 128 - Add barcode to your pictures",array("R"=>255,"G"=>255,"B"=>255));

 /* Create the barcode 128 object */
 $Barcode = new pBarcode128();

 /* 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 */

This will draw three barcodes.
Last updated on 06/07/2010 
by Jean-Damien 
Linked resources
  There is no linked topic yet.
Community comments
  No comments have been posted yet.
© 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. 415 users have registered. This page has been rendered in 0,01 seconds. Wiki revision 1.37.