PCL Programming

I am having trouble with PCL printer programming and hope this isn't too specialized a topic.  We have - invoices, statements, purchase orders etc etc all continuous stationery for a multi company business and it is all getting out of control so -

I have been trying to get our lasetjet 2100 printers (we have about 10) to print "pre-printed" stationery with an "overlay macro" in PCL5 but cannot get the following data to print less the one and a half inches down the landscape form.  I can print the invoice on the laser perfectly and it starts printing right up the top of the A4 sheet as expected - beautifull!  I send an "overlay macro" and the invoices data prints about an inch and a half down the form.  I have tried to position the cursor in PCL before the macro, after the macro and both before AND after the macro without success.  I have tried the positioning in the HP/GL2 segment and using the exit Ec%1A and all sorts of combinations but cannot cause the invoice data to print any higher than 1.6 inches down the page.  I have included the "macro" below.  That little boxes are "escape's".

E            reset
&l1O         landscape
9            reset margins
&l2E         ditto
&f1Y         define macro 1
&f0X         start macro definition
%0B          enter HP/GL2
IN;           inialize
SP1;          select pen

the following coding draws boxes and lines


PA0,7300;      position cursor
%1A           exit HP/GL2 with cursor  positioning
&f1X          stop macro definition
&f4X          enable overlay
&f10X         make macro permanent

If I send the invoice without the overlay it prints as expected.  If I send the above overlay first it prints too low.

I tried just print the word "INSERT".  Without the overlay it prints right on top.  With the overlay it prints 1.6 inches down the page.

I've tried ALL sorts of combinations, this is the last I tried.


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I don't have access to a LaserJet 2100,
so I tested on a LaserJet 4, using
"letter" sized paper.  For the basic
operations used here, they should be

Taking the program you included in
the problem statement, line for line,
WITHOUT the comments ("reset",
"landscape", etc.), and with the
line "INSERT" as the last line, I
replicated your print behavior, with
about 1.68" from the top of the page
to the top of the word "INSERT".

I added the following 5 lines after
the "INSERT" line, to test cursor
positioning (where "<esc>" represents
the ASCII escape character):
---------- next line is first line added
<esc>&a00r00CX row  0 column  0
X row  1 column  0<esc>&a01r20CX row  1 column 20
X row  2 column  0<esc>&a02r40CX row  2 column 40
X row  3 column  0<esc>&a03r60CX row  3 column 60
<esc>&a20r01CX row 20 column  1
---------- previous line is last line added
This did result in printing where I
expected it, with about .35" from
the top of the page to the top of the
"X" in the "row  0" line.

You should be able to manipulate the
cursor position as shown before
sending your other data, or as part
of each line or field you send.

Please note that contrary to your
comment, you did not "reset" the
top margin with "<esc>&l2E", you set
it to line 2.  "Absolute" cursor
positioning after that is based on
top margin you have set.  If you
set the top margin to 0 and positioned
the cursor there, you could be in an unprintable area for your model of

If your use of HP/GL2 is just for
drawing boxes like those in the
example, that can also be done by
using PCL commands to print
rectangles - very narrow rectangles,
to draw rules.  Some older LaserJets
may not handle the program as written
- the "LaserJet III Technical Reference
Manual" mentions that "HP-GL/2 mode is
not supported in a macro".

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
louwinAuthor Commented:
Hello Spangler,

As you can imagine I continued to experiment and eventually got things to work.  As with the rest of the macro, pixel rather than column positioning, I used <esc>&a0h0V to position the cursor.

The real problem was the fact that each line in the original programming sequence ended with a line feed.  The printer was interpreting all the commands and after each was linefeeding.  I concatenated all the commands and Viola! everything started to work.

My printer (Laserjet 2100) does support HP/GL2 in macros but very unreliably.  Sometimes it would print the lines, sometimes (more often) not, so I had replaced the HP/GL2 with PCL alternatives.  I proved this by issueing the original commands as a normal print file and the lines ALWAYS printed correctly.  I then made it a macro only to have the lines NOT print.  I spent hours trying to get the HP/GL2 working before changing to PCL as a last measure.  I don't know why the HP/GL2 didn't work but that is now moot as PCL works fine.

I was having a lot of trouble getting a logo on the top left hand side of the page but am now following advice from my brother and doing ALL the overlaying etc on MS Word.  The problem with this method is that, in my previous experiments, the printer driver outputs PJL and I don't know how this will interface with the following data.

I have added this LONG comment to the solution to help any other poor @#$%^& who tries to do soemprinter overlay programming.


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Printers and Scanners

From novice to tech pro — start learning today.