Contents
Login Register Wishes Forum About
Language Reference » Barcode 128 functions » getSize
Help topics
Latest updates
2026d  replaceImageMapTitle
2026d  replaceImageMapValues
2026d  createFunctionSerie
2026d  setAbsicssaPosition
2026d  negateValues
Toolbox
  Download as PDF
  Print this page
  Share this page
  Create an account
  Feed the updates!
Google AdSense
getSize - Return the projected size of a code 128 barcode

This function allows you to estimate the target size of a code 128 barcode. You‘ll have to give it the same $Format array than the one you‘ll use when calling the draw method in order to have an accurate projection of the barcode size.

This function is particulary useful when you want to create a picture containing only a barcode (to embed it in a more complex document like PDF file).

If you plan to display the barcode legend in plain text (ShowLegend parameter), you‘ll need to specify the font height manually (FontSize parameter) as when you‘ll call this function the pChart object will not be instantiated yet.


Calling this function
getSize($TextString,$Format="")
Where :

$TextString is the text to be encoded.
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.

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 LegendOffset. (default is 5)
You can draw a surrounding area by setting DrawArea to TRUE.
You can specify the font height to use with FontSize.


Sample script



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

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

 /* String to be written on the barcode */
 $String = "This is a test";

 /* Retrieve the barcode projected size */
 $Settings = array("ShowLegend"=>TRUE,"DrawArea"=>TRUE);
 $Size = $Barcode->getSize($String,$Settings);

 /* Create the pChart object */
 $myPicture = new pImage($Size["Width"],$Size["Height"]);

 /* Render the barcode */
 $Barcode->draw($myPicture,$String,10,10,$Settings);

 /* Render the picture */
 $myPicture->Render("singlebarcode128.png");

This will draw a single barcode.
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. 409 users have registered. This page has been rendered in 0,01 seconds. Wiki revision 1.37.