Manual - Intelligent Mail
Introduction
Intelligent Mail code allows you to encode postal codes in the United States including a tracking code.
You must set the tracking code with the setTrackingCode() method before calling the parse() method.
The parse() method takes the zipcode as its parameter.
The zipcode must be one of those values:
- 5 numbers(ZIP Code)
- 9 numbers(ZIP Code + 4)
- 11 numbers(ZIP Code + 4 + 2 numbers)
This class inherits the BCGBarcode1D class.
Example
Methods
BCGintelligentmail's Methods
- getQuietZone() — Gets if the quiet zone will be drawn
-
setQuietZone(
$quietZone ) — Specifies to draw a quiet zone around the barcode -
setTrackingCode(
$barcodeIdentifier ,$serviceTypeIdentifier ,$mailerIdentifier ,$serialNumber ) — Sets the tracking code
BCGBarcode1D's Methods
- getThickness() — Returns the thickness of the barcode
-
setThickness(
$thickness ) — Specifies the thickness of the barcode - getLabel() — Gets the label
-
setLabel(
$label ) — Sets the label - getFont() — Gets the text font for the label
-
setFont(
$font ) — Sets the text font for the label - getChecksum() — Gets the checksum appended to the barcode
-
setDisplayChecksum(
$display ) — Specifies the checksum to be added to the label
BCGBarcode's Methods
-
parse(
$text ) — Analyzes a$text message to draw afterwards -
draw(
$image ) — Draws the barcode on the$image -
getDimension(
$width ,$height ) — Returns an array containing the required size for the image - getScale() — Gets the scale of the barcode
-
setScale(
$scale ) — Sets the scale of the barcode - getForegroundColor() — Gets the color of the bars
-
setForegroundColor(
$color ) — Sets the color of the bars - getBackgroundColor() — Gets the color of the spaces
-
setBackgroundColor(
$color ) — Sets the color of the spaces -
setColor(
$foregroundColor ,$backgroundColor ) — Sets the color of the bars and spaces - getOffsetX() — Gets the X offset
-
setOffsetX(
$value ) — Sets the X offset - getOffsetY() — Gets the Y offset
-
setOffsetY(
$value ) — Sets the Y offset -
addLabel(
$label ) — Adds a label to the graphic -
removeLabel(
$label ) — Removes a label from the graphic - clearLabels() — Removes the labels from the graphic
Code Example
<?php
use BarcodeBakery\Common\BCGFontFile;
use BarcodeBakery\Common\BCGColor;
use BarcodeBakery\Common\BCGDrawing;
use BarcodeBakery\Barcode\BCGintelligentmail;
$font = new BCGFontFile(__DIR__ . '/font/Arial.ttf', 18);
$colorBlack = new BCGColor(0, 0, 0);
$colorWhite = new BCGColor(255, 255, 255);
// Barcode Part
$code = new BCGintelligentmail();
$code->setScale(2);
$code->setForegroundColor($colorBlack);
$code->setBackgroundColor($colorWhite);
$code->setFont($font);
$code->setTrackingCode('01', '234', '567094', '987654321');
$code->parse('98103');
// Drawing Part
$drawing = new BCGDrawing($code, $colorWhite);
header('Content-Type: image/png');
$drawing->finish(BCGDrawing::IMG_FORMAT_PNG);
?>
Method explanations
-
getQuietZone()
—
Gets if the quiet zone will be drawn
Returns
bool -true if activated,false otherwise -
setQuietZone(
$quietZone ) — Specifies to draw a quiet zone around the barcodeDescriptionTo be read correctly, the Intelligent Mail must have a quiet zone around the image. You can, however, turn this off.
The default value is true. -
setTrackingCode(
$barcodeIdentifier ,$serviceTypeIdentifier ,$mailerIdentifier ,$serialNumber ) — Sets the tracking codeDescriptionAdd some information to the barcode such as:
- Barcode Identifier: Assigned by USPS, encodes the pre-sort identification. 2 digits, last digit must be between 0 and 4.
- Service Type: Assigned by USPS, type of service of the mail. 3 digits.
- Mailer Identifier: Assigned by USPS as unique id to identify your business. 6 or 9 digits.
- Serial Number: Assigned by the mailer for uniquely identifying and tracking mail pieces. 9 digits if mailer identifier is 6 digits. 6 otherwise.
-
getThickness()
—
Returns the thickness of the barcode
DescriptionThe thickness of the barcode in pixels. The value isn't multiplied by the scale.Returns
int - value in pixels -
setThickness(
$thickness ) — Specifies the thickness of the barcodeDescriptionThe thickness of the barcode in pixels. This is the vertical size. -
getLabel()
—
Gets the label
DescriptionReturns the real value that will be displayed with the barcode. You have to have called the
parse() method first.Returnsstring - final label -
setLabel(
$label ) — Sets the labelDescriptionThe text label will be written below or above the barcode depending on the barcode. You can write the special valueBCGBarcode1D::AUTO_LABEL if you would like your text to be chosen automatically. It will be the value passed to theparse() method. -
getFont()
—
Gets the text font for the label
DescriptionGets the text font for the label.Returns
-
setFont(
$font ) — Sets the text font for the labelDescriptionThe value of the argument can be either an instance of theBCGFontFile class,BCGFontPhp , or a number between 1 and 5.
If you are using numbers 1 through 5, PHP fonts are used. Check the PHP Manual. -
getChecksum()
—
Gets the checksum appended to the barcode
DescriptionReturns the value that will be appended to the barcode. This method must be called after the method
parse() .Returnsint - checksum added orfalse if no checkum is included -
setDisplayChecksum(
$display ) — Specifies the checksum to be added to the labelDescriptionSettingtrue will append the checksum to the default label.
The default value is true.
-
parse(
$text ) — Analyzes a$text message to draw afterwardsDescriptionThe data you pass to the$text argument must be supported by the type of barcode you use.
Check each barcode's introduction section to obtain more information on how to use this method within each symbology. -
draw(
$image ) — Draws the barcode on the$image DescriptionThe value of the$image argument must be an image resource. The size of the image can be defined by the value received fromgetDimension() . -
getDimension(
$width ,$height ) — Returns an array containing the required size for the imageDescriptionReturns an array in which the first index is the image width and the second index is the image height.
The arguments are used to specify the starting point of the drawing. Should be 0 for both.
TheBCGDrawing class uses this method to create the image resource.Returnsarray(int, int) - [0] is the width, [1] is the height -
getScale()
—
Gets the scale of the barcode
DescriptionGets the scale of the barcode. The value is the number of the "smallest" unit in pixel.Returns
int - value in pixels -
setScale(
$scale ) — Sets the scale of the barcodeDescriptionThe barcode will be$x times bigger. Then a pixel will be$x by$x for its size. -
getForegroundColor()
—
Gets the color of the bars
DescriptionGets the color of the bars of the barcode.Returns
-
setForegroundColor(
$color ) — Sets the color of the bars -
getBackgroundColor()
—
Gets the color of the spaces
DescriptionGets the color of the spaces of the barcode.Returns
-
setBackgroundColor(
$color ) — Sets the color of the spaces -
setColor(
$foregroundColor ,$backgroundColor ) — Sets the color of the bars and spacesDescriptionAn easy and fast method to set the color of the bars and spaces. Check thesetForegroundColor() andsetBackgroundColor() . -
getOffsetX()
—
Gets the X offset
DescriptionGets the X offset of the barcode in pixels. The value isn't multiplied by the scale.Returns
int - value in pixels -
setOffsetX(
$value ) — Sets the X offsetDescriptionSpecifies the X offset of the barcode in pixels multiplied by the scale. The required size returned bygetDimension() will be modified accordingly. -
getOffsetY()
—
Gets the Y offset
DescriptionGets the Y offset of the barcode in pixels. The value isn't multiplied by the scale.Returns
int - value in pixels -
setOffsetY(
$value ) — Sets the Y offsetDescriptionSpecifies the Y offset of the barcode in pixels multiplied by the scale. The required size returned bygetDimension() will be modified accordingly. -
addLabel(
$label ) — Adds a label to the graphicDescriptionAdds aBCGLabel object to the drawing. -
removeLabel(
$label ) — Removes a label from the graphicDescriptionRemoves a specificBCGLabel object from the drawing. -
clearLabels()
—
Removes the labels from the graphic
DescriptionClears the
BCGLabel objects from the drawing.