| 1 |
#! @SCRIPT_SH@ |
| 2 |
# $Id$ |
| 3 |
# |
| 4 |
# HylaFAX Facsimile Software |
| 5 |
# |
| 6 |
# Copyright (c) 1990-1996 Sam Leffler |
| 7 |
# Copyright (c) 1991-1996 Silicon Graphics, Inc. |
| 8 |
# HylaFAX is a trademark of Silicon Graphics |
| 9 |
# |
| 10 |
# Permission to use, copy, modify, distribute, and sell this software and |
| 11 |
# its documentation for any purpose is hereby granted without fee, provided |
| 12 |
# that (i) the above copyright notices and this permission notice appear in |
| 13 |
# all copies of the software and related documentation, and (ii) the names of |
| 14 |
# Sam Leffler and Silicon Graphics may not be used in any advertising or |
| 15 |
# publicity relating to the software without the specific, prior written |
| 16 |
# permission of Sam Leffler and Silicon Graphics. |
| 17 |
# |
| 18 |
# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, |
| 19 |
# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY |
| 20 |
# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. |
| 21 |
# |
| 22 |
# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR |
| 23 |
# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, |
| 24 |
# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, |
| 25 |
# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF |
| 26 |
# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE |
| 27 |
# OF THIS SOFTWARE. |
| 28 |
# |
| 29 |
|
| 30 |
# |
| 31 |
# Convert PostScript to facsimile using Ghostscript. |
| 32 |
# |
| 33 |
# ps2fax [-o output] [-l pagelength] [-w pagewidth] |
| 34 |
# [-r resolution] [-m maxpages] [-*] [file ...] |
| 35 |
# |
| 36 |
# We need to process the arguments to extract the input |
| 37 |
# files so that we can prepend a prologue file that sets |
| 38 |
# up a non-interactive environment. |
| 39 |
# |
| 40 |
# NB: this shell script is assumed to be run from the |
| 41 |
# top of the spooling hierarchy -- s.t. the etc directory |
| 42 |
# is present. |
| 43 |
# |
| 44 |
|
| 45 |
test -f etc/setup.cache || { |
| 46 |
SPOOL=`pwd` |
| 47 |
cat<<EOF |
| 48 |
|
| 49 |
FATAL ERROR: $SPOOL/etc/setup.cache is missing! |
| 50 |
|
| 51 |
The file $SPOOL/etc/setup.cache is not present. This |
| 52 |
probably means the machine has not been setup using the faxsetup(@MANNUM1_8@) |
| 53 |
command. Read the documentation on setting up HylaFAX before you |
| 54 |
startup a server system. |
| 55 |
|
| 56 |
EOF |
| 57 |
exit 1 |
| 58 |
} |
| 59 |
. etc/setup.cache |
| 60 |
|
| 61 |
PS=$GSRIP |
| 62 |
|
| 63 |
fil= |
| 64 |
out=ps.fax # default output filename |
| 65 |
pagewidth=1728 # standard fax width |
| 66 |
pagelength=297 # default to A4 |
| 67 |
vres=98 # default to low res |
| 68 |
device=tiffg3 # default to 1D |
| 69 |
unlimitedlength=no # default to fixed length-pages |
| 70 |
while test $# != 0 |
| 71 |
do |
| 72 |
case "$1" in |
| 73 |
-o) shift; out="$1" ;; |
| 74 |
-w) shift; pagewidth="$1" ;; |
| 75 |
-l) shift; pagelength="$1" ;; |
| 76 |
-r) shift; vres="$1" ;; |
| 77 |
-m) shift;; # NB: not implemented |
| 78 |
-U) unlimitedlength=yes ;; |
| 79 |
-1) device=tiffg3 ;; |
| 80 |
-2) ($PS -h | grep tiffg32d >/dev/null 2>&1) \ |
| 81 |
&& { device=tiffg32d; } \ |
| 82 |
|| { device=tiffg3; } |
| 83 |
;; |
| 84 |
-3) ($PS -h | grep tiffg4 >/dev/null 2>&1) \ |
| 85 |
&& { device=tiffg4; } \ |
| 86 |
|| { device=tiffg3; } |
| 87 |
;; |
| 88 |
-*) ;; |
| 89 |
*) fil="$fil $1" ;; |
| 90 |
esac |
| 91 |
shift |
| 92 |
done |
| 93 |
test -z "$fil" && fil="-" # read from stdin |
| 94 |
case "${pagewidth}x${pagelength}" in |
| 95 |
1728x280|1728x279|2592x280|2592x279|3456x280|3456x279) # 279.4mm is actually correct... |
| 96 |
paper=letter;; |
| 97 |
1728x364|2592x364|3456x364) |
| 98 |
paper=legal;; |
| 99 |
*x296|*x297) # more roundoff problems... |
| 100 |
paper=a4;; |
| 101 |
*x364) |
| 102 |
paper=b4;; |
| 103 |
2432x*|3648x*|4864x*) |
| 104 |
paper=a3;; |
| 105 |
*) |
| 106 |
echo "$0: Unsupported page size: $pagewidth x $pagelength"; |
| 107 |
exit 254;; # causes document to be rejected |
| 108 |
esac |
| 109 |
# |
| 110 |
# The image must end up with a pixel width according to T.32 Table 21. |
| 111 |
# Ghostscript contains code to fixate a4 and letter to 1728 pixels |
| 112 |
# when using 196-204 dpi and tiffg3/4, it supposedly does the same for |
| 113 |
# B4 but not for A3, thus the floats are needed (for A3's benefit). |
| 114 |
# |
| 115 |
# See ghostscript/doc/Devices.htm under -dAdjustWidth=1 (default). |
| 116 |
# Use -dAdjustWidth=0 to disable. With the right patch, |
| 117 |
# http://bugs.ghostscript.com/show_bug.cgi?id=688064 |
| 118 |
# AdjustWidth can be made to specify the pagewidth directly and |
| 119 |
# replace -dFIXEDMEDIA to permit TIFFs to be produced with |
| 120 |
# varied lengths. |
| 121 |
# |
| 122 |
case "$paper" in |
| 123 |
a4) |
| 124 |
case "$pagewidth" in |
| 125 |
2592) hres=313.65;; # VR_300X300 |
| 126 |
3456) hres=418.20;; # VR_R16 |
| 127 |
*) hres=209.10;; # everything else, 1728 pixels |
| 128 |
esac;; |
| 129 |
b4) |
| 130 |
case "$pagewidth" in |
| 131 |
3072) hres=311.97;; # VR_300X300 |
| 132 |
4096) hres=415.95;; # VR_R16 |
| 133 |
*) hres=207.98;; # everything else, 2048 pixels |
| 134 |
esac;; |
| 135 |
a3) |
| 136 |
case "$pagewidth" in |
| 137 |
3648) hres=311.94;; # VR_300X300 |
| 138 |
4864) hres=415.93;; # VR_R16 |
| 139 |
*) hres=207.96;; # everything else, 2432 pixels |
| 140 |
esac;; |
| 141 |
*) # letter, legal |
| 142 |
case "$pagewidth" in |
| 143 |
2592) hres=304.94;; # VR_300X300 |
| 144 |
3456) hres=406.59;; # VR_R16 |
| 145 |
*) hres=203.29;; # everything else, 1728 pixels |
| 146 |
esac;; |
| 147 |
esac |
| 148 |
|
| 149 |
# |
| 150 |
# The sed work fixes bug in Windows-generated |
| 151 |
# PostScript that causes certain international |
| 152 |
# character marks to be placed incorrectly. |
| 153 |
# |
| 154 |
# | $SED -e 's/yAscent Ascent def/yAscent 0 def/g' \ |
| 155 |
# |
| 156 |
# NB: unfortunately it appears to break valid PostScript; |
| 157 |
# so it's been disabled. |
| 158 |
|
| 159 |
# |
| 160 |
# Suggestion from "Alan Sparks" <[email protected]>, |
| 161 |
# Add the -DFIXEDMEDIA argument to the last command in ps2fax. |
| 162 |
# This prevents page sizing within the documents from altering |
| 163 |
# the command-line page size specification. This prevents |
| 164 |
# TIFFs to be made with pages of varied lengths, however. |
| 165 |
# See the comments on AdjustWidth above. |
| 166 |
# |
| 167 |
FIXEDWIDTH="-dFIXEDMEDIA" |
| 168 |
STRIPSIZE="-dMaxStripSize=0" |
| 169 |
|
| 170 |
# |
| 171 |
# Apply customizations such as watermarking. |
| 172 |
# |
| 173 |
if [ -f etc/FaxModify ]; then |
| 174 |
. etc/FaxModify |
| 175 |
fi |
| 176 |
|
| 177 |
$CAT $fil | $PS -q \ |
| 178 |
-sDEVICE=$device \ |
| 179 |
-dNOPAUSE \ |
| 180 |
-dSAFER=true \ |
| 181 |
-sPAPERSIZE=$paper \ |
| 182 |
$FIXEDWIDTH \ |
| 183 |
$STRIPSIZE \ |
| 184 |
-r$hres\x$vres \ |
| 185 |
"-sOutputFile=$out" \ |
| 186 |
- |