From Wiki-UX.info

Wiki-UX / Jetdirect / How to use PCL and PJL codes to set text files print options
Jump to: navigation, search

How to use PCL and PJL codes to set text files print options

Contents

Abstract

This article explains how to use PCL and PJL codes to configure LaserJet printers and set special options like Paper Size, Font Pitch and Lines per Page. This paper don't cover the usability of the PostScript language to acomplish the same tasks.

LaserJet printers works very differenty to impact printers, were characters are printer using a fixed set of dots to produce standard fonts, width, height with as well as control of the paper displacement on a continuous paper feeder.

LaserJet printers works like a canvas, were the whole page is rendered to produce the desire results. Current desktop Operating Systems offers different APIs to directly render the pages. Nonetheless. the following options are very useful to provided look-a-like reports for legacy applications that created plain text outputs.

Introduction

To properly understand the usability of the PCL, PJL languages it's important to understand the impact printer characteristics and what is possible on LaserJet printers. Let's start with the standard Letter sheet (8.5' x 11').

->        8.5'
+0+----------------+0+
|0|                |0|
|0|                |0|
|0|                |0|
|0|                |0|
|0|                |0|
|0|                |0| <- 11' 
|0|                |0|
|0|                |0|
|0|                |0|
|0|                |0|
|0|                |0|
|0+----------------+0+

In a fixed font (pitch) environment, like a dot matrix printer, the available printer area can be define by a matrix of all the caracters that can be printed in the sheet on given Font Pitch and Lines per Inch.

For example, assuming a 10 CPI (characters per inch) Font Pich with a 6 LPI (lines per inch) displacement, the total capacity of the page will be:
( 8.5 * 10 ) ( 11 * 6 ) = 5610 characters.

->   85 columns
+0+----------------+0+
|0|xxxxxxxxxxxxxxxx|0|
|0|x               |0|
|0|x               |0|
|0|x               |0|
|0|x               |0|
|0|x               |0| <- 66 rows
|0|x               |0|
|0|x               |0|
|0|x               |0|
|0|x               |0|
|0|x               |0|
|0+----------------+0+

LaserJet print area in the other hand, is define by the mechanical capacities of the printer. Due to the way that paper sheets are feed and handle inside of a laser printer, there are Top, Down, Left and Right margins restrictions. In modern printers, the margins can be as small as 0.17 of an inch (4.23 mm).

+----------------+
|+--------------+|
||     top      ||
||              ||
||              ||
||              ||
||left     right||
||              ||
||              ||
||              ||
||     down     ||
|+--------------+|
+----------------+

These limitations impose restrictions for the usability of LaserJet printers to replace traditional impact printer reports commons of UNIX (HP-UX) or Mainframe environments (AS400), special due to the margin tolerances between the models of LaserJet printers.

To try to reduce the problem of having to deal with special settings for each available model, a convention to use 0.5' Top and Bottom margins and 0.25' left and right margins is widely adopted.

->   80 columns
+----------------+
|+--------------+|
|| xxxxxxxxxxxx ||
|| xxxxxxxxxxxx ||
|| xxxxxxxxxxxx ||
|| xxxxxxxxxxxx ||
|| xxxxxxxxxxxx || <- 60 rows
|| xxxxxxxxxxxx ||
|| xxxxxxxxxxxx ||
|| xxxxxxxxxxxx ||
|| xxxxxxxxxxxx ||
|+--------------+|
+----------------+

This convention allows a 80 COLS x 60 LINES print area using 10 CPI x 6 LPI. This capacity falls short for to transition from the iconic "green bar" forms that dominated the early computer age.

Standard "green bar" page sizes included portrait-format pages of 8½ × 11 inches, usually printed at 80 columns by 66 lines (at 6 lines per inch) or 88 lines (at 8 LPI), and landscape-format pages of 14 × 11 inches, usually printed at 132 columns by 66 or 88 lines. Also common were landscape-format pages of 14 × 8½ inches, allowing for 132 columns by 66 lines (at 8 LPI) on a more compact page.


Due to the great popularity of the "green bar" based reports, providing the capacity to render 66 lines per page was required. To support this this format, the space between the lines is slightly reduced using 6.6 LPI displacement. Since laser printer offer high quality printing with higher resolution, readability is not seriously affected. HP LaserJet printerd call this feature FORMLINES, that is value between 5 a 128.

Using PCL Language

The PCL language can be use to set different print operation options like the Page Size, Font Pitch and Lines per Inch values. The process consist of adding the required PCL specification options in the header of the document preceed by the text payload.

66p10cpi

echo "\033&l2a0o7.27C\c" > 66p10cpi
echo "\033(s0p10h3T\c" >> 66p10cpi

66p12cpi

echo "\033&l2a0o7.27C\c" > 66p12cpi
echo "\033(s0p12h3T\c" >> 66p12cpi

66p16.67cpi

echo "\033&l2a0o7.27C\c" > 66p1667cpi
echo "\033(s0p16.67h0T\c" >> 66p1667cpi

Using PJL Language

Using the PJL language, the FORMLINES to 66 lines pager page and the font pitch to 10 CPI, without using the printer control panel or any web-based administration tool. For example:

# echo "\033%-12345X@PJL DEFAULT FORMLINES = 66\r" > setforms66
# echo "\033%-12345X@PJL SET LPARM : PCL PITCH=10\r" >> setforms66
# echo "\033%-12345X\r >> setform66
# lp -d<print_queue> -o raw setforms66
# rm setforms66
# lp -d<print_queue> -o raw /etc/hosts

For example:

echo "\033%-12345X@PJL DEFAULT FORMLINES = 66\r" > setforms66
echo "\033%-12345X@PJL SET LPARM : PCL PITCH=10\r" >> setforms66
echo "\033%-12345X\r" >> setforms66
lp -dhppcl -o raw setforms66
rm setforms66
unix2dos /etc/hosts | lp -dhppcl -oraw
echo "\033%-12345X@PJL DEFAULT FORMLINES = 60\r" > setforms60
echo "\033%-12345X" >> setforms60
lp -dhppcl -o raw setforms60
unix2dos /etc/hosts | lp -dhppcl -o raw
echo "\033%-12345X@PJL SET LPARM : PCL FONTNUMBER=2\r" > setforms60 
echo "@PJL SET LPARM : PCL PITCH=16.67\r" >> setforms60
echo "\033%-12345X" >> setforms60
lp -dhppcl -o raw setforms60

Reference

Authors

This page was last modified on 19 July 2010, at 21:04. This page has been accessed 5,278 times.