: I'm using a panasonic kx-p6500 laserjet printer and when I try to print
: a text file it prints it out as a stair case. I've tried to use a hp
: laserjet 4 and hp laserjet 2p and still get the stair case effect. I
: need to put a carriage return code after each line but I don't know the code
: to do that. Can someone please help me, thanks
Some printers have a special control code that you can send to put them
in a mode where a newline is a linefeed (instead of a cr lf pair).
But I fire up perl to handle it.
Real basically, in perl:
-----
#!/usr/bin/perl
while(<STDIN>){
chop;
print "$_\r\n";
Quote:}
-----
My filter needs a bit of explaining...
We read the first line of input, to determine if it's postscript or not.
I'm using one of those printers that uses a "color cartridge", but usually
it's black and white. Ghostscript has different arguments for color. So we
use a flag file to tell ghostscript we're in "color".
The variable $gs is the actual gs command used for color or b&w.
I like to have an audio file played to tell me when a print job has
started and ended. (different for color)
If it's NOT postscript (as is usually the case) I have perl remove the
linefeed, add a carriage return and a line feed.
When the print job is over, I have it send a form feed (and play another
sound)
So here's my messy (but fairly simple) print filter, you'll want to change
the line that says system("/usr/local/bin/lps $sound"); to a command
that plays a sound file, (or remove it completely), change the $gs
to whatever you use. (maybe you never have to deal with color cartridges,
I dunno)
In /etc/printcap set your if= to whatever_you_save_this_filter_as make
sure to chmod +x it, (and look it over _real_ good, as I believe it runs
as user root).
Good luck! Let me know if you use it, or have any questions, ok?
Jamie
----
#!/usr/bin/perl
$Line=<STDIN>;
$|=1;
if( -f "/var/spool/lpd/color" ){
$gs='/usr/bin/gs -dSAFER -q -dBitsPerPixel=16 -sDEVICE=cdeskjet -sOutputFile=- -sShingling-1 -';
$sound_begin="print_color";
Quote:}else{
$gs='/usr/bin/gs -dSAFER -sOutputFile=- -q -sDEVICE=deskjet /var/spool/lpd/gamma.ps -';
$sound_begin="print_bw";
Quote:}
if($Line=~ /^\%\!/){ # look at first line, if %!, it's postscript
open(GS,"| $gs");
&play($sound_begin);
print GS $Line;
while(<STDIN>){
print GS $_;
}
close(GS);
&play("print_end");
Quote:}else{ # File is assumed to be plaintext.
&play("print_start");
chop $Line; # Add Linefeeds
print "$Line\r\n";
while(<STDIN>){
chop;
print "$_\r\n";
}
print "\014"; # formfeed.
&play("print_end");
Quote:}
sub play(){
my($sound)=shift;
system("/usr/local/bin/lps $sound");
Quote:}