POSTNET barcodes

Informations

Author: Shailesh Humbad
License: Freeware

Description

This is an extension for printing U.S. Postal Service POSTNET bar codes in PDF. It supports both 5 and 9 digit zip codes and includes a utility function for parsing zip codes from an address line. The bar code is drawn directly in PDF without using an image or special font.

POSTNETBarCode(float x, float y, string zipcode)

x: abscissa of barcode
y: ordinate of barcode
zipcode: zip code to draw

Zipcode must be a string containing a zip code of the form DDDDD or DDDDD-DDDD. This function will trigger a PHP error if the zip code is invalid, so if the string's validity is in question, use ParseZipCode first. The parameters $x and $y specify the lower left corner of the bar code in user units. This function changes the line width in the FPDF context.

string ParseZipCode(string stringToParse)

The parsed zip code returned will be the first string matching DDDDD or DDDDD-DDDD, in that order, where D is a digit from 0 through 9. The search begins at the end of $stringToParse.
If a valid zip code cannot be found, it returns an empty string. Otherwise, it returns the parsed zip code (including the hyphen if it's a 9-digit zip).

A complete envelope generating example with source code is available at:

http://www.somacon.com/fpdf/dynamic_envelope_in_pdf.php

POSTNET BAR CODES

The specifications for POSTNET Bar Codes can be found in U.S. Postal Service Publication 25, Designing Letter and Reply Mail, available via:

http://www.usps.com/businessmail101/resources/

See Chapter 2 for bar code placement specifications, and Chapter 4 for bar code reading and writing specifications.
You can print bar codes on papers that will be inserted into envelopes with windows, or directly on envelopes. For envelopes with windows, in general, the bar code should be printed a minimum of 1/25" above the first line of the address, and below the top edge of the envelope window. The left and right clearance for the address should be a minimum of 1/8", and the bottom clearance should be 1/25" minimum. The address must satisfy the minimum clearances regardless of where the mailpiece shifts to within the envelope. Note that 1/4" of clearance is preferred.
Refer to the Guidelines for complete details.