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

This function allows you to draw a code 39 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.

Calling this function
draw($pChartObject,$TextString,$X,$Y,$Format="");
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.
You can add the MOD43 security character setting EnableMOD43 to TRUE.


Sample script



 /* pChart library inclusions */
 include("../class/pDraw.class.php");
 include("../class/pBarcode39.class.php");
 include("../class/pImage.class.php");

 /* 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);
 $myPicture->drawFilledRectangle(0,0,700,230,$Settings);

 /* 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,230,DIRECTION_VERTICAL,$Settings);
 $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 */
 $myPicture->drawRectangle(0,0,699,229,array("R"=>0,"G"=>0,"B"=>0));

 /* Write the title */
 $myPicture->setFontProperties(array("FontName"=>"../fonts/Silkscreen.ttf","FontSize"=>6));
 $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 */
 $myPicture->setFontProperties(array("FontName"=>"../fonts/pf_arma_five.ttf","FontSize"=>6));
 $Settings = array("ShowLegend"=>TRUE,"DrawArea"=>TRUE);
 $Barcode->draw($myPicture,"pChart Rocks!",50,50,$Settings);

 /* Draw a rotated barcode */
 $myPicture->setFontProperties(array("FontName"=>"../fonts/Forgotte.ttf","FontSize"=>12));
 $Settings = array("ShowLegend"=>TRUE,"DrawArea"=>TRUE,"Angle"=>90);
 $Barcode->draw($myPicture,"Turn me on",650,50,$Settings);

 /* Draw a rotated barcode */
 $myPicture->setFontProperties(array("FontName"=>"../fonts/Forgotte.ttf","FontSize"=>12));
 $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) */
 $myPicture->autoOutput("pictures/example.barcode39.png");

This will draw three barcodes.
Last updated on 06/07/2010 
by Jean-Damien 
Linked resources
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,19 seconds. Wiki revision 1.37.