Date: Wed, 16 Mar 94 15:17:31 MST
From: morrow@cns.ucalgary.ca (Bill Morrow)
Subject: SUMMARY: faxing Wordperfect files directly
last week I asked about how to get sendfax to handle Wordperfect
format files directly, so that users would not have to convert their
WP files to text or Postcript by hand. The following is what I came up with.
I've attached the "source" below, it's fairly simple and short.
Note that this requires Unix Wordperfect, we have version 5.0.
Thanks to les@fb.com (Les Mikesell) for hints, and the wptops script.
First add this rule to your typerules:
---------------------- cut here ----------------------------------
0 byte 0xff error WordPerfect document
>1 string WPC ps /usr/local/bin/wpr %i >%o
---------------------- cut here ----------------------------------
the wpr script converts WP format to Postscript by running
Wordperfect's wprint, which WP cleverly did not make a filter.
---------------------- cut here ----------------------------------
#!/bin/sh
# wpr - output Postscript from a WP file
infile=/tmp/WP2PSin$$;
outfile=/tmp/WP2PSout$$;
cat $1 > $infile
/usr/local/wp/sun4/bin/wprint -i$outfile $infile > /dev/null 2>&1
# wait for wprint to finish
while [ ! -f $outfile ]; do
sleep 1
done
/usr/local/etc/wptops < $outfile
/bin/rm -f $infile $outfile
---------------------- cut here ----------------------------------
wptops is Les Miksell's perl script which cleans up Word Perfect's
corrupt Postscript files.
---------------------- cut here ----------------------------------
#!/usr/local/bin/perl
# Original version came from Angus Duggans's psutils
# modified version from les@fb.com (Les Mikesell )
# fixwpps: get semi-conforming PostScript out of WordPerfect 5.[01] file
# feed this into perl
#eval 'exec perl -S $0 "$@"'
# if $running_under_some_shell;
$page = 0;
while (<>) {
s/^ *%!/%!/;
s/\015//;
s/\004//;
# s/(_[a-zA-Z]+)([0-9]+)/\1 \2/g;
if (/^_bp/) {
$page++;
print STDOUT "%%Page: $page $page\n";
print STDOUT $_;
} elsif (/^([^\/].*\S.*)(_bp.*)/) {
$page++;
print STDOUT "$1\n";
print STDOUT "%%Page: $page $page\n";
print STDOUT "$2\n";
} elsif (/^_ed/) {
print STDOUT "%%Trailer:\n";
print STDOUT $_;
print STDOUT "%%Pages: $page\n";
} elsif (/^([^\/].*\S.*)(_ed.*)/) {
print STDOUT "$1\n";
print STDOUT "%%Trailer:\n";
print STDOUT "$2\n";
print STDOUT "%%Pages: $page\n";
} else {
print STDOUT $_;
}
}
---------------------- cut here ----------------------------------