Printing - a minority report
Declan Moriarty
declan.moriarty at ntlworld.ie
Wed Jan 8 03:23:28 MST 2003
Surely the last thing needed is another print hint.
Yes. but this one uses _no_ printing programs :-D. It if for dissented
losers with all of this printed paraphanelia in linux who have their
compilers in overdrive making porograms that don't work and are fed up
wrestling - like me!
Laugh at it, delete it or even make it available if you think
appropiate. But it works :-)
--
Regards,
Declan Moriarty
-------------- next part --------------
The Printing Minority Report
For those without Postscript printers who get pissed off big time with
printing programs in linux and only need basic functionality, one
dissented loser with all this printing crap (declan.moriarty
@ ntlworld .ie)took the following way out. We can print without a print
program. If you're mailing me flames, don't put spaces in the e-mail like
I did. Enough spam gets lost already.
1. Get ghostscript going. Get a display of that tiger up on screen, as
per Ghostscript hints, printing hints, etc, etc. I won't bore you.
Likewise get a word processor - Abiword is mine. A hint is there,
and it worked for me. If it doesn't work for you, argue with him, not
me. That's all you need.
If you haven't done this much yet, build abiword first. It has loads
of nice fonts which you can include in ghostscript by adding
'--with-fontpath=/usr/local/share/AbiSuite/fonts' to the gs
'./configure'. Otherwise see 8 below.
2. Type gs -h at a prompt and select your printer from the pageful of
drivers that it gives up. I have a BJC-4000 (bjc600 driver), but like a
true cheapskate, I use b/w cartridges, so bjcmono suits me. The bjc600
driver performs poorly giving colour to a b/w printer. You may then
want to fire up vim and edit the ppd slightly.
vim /usr/local/share/ghostscript-7.05/filter/bjcmono.ppd
or whatever yourghostscript /filter directory is. Don't muck it up,
just change defaults to another blindingly obvious option. If you
screw up completely, delete and you can do another 'make install'.
Test this driver by executing the following commands from a console.
gs -q --dBATCH -dNOPAUSE -dSAFER -sDEVICE=<your-printer-driver> \
-sOutputFile=/tmp/testit <some_file.ps> .
There are good postscript files in the ghostscript source ~/examples
directory. Give it a few seconds. Make sure your printer is on.
Follow this with
cat /tmp/testit > /dev/lp0
or whatever point in the /dev directory your printer resides in. Paper
& ink should flow relatively productively.Repeat until it does. If you
get a ghostscript crash, look for a wordlike 'invalidfileaccess' (file error)
as a hint to what went wrong. If you can see the file but not send it to
print,have you permission? If so, it's your '-sDEVICE=' option or a
syntax error.
3 I have following alias in /etc/profile or some config file like
that which bash reads.
alias lps='gs -q -dBATCH -dNOPAUSE -dSAFER -sDEVICE=bjcmono -r360 \
- sOutputFile=/var/spool/canon'
It is for postscript and pdf files. The usage is 'lps <filename.ps or
filename.pdf> . It hangs you there for a few seconds, and when it
returns, /var/spool/canon has the file in canon printer language.
Less /ver/spool/canon
should show you a binary file full of gibberish. Perfect!
The details after ' -sOutputFile=' can be any filename.
-sOutputFile=/home/your_dir/rude_word would work just as well. Those
options mean:
-q - tells gs not to display anything & saves it looking for X.
-dBATCH - tells gs to quit after processing your files - always a good
idea.
-dNOPAUSE - tells gs not to play it's usual dance of pressing return to
show a page.
-dSAFER - tells gs from deleting your file or doing other stupid
things like that.
-sDEVICE= your printer driver. Be exact and case sensitive. GS is
stupid.Use the spelling on the info at 'gs -h'.
-r360 - tells the resolution to use. You may not need this. You hacked
the ppd, remember? Yours may be different. It's the dpi.
-sOutputFile= write to this output file (congratulations for guessing!)
Brew your own cocktail of these options. Refine & remember it, or write
it down.
4. I found I needed a few lines on top of the page with cat as my
printing tool. I got them the lazy way vim /tmp/header. It says "new
file"; hit insert, return 3 times, escape, and :wq. You should have a
/tmp/header file with three blank lines ;-)
5. Another alias in etc/profile to get it out to the printer
alias print='cat /tmp/header /var/spool/canon >/dev/lp0'
This sends my file /var/spool/canon to the printer after /tmp/header.
Alter the space with more or less return characters in the header
file. The filename (I show /var/spool/canon) has to be the same in both
aliases. Log out and in again, to get the profile read. Type
alias
at a prompt to check they are being read.
6. Usage is as follows: To print from any applications, (e.g. abiword)
print to file and you get a postscript file. Save it. Note in passing
that nearly any program can do better <some-format-to-postscript>
conversions than the 'print' programs that sell themselves as doing it
:-/. Images can also be sorted in this fashion. Print to file. Then
at any console, type
lps <filename.ps or filename.pdf> && print
and you WILL get output. No if, but, or maybe. If it's crap, then you
have the wrong print driver. Punish yourself, and go back to step 2.
For single page ascii, where you don't want the bother of doing the
load/save, you can use either
cp <filename> /var/spool/canon && print
or
cat /tmp/header your_text_file > /dev/lp0
which will send yourfilename after your blank header file. This can
probably be reduced to a single command by someone with the least bit
of scripting intelligence, but I haven't got that. When you do it,
E-mail me.
A hidden gotcha is that multipage ascii docs will mess up by
missing headers and often a few lines between pages. Load them in
abiword, or any wp that will print to a .ps file, and that will sort
them neatly into pages. Go around & set defaults to your paper size.
7. Some tidying up :-D. Use 'make uninstall' targets on your
"printing" programs if they exist. Then, if cups
has you seriously browned off (like it has me), for example
rm -rf /etc/cups
rm -rf /usr/share/cups
rm -rf /var/spool/cups
rm -rf /usr/src/cups*
rm -rf /usr/share/docs/cups
All those unnecessary files in the /usr/bin & /usr/local/bin
directories (broken loser program to do what I'm doing with two
aliases): gsbj; gsdj gsdj500; gslp; lp; lpr; lpd; lpadmin; lpstat, and
probably lp*. You get the idea. Have fun, and don't come crying to me
if you mess up by overdoing it. You can always reinstall, and
reconfigure. It's your system. You're the boss. I suggest you choose a
directory for print files - NOT
/home/you/followed/by/a/long/directory/name but /tmp. You can then add a
rm -f /tmp/*.ps
to some startup or shutdown file to clean up printed matter on a
reboot.. If you're fussy & security conscious,
make that something fussy & secure like
rm -i /tmp/*.ps and play God with these files.
8. An added refinement is to review the gs -h info. At the end it
mentions a number of places where ghostscript checks for fonts.
Let one of them symlink to wherever abiword hid it's selection
(/usr/local/share/AbiSuite/fonts on my system), so ghostscript can
tap in, in the vain hope that you might get a WYSIWYG word processor.
It might even work.
Some day, someone may write a reliable printing program in linux, and
then this will be unnecessary.
Declan Moriarty.
More information about the blfs-support
mailing list