~ubuntu-branches/debian/experimental/cups-filters/experimental

« back to all changes in this revision

Viewing changes to filter/pstopdf

  • Committer: Package Import Robot
  • Author(s): Didier Raboud
  • Date: 2015-01-15 18:06:05 UTC
  • mfrom: (1.2.25)
  • mto: This revision was merged to the branch mainline in revision 39.
  • Revision ID: package-import@ubuntu.com-20150115180605-fnfbqv85k3y5zggk
Tags: upstream-1.0.62
ImportĀ upstreamĀ versionĀ 1.0.62

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
PS2PDF_OPTIONS="-q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.3"
23
23
PS2PDF_OPTIONS="$PS2PDF_OPTIONS $PS2PS_OPTIONS"
24
24
PS2PDF_OPTIONS="$PS2PDF_OPTIONS -dColorImageFilter=/FlateEncode \
25
 
                -dPDFSETTINGS=/printer \
 
25
                -dPDFSETTINGS=/printer -dUseCIEColor \
26
26
                -dColorConversionStrategy=/LeaveColorUnchanged"
27
27
 
28
28
echo "DEBUG: pstopdf $# args: $@" >&2
85
85
  fi
86
86
fi
87
87
 
 
88
orientation=
88
89
width=
89
90
height=
90
91
bl_x=
99
100
unit=
100
101
customw=
101
102
customh=
 
103
 
 
104
eval "$(printf "%s" "$5" | sed -nre 's/.*(^|\s)orientation-requested=3.*/orientation="${orientation:-0}"/p')"
 
105
eval "$(printf "%s" "$5" | sed -nre 's/.*(^|\s)orientation-requested=4.*/orientation="${orientation:-90}"/p')"
 
106
eval "$(printf "%s" "$5" | sed -nre 's/.*(^|\s)orientation-requested=5.*/orientation="${orientation:-270}"/p')"
 
107
eval "$(printf "%s" "$5" | sed -nre 's/.*(^|\s)orientation-requested=6.*/orientation="${orientation:-180}"/p')"
 
108
if printf "%s" "$5" | grep -qiE '(\s|^)landscape(=(1|on|yes|true))?(\s|$)'; then
 
109
    if test -e "$PPD"; then
 
110
        eval "$(sed -nre 's/^\*LandscapeOrientation:\s*Plus90.*/orientation="${orientation:-90}"/p' "$PPD")"
 
111
        eval "$(sed -nre 's/^\*LandscapeOrientation:\s*Minus90.*/orientation="${orientation:-270}"/p' "$PPD")"
 
112
    else
 
113
        orientation="${orientation:-270}"
 
114
    fi
 
115
fi
 
116
orientation="${orientation:-0}"
 
117
echo "DEBUG: Orientation requested: $orientation" >&2
 
118
 
102
119
eval "$(printf "%s" "$5" | sed -nre 's/.*(^|\s)(PageSize|PageRegion)=(\S+).*/pagesize="${pagesize:-\3}"/p')"
103
120
if test -e "$PPD"; then
104
121
    eval "$(sed -nre 's/^\*DefaultPageSize:\s*(\S+).*/pagesize="${pagesize:-\1}"/p' "$PPD")"
157
174
fi
158
175
echo "DEBUG: Relative margins: $margin_l, $margin_b, $margin_r, $margin_t" >&2
159
176
 
 
177
if test "$orientation" = "90" || test "$orientation" = "270"; then
 
178
    swap="$width"
 
179
    width="$height"
 
180
    height="$swap"
 
181
fi
 
182
if test "$orientation" = "90"; then
 
183
    swap="$margin_l"
 
184
    margin_l="$margin_b"
 
185
    margin_b="$margin_r"
 
186
    margin_r="$margin_t"
 
187
    margin_t="$swap"
 
188
elif test "$orientation" = "180"; then
 
189
    swap="$margin_l"
 
190
    margin_l="$margin_r"
 
191
    margin_r="$swap"
 
192
    swap="$margin_t"
 
193
    margin_t="$margin_b"
 
194
    margin_b="$swap"
 
195
elif test "$orientation" = "270"; then
 
196
    swap="$margin_l"
 
197
    margin_l="$margin_t"
 
198
    margin_t="$margin_r"
 
199
    margin_r="$margin_b"
 
200
    margin_b="$swap"
 
201
fi
 
202
 
160
203
if test -n "$margin_l" && test -n "$margin_b" && \
161
204
    test -n "$margin_r" && test -n "$margin_t"; then
162
205
    inject_ps="<</.HWMargins[$margin_l $margin_b $margin_r $margin_t] /Margins[0 0]>>setpagedevice"
173
216
  ppd_opts="${ppd_opts:+$ppd_opts }-dDEVICEHEIGHTPOINTS=$height"
174
217
fi
175
218
echo "DEBUG: PPD options: $ppd_opts" >&2
176
 
 
177
 
# We do not supply the margins to the ps2pdf process, as this breaks
178
 
# full-bleed printing and also disturbs the printing if PPDs have too
179
 
# conservative margin definitions.
180
 
inject_ps=
181
 
 
182
 
# Injection
183
219
echo "DEBUG: PostScript to be injected: $inject_ps" >&2
184
 
if test -n "$inject_ps"; then
185
 
  echo "DEBUG: Injecting PostScript: $inject_ps" >&2
186
 
 
187
 
  orig_infile="$infile"
188
 
 
189
 
  infile=$(mktemp -t pstopdf.XXXXXX)
190
 
  tempfiles="$tempfiles $infile"
191
 
 
192
 
  perl -p -e 'if (! $did) { s:(^%!.*)$:\1\n'"$inject_ps"': && $did++; }' "$orig_infile" > "$infile"
193
 
fi
194
220
 
195
221
# DRM
196
222
 
204
230
  DRMFILTER=cat
205
231
fi
206
232
 
207
 
echo "DEBUG: Running $DRMFILTER | $GS $PS2PDF_OPTIONS $donumcopies $ppd_opts -sOutputFile=- $OPTIONS -c .setpdfwrite -f -" >&2
208
 
cat "$infile" | $DRMFILTER | $GS $PS2PDF_OPTIONS $donumcopies $ppd_opts -sOutputFile=- $OPTIONS -c .setpdfwrite -f -
 
233
echo "DEBUG: Running $DRMFILTER | $GS $PS2PDF_OPTIONS $donumcopies $ppd_opts -sOutputFile=- $OPTIONS -c $inject_ps .setpdfwrite -f -" >&2
 
234
cat "$infile" | $DRMFILTER | $GS $PS2PDF_OPTIONS $donumcopies $ppd_opts -sOutputFile=- $OPTIONS -c "$inject_ps" .setpdfwrite -f -