How to make a PDF417 barcode fit in a given width, using PGL syntax, on Printronix's printers P7000, T5r, T4M and L7032?



PDF417 barcode can be programmed to fit within a given space. The Wn parameter, which should set a maximum width, doesn’t work for some values of Wn. In these cases, the printing parameters used may result in PGL off-page errors.


The solution is to calculate the X-dimension that is required to produce a barcode with the desired maximum width. If an X-dimension of this value or smaller is used, the Wn parameter can be used to set the barcode maximum width. All printers have a minimum possible width Wn, based on the smallest Xdimension possible for the printer.

The PDF417 barcode must be at least 85 times as wide as the X-dimension. The Wn parameter is intended to force the barcode to be smaller than ‘n’ tenths of an inch. If a maximum width parameter Wn is smaller than 85 times the X-dimension parameter (or the default value of X-dimension if no parameter is used), then Wn is ignored and the barcode is printed at the default aspect ratio.

PDF417 can be printed on impact, laser and thermal Printronix printers. The PGL syntax is:
(D)data field(D)

The barcode is rectangular, made up of rows and columns. All the columns have the same width. Each row is the height of the “Y” parameter, and each column is 17 times the width of the “X” parameter. Note that Xn measures increments of 1/60″ and Yn measures increments of 1/72″, whereas XDn and YDn measure increments of printhead resolution which depends on the printer being used. The width of the “Xn” or “XDn” parameter is also known as the X-dimension. The X parameter and Y parameter are each optional. The default values are X1 and Y2, so the default X-dimension is 16.7 mils (1/60”).

The horizontal and vertical extents of the barcode can be limited in one of the following five ways. Only one of the five parameters is allowed in a given barcode definition. If none of the five are used, the barcode is printed with an aspect ratio (number of rows to number of data columns) of 2:1.

Hn; Height in 1/10” increments
Wn; Width in inches in 1/10” increments
ASPECT;h:w; Aspect ratio, height:width (NOTE: defaults to 2:1 if none of these are used)
Rn; Number of rows
Number of data columns (NOTE: each row contains 4 columns of overhead also, so C1 prints 5 total columns)

The barcode may be defined to have a maximum width in inches using the Wn parameter, where the width is n times 0.10”. However, there is always a minimum width as well. Every row contains four columns of overhead plus at least one column of data, and each column is exactly 17 times as wide as Xn or XDn. So the maximum width defined in Wn must be equal to or larger than the minimum length needed for data, Wn >= (5 columns)*(17 X-dimensions per column)*(Xn inches per X-dimension).

When the X-dimension is expressed in printer dots and (dpi) is the dot per inch resolution of the printer, Wn >= (5 columns *17 X-dimensions per column)*(XDn dots per X-dimension)/(dpi).

The default X-dimension parameter is “X1”, where the X-dimension is 1/60” or 0.017”. The minimum Wn for an X-dimension of 0.017” would be:
Wn = 5 * 17 * 0.017″ = 1.45″ therefore n=15 rounded up (15 tenths of an inch wide). This means an impact printer with a 16.7 mil hammer tip cannot produce a PDF417 barcode less than 1.45” wide.

On a 300 dpi printer, the X-dimension that would result in a maximum 1″ wide barcode is calculated as follows:
W10 = 1.0″ max width >= 5*17*(XDn dots/300 dpi) therefore n <= 300/(5*17) or n <= 3 since n is a whole number of dots. Use XD3;W10 in the barcode definition on a 300 dpi printer for an X-dimension of 10 mils and an overall width of under 1″.

If a barcode is printed using a Wn width parameter that does not allow enough room to include at least one data column at the given X-dimension, the Wn is ignored because the output is not possible. In this case, the barcode is printed at the default aspect ratio of two rows to every data column. This does not generate a PGL barcode error, and if the barcode fits on the page it will print. The width of the barcode depends on the data.

The printed barcode may be quite a bit wider than the Wn parameter would indicate, and could even extend off the form, generating a PGL off-page error. The solution is to calculate the maximum X-dimension that generates the desired width, then see if this X-dimension is allowed by design spec or is possible for the printer. It may be necessary to include the proper Xn or XDn parameter along with the Wn parameter to insure that the barcode will print as desired.