54
eval "$(printf "%s" "$5" | sed -nre 's/.*(^|\s)Resolution=([0-9.]+(x[0-9.]+)?).*/resolution="${resolution:-\2}"/p')"
55
if test -e "$PPD"; then
56
eval "$(sed -nre 's/^\*DefaultResolution:\s+([0-9.]+(x[0-9.]+)?).*/resolution="${resolution:-\1}"/p' "$PPD")"
58
echo "DEBUG: Resolution: $resolution" >&2
59
if test -n "$resolution"; then
60
ppd_opts="${ppd_opts:+$ppd_opts }-r$resolution"
64
eval "$(printf "%s" "$5" | sed -nre 's/.*(^|\s)(media|PageSize)=(\S+).*/pagesize="${pagesize:-\3}"/p')"
65
if test -e "$PPD"; then
66
eval "$(sed -nre 's/^\*DefaultPageSize:\s+(\S+).*/pagesize="${pagesize:-\1}"/p' "$PPD")"
68
echo "DEBUG: Page size: $pagesize" >&2
71
if test -n "$pagesize" && test -e "$PPD"; then
72
eval "$(sed -nre 's|^\*PaperDimension\s+'"$pagesize"'/[^:]+:\s+"(\S+)\s+(\S+)".*|width="\1"; height="\2"|p' "$PPD")"
74
echo "DEBUG: Width: $width, height: $height" >&2
75
if test -n "$width"; then
76
ppd_opts="${ppd_opts:+$ppd_opts }-dDEVICEWIDTHPOINTS=$width"
78
if test -n "$height"; then
79
ppd_opts="${ppd_opts:+$ppd_opts }-dDEVICEHEIGHTPOINTS=$height"
86
if test -n "$pagesize" && test -e "$PPD"; then
87
eval "$(sed -nre 's|^\*ImageableArea\s+'"$pagesize"'/[^:]+:\s+"(\S+)\s+(\S+)\s+(\S+)\s+(\S+)".*|bl_x="\1"; bl_y="\2"; tr_x="\3"; tr_y="\4"|p' "$PPD")"
89
echo "DEBUG: Absolute margins: $bl_x, $bl_y, $tr_x, $tr_y" >&2
94
if test -n "$width" && test -n "$height" && \
95
test -n "$bl_x" && test -n "$bl_y" && \
96
test -n "$tr_x" && test -n "$tr_y"; then
99
margin_r="$(printf "scale=8; (%s)-(%s)\n" "$width" "$tr_x" | bc)"
100
margin_t="$(printf "scale=8; (%s)-(%s)\n" "$height" "$tr_y" | bc)"
102
echo "DEBUG: Relative margins: $margin_l, $margin_b, $margin_r, $margin_t" >&2
103
if test -n "$margin_l" && test -n "$margin_b" && \
104
test -n "$margin_r" && test -n "$margin_t"; then
105
ps_code="${ps_code:+$ps_code }<</.HWMargins[$margin_l $margin_b $margin_r $margin_t] /Margins[0 0]>>setpagedevice"
109
eval "$(printf "%s" "$5" | sed -nre 's/.*(^|\s)(InputSlot)=(\S+).*/inputslot="${inputslot:-\3}"/p')"
110
if test -e "$PPD"; then
111
eval "$(sed -nre 's/^\*DefaultInputSlot:\s+(\S+).*/inputslot="${inputslot:-\1}"/p' "$PPD")"
113
echo "DEBUG: InputSlot: $inputslot" >&2
115
if test -n "$inputslot" && test -e "$PPD"; then
116
eval "$(sed -nre 's|^\*InputSlot\s+'"$inputslot"'/[^:]+:\s+"\s*<\s*<\s*/MediaPosition\s*([0-9]+)\s*>\s*>\s*setpagedevice\s*".*|inputslot_val="\1"|p' "$PPD")"
118
echo "DEBUG: Value for MediaPosition: $inputslot_val" >&2
119
if test -n "$inputslot_val"; then
120
ppd_opts="${ppd_opts:+$ppd_opts }-dMediaPosition=$inputslot_val"
124
eval "$(printf "%s" "$5" | sed -nre 's/.*(^|\s)(ColorModel)=(\S+).*/colormodel="${colormodel:-\3}"/p')"
125
if test -e "$PPD"; then
126
eval "$(sed -nre 's/^\*DefaultColorModel:\s+(\S+).*/colormodel="${colormodel:-\1}"/p' "$PPD")"
128
echo "DEBUG: ColorModel: $colormodel" >&2
130
if test -n "$colormodel" && test -e "$PPD"; then
131
eval "$(sed -nre 's|^\*ColorModel\s+'"$colormodel"'/[^:]+:\s+"\s*<\s*<\s*/BitsPerPixel\s*([0-9]*)\s*>\s*>\s*setpagedevice\s*".*|colormodel_val="\1"|p' "$PPD")"
133
echo "DEBUG: Value for BitsPerPixel: $colormodel_val" >&2
134
if test -n "$colormodel_val"; then
135
ppd_opts="${ppd_opts:+$ppd_opts }-dBitsPerPixel=$colormodel_val"
139
eval "$(printf "%s" "$5" | sed -nre 's/.*(^|\s)(Duplex)=(\S+).*/duplex="${duplex:-\3}"/p')"
140
if test -e "$PPD"; then
141
eval "$(sed -nre 's/^\*DefaultDuplex:\s+(\S+).*/duplex="${duplex:-\1}"/p' "$PPD")"
143
echo "DEBUG: Duplex: $duplex" >&2
146
if test -n "$duplex" && test -e "$PPD"; then
147
eval "$(sed -nre 's|^\*Duplex\s+'"$duplex"'/[^:]+:\s+"\s*<\s*<\s*/Duplex\s*(\S*)\s*(/Tumble\s*(\S*)\s*)?>\s*>\s*setpagedevice\s*".*|duplex_val="\1"; tumble_val="\3"|p' "$PPD")"
149
echo "DEBUG: Value for Duplex: $duplex_val; Value for Tumble: $tumble_val" >&2
150
if test -n "$duplex_val"; then
151
ppd_opts="${ppd_opts:+$ppd_opts }-dDuplex=$duplex_val"
153
if test -n "$tumble_val"; then
154
ppd_opts="${ppd_opts:+$ppd_opts }-dTumble=$tumble_val"
158
echo "DEBUG: PPD options: $ppd_opts" >&2
159
echo "DEBUG: PostScript code from options: $ps_code" >&2
48
161
# Options we use with Ghostscript...
49
gsopts="-dQUIET -dDEBUG -dPARANOIDSAFER -dNOPAUSE -dBATCH"
50
gsopts="$gsopts -dNOMEDIAATTRS -sDEVICE=$device -sstdout=%stderr"
162
gsopts="-dQUIET -dPARANOIDSAFER -dNOPAUSE -dBATCH"
163
gsopts="$gsopts -sDEVICE=$device -sstdout=%stderr"
52
165
# See if we have a filename on the command-line...
170
# We read the data into a temporary file as Ghostscript needs this to be
171
# able to also work with PDF input
173
trap 'rm -f $tempfiles' 0 1 2 13 15
175
ifile=$(mktemp -t pstopxl.XXXXXX)
176
tempfiles="$tempfiles $ifile"
59
180
echo INFO: Starting GPL Ghostscript `$bindir/@GS@ --version`... 1>&2
60
echo DEBUG: Running $bindir/@GS@ $gsopts -sOUTPUTFILE="%stdout" "$ifile" 1>&2
181
echo DEBUG: Running $bindir/@GS@ $gsopts $ppd_opts -sOUTPUTFILE="%stdout" -c "$ps_code" -f "$ifile" 1>&2
62
183
# Now run Ghostscript...
63
exec $bindir/@GS@ $gsopts -sOUTPUTFILE="%stdout" "$ifile"
184
$bindir/@GS@ $gsopts $ppd_opts -sOUTPUTFILE="%stdout" -c "$ps_code" -f "$ifile"
66
# End of "$Id: pstopxl.in,v 1.1.2.2 2004/06/29 13:15:10 mike Exp $".
187
# End of "$Id: pstopxl.in 9250 2008-11-29 12:27:04Z till $".