Operating System - HP-UX
1822142 Members
3963 Online
109640 Solutions
New Discussion юеВ

Escape sequence to print proper font from unix

 
SOLVED
Go to solution
Clint Gibler
Frequent Advisor

Escape sequence to print proper font from unix

I have an HP color laserjet printer 2820 and I have the correct model script installed but a program printing through unix is not printing in line mode the printer keeps defaulting to courier or something, I have changed the settings on the printer but that didn't work and the hp support people are telling me I need to put the escape sequence in unix. I have the sequence for a line printer
(10U(s0p16.67h8.5v0s0b0T
how do I do use this and get it to always print in line printer mode from unix?
7 REPLIES 7
RAC_1
Honored Contributor
Solution

Re: Escape sequence to print proper font from unix

Look at the interface file. Yu should have something in there. /etc/lp/inetface/"queue_name"

Also, how you have configured the printer?? Is it network, remote or Jetadmin.
There is no substitute to HARDWORK
Clint Gibler
Frequent Advisor

Re: Escape sequence to print proper font from unix

I used hppi to configure it and I have looked at the file for the queue name of the printer but I don't know where to put the escape sequence.
Clint Gibler
Frequent Advisor

Re: Escape sequence to print proper font from unix

Also I do have another unix machine that uses the old jetadmin and couldn't configure it properly so it is set as remote printer on that machine.
Bill Hassell
Honored Contributor

Re: Escape sequence to print proper font from unix

Unlike PCs where there is a printer meta-language and a driver, HP-UX is a text-based OS like most other flavors of Unix. Now when you say "line mode", do you mean landscape (or sideways) versus portrait, or do you mean compressed printing with a smaller font?

Getting you the right answer will require defining how the printer is connected. Does this printer have a JetDirect interface card? If so, did you use hppi to connect it to the lp spooler? If so, then to print landscape and compressed mode, simply use these options:

lp -dmyprinter -olandscape -oc /etc/profile

To get a page of available options, you can add the option: -ooptions as in:

lp -dmyprinter -olandscape -oc -ooptions /etc/profile

Now the old jetadmin software is obsolete (has been for more than 5 years) so if your older is running 10.10 or 10.20, upgrade to hppi and delete the remote printer and add it back with hppi.

If your older machine is pre-10.00, then you're stuck with jetadmin. Just add the printer normally and override the printer script with a generic printer model such as PCL5. You'll have lots of options available which can be listed with the -ooptions option.

For hppi, there are man pages for the printer scripts with more details than the options page. Try man net_ljx000


Bill Hassell, sysadmin
Clint Gibler
Frequent Advisor

Re: Escape sequence to print proper font from unix

What I mean by line mode is the printer has a list of internal fonts that are built into it. An HP typically come set to zero for its built in default font. This is almost always courier. I have a payroll program that prints some reports through oracle. When it does this the print jobs defualt to the internal font of courier and then they don't fit all the text on to the page. So what I do is change it, I print off the font list and go down to the list until I find the fonts at the end called line printer that are much smaller, then I change it in this case to font 11 and all the print jobs sent through unix work. This doesn't seem to effet any print jobs sent any other way as they override with there own fonts. This particular printer this is not working for me and they are still printing in a big font. So the HP tech support people told me I had to use escape codes which I know very little about and I am finding it hard to find documentation to help me. The unix machine I am doing this all on is running hppi, so my problem isn't printing unix things its the unix program that sends the jobs that I am having trouble with and I was trying to find a way to make it printer the line printer font everytime a print job is sent, which I don't even know if that is possible.
Clint Gibler
Frequent Advisor

Re: Escape sequence to print proper font from unix

Sorry I don't proofread very well on the fourth line that should be unix not oracle.
Bill Hassell
Honored Contributor

Re: Escape sequence to print proper font from unix

Well, the lp command has everything you need to control the font. However, it sounds like your payroll program does not use the lp command or has no way to specify the options. This is a painful reality of some programs leftover from the days of line printers and greenbarr paper. But just to show you the features of the printer script, try the lp commands mentioned before and see how the font size can be varied. Note that the Courier font can be made any size and any spacing you'd like to use. Options like -o12, -oc, -ohsi5.5, -ovsi6.4 can all vary the font as all fonts in your printer are scalable.

Now it is critical to understand the difference between proportional and fixed fonts. In all those font choices from the printer's selftest, more than 75% of these fonts are proportional and that means that you can put 500 i's on a single line but only 100 W's because W is much wider than i in a proportional font. So choosing font number 11 may produce a mess for your report because the data doesn't line up. So before you choose font 11 from the font test page, test it with a simple script. We could use vi to create the test file but putting escape sequences into a text file is somewhat advanced. So put this into a file:

#!/usr/bin/sh
export PATH=/usr/bin
ESC="\033"
FONT11="${ESC}(10U${ESC}(s0p16.67h8.5v0s0b0T"
echo "$FONT11\c"
echo "1234567890"
echo "iiiiiiiiii"
echo "mmmmmmmmmm"

To test this script, just send it to your printer with the command:

sh ./myscript | lp -dlj2820

Now I tried this on a couple of HP printers and it indeed produces a small, fixed spacing font (which is what you want) so this escape sequence should work for you.

Now the question is how to insert this string in front of your reports. I am going to assume that your program is of no use in customizing the reports (ie, being able to specify setup strings) so you'll need to create another print queue using the 'dumb' model script. I recommend the dumb script since you don't want all the complexity of a full net_ljx000 script. And yes, you can create multiple print queues for the same printer. In this way, the standard queue gives you all the net_ljx000 options while the custom queue always prints with the specified font and no other options.

So create another print queue with hppi and specify the dumb script. For hppi, select any printer number from the list (or accept the one automatically chosen). We'll change it later. Select the first option to rename the ridiclous default print queue name, then save the changes and select 0 (zero) to create the queue. Verify that it works with the lp command.

Now replace the current model script with the dumb script by copying it from the model directory. Assuming your printer was called lpsmall:

cp /usr/lib/lp/model/dumb /etc/lp/interface/model.orig/lpsmall

Then cd to the model.orig directory and edit the lpsmall script. First, search for the word banner. You should see banner="yes", so change this to banner=""

Now search for the word cat and you will see: cat "$file" 2>&1. Insert this line ABOVE the cat line:

echo "\033(10U\033(s0p16.67h8.5v0s0b0T\c"

Now save this file and test it by printing something like this:

lp -dlpsmall /etc/profile

That should select font 11 and print quite small. And to anticipate your next question, the spacing between lines (or lines per page) can be controlled too. Many report generators are stuck in prehistoric line printer mode and count lines to control spacing to the next page. So if your report does not position the top of the next page correctly (it 'creeps' up or down with each additional page, you must adjust the lines per inch. Add two more lines after the echo line above like this:

VSI=4.0
echo "\033&l${VSI}C\c

Now VSI=4.0 selects 12 lines per inch. The units of measure for VSI are 1/48th of an inch. If the report is too long and spills over onto the next page, make VSI smaller, perhaps VSI=3.85. If the length of the report is too short, make VSI larger as in VSI=4.37. In all cases, you can edit the printer script, save it and then immediately print to test the results.

Here is what your new script will have at the cat line:



for file in $files
do

echo "\033(10U\033(s0p16.67h8.5v0s0b0T\c"
VSI=4.0
echo "\033&l${VSI}C\c
cat "$file" 2>&1

done


Bill Hassell, sysadmin