Language Reference » Barcode 128 functions » getSize
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).
Calling this function
$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.
/* 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.
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.