				lj2ps
	       A LaserJet PCL to PostScript Translator

			Version 1.2 (release)

			  Christopher Lishka
		Wisconsin State Laboratory of Hygiene
		      Data Processing Department

			    July 7th, 1990


			      Contents:

		1. Introduction
		2. This Distribution, and How To Create lj2ps
		3. Implementation Notes
		4. Miscellaneous (Things I Have To Get Off My Chest)
		5. Contacting Me


1. Introduction

The lj2ps program translates HP LaserJet PCL ("Page Control Language")
to PostScript.  Currently it converts a subset of the LaserJet Series
II language (PCL 4) to device-independent PostScript.

lj2ps was originally written to allow my organization to "upgrade" our
LaserJets to LaserWriters, yet still have a way to print PCL files.
Due to a lack of time, not all of PCL is emulated (this is discussed
below).  I am releasing this program to the "real world" at the
suggestion of by boss and coworkers, and with the hope that others
will also find this program useful and may even extend its
capabilities.

lj2ps is currently at revision 1.2.  This revision simply fixes
problems in the revision 1.1 distribution that was sent out on June
30th, 1990.  Specifically, the shar which I was using (which I thought
was *supposed* to automatically uuencode files which contained
non-printing ASCII characters) failed to uuencode anything (I guess it
only uuencodes binary files, which is somewhat useless in this case).
Therefore, all of the escape characters were eaten in the Metrics and
Tests directories.  *All* files in the these directories are now
properly uuencoded.  Also, I have a habit of using long filenames,
which 4.3 BSD UNIX is perfectly happy with, but which System V UNIX
and MS-DOS choke on.  Therefore, I have fixed all filenames so that
they are no longer than eight characters, with a "dot-extension" of no
more than three characters.  This should make most people happy.


2. This Distribution, and How To Create lj2ps

Included in this distribution are all of the source files for lj2ps,
documentation, a test suite, and a metrics suite.

All source files are included in the top level directory, along with
the Makefile and README file.  To create lj2ps, simply type "make".
To clean the directory, type "make clean".  Pretty simple, huh? ;-)
There are probably other options in the Makefile, but since I
regularly use "cake" (instead of make), and since I generated it with
mkmf (automatic Makefile creator), I am not sure what they are.  Feel
free to edit it.  Those who are interested in the Cakefile, please
contact me.

The Tests directory contains many tests used to check the
compatibility of lj2ps with real LaserJets.  Similarly, the Metrics
directory is used to tune lj2ps to produce output which looks like
LaserJet output.  These are discussed in more detail in the
implementation section below.  Both directories have been packaged
with all files uuencoded, because there was a major problem in the 1.1
distribution with the escape characters getting eaten by mailers.  To
unpack the files, "cd" into each directory and run the sh-script
"uu.unpack".  This will automatically uudecode each file and remove
the uuencoded files.

The documentation directory has several files in it.  Here are
explanations of them:

BugFile		Known bugs that affect lj2ps are detailed here.  Each
		entry identifies the date detected, revision affected,
		and the person logging the bug (usually me!).  The
		LogFile describes which bugs have been fixed.

Copying		This is the standard Free Software Foundation
		copyleft.  lj2ps is distributed according to these
		restrictions.  Please look through it so that you are
		familiar with the conditions of use for lj2ps.  The
		only other thing that I ask is that you send me
		changes (with descriptions) if you make them, so that
		I can benefit from your work.

LogFile		This file contains descriptions of each revision of
		lj2ps.  All changes including bug fixes, added
		features, and removals are detailed here.

commands.doc	As detailed below, I did not have time to emulate all
		PCL commands.  This list shows which ones are (and
		are not) supported.

comopts.doc	Options are available at compile-time to conditionally
		include or exclude features when the program is
		created.  This file describes the options currently
		available.

limits.doc	Any program worth its salt has certain limitations.
		lj2ps is no exception.  This file lists some that I
		know about.  Feel free to fix any (or all) of them.

lj2ps.l		The man page for lj2ps, to be installed in
		/usr/man/manl.  Use the command "nroff -man lj2ps.l"
		to create the documentation file.

measures.doc	One of the worst aspects of LaserJets is the many
		different measurements used by different commands,
		This file lists all measurements that I know of.

pscan.idr	A diagram of the parameter scanner.  This file was
		produced with the drawing program "idraw," and can be
		printed on any PostScript printer.

scanner.doc	There are two distinct (yet related) scanners used in
		lj2ps.  Scanner.doc describes the conceptual design I
		used in creating them, which is derived from standard
		scanner and finite state automata theory taught in
		college (where do you think I learned it from? ;-).

suggest.doc	This file lists aspects of lj2ps that need work.  It
		may also provide some insight as to how lj2ps was
		designed.  If you have some free time, and need some
		suggestions on how to improve the program, then look
		here. 

tscan.idr	A diagram of the text scanner.  This file was produced
		with the drawing program "idraw," and can be printed
		on any PostScript printer.


3. Implementation Notes

The program is written completely in K&R C (although not ANSI), and
the C code should compile on nearly every standard machine out there.
To my knowledge, I have not used any "strange" C operators or
combinations, so this program should work on anything from a PC to a
super-computer.

I built the program with the idea of emulating full LJII PCL, so all
of the actual command syntax is parsed.  However, I have only
implemented the commands which I needed.  Left out are graphics,
macros, and soft font commands (among others).  It should not be that
hard to add features to this program, and I have included variables
(some yet unused) for most (if not all) aspects of LaserJet operation.
Feel free to work on extending this program to emulate the unfinished
PCL commands, as well as fixing some of the inconsistencies that will
likely pop up.  All I ask is that you send me any changes that you
make, so I can add the same features to my own version (my address is
listed at the end of this file).

I have designed lj2ps with efficiency in mind.  To this end, I
hand-coded the scanner in C instead of generating it with Lex.  I have
also spent some time profiling the execution.  Although one major
bottleneck has been fixed, most of the program actually runs at a
reasonable rate.  As would be expected, much of the execution time is
spent in the scanner and _doprnt.  The scanner could likely be sped up
some more (a colleague suggests "caching" several variables in
registers), but I have left this for the future.

I have also designed the program with accuracy in mind.  Included in
this distribution are two suites of files: one for testing, the other
for accurate reproduction.  The test suite is an attempt at providing
test files which will exercise critical and nit-picky features of
LaserJet Series II printers.  It is by no means complete.  I have only
included tests for features that are needed at our organization, and I
have likely even left out some of these.  I encourage you to add more
files to the test suite; if several people contribute, a nice
collection could be created.  The metrics suite provides print samples
which highlight different measurements.  For instance, you could test
inter-line spacing by printing the appropriate metrics file on a
LaserJet and a PostScript printer, and then tweak lj2ps to match the
LaserJet's output.  This suite is also not complete, so feel free to
add more files.


4. Miscellaneous (Things I Have To Get Off My Chest)

It is unlikely that I will have any time at work to extend this
program.  I will only support it locally for our users at my
organization.  Although it would be nice to work on this during my
free time (i.e. after work), I have so many other program (and
non-program) ideas that I likely won't do much more with lj2ps.
Therefore it is up to you to build in the missing functionality that
you want and need.

Even though the major reason I wrote this was because our organization
needed it, a significant driving-force for me was a "proof of
concept."  I always thought that PostS