ftp.nice.ch/pub/next/tools/printer/lj2ps.README

This is the README for lj2ps.s.tar.gz [Download] [Browse] [Up]

				lj2ps
	       A LaserJet PCL to PostScript Translator

			Version 1.3 (release)

			  Christopher Lishka
		Wisconsin State Laboratory of Hygiene
		      Data Processing Department
				
				Modifications for the NeXT by:
				
				Dave Nanian, UnderWare, Inc.

			    30 May 1991


			      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
		6. Notes on the NeXT release


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.3.  This revision contains changes
implemented by Dave Nanian to make lj2ps work on the NeXT.

The previous revision (1.2) simply fixed
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 PostScript was a much better language
than LaserJet PCL, and this program provided me with a way to prove
it.  Even though this revision of lj2ps is limited, I am convinced
that one could fully emulate a LaserJet with a filter (like lj2ps) and
a PostScript printer.  In fact, I bet it could be done with PostScript
alone, although it would be incredibly slow.  However, one cannot
emulate a PostScript printer using PCL.  Most (if not all) PostScript
to LaserJet emulators are programs (in software or hardware) which
send bitmaps to a LaserJet; PCL is pretty-much bypassed.  This says a
lot about the two languages.

I have spent several years writing programs which use PCL on
LaserJets.  I have just finished a translator that parses and emulates
PCL.  With all this experience and time spent using PCL, all I can say
is that it leaves a really bad taste in my mouth.  It is not user
friendly, not consistent, and not robust.  Its syntax is lousy, its
commands are impossible to remember, and it inner workings are very
hard to figure out (believe me, I spent too much time doing this!).
Whoever is responsible for developing PCL ought to be taught a lesson,
and probably sent back to college to study language design.  I have
much respect for many Hewlett Packard products (like the hp28s and
hp48sx calculators).  However, the LaserJet's language is one of HP's
worst creations.  Suffice it to say that the HP LaserJet is the IBM PC
of the laser-printer world.


5. Contacting Me

If you have any additions, fixes, or problems; need to know more about
the secret workings of the code; have suggestions for improving lj2ps;
or simply want to say hello, you can contact me at:

	Internet:	lishka@uwslh.slh.wisc.edu
	UUCP:		...!uunet!uwvax!uwslh!lishka

	Work phone:	(608) 262-4485 (Tues.-Sat., 9am-5pm)

	Address:	Christopher Lishka
			Data Processing Dept.
			Wisconsin State Laboratory of Hygiene
			465 Henry Mall
			Madison, WI     53715

My only real request is that you send me any bug fixes, enhancements,
or other modifications that you have made.  Please don't send source
trees without contacting me first.  The best thing to send is a
context-diff (e.g. for "patch") from some released version.

If you like this program enough to donate some money, then I ask that
you give it to charity (for example: an environmental, peace, or
homeless organization).  It will make both of us feel good, and it is
even tax-deductible.

6. Notes on the NeXT specific changes

As Christopher didn't have a NeXT to play with, and doesn't seem to be
available at his old EMAIL address any more, I guess I take responsibility
for this program on the NeXT.  I ported the program to make it easy to print
from PCL programs under SoftPC, and it seems to work quite well for this
purpose.

I've made some changes and fixed some problems, specifically with Landscape
mode.  Changes were made to support manual feed on the NeXT, allow page
reversing to be suppresed, and include the proper include files.  The
measurements were also tailored to the capabilities of the NeXT printer.

Compiling this program on a non-NeXT should work just fine:  the bugs that
I fixed should be fixed in all versions, and if compiled on the NeXT, I've
put #if defined (NeXT) ...#endif pairs around the NeXT specific code.

Problems:  Note that some problems remain.  I've noticed that the movement
calls aren't entirely accurate, though this seems to be a problem with all
versions.  Also, on the NeXT, there doesn't seem to be any way to turn
manual feed on and off on a per-page basis.  Because of this, if manual
feed is turned on at any time during the translation of the document, the
resulting postscript file will all be manual feed.  Finally, page reversing
is suppressed by removing the %%Page comments from the output, which also
makes the documents non-conforming.  I expect to fix all of these problems
when NeXT's PostScript conforms to the new Adobe Reference manual.

Hope this works for you:  enjoy!  You can reach me at dnanian@uw.com, or
uunet!uw!dnanian.

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.